﻿/* ============================================================
   LPT AutoCare System — Design System
   โครง: sidebar เข้ม + พื้นเทาอ่อน + การ์ดขาวมุมมน + accent น้ำเงินตามแบรนด์ LPT

   หมายเหตุ: มีเฉพาะกลุ่ม brand ที่เปลี่ยนจากส้มเป็นน้ำเงิน
   สีอื่นทั้งหมดเป็นค่าเดิมตามดีไซน์ตั้งต้น
   ============================================================ */

:root {
    /* --- brand (เดิมเป็นส้ม เปลี่ยนเป็นน้ำเงินตามโปสเตอร์ LPT) --- */
    --brand-50: #EAF2FE;
    --brand-100: #CFE2FC;
    --brand-400: #4A93EF;
    --brand-500: #1268D8;
    --brand-600: #0B52B5;

    /* rgb ของ brand-500 ไว้ใช้กับเงา/โฟกัสที่ต้องใส่ alpha */
    --brand-rgb: 18, 104, 216;

    /* --- semantic --- */
    --green-50: #E9F8EF;
    --green-500: #16A34A;
    --blue-50: #EAF1FE;
    --blue-500: #2563EB;
    --red-50: #FDECEE;
    --red-500: #E0384B;
    --amber-50: #FFF7E6;
    --amber-500: #D9880A;
    --slate-50: #F1F3F6;
    --slate-500: #64748B;

    /* --- surface --- */
    --bg: #F4F5F7;
    --card: #FFFFFF;
    --line: #EDEFF2;
    --line-strong: #E1E4E9;

    /* --- ink --- */
    --ink: #1F2430;
    --ink-2: #4B5563;
    --ink-3: #6B7280;
    --ink-4: #9AA3AF;

    /* --- sidebar --- */
    --sidebar-bg: #1B1E25;
    --sidebar-panel: #23272F;
    --sidebar-line: #2E333C;
    --sidebar-w: 236px;
    --sidebar-ink: #A9B0BC;
    --sidebar-ink-dim: #7C8598;
    --sidebar-ink-hover: #FFFFFF;

    /* --- shape --- */
    --r-sm: 10px;
    --r: 14px;
    --r-lg: 18px;
    --shadow-card: 0 1px 2px rgba(16,24,40,.04), 0 6px 16px rgba(16,24,40,.035);
    --shadow-pop: 0 10px 30px rgba(16,24,40,.12);

    --topbar-h: 68px;

    /* ความสูงแถบเมนูล่างบนมือถือ — ต้องคลุมปุ่มกลางที่สูงสุด และแถบบันทึกอ้างอิงค่านี้ไม่ให้ทับกัน */
    --bottom-nav-h: 70px;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'IBM Plex Sans Thai', 'Segoe UI', system-ui, sans-serif;
    font-size: .875rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--ink); }

a { text-decoration: none; }

/* ตัวเลขให้ความกว้างเท่ากันทุกหลัก ตารางจะไม่ขยับตอนค่าเปลี่ยน */
.num, .stat-value, .kpi-value, table td, table th {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* ============================================================
   1. โครงหน้า (App shell)
   ============================================================ */

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1045;
    transition: transform .25s ease;
}

.app-main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-content {
    padding: 1.15rem 1.35rem 2.5rem;
    flex: 1;
}

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-pop); }
    .app-sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .app-content { padding: 1rem .9rem 5.5rem; }
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16,24,40,.45);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

/* --- โลโก้ --- */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.35rem 1.15rem 1.5rem;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.25rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(var(--brand-rgb), .38);
}

.brand-text .brand-name {
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1.1;
}
.brand-text .brand-sub {
    color: var(--sidebar-ink-dim);
    font-size: .72rem;
}

/* --- เมนู --- */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0 .7rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .72rem .85rem;
    margin-bottom: .18rem;
    border-radius: var(--r);
    color: var(--sidebar-ink);
    font-size: .875rem;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: var(--sidebar-ink-hover); }

