/* ============================================================
   TMS Web — Blazor mockup styles
   แปลงมาจากไฟล์ wireframe ต้นฉบับ (tms-wireframe_1.html)
   หมายเหตุ: ฟอนต์ Kanit/Sarabun โหลดผ่าน <link> ใน App.razor แล้ว
   ============================================================ */

  :root{
    --navy-900:#0F2038;
    --navy-800:#152A47;
    --navy-700:#1D3A5F;
    --amber-500:#F2A93B;
    --amber-600:#DB8F1F;
    --amber-100:#FDEFD8;
    --teal-500:#1E8F82;
    --teal-100:#E1F3F1;
    --bg:#F5F6F8;
    --card:#FFFFFF;
    --border:#E4E7EC;
    --text-900:#16202E;
    --text-600:#5B6472;
    --text-400:#98A2AF;
    --success:#1E8F5F;
    --success-bg:#E7F6EE;
    --warning:#D9822B;
    --warning-bg:#FCEEDC;
    --danger:#D64545;
    --danger-bg:#FBE9E9;
  }
  *{box-sizing:border-box;}
  html,body{margin:0;padding:0;}
  body{
    font-family:'Sarabun',sans-serif;
    background:var(--bg);
    color:var(--text-900);
    -webkit-font-smoothing:antialiased;
  }
  h1,h2,h3,.brand,.navlabel,button,.btn{font-family:'Kanit',sans-serif;}

  /* ---------- shell ---------- */
  .shell{display:flex;min-height:100vh;}

  /* ---------- sidebar ---------- */
  .sidebar{
    width:252px;flex:none;background:var(--navy-900);color:#fff;
    display:flex;flex-direction:column;position:sticky;top:0;height:100vh;
    z-index:60;
  }
  .sidebar-close{display:none;}
  .brandrow{
    display:flex;align-items:center;gap:10px;padding:20px 18px 16px 18px;
  }
  .brand-mark{
    width:34px;height:34px;border-radius:8px;background:var(--amber-500);
    display:flex;align-items:center;justify-content:center;flex:none;
  }
  .brand-mark svg{width:19px;height:19px;}
  .brand{font-size:17px;font-weight:700;letter-spacing:.2px;line-height:1.1;}
  .brand small{display:block;font-family:'Sarabun',sans-serif;font-weight:400;font-size:11px;color:#93A6C2;letter-spacing:.4px;}

  .route-strip{
    margin:2px 18px 14px 18px;height:1px;
    background-image:linear-gradient(to right, #33507A 50%, transparent 0%);
    background-size:8px 1px;background-repeat:repeat-x;
  }

  nav.navlist{flex:1;overflow-y:auto;padding:4px 10px 10px 10px;}
  .navgroup-title{
    font-size:11px;color:#6C82A6;text-transform:uppercase;letter-spacing:.8px;
    padding:14px 10px 6px 10px;font-weight:600;
  }
  .navitem{
    display:flex;align-items:center;gap:10px;padding:9px 10px;border-radius:8px;
    color:#C7D3E6;text-decoration:none;font-size:14px;cursor:pointer;font-family:'Sarabun',sans-serif;
    margin-bottom:2px;border:none;background:none;width:100%;text-align:left;
  }
  .navitem svg{width:17px;height:17px;flex:none;opacity:.85;}
  .navitem:hover{background:var(--navy-700);color:#fff;}
  .navitem.active{background:var(--amber-500);color:#1A1204;font-weight:600;}
  .navitem.active svg{opacity:1;}
  .navitem .chev{margin-left:auto;width:12px;height:12px;transition:transform .15s;}
  .navitem.expanded .chev{transform:rotate(90deg);}
  .subnav{padding-left:14px;display:none;}
  .subnav.open{display:block;}
  .subnav .navitem{font-size:13.5px;padding:7px 10px 7px 30px;}

  .sidebar-foot{
    padding:14px 46px 14px 18px;border-top:1px solid var(--navy-700);
    display:flex;align-items:center;gap:10px;position:relative;
  }
  .avatar{width:30px;height:30px;border-radius:50%;background:var(--teal-500);color:#fff;
    display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;flex:none;}
  .sidebar-foot .who{font-size:12.5px;line-height:1.3;flex:1;min-width:0;}
  .sidebar-foot .who b{display:block;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
  .sidebar-foot .who span{color:#8FA1BE;font-size:11.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;}

  /* ---------- main ---------- */
  .main{flex:1;min-width:0;display:flex;flex-direction:column;}
  .topbar{
    height:64px;background:#fff;border-bottom:1px solid var(--border);
    display:flex;align-items:center;justify-content:space-between;
    padding:0 24px;position:sticky;top:0;z-index:5;
    gap:12px;
  }
  .topbar-left{display:flex;align-items:center;gap:14px;min-width:0;}
  .hamburger{
    display:none;flex:none;width:36px;height:36px;border-radius:8px;
    border:1px solid var(--border);background:#fff;align-items:center;justify-content:center;
    color:var(--text-600);cursor:pointer;
  }
  .hamburger svg{width:19px;height:19px;}
  .crumbs{font-size:13px;color:var(--text-400);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
  .crumbs b{color:var(--text-900);font-weight:600;}
  .topbar-right{display:flex;align-items:center;gap:14px;}
  .search{
    display:flex;align-items:center;gap:8px;background:var(--bg);border:1px solid var(--border);
    border-radius:8px;padding:7px 12px;color:var(--text-400);font-size:13px;width:220px;
  }
  .search svg{width:15px;height:15px;flex:none;}
  .iconbtn{
    width:36px;height:36px;border-radius:8px;border:1px solid var(--border);background:#fff;
    display:flex;align-items:center;justify-content:center;color:var(--text-600);cursor:pointer;position:relative;
  }
  .iconbtn svg{width:17px;height:17px;}
  .dot{position:absolute;top:6px;right:6px;width:7px;height:7px;border-radius:50%;background:var(--danger);border:1.5px solid #fff;}

  .notif-wrap{position:relative;}
  .notif-dropdown{
    position:absolute;top:44px;right:0;width:340px;max-width:88vw;background:#fff;border:1px solid var(--border);
    border-radius:12px;box-shadow:0 12px 32px rgba(0,0,0,.14);z-index:60;overflow:hidden;
  }
  .notif-head{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;border-bottom:1px solid var(--border);background: #f2a93b;}
  .notif-head b{font-size:13.5px;color:var(--text-900);}
  .notif-markall{background:none;border:none;color:var(--text-600);font-size:12px;cursor:pointer;padding:0;}
  .notif-list{max-height:360px;overflow-y:auto;     background: #0f203824;}
  .notif-empty{padding:24px 14px;text-align:center;color:var(--text-400);font-size:13px;}
  .notif-item{padding:10px 14px;border-bottom:1px solid var(--border);cursor:pointer;transition:background .12s;}
  .notif-item:last-child{border-bottom:none;}
  .notif-item:hover{background:var(--bg);}
  .notif-item.unread{background:#fff8ec;}
  .notif-item.unread .notif-title{font-weight:700;}
  .notif-title{font-size:13px;color:var(--text-900);margin-bottom:2px;}
  .notif-msg{font-size:12.5px;color:var(--text-600);line-height:1.4;}
  .notif-time{font-size:11px;color:var(--text-400);margin-top:4px;}

  .content{padding:24px 28px 48px 28px;max-width:1360px;width:100%;margin:0 auto;}

  /* ---------- responsive: sidebar / topbar ---------- */
  .sidebar-backdrop{display:none;}

  @media (max-width: 960px){
    .sidebar{
      position:fixed;top:0;left:0;bottom:0;width:270px;
      transform:translateX(-100%);
      transition:transform .22s ease;
      box-shadow:0 0 0 rgba(0,0,0,0);
    }
    .sidebar.open{
      transform:translateX(0);
      box-shadow:0 10px 40px rgba(0,0,0,.28);
    }
    .sidebar-close{
      display:flex;align-items:center;justify-content:center;
      width:30px;height:30px;border-radius:8px;border:none;
      background:var(--navy-700);color:#fff;cursor:pointer;flex:none;
    }
    .sidebar-close svg{width:16px;height:16px;}

    .hamburger{display:flex;}

    .sidebar-backdrop{
      display:none;position:fixed;inset:0;background:rgba(15,32,56,.45);
      z-index:55;
    }
    .sidebar-backdrop.open{display:block;}

    .search{display:none;}
    .content{padding:16px 14px 36px 14px;}
    .topbar{padding:0 14px;}
    .pagehead{align-items:flex-start;}
  }

  @media (max-width: 640px){
    .grid-2, .grid-3, .grid-4{grid-template-columns:1fr !important;}
    .form-grid{grid-template-columns:1fr !important;}
    .card{padding:14px !important;}
  }

  /* ---------- PM รถขนส่ง / LINE preview ---------- */
  .pm-line-grid{
    display:grid;grid-template-columns:repeat(auto-fill, minmax(280px, 1fr));gap:16px;
  }
  .line-bubble{
    background:#06C755;color:#fff;border-radius:14px;padding:14px 16px;
    font-size:13px;line-height:1.7;margin-top:10px;
  }
  .line-bubble-head{
    display:flex;align-items:center;gap:7px;margin-bottom:10px;
    font-weight:600;font-size:11.5px;color:#fff;opacity:.85;text-transform:uppercase;letter-spacing:.3px;
  }
  .line-bubble-head svg{width:16px;height:16px;flex:none;}

  .pagehead{display:flex;align-items:flex-end;justify-content:space-between;margin-bottom:20px;flex-wrap:wrap;gap:12px;}
  .pagehead h1{font-size:22px;margin:0 0 4px 0;font-weight:600;}
  .pagehead p{margin:0;color:var(--text-600);font-size:13.5px;}

  .btn{
    border:none;border-radius:8px;padding:10px 16px;font-size:13.5px;font-weight:500;
    cursor:pointer;display:inline-flex;align-items:center;gap:7px;font-family:'Sarabun',sans-serif;
  }
  .btn svg{width:15px;height:15px;}
  .btn-primary{background:var(--navy-900);color:#fff;}
  .btn-primary:hover{background:var(--navy-700);}
  .btn-amber{background:var(--amber-500);color:#1A1204;font-weight:600;}
  .btn-amber:hover{background:var(--amber-600);}
  
  .btn-ghost{background:#fff;border:1px solid var(--border);color:var(--text-900);}
  .btn-ghost:hover{border-color:var(--text-400);}
  .btn-sm{padding:6px 11px;font-size:12.5px;}
  .btn-danger-ghost{background:#fff;border:1px solid var(--border);color:var(--danger);}

  /* ---------- cards / grid ---------- */
  .grid{display:grid;gap:16px;}
  .grid-4{grid-template-columns:repeat(4,1fr);}
  .grid-3{grid-template-columns:repeat(3,1fr);}
  .grid-2{grid-template-columns:2fr 1fr;}
  @media(max-width:1100px){.grid-4{grid-template-columns:repeat(2,1fr);} .grid-2{grid-template-columns:1fr;}}

  .card{background:var(--card);border:1px solid var(--border);border-radius:12px;padding:18px 20px;}
  .card h3{margin:0 0 14px 0;font-size:15px;font-weight:600;}
  .card-title-row{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px;}
  .card-title-row h3{margin:0;}

  .kpi-card{position:relative;overflow:hidden;}
  .kpi-label{font-size:12.5px;color:var(--text-600);margin-bottom:8px;display:flex;align-items:center;gap:7px;}
  .kpi-icon{width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;flex:none;}
  .kpi-icon svg{width:14px;height:14px;}
  .kpi-value{font-size:26px;font-weight:700;font-family:'Kanit',sans-serif;}
  .kpi-sub{font-size:12px;margin-top:6px;color:var(--text-400);}
  .kpi-sub.up{color:var(--success);}
  .kpi-sub.down{color:var(--danger);}

  /* ---------- table (โทนเหลือง-เทา-ดำ) ---------- */
  .table-wrap{overflow-x:auto;}
  table{width:100%;border-collapse:collapse;font-size:13.5px;}
  th{
    text-align:left;color:#57534A;font-weight:700;font-size:12px;
    text-transform:uppercase;letter-spacing:.3px;padding:11px 12px;
    border-bottom:2px solid #E7E1D2;white-space:nowrap;background:#F6F4EF;
  }
  td{padding:11px 12px;border-bottom:1px solid #ECE7DA;white-space:nowrap;color:#1C1917;}
  tr:last-child td{border-bottom:none;}
  .table-wrap tbody tr:nth-child(even) td{background:#FBFAF6;}
  .table-wrap tbody tr:hover td{background:#FFF6D8;}

  /* แถวรวม/ยอดสรุป (มี <b> อยู่ในเซลล์) ไฮไลต์เป็นแถบเหลืองอ่อนแบบในภาพตัวอย่าง — เฉพาะตารางข้อมูลหลัก */
  .table-wrap tbody tr:has(td b){background:#FFF3C4;}
  .table-wrap tbody tr:has(td b) td{font-weight:700;color:#1C1917;background:transparent;border-top:1px solid #E8CE72;}
  .table-wrap tbody tr:has(td b):hover td{background:#FFEDA8;}

  .row-flag td{background:var(--danger-bg) !important;}
  .table-wrap tbody tr.row-flag:hover td{background:#F8DEDE !important;}

  .badge{display:inline-flex;align-items:center;gap:5px;padding:3px 10px;border-radius:100px;font-size:12px;font-weight:600;}
  .badge svg{width:10px;height:10px;}
  .badge-success{background:var(--success-bg);color:var(--success);}
  .badge-warning{background:var(--warning-bg);color:var(--warning);}
  .badge-danger{background:var(--danger-bg);color:var(--danger);}
  .badge-neutral{background:#F0EDE4;color:#57534A;}

  .toolbar{display:flex;align-items:center;gap:10px;margin-bottom:16px;flex-wrap:wrap;justify-content:space-between;}
  .filters{display:flex;gap:8px;flex-wrap:wrap;align-items:center;}
  select,.tinput{
    border:1px solid var(--border);border-radius:8px;padding:8px 10px;font-size:13px;
    font-family:'Sarabun',sans-serif;color:var(--text-900);background:#fff;
  }
  .tabs{display:flex;gap:4px;background:#EEF0F3;padding:4px;border-radius:9px;width:fit-content;}
  .tab{padding:7px 14px;border-radius:7px;font-size:13px;cursor:pointer;color:var(--text-600);font-weight:500;}
  .tab.active{background:#fff;color:var(--text-900);box-shadow:0 1px 2px rgba(16,24,40,.08);}

  /* ---------- forms ---------- */
  .form-section{margin-bottom:18px;}
  .form-section-title{
    font-size:13px;font-weight:600;color:var(--navy-900);margin-bottom:12px;
    display:flex;align-items:center;gap:8px;
  }
  .form-section-title .num{
    width:20px;height:20px;border-radius:6px;background:var(--amber-100);color:var(--amber-600);
    font-size:11px;font-weight:700;display:flex;align-items:center;justify-content:center;flex:none;
  }
  .form-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;}
  .form-grid.cols-3{grid-template-columns:repeat(3,1fr);}
  .form-grid.cols-2{grid-template-columns:repeat(2,1fr);}
  @media(max-width:900px){.form-grid{grid-template-columns:repeat(2,1fr);}}
  .field label{display:block;font-size:12.5px;color:var(--text-600);margin-bottom:6px;font-weight:500;}
  .field input,.field select{
    width:100%;border:1px solid var(--border);border-radius:8px;padding:9px 11px;font-size:13.5px;
    font-family:'Sarabun',sans-serif;color:var(--text-900);background:#fff;
  }
  .field input:focus,.field select:focus{outline:2px solid var(--amber-500);outline-offset:0;border-color:var(--amber-500);}
  .field input[readonly]{background:var(--amber-100);color:var(--amber-600);font-weight:600;border-color:var(--amber-100);}
  .field .hint{font-size:11px;color:var(--text-400);margin-top:4px;}
  .field.wide{grid-column:span 2;}

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

  .summary-strip{
    display:flex;align-items:center;justify-content:space-between;background:var(--navy-900);
    border-radius:12px;padding:16px 20px;color:#fff;margin-top:18px;flex-wrap:wrap;gap:14px;
  }
  .summary-strip .item{text-align:left;}
  .summary-strip .item span{display:block;font-size:11.5px;color:#93A6C2;margin-bottom:4px;}
  .summary-strip .item b{font-size:19px;font-family:'Kanit',sans-serif;}
  .summary-strip .actions{display:flex;gap:8px;}

    /* ---------- General Table (ตาราง ) ---------- */
  .table-wraper{border:1px solid #E7E1D2;border-radius:10px;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;background:#fff;max-width:100%;}
  .table{width:100%;border-collapse:collapse;font-size:13px;}
  .table th{
    background:#F6F4EF;color:#57534A;font-size:11.5px;font-weight:600;text-transform:none;letter-spacing:0;
    padding:8px 12px;border-bottom:1px solid #E7E1D2;text-align:left;
  }
  .table td{padding:5px 12px;border-bottom:1px solid #F0ECE2;color:#1C1917;height:38px;vertical-align:middle;}
  .table tbody tr:last-child td{border-bottom:none;}
  .table tbody tr:hover td{background:#FFFBEB;}
  .table .num{text-align:right;width:150px;font-variant-numeric:tabular-nums;}
  .table .act{width:64px;text-align:center;}
  .table td.paid{color:#8A857B;}
  .input,.select{
    height:28px;border:1px solid #DDD8CB;border-radius:6px;background:#fff;font-size:13px;
    font-family:'Sarabun',sans-serif;color:#1C1917;padding:0 8px;
  }
  .input{width:110px;text-align:right;font-variant-numeric:tabular-nums;}
  .select{width:100%;max-width:340px;color:#57534A;}
  .input:focus,.select:focus{outline:2px solid var(--amber-500);outline-offset:-1px;border-color:var(--amber-500);}
  .table-del{
    width:26px;height:26px;border:none;background:none;color:#A8A29E;border-radius:6px;cursor:pointer;
    display:inline-flex;align-items:center;justify-content:center;
  }
  .table-del:hover{background:var(--danger-bg);color:var(--danger);}
  .table-del svg{width:15px;height:15px;}
  .table-add td{background:#FAF8F2;border-top:1px dashed #DDD8CB;border-bottom:none;}
  .table-add-btn{
    height:28px;padding:0 14px;border:none;border-radius:6px;background:var(--amber-500);color:#1A1204;
    font-family:'Kanit',sans-serif;font-weight:600;font-size:12.5px;cursor:pointer;
  }
  .table-add-btn:hover:not(:disabled){background:var(--amber-600);}
  .table-add-btn:disabled{background:#E7E5DF;color:#A8A29E;cursor:not-allowed;}
  .table-total td{background:#FFF3C4;font-weight:700;border-top:1px solid #E8CE72;height:36px;}

  /* ---------- ExpenseTable (ตารางค่าใช้จ่ายแบบกะทัดรัด) ---------- */
  .exp{border:1px solid #E7E1D2;border-radius:10px;overflow:hidden;background:#fff;}
  .exp-table{width:100%;border-collapse:collapse;font-size:13px;}
  .exp-table th{
    background:#F6F4EF;color:#57534A;font-size:11.5px;font-weight:600;text-transform:none;letter-spacing:0;
    padding:8px 12px;border-bottom:1px solid #E7E1D2;text-align:left;
  }
  .exp-table td{padding:5px 12px;border-bottom:1px solid #F0ECE2;color:#1C1917;height:38px;vertical-align:middle;}
  .exp-table tbody tr:last-child td{border-bottom:none;}
  .exp-table tbody tr:hover td{background:#FFFBEB;}
  .exp-table .num{text-align:right;width:150px;font-variant-numeric:tabular-nums;}
  .exp-table .act{width:64px;text-align:center;}
  .exp-table td.paid{color:#8A857B;}
  .exp-input,.exp-select{
    height:28px;border:1px solid #DDD8CB;border-radius:6px;background:#fff;font-size:13px;
    font-family:'Sarabun',sans-serif;color:#1C1917;padding:0 8px;
  }
  .exp-input{width:110px;text-align:right;font-variant-numeric:tabular-nums;}
  .exp-select{width:100%;max-width:340px;color:#57534A;}
  .exp-input:focus,.exp-select:focus{outline:2px solid var(--amber-500);outline-offset:-1px;border-color:var(--amber-500);}
  .exp-del{
    width:26px;height:26px;border:none;background:none;color:#A8A29E;border-radius:6px;cursor:pointer;
    display:inline-flex;align-items:center;justify-content:center;
  }
  .exp-del:hover{background:var(--danger-bg);color:var(--danger);}
  .exp-del svg{width:15px;height:15px;}
  .exp-add td{background:#FAF8F2;border-top:1px dashed #DDD8CB;border-bottom:none;}
  .exp-add-btn{
    height:28px;padding:0 14px;border:none;border-radius:6px;background:var(--amber-500);color:#1A1204;
    font-family:'Kanit',sans-serif;font-weight:600;font-size:12.5px;cursor:pointer;
  }
  .exp-add-btn:hover:not(:disabled){background:var(--amber-600);}
  .exp-add-btn:disabled{background:#E7E5DF;color:#A8A29E;cursor:not-allowed;}
  .exp-total td{background:#FFF3C4;font-weight:700;border-top:1px solid #E8CE72;height:36px;}
  @media(max-width:640px){
    .exp-table .num{width:auto;}
    .exp-input{width:84px;}
  }

  /* mini employee add table */
  .mini-add{display:flex;gap:10px;align-items:flex-end;margin-bottom:12px;flex-wrap:wrap;}
  .mini-add .field{flex:1;min-width:140px;}

  /* modal */
  .modal-backdrop{
    display:none;position:fixed;inset:0;background:rgba(15,32,56,.55);
    align-items:center;justify-content:center;z-index:50;padding:20px;
  }
  .modal-backdrop.open{display:flex;}
  .modal{background:#fff;border-radius:14px;width:560px;max-width:100%;max-height:90vh;overflow-y:auto;}
  .modal-head{
    display:flex;align-items:center;justify-content:space-between;padding:18px 22px;
    border-bottom:1px solid var(--border);
  }
  .modal-head h3{margin:0;font-size:16px;}
  .modal-close{background:none;border:none;cursor:pointer;color:var(--text-400);width:28px;height:28px;}
  .modal-body{padding:20px 22px;}
  .modal-foot{padding:16px 22px;border-top:1px solid var(--border);display:flex;justify-content:flex-end;gap:8px;}

  .empty-state{
    text-align:center;padding:50px 20px;color:var(--text-400);
  }
  .empty-state svg{width:40px;height:40px;margin-bottom:10px;opacity:.5;}
  .empty-state p{margin:2px 0;font-size:13.5px;}

  .callout{
    display:flex;gap:10px;background:var(--teal-100);border:1px solid #BFE3DF;color:#0F5951;
    border-radius:9px;padding:11px 14px;font-size:12.5px;margin-bottom:16px;align-items:flex-start;
  }
  .callout svg{width:16px;height:16px;flex:none;margin-top:1px;}

  .placeholder-chart{
    height:220px;border-radius:10px;background:
      repeating-linear-gradient(to top, transparent, transparent 34px, var(--border) 34px, var(--border) 35px),
      linear-gradient(180deg,#FBFBFC,#fff);
    border:1px solid var(--border);display:flex;align-items:flex-end;gap:10px;padding:16px;
  }
  .bar{flex:1;background:linear-gradient(180deg,var(--amber-500),var(--amber-600));border-radius:5px 5px 0 0;position:relative;}
  .bar.teal{background:linear-gradient(180deg,var(--teal-500),#166F65);}
  .bar span{position:absolute;bottom:-20px;left:0;right:0;text-align:center;font-size:10.5px;color:var(--text-400);}

  .foot-note{margin-top:26px;padding-top:16px;border-top:1px dashed var(--border);color:var(--text-400);font-size:12px;text-align:center;}

  ::-webkit-scrollbar{width:9px;height:9px;}
  ::-webkit-scrollbar-thumb{background:#D3D9E1;border-radius:6px;}

  /* ---------- GPS tracking ---------- */
  .map-card{
    border-radius:12px;overflow:hidden;position:relative;height:420px;
    background:
      linear-gradient(rgba(15,32,56,.03),rgba(15,32,56,.03)),
      repeating-linear-gradient(0deg, #EEF1F5 0 1px, transparent 1px 34px),
      repeating-linear-gradient(90deg, #EEF1F5 0 1px, transparent 1px 34px),
      #FAFBFC;
  }
  .map-toolbar{
    position:absolute;top:12px;left:12px;right:12px;display:flex;justify-content:space-between;
    align-items:center;gap:8px;z-index:2;
  }
  .map-legend{
    position:absolute;bottom:12px;left:12px;background:#fff;border:1px solid var(--border);
    border-radius:9px;padding:10px 12px;font-size:11.5px;color:var(--text-600);z-index:2;box-shadow:0 2px 6px rgba(16,24,40,.06);
  }
  .map-legend .lg{display:flex;align-items:center;gap:6px;margin-bottom:5px;}
  .map-legend .lg:last-child{margin-bottom:0;}
  .dot-sw{width:9px;height:9px;border-radius:50%;flex:none;}
  .live-vehicle{
    position:absolute;width:30px;height:30px;border-radius:50%;background:var(--navy-900);
    display:flex;align-items:center;justify-content:center;color:#fff;z-index:3;
    box-shadow:0 0 0 6px rgba(15,32,56,.12);
  }
  .live-vehicle svg{width:15px;height:15px;}
  .live-vehicle::after{
    content:'';position:absolute;inset:-6px;border-radius:50%;border:2px solid var(--navy-900);
    opacity:.4;animation:pulse 2s infinite;
  }
  @keyframes pulse{0%{transform:scale(.8);opacity:.5;}100%{transform:scale(1.6);opacity:0;}}
  .pin{
    position:absolute;width:24px;height:24px;border-radius:50% 50% 50% 0;transform:rotate(-45deg);
    display:flex;align-items:center;justify-content:center;z-index:2;box-shadow:0 2px 4px rgba(16,24,40,.25);
  }
  .pin span{transform:rotate(45deg);font-size:10px;font-weight:700;color:#fff;}
  .pin.done{background:var(--success);}
  .pin.pending{background:var(--text-400);}
  .pin.flag{background:var(--danger);}
  .route-line{position:absolute;z-index:1;stroke:var(--amber-500);stroke-width:2.5;stroke-dasharray:6 5;fill:none;}

  .phone-frame{
    width:100%;max-width:280px;margin:0 auto;background:var(--navy-900);border-radius:32px;
    padding:14px 10px;box-shadow:0 10px 30px rgba(15,32,56,.25);
  }
  .phone-screen{background:#fff;border-radius:22px;overflow:hidden;min-height:420px;display:flex;flex-direction:column;}
  .phone-status{display:flex;justify-content:space-between;padding:8px 16px 2px 16px;font-size:10.5px;color:var(--text-400);}
  .phone-head{padding:10px 16px 12px 16px;border-bottom:1px solid var(--border);}
  .phone-head .tripno{font-size:11px;color:var(--text-400);}
  .phone-head .stopcount{font-size:15px;font-weight:600;font-family:'Kanit',sans-serif;margin-top:2px;}
  .phone-body{padding:14px 16px;flex:1;display:flex;flex-direction:column;}
  .stop-card{background:var(--bg);border:1px solid var(--border);border-radius:12px;padding:13px 14px;margin-bottom:12px;}
  .stop-card .name{font-weight:600;font-size:13.5px;margin-bottom:3px;}
  .stop-card .addr{font-size:11.5px;color:var(--text-600);line-height:1.5;}
  .gps-capture{
    border:1.5px dashed #C9D2DE;border-radius:12px;padding:16px;text-align:center;margin-bottom:14px;background:#FAFBFC;
  }
  .gps-capture svg{width:22px;height:22px;color:var(--teal-500);margin-bottom:6px;}
  .gps-capture .coords{font-size:11.5px;color:var(--text-600);font-family:'Kanit',sans-serif;}
  .gps-capture .accuracy{font-size:10.5px;color:var(--text-400);margin-top:2px;}
  .confirm-btn{
    margin-top:auto;background:var(--amber-500);color:#1A1204;border:none;border-radius:12px;
    padding:14px;font-family:'Kanit',sans-serif;font-weight:600;font-size:14.5px;display:flex;
    align-items:center;justify-content:center;gap:8px;cursor:pointer;
  }
  .confirm-btn svg{width:18px;height:18px;}
  .stop-progress{display:flex;gap:4px;padding:0 16px 10px 16px;}
  .stop-progress i{flex:1;height:4px;border-radius:3px;background:var(--border);}
  .stop-progress i.done{background:var(--success);}
  .stop-progress i.current{background:var(--amber-500);}

  .timeline{position:relative;padding-left:26px;}
  .timeline::before{content:'';position:absolute;left:9px;top:4px;bottom:4px;width:2px;background:var(--border);}
  .timeline-item{position:relative;padding-bottom:18px;}
  .timeline-item:last-child{padding-bottom:0;}
  .timeline-dot{
    position:absolute;left:-26px;top:1px;width:19px;height:19px;border-radius:50%;
    display:flex;align-items:center;justify-content:center;flex:none;border:3px solid #fff;
  }
  .timeline-dot svg{width:10px;height:10px;}
  .timeline-dot.done{background:var(--success);}
  .timeline-dot.flag{background:var(--danger);}
  .timeline-dot.pending{background:var(--text-400);}
  .timeline-row{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;}
  .timeline-row .t-name{font-size:13.5px;font-weight:600;}
  .timeline-row .t-meta{font-size:11.5px;color:var(--text-400);margin-top:2px;}
  .timeline-row .t-time{font-size:12px;color:var(--text-600);white-space:nowrap;text-align:right;}

  /* ---------- auth: login page ---------- */
  .auth-shell{
    min-height:100vh;display:flex;align-items:center;justify-content:center;
    background:var(--navy-900);padding:24px;
  }
  .auth-card{
    width:100%;max-width:400px;background:#fff;border-radius:16px;
    padding:32px 30px;box-shadow:0 24px 60px rgba(0,0,0,.35);
  }
  .auth-brand{text-align:center;margin-bottom:24px;}
  .auth-brand h1{font-family:'Kanit',sans-serif;font-size:22px;margin-bottom:4px;}
  .auth-brand p{font-size:13px;color:var(--text-600);}
  .auth-error{
    background:var(--danger-bg);color:var(--danger);border-radius:8px;
    padding:10px 12px;font-size:12.5px;
  }
  .auth-hint{
    margin-top:22px;padding-top:18px;border-top:1px solid var(--border);
    font-size:12px;color:var(--text-600);
  }
  .auth-hint b{display:block;margin-bottom:8px;color:var(--text-900);font-size:12.5px;}
  .auth-hint table td{border:none;padding:3px 8px 3px 0;font-size:11.5px;white-space:normal;}
  .auth-hint table tr td:first-child{font-family:'Kanit',sans-serif;color:var(--amber-600);font-weight:600;}

  /* ---------- sidebar: logged-in user + logout ---------- */
  .logout-btn{
    position:absolute;right:14px;top:50%;transform:translateY(-50%);
    width:30px;height:30px;border-radius:8px;border:none;background:rgba(255,255,255,.08);
    color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;flex:none;
  }
  .logout-btn:hover{background:rgba(255,255,255,.16);}
  .logout-btn svg{width:15px;height:15px;}


  .status-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
    margin: 0;
    cursor: pointer;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* ตัวราง */
.slider {
    position: absolute;
    inset: 0;
    background-color: #d1d5db;
    border-radius: 24px;
    transition: 0.25s;
}

/* ปุ่มวงกลม */
.slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background-color: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: 0.25s;
}

/* เปิด */
.switch input:checked + .slider {
    background-color: #1e8f82;
}

.switch input:checked + .slider::before {
    transform: translateX(22px);
}

/* ข้อความสถานะ */
.status-text {
    font-size: 14px;
    font-weight: 500;
}

.status-text.active {
    color: #198754;
}

.status-text.inactive {
    color: #6c757d;
}

.check-item label{
   font-size: 14px;
}

  
#tripDay input { 
    width: 80px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 13.5px;
    font-family: 'Sarabun', sans-serif;
    color: var(--text-900);
    background: #fff;
 }

/* Column 1 */
#tripDay th:nth-child(1),
#tripDay td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 80px;
    width: 80px;
    text-align: left;
    background: #f6f4ef;
}

/* Column 2 */
#tripDay th:nth-child(2),
#tripDay td:nth-child(2) {
    position: sticky;
    left: 80px;
    z-index: 2;
    min-width: 80px;
    width: 80px;
    text-align: left;
    background: #f6f4ef;
    box-shadow: 6px 0 12px rgba(15, 23, 42, .04);
}

#tripDay th, #tripDay td:not(nth-child(2)) {
    min-width: 78px;
    padding: 8px;
    border-right: 1px solid #e6ebf2;
    border-bottom: 1px solid #e6ebf2;
    text-align: center;
    vertical-align: middle;
}
#tripDay th, #tripDay td:not(nth-child(2)) {
    min-width: 78px;
    padding: 8px;
    border-right: 1px solid #e6ebf2;
    border-bottom: 1px solid #e6ebf2;
    text-align: center;
    vertical-align: middle;
}

#tripDay th, #tripDay td {
    min-width: 78px;
    padding: 8px;
    border-right: 1px solid #e6ebf2;
    border-bottom: 1px solid #e6ebf2;
    text-align: center;
    vertical-align: middle;
}

.month-labels {
    display: flex;
    gap: 8px;
    flex-wrap: wrap; 
    border: 1px solid #e9effd;
    border-radius: 8px;
    background: #e9effd;
}

.paper-label {
    position: relative;
    min-height: 32px;
    padding: 5px 12px 5px 14px;
    border: 1px solid #d8dec8;
    border-radius: 4px 8px 8px 4px;
    color: #526047;
    background: linear-gradient(180deg, #fffef8, #f1efd9);
    box-shadow: 0 3px 8px rgba(82, 96, 71, .08);
    font-size: 12px; 
}

    .paper-label::before {
        content: "";
        position: absolute;
        left: -1px;
        top: 7px;
        width: 4px;
        height: calc(100% - 14px);
        border-radius: 0 3px 3px 0;
        background: #c7d6a6;
    }

    .paper-label:hover {
        color: #1f5f32;
        border-color: #b9c994;
        background: #eef3df;
    }

    .paper-label.active {
        color: #fff;
        border-color: #f2a93b;
        background: #f2a93b ;
    }

        .paper-label.active::before {
            background: #55554f;
        }


/* ---------- รายการทริป: filter 2 แถว ---------- */
.trip-filters{display:flex;flex-direction:column;gap:10px;margin-bottom:16px;}
.trip-filter-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap;}

/* ---------- แดชบอร์ด: กราฟเส้นค่าใช้จ่ายแยกประเภท ---------- */
.cost-legend{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px;}
.cost-legend-item{display:inline-flex;align-items:center;gap:6px;padding:4px 10px;border:1px solid var(--border);border-radius:999px;background:#fff;font-size:12.5px;color:var(--text-900);cursor:pointer;}
.cost-legend-item i{width:10px;height:10px;border-radius:50%;display:inline-block;}
.cost-legend-item.off{opacity:.45;text-decoration:line-through;}
.cost-linechart{border:1px solid var(--border);border-radius:10px;padding:8px;background:#fff;}
.cost-linechart svg{width:100%;height:auto;display:block;}
.cost-dot{display:inline-block;width:9px;height:9px;border-radius:50%;margin-right:8px;}

/* Chart.js wrapper (ChartView) */
.chart-view{position:relative;width:100%;}
.chart-view canvas{max-width:100%;}

.kpi-annual th,.kpi-annual td{text-align:right;white-space:nowrap;}
.kpi-annual th:nth-child(-n+2),.kpi-annual td:nth-child(-n+2){text-align:left;}
.kpi-annual td:nth-child(1){min-width:230px;}

/* ใบรายการโอนทริป (TransferPrint): ความกว้างคอลัมน์ — รวมต้อง = 100%
   1 ลำดับ | 2 เลขที่ใบ | 3 รายชื่อพนักงาน | 4 เลขที่บัญชี | 5 สาย | 6 จำนวนเงิน | 7 เลขที่อนุมัติ | 8 วันที่ออกทริป | 9 ผู้จัดการ | 10 ผู้โอน/วันที่โอน | 11 หมายเหตุ */
.pay-sheet colgroup col:nth-child(1)  { width: 3.5% !important; }
.pay-sheet colgroup col:nth-child(2)  { width: 8%   !important; }
.pay-sheet colgroup col:nth-child(3)  { width: 23%  !important; }
.pay-sheet colgroup col:nth-child(4)  { width: 8%   !important; }
.pay-sheet colgroup col:nth-child(5)  { width: 11%  !important; }
.pay-sheet colgroup col:nth-child(6)  { width: 7%   !important; }
.pay-sheet colgroup col:nth-child(7)  { width: 8%   !important; }
.pay-sheet colgroup col:nth-child(8)  { width: 8%   !important; }
.pay-sheet colgroup col:nth-child(9)  { width: 8%   !important; }
.pay-sheet colgroup col:nth-child(10) { width: 8%   !important; }
.pay-sheet colgroup col:nth-child(11) { width: 7.5% !important; }

/* ตาราง Responsive (ใส่ class "table-resp" ที่ <table class="table table-resp">):
   หน้าจอแคบจะเลื่อนซ้าย-ขวาได้ในกรอบตาราง ไม่ถูกตัดคอลัมน์ท้าย และไม่ตัดบรรทัดข้อความ */
.table.table-resp{min-width:980px;}
.table.table-resp th,.table.table-resp td{white-space:nowrap;}
.table.table-resp th:first-child,.table.table-resp td:first-child{position:sticky;left:0;z-index:1;background:#fff;box-shadow:1px 0 0 #E7E1D2;}
.table.table-resp th:first-child{background:#F6F4EF;z-index:2;}
.table.table-resp tbody tr:hover td:first-child{background:#FFFBEB;}
@media(max-width:640px){
  .table.table-resp{min-width:900px;font-size:12.5px;}
  .table.table-resp td{height:44px;}
}

/* ปุ่มติดตั้ง PWA: แสดงเมื่อเบราว์เซอร์พร้อมให้ติดตั้งเท่านั้น (pwa.js ตั้ง data-can-install) */
#installApp{display:none}
html[data-can-install] #installApp{display:block}
