  :root {
    --bg: #f1f4f9;
    --panel: #ffffff;
    --sidebar: #14213d;
    --sidebar-hover: #1f3160;
    --accent: #e07a00;
    --accent-dark: #b86000;
    --text: #1d2433;
    --muted: #6b7587;
    --border: #dfe4ee;
    --danger: #d64545;
    --success: #1f9d63;
    --warning: #e0a100;
    --radius: 10px;
    --shadow: 0 2px 10px rgba(20, 33, 61, 0.08);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
  .hidden { display: none !important; }
  button { font-family: inherit; cursor: pointer; }

  /* ---------- Login ---------- */
  #login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #14213d 0%, #2a3f73 100%); padding: 20px; }
  .login-card { background: var(--panel); width: 100%; max-width: 400px; padding: 36px 32px; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
  .login-card h1 { font-size: 1.35rem; text-align: center; color: var(--sidebar); }
  .login-card .sub { text-align: center; color: var(--muted); font-size: .9rem; margin: 6px 0 24px; }
  .brand-badge { width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 1.3rem; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
  .hint { margin-top: 18px; font-size: .8rem; color: var(--muted); background: #f6f8fc; border: 1px dashed var(--border); padding: 10px 12px; border-radius: 8px; line-height: 1.6; }

  /* ---------- Forms ---------- */
  label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
  input, select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: .95rem; background: #fff; color: var(--text); font-family: inherit; }
  input:focus, select:focus { outline: 2px solid rgba(224,122,0,.35); border-color: var(--accent); }
  select:disabled { background: #eef1f6; color: var(--muted); }
  .field { margin-bottom: 14px; }
  .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: end; }
  .error-msg { color: var(--danger); font-size: .85rem; margin-bottom: 12px; min-height: 1em; }

  .btn { border: none; padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: .9rem; transition: background .15s, transform .05s; }
  .btn:active { transform: translateY(1px); }
  .btn-primary { background: var(--accent); color: #fff; }
  .btn-primary:hover { background: var(--accent-dark); }
  .btn-secondary { background: #e8ecf4; color: var(--text); }
  .btn-secondary:hover { background: #d9dfeb; }
  .btn-danger { background: var(--danger); color: #fff; }
  .btn-danger:hover { background: #b83636; }
  .btn-block { width: 100%; padding: 12px; }
  .btn-sm { padding: 6px 12px; font-size: .8rem; }

  /* ---------- Layout ---------- */
  #app { display: flex; min-height: 100vh; }
  .sidebar { width: 250px; background: var(--sidebar); color: #fff; display: flex; flex-direction: column; padding: 22px 14px; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
  .sidebar .logo { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 18px; }
  .sidebar .logo .brand-badge { margin: 0; width: 40px; height: 40px; font-size: 1rem; flex-shrink: 0; }
  .sidebar .logo span { font-size: .95rem; font-weight: 600; line-height: 1.25; }
  .nav-item { display: block; width: 100%; text-align: left; background: none; border: none; color: #c9d3ea; padding: 12px 14px; border-radius: 8px; font-size: .95rem; margin-bottom: 4px; }
  .nav-item:hover { background: var(--sidebar-hover); color: #fff; }
  .nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
  .sidebar .spacer { flex: 1; }
  .user-box { padding: 12px; background: rgba(255,255,255,.07); border-radius: 8px; margin-bottom: 12px; font-size: .85rem; }
  .user-box strong { display: block; font-size: .95rem; }
  .role-pill { display: inline-block; margin-top: 4px; font-size: .7rem; padding: 2px 8px; border-radius: 20px; background: var(--accent); text-transform: uppercase; letter-spacing: .5px; }
  .role-pill.user { background: #4a6fd1; }

  .main { flex: 1; padding: 28px 32px; min-width: 0; }
  .page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
  .page-head h2 { font-size: 1.5rem; }

  /* ---------- Cards ---------- */
  .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 26px; }
  .card { background: var(--panel); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border-left: 5px solid var(--accent); }
  .card.alert { border-left-color: var(--danger); }
  .card.ok { border-left-color: var(--success); }
  .card .label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
  .card .value { font-size: 2.1rem; font-weight: 700; margin-top: 6px; }
  .card.alert .value { color: var(--danger); }

  .panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 26px; }
  .panel h3 { margin-bottom: 16px; font-size: 1.1rem; }

  .toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
  .toolbar .grow { flex: 1; min-width: 180px; }
  .toolbar select { width: auto; min-width: 180px; }

  /* ---------- Table ---------- */
  .table-wrap { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; font-size: .92rem; }
  th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
  td.wrap { white-space: normal; min-width: 160px; max-width: 280px; }
  th { background: #f6f8fc; font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
  tbody tr:hover { background: #fafbfe; }
  tr.low-row { background: #fff6f6; }
  .badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
  .badge.ok { background: #e3f6ec; color: var(--success); }
  .badge.low { background: #fff1d6; color: #9a6b00; }
  .badge.out { background: #fde6e6; color: var(--danger); }
  .actions { display: flex; gap: 6px; }
  .empty { text-align: center; color: var(--muted); padding: 30px 0; }

  /* ---------- Modal ---------- */
  .modal-backdrop { position: fixed; inset: 0; background: rgba(15, 22, 40, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
  .modal { background: #fff; border-radius: 12px; width: 100%; max-width: 440px; padding: 26px; box-shadow: 0 20px 60px rgba(0,0,0,.35); max-height: 92vh; overflow-y: auto; }
  .modal h3 { margin-bottom: 16px; }
  .modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
  .stock-note { font-size: .85rem; color: var(--muted); margin-top: 6px; }

  /* ---------- Toast ---------- */
  #toast { position: fixed; bottom: 24px; right: 24px; background: var(--sidebar); color: #fff; padding: 12px 20px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 100; opacity: 0; transform: translateY(20px); transition: all .25s; pointer-events: none; max-width: 340px; font-size: .9rem; }
  #toast.show { opacity: 1; transform: translateY(0); }
  #toast.error { background: var(--danger); }

  /* ---------- Audit sheet ---------- */
  .audit-sheet { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; color: #000; }
  .audit-head { text-align: center; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 12px; }
  .audit-head .co { font-size: 1.3rem; font-weight: 700; letter-spacing: .5px; }
  .audit-head .ttl { font-size: 1rem; font-weight: 600; margin-top: 3px; text-transform: uppercase; letter-spacing: 1px; }
  .audit-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; font-size: .85rem; margin-bottom: 14px; }
  .audit-meta div span { font-weight: 600; }
  .audit-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
  .audit-table th, .audit-table td { border: 1px solid #333; padding: 7px 8px; white-space: normal; color: #000; }
  .audit-table th { background: #e9e9e9; font-size: .75rem; text-transform: uppercase; letter-spacing: .3px; }
  .audit-table td.c, .audit-table th.c { text-align: center; }
  .audit-table td.blank { min-width: 80px; height: 30px; }
  .audit-table td.remarks { min-width: 120px; }
  .audit-table tr.cat td { background: #f2f2f2; font-weight: 700; text-transform: uppercase; font-size: .8rem; letter-spacing: .4px; }
  .audit-table tr.sub td { font-weight: 700; background: #fafafa; }
  .audit-table tr.grand td { font-weight: 700; background: #e9e9e9; font-size: .9rem; }
  .audit-note { font-size: .78rem; margin-top: 10px; }
  .audit-sign { display: grid; grid-template-columns: repeat(3, 1fr) 150px; gap: 18px; margin-top: 46px; font-size: .82rem; align-items: end; }
  .audit-sign .line { border-top: 1px solid #000; padding-top: 5px; text-align: center; }
  .audit-sign .stamp { border: 1.5px dashed #555; height: 100px; display: flex; align-items: center; justify-content: center; color: #777; font-size: .75rem; text-align: center; }

  /* ---------- Print ---------- */
  @page { size: A4 portrait; margin: 12mm; }
  @media print {
    html, body { background: #fff !important; }
    .sidebar, .no-print, #toast, .modal-backdrop { display: none !important; }
    #app { display: block; }
    .main { padding: 0; }
    .audit-sheet { box-shadow: none; border-radius: 0; padding: 0; }
    .audit-table { font-size: 10pt; }
    .audit-table thead { display: table-header-group; }
    .audit-table tr { page-break-inside: avoid; }
    .audit-table th, .audit-table tr.cat td, .audit-table tr.sub td, .audit-table tr.grand td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .audit-sign { page-break-inside: avoid; }
  }

  /* ---------- Responsive ---------- */
  @media (max-width: 800px) {
    #app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; gap: 6px; }
    .sidebar .logo { border: none; margin: 0; padding: 0 8px 0 0; }
    .sidebar .spacer, .user-box { display: none; }
    .nav-item { width: auto; margin: 0; padding: 8px 12px; }
    .main { padding: 18px 14px; }
  }