.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
    color: #fff;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(var(--brand-rgb), .35);
}

.sidebar-section {
    color: #5C6577;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 1.1rem .9rem .45rem;
}

/* --- การ์ดโปรโมทท้าย sidebar --- */
.sidebar-foot { padding: 1rem .95rem 1.15rem; }

.sidebar-promo {
    background: var(--sidebar-panel);
    border: 1px solid var(--sidebar-line);
    border-radius: var(--r-lg);
    padding: 1.1rem .9rem 1rem;
    text-align: center;
}
.sidebar-promo .promo-icon { font-size: 1.6rem; color: var(--brand-500); }
.sidebar-promo .promo-title { color: #fff; font-weight: 600; font-size: .85rem; margin-top: .35rem; }
.sidebar-promo .promo-sub { color: #79808F; font-size: .7rem; line-height: 1.4; margin-bottom: .75rem; }

.sidebar-version {
    color: #5C6577;
    font-size: .68rem;
    line-height: 1.5;
    padding: .9rem .35rem 0;
    border-top: 1px solid var(--sidebar-line);
    margin-top: .9rem;
}

/* ============================================================
   2. แถบบน (Topbar)
   ============================================================ */

.app-topbar {
    background: var(--bg);
    padding: 1.1rem 1.35rem .35rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

@media (max-width: 991.98px) {
    .app-topbar { padding: .85rem .9rem .25rem; }
}

.topbar-toggle {
    background: transparent;
    border: 0;
    color: var(--ink-2);
    font-size: 1.35rem;
    line-height: 1;
    padding: .35rem;
    border-radius: var(--r-sm);
}
.topbar-toggle:hover { background: #E9EBEF; }

.page-title { font-size: 1.6rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-subtitle { color: var(--ink-3); font-size: .84rem; margin: 0; }

@media (max-width: 575.98px) {
    .page-title { font-size: 1.25rem; }
}

/* กล่องเครื่องมือมุมขวาบน */
.topbar-chip {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: .55rem .9rem;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-size: .82rem;
    font-weight: 500;
    color: var(--ink-2);
    box-shadow: var(--shadow-card);
    white-space: nowrap;
}
.topbar-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-500); }

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink-2);
    display: inline-grid;
    place-items: center;
    position: relative;
    font-size: 1.05rem;
    box-shadow: var(--shadow-card);
}
.icon-btn:hover { color: var(--brand-500); border-color: var(--brand-100); }

.icon-btn .badge-dot {
    position: absolute;
    top: -5px; right: -5px;
    min-width: 18px; height: 18px;
    border-radius: 999px;
    background: var(--red-500);
    color: #fff;
    font-size: .65rem;
    font-weight: 600;
    display: grid;
    place-items: center;
    padding: 0 4px;
    border: 2px solid var(--bg);
}

.updated-note { color: var(--ink-4); font-size: .74rem; }

/* ============================================================
   3. การ์ด
   ============================================================ */

/* ไม่ตั้ง height:100% ตรงนี้ — คอลัมน์ของ Bootstrap เป็น flex item ที่ยืดเต็มความสูงแถวอยู่แล้ว
   ถ้าการ์ดเป็น 100% ด้วย การ์ดทุกใบในคอลัมน์ที่มีหลายใบจะสูงเท่าคอลัมน์ทั้งหมด
   ต้องการให้การ์ดข้าง ๆ สูงเท่ากันเมื่อไหร่ ให้ใส่ .h-100 ที่การ์ดนั้นเอง */
.card-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card);
    padding: 1.25rem;
}

.card-panel-flush { padding: 0; overflow: hidden; }

.panel-head {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 1rem;
}
.panel-head h2 { font-size: 1.02rem; font-weight: 600; margin: 0; }
.panel-head .panel-note { color: var(--ink-4); font-size: .8rem; font-weight: 400; }

.panel-foot {
    display: flex;
    justify-content: flex-end;
    padding-top: .9rem;
    margin-top: .25rem;
}

.link-more {
    color: var(--brand-500);
    font-size: .82rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}
.link-more:hover { color: var(--brand-600); }

/* ============================================================
   4. KPI cards
   ============================================================ */

.kpi {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card);
    padding: 1.15rem 1.2rem;
    display: flex;
    align-items: center;
    gap: .95rem;
    height: 100%;
}

.kpi-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--r);
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* .kpi ตั้ง height:100% ไว้ให้การ์ดในแถวเดียวกันสูงเท่ากัน
   แต่ถ้าเอาไปวางซ้อนในการ์ดอื่นจะยืดเต็มความสูงจนผิดรูป — ในนั้นให้สูงตามเนื้อหา */
.card-panel .kpi { height: auto; }

.kpi-body { min-width: 0; }
.kpi-label { color: var(--ink-3); font-size: .8rem; margin-bottom: .1rem; }
.kpi-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.kpi-value .unit { font-size: .8rem; font-weight: 500; color: var(--ink-3); margin-left: .2rem; }
.kpi-delta { font-size: .76rem; font-weight: 500; margin-top: .15rem; }

/* การ์ดตัวเด่น — พื้นส้มทึบ */
.kpi-feature {
    background: linear-gradient(120deg, var(--brand-500) 0%, var(--brand-400) 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 22px rgba(var(--brand-rgb), .32);
}
.kpi-feature .kpi-label { color: rgba(255,255,255,.88); }
.kpi-feature .kpi-value,
.kpi-feature .kpi-delta { color: #fff; }
.kpi-feature .kpi-value .unit { color: rgba(255,255,255,.85); }
.kpi-feature .kpi-icon { background: rgba(255,255,255,.18); color: #fff; }

/* สีพื้นไอคอน */
.tint-brand { background: var(--brand-50); color: var(--brand-500); }
.tint-green  { background: var(--green-50);  color: var(--green-500); }
.tint-blue   { background: var(--blue-50);   color: var(--blue-500); }
.tint-red    { background: var(--red-50);    color: var(--red-500); }
.tint-amber  { background: var(--amber-50);  color: var(--amber-500); }
.tint-slate  { background: var(--slate-50);  color: var(--slate-500); }

.text-up   { color: var(--green-500); }
.text-down { color: var(--red-500); }
.text-muted-2 { color: var(--ink-3); }
.text-muted-3 { color: var(--ink-4); }

/* ============================================================
   5. รายการแบบแถว (list rows)
   ============================================================ */

.row-list { display: flex; flex-direction: column; }

.row-item {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .8rem .25rem;
    border-bottom: 1px solid var(--line);
    color: inherit;
    transition: background .15s ease;
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: #FAFBFC; }

.row-icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.row-main { flex: 1; min-width: 0; }
.row-title { font-size: .875rem; font-weight: 500; color: var(--ink); }
.row-sub { font-size: .76rem; color: var(--ink-4); }

.row-meta { text-align: right; white-space: nowrap; }
.row-meta .m-strong { font-weight: 600; font-size: .9rem; }
.row-meta .m-sub { font-size: .74rem; color: var(--ink-4); }

.row-chevron { color: var(--ink-4); font-size: .95rem; flex-shrink: 0; }

@media (max-width: 575.98px) {
    .row-item { gap: .65rem; padding: .7rem .1rem; }
    .row-icon { width: 36px; height: 36px; font-size: .95rem; }
}

/* ============================================================
   6. แถบความคืบหน้า
   ============================================================ */

.progress-line {
    height: 8px;
    border-radius: 999px;
    background: #EEF0F3;
    overflow: hidden;
}
.progress-line > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--brand-500);
    transition: width .5s ease;
}
.progress-line.is-green > span { background: var(--green-500); }
.progress-line.is-blue > span  { background: var(--blue-500); }
.progress-line.is-red > span   { background: var(--red-500); }

/* ============================================================
   7. Badge / pill
   ============================================================ */

.pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    border-radius: 999px;
    padding: .18rem .6rem;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.5;
}
.pill-brand { background: var(--brand-50); color: var(--brand-600); }
.pill-green  { background: var(--green-50);  color: var(--green-500); }
.pill-blue   { background: var(--blue-50);   color: var(--blue-500); }
.pill-red    { background: var(--red-50);    color: var(--red-500); }
.pill-amber  { background: var(--amber-50);  color: var(--amber-500); }
.pill-slate  { background: var(--slate-50);  color: var(--slate-500); }

/* ============================================================
   8. ปุ่ม
   ============================================================ */

.btn {
    border-radius: var(--r-sm);
    font-weight: 500;
    font-size: .875rem;
    padding: .55rem 1.1rem;
}

.btn-brand {
    background: var(--brand-500);
    border-color: var(--brand-500);
    color: #fff;
}
.btn-brand:hover, .btn-brand:focus {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
}

.btn-soft {
    background: var(--card);
    border: 1px solid var(--line-strong);
    color: var(--ink-2);
}
.btn-soft:hover { background: #F7F8FA; color: var(--ink); }

/* ============================================================
   9. ฟอร์ม
   ============================================================ */

.form-label { font-size: .82rem; font-weight: 500; color: var(--ink-2); margin-bottom: .35rem; }

.form-control, .form-select {
    border-radius: var(--r-sm);
    border: 1px solid var(--line-strong);
    /* 16px กัน iOS zoom เองตอนโฟกัส */
    font-size: 1rem;
    padding: .58rem .8rem;
    color: var(--ink);
}
@media (min-width: 768px) {
    .form-control, .form-select { font-size: .875rem; }
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-400);
    box-shadow: 0 0 0 .18rem rgba(var(--brand-rgb), .18);
}
.form-control::placeholder { color: var(--ink-4); }

/* ============================================================
   10. ตาราง
   ============================================================ */

.table-clean { width: 100%; margin: 0; }
.table-clean thead th {
    background: #FAFBFC;
    color: var(--ink-3);
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .7rem .9rem;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table-clean tbody td {
    padding: .8rem .9rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.table-clean tbody tr:last-child td { border-bottom: 0; }
.table-clean tbody tr:hover { background: #FAFBFC; }

/* ============================================================
   11. Bottom nav (มือถือ)
   ============================================================ */

.bottom-nav {
    position: fixed;
    inset: auto 0 0 0;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid var(--line);
    display: none;
    align-items: center;
    z-index: 1030;
    padding: .25rem .25rem calc(.25rem + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 12px rgba(16,24,40,.06);
}

@media (max-width: 991.98px) {
    .bottom-nav { display: flex; }
}

.bottom-nav a {
    flex: 1;
    /* 44px = ขนาดเป้ากดขั้นต่ำที่นิ้วโป้งกดไม่พลาด */
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .1rem;
    color: var(--ink-4);
    font-size: .68rem;
    font-weight: 500;
    border-radius: var(--r-sm);
    padding: .3rem 0;
}
.bottom-nav a i { font-size: 1.2rem; }
.bottom-nav a.active { color: var(--brand-500); }

.bottom-nav a.fab-item i {
    width: 38px; height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
    color: #fff;
    display: grid; place-items: center;
    box-shadow: 0 6px 14px rgba(var(--brand-rgb), .38);
    margin-bottom: .1rem;
}
.bottom-nav a.fab-item.active i { color: #fff; }

/* ============================================================
   12. เกจวงกลม (Business Health)
   ============================================================ */

.gauge { position: relative; width: 88px; height: 88px; flex-shrink: 0; }
.gauge svg { transform: rotate(-90deg); }
.gauge-track { stroke: #EEF0F3; }
.gauge-fill { stroke: var(--green-500); stroke-linecap: round; transition: stroke-dashoffset .7s ease; }
.gauge-text {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    line-height: 1;
}
.gauge-text .g-num { font-size: 1.45rem; font-weight: 700; }
.gauge-text .g-den { font-size: .68rem; color: var(--ink-4); }

/* ============================================================
   13. เบ็ดเตล็ด
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--ink-4);
    font-size: .85rem;
}
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .5; }

.spark { width: 100%; height: 42px; display: block; }

.divider { height: 1px; background: var(--line); margin: 1rem 0; }

/* ============================================================
   14. ฟอร์มใบงานซ่อม
   ============================================================ */

.section-head {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: 1.1rem;
}
.section-head .num {
    width: 26px; height: 26px;
    border-radius: 8px;
    background: var(--sidebar-bg);
    color: #fff;
    font-size: .76rem;
    font-weight: 700;
    display: grid; place-items: center;
    flex-shrink: 0;
}
.section-head h2 { font-size: 1rem; font-weight: 600; margin: 0; }
.section-head .hint { font-size: .76rem; color: var(--ink-4); margin-left: auto; }

/* --- ป้ายทะเบียนจำลอง --- */
.plate-box { display: flex; align-items: center; gap: .85rem; margin-top: .6rem; }
.plate {
    background: #fff;
    border: 2px solid var(--sidebar-bg);
    border-radius: 6px;
    padding: .35rem .7rem;
    text-align: center;
    min-width: 132px;
    flex-shrink: 0;
}
.plate .plate-code { font-size: 1.05rem; font-weight: 700; letter-spacing: .02em; }
.plate .plate-province {
    font-size: .62rem;
    color: #fff;
    background: var(--sidebar-bg);
    border-radius: 3px;
    padding: 1px 6px;
    margin-top: 2px;
    display: inline-block;
}
.plate.is-empty { border-color: #D3D7DE; }
.plate.is-empty .plate-code { color: #B7BCC4; }
.plate.is-empty .plate-province { background: #D3D7DE; color: #8A8F98; }

/* --- ช่องแนบรูป --- */
.photo-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.dropzone {
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--r);
    background: #FAFBFC;
    height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--ink-4);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover { border-color: var(--brand-400); background: var(--brand-50); }
.dropzone i { font-size: 1.6rem; margin-bottom: .35rem; }
.dropzone span.label { font-size: .78rem; padding: 0 .5rem; }
.dropzone img { width: 100%; height: 100%; object-fit: cover; }
.dropzone .tag {
    position: absolute; top: .5rem; left: .5rem;
    font-size: .68rem; font-weight: 600;
    background: rgba(27,30,37,.85); color: #fff;
    padding: .15rem .55rem; border-radius: 999px;
    z-index: 2;
}
.dropzone .remove-photo {
    position: absolute; top: .5rem; right: .5rem;
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(20,20,20,.6); color: #fff;
    display: grid; place-items: center;
    font-size: .8rem; z-index: 2; border: 0;
}

/* --- ตัวเลือกอะไหล่ --- */
.parts-input-wrap { position: relative; }

.parts-dropdown {
    position: absolute;
    top: calc(100% + 6px); left: 0; right: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-pop);
    max-height: 300px;
    overflow-y: auto;
    z-index: 20;
    display: none;
}
.parts-dropdown.show { display: block; }

.parts-option {
    display: flex; align-items: center; gap: .6rem;
    padding: .65rem .9rem;
    cursor: pointer;
    border-bottom: 1px solid #F3F4F6;
}
.parts-option:last-child { border-bottom: 0; }
.parts-option:hover, .parts-option.is-active { background: var(--brand-50); }
.parts-option.disabled { opacity: .45; pointer-events: none; }
.parts-option .p-main { flex: 1; min-width: 0; }
.parts-option .p-name { font-size: .86rem; font-weight: 500; }
.parts-option .p-code { color: var(--ink-4); font-size: .74rem; }

.part-chip {
    display: flex; align-items: center; gap: .7rem;
    background: #FAFBFC;
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: .6rem .7rem .6rem .9rem;
    margin-bottom: .5rem;
    flex-wrap: wrap;
}
.part-chip .p-info { flex: 1; min-width: 130px; }
.part-chip .p-name { font-size: .86rem; font-weight: 500; }
.part-chip .p-code { font-size: .72rem; color: var(--ink-4); }
.part-chip .unit-lbl { font-size: .75rem; color: var(--ink-4); min-width: 30px; }
.part-chip .line-amount { font-weight: 600; font-size: .88rem; min-width: 92px; text-align: right; }

.part-chip .rm {
    color: var(--red-500);
    width: 32px; height: 32px;
    border: 0; background: transparent;
    border-radius: var(--r-sm);
    display: grid; place-items: center;
    flex-shrink: 0;
}
.part-chip .rm:hover { background: var(--red-50); }

.part-chip .cost-input { width: 108px; }
.part-chip .cost-input .form-control { text-align: right; padding: .35rem .5rem; font-size: .85rem; }

.qty-stepper {
    display: flex; align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    overflow: hidden;
    background: #fff;
    flex-shrink: 0;
}
.qty-stepper button {
    width: 34px; height: 34px;
    border: 0; background: #fff;
    color: var(--ink);
    font-size: 1.05rem;
    display: grid; place-items: center;
}
.qty-stepper button:hover { background: #F1F3F6; }
.qty-stepper input {
    width: 52px; text-align: center;
    border: 0;
    border-left: 1px solid var(--line-strong);
    border-right: 1px solid var(--line-strong);
    font-size: .85rem;
    padding: .3rem 0;
}

.empty-parts {
    font-size: .82rem;
    color: var(--ink-4);
    text-align: center;
    padding: 1.25rem 1rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-sm);
    background: #FAFBFC;
}

/* --- ฟอร์มสองคอลัมน์บนจอกว้าง --- */
/* ไม่ปล่อยให้ยืดเต็มจอ ultrawide เพราะช่องกรอกยาว ๆ อ่านลำบาก */
.form-columns { max-width: 1360px; }

/* --- การ์ดแจกแจงต้นทุนข้างฟอร์ม --- */
.cost-breakdown .cb-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: .5rem 0;
    font-size: .88rem;
    color: var(--ink-2);
}
.cost-breakdown .cb-row + .cb-row { border-top: 1px solid var(--line); }
.cost-breakdown .cb-row b {
    color: var(--ink);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.cost-breakdown .cb-row.is-total {
    margin-top: .25rem;
    padding-top: .7rem;
    border-top: 1px solid var(--line-strong);
    color: var(--ink);
    font-weight: 600;
}
.cost-breakdown .cb-row.is-total b { font-size: 1.15rem; color: var(--brand-500); }

/* ข้อความวันที่ไทยใต้ช่อง input[type=date] — ว่างอยู่ก็ไม่กินที่ */
/* ป้ายวันที่ไทยใต้ช่องเลือกวันที่ — ตอนไม่มีข้อความต้องไม่กินที่ แต่ยังต้องคงระยะห่างล่างไว้
   (สคริปต์ย้ายคลาส mb-* จากช่องวันที่มาไว้ที่ป้ายนี้) จึงเหลือความสูงศูนย์แทนการซ่อนทิ้ง */
.date-hint { margin-top: .2rem; }
.date-hint:empty { margin-top: 0; }

/* --- แถบบันทึกติดล่างจอ --- */
.submit-bar {
    position: fixed;
    inset: auto 0 0 0;
    left: var(--sidebar-w);
    background: var(--card);
    border-top: 1px solid var(--line);
    padding: .8rem 1.35rem;
    z-index: 1035;
    box-shadow: 0 -2px 12px rgba(16,24,40,.06);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}
.submit-bar .cost-summary { flex: 1; min-width: 0; }
.submit-bar .cost-total { font-size: 1.15rem; font-weight: 700; }

@media (max-width: 991.98px) {
    /* วางให้พอดีเหนือ bottom nav — ผูกกับตัวแปรเดียวกันจะได้ไม่ทับกัน */
    .submit-bar {
        left: 0;
        bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
        padding: .7rem .9rem;
    }
    .photo-row { gap: .7rem; }
    .part-chip .line-amount { min-width: 78px; }
}

/* หน้าที่มี submit-bar ต้องเว้นที่ด้านล่างไม่ให้ทับเนื้อหา */
.has-submit-bar .app-content { padding-bottom: 7rem; }
@media (max-width: 991.98px) {
    .has-submit-bar .app-content { padding-bottom: 11rem; }
}

/* ============================================================
   15. ไทม์ไลน์สถานะ
   ============================================================ */

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
    position: relative;
    padding: 0 0 1.1rem 1.75rem;
    border-left: 2px solid var(--line);
    margin-left: .5rem;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
    content: "";
    position: absolute;
    left: -7px; top: 3px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--line-strong);
    border: 2px solid var(--card);
}
.timeline li.done::before { background: var(--green-500); }
.timeline li.current::before { background: var(--brand-500); box-shadow: 0 0 0 4px var(--brand-50); }
.timeline .t-title { font-size: .86rem; font-weight: 500; }
.timeline .t-sub { font-size: .74rem; color: var(--ink-4); }

/* ============================================================
   16. แถวกรอกผลตรวจนับ — ออกแบบให้กดง่ายขณะเดินนับด้วยมือถือ
   ============================================================ */

.count-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem .6rem;
    border-bottom: 1px solid var(--line);
}
.count-row:last-child { border-bottom: 0; }

.count-row .cr-main { flex: 1; min-width: 0; }
.count-row .cr-diff { min-height: 1.15rem; font-weight: 500; }

.count-row .cr-input {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
}
.count-row .cr-input .form-control {
    width: 92px;
    text-align: right;
    font-weight: 600;
    /* 16px กัน iOS zoom ตอนโฟกัส — หน้านี้ใช้บนมือถือเป็นหลัก */
    font-size: 1rem;
}
.count-row .cr-unit { font-size: .78rem; color: var(--ink-4); width: 34px; }

.count-row.is-saving .cr-input .form-control { border-color: var(--brand-400); }
.count-row.is-saved .cr-input .form-control { border-color: var(--green-500); }
.count-row.is-error .cr-input .form-control { border-color: var(--red-500); }

/* ============================================================
   17. หน้าเข้าสู่ระบบ
   ============================================================ */

.auth-body {
    background: linear-gradient(160deg, var(--sidebar-bg) 0%, #232833 45%, var(--brand-600) 130%);
    min-height: 100vh;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    gap: 1rem;
}

.auth-card {
    background: var(--card);
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(4, 20, 45, .35);
    padding: 2rem 1.75rem;
    width: 100%;
    max-width: 420px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: .8rem;
    margin-bottom: 1.75rem;
}
.auth-brand-name { font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.auth-brand-sub { font-size: .78rem; color: var(--ink-4); }

.auth-title { font-size: 1.05rem; font-weight: 600; margin-bottom: .25rem; }
.auth-sub { font-size: .84rem; color: var(--ink-3); margin-bottom: 1.25rem; }

.auth-foot { color: rgba(255,255,255,.55); font-size: .74rem; }

/* --- แถบผู้ใช้มุมขวาบน --- */
.user-chip {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: .35rem .5rem .35rem .75rem;
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    box-shadow: var(--shadow-card);
    color: var(--ink);
    max-width: 230px;
}
.user-chip .u-avatar {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
    color: #fff;
    display: grid; place-items: center;
    font-size: .8rem; font-weight: 700;
    flex-shrink: 0;
}
.user-chip .u-name { font-size: .82rem; font-weight: 600; line-height: 1.15; }
.user-chip .u-role { font-size: .7rem; color: var(--ink-4); line-height: 1.15; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #D3D7DE; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #BCC2CC; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #343943; }
