:root {
  --navy: #1b2a4a; --navy-dark: #121e36; --accent: #2563eb; --accent-light: #eaf0ff;
  --green: #15803d; --amber: #b45309; --red: #b91c1c; --gray-bg: #f4f6f9;
  --border: #dfe4ec; --text: #1f2937; --muted: #6b7280;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: var(--gray-bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy), var(--navy-dark)); }
.login-card { background: #fff; padding: 36px 40px; border-radius: 10px; width: 340px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p.sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; }
.btn:hover { background: #1d4ed8; }
.btn.secondary { background: #fff; color: var(--accent); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.error-msg { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; padding: 8px 10px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 14px; line-height: 1.5; }

/* ---------- Shell ---------- */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 10; }
.topbar .brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav button { background: transparent; border: none; color: #cbd5e1; padding: 8px 14px; border-radius: 6px; font-size: 13px; font-weight: 600; }
.topbar nav button.active, .topbar nav button:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar .user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #cbd5e1; }
.topbar .user b { color: #fff; }
main { max-width: 1200px; margin: 0 auto; padding: 22px 20px 60px; }

/* ---------- Cards / summary ---------- */
.summary-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 20px; }
.summary-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; cursor: pointer; transition: box-shadow .15s; }
.summary-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.summary-card .num { font-size: 22px; font-weight: 700; }
.summary-card .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 2px; }
.summary-card.alert .num { color: var(--red); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; background: #fff; border: 1px solid var(--border); padding: 10px; border-radius: 8px; }
.toolbar input, .toolbar select { padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.toolbar .spacer { flex: 1; }

/* ---------- Table ---------- */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { background: #fafbfc; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); cursor: pointer; user-select: none; }
th:hover { color: var(--text); }
tbody tr:hover { background: var(--accent-light); cursor: pointer; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge.Draft { background: #f1f5f9; color: #475569; }
.badge.DocumentsinProgress { background: #fef3c7; color: var(--amber); }
.badge.ReadyforDispatch { background: #dbeafe; color: var(--accent); }
.badge.Dispatched, .badge.InTransit { background: #e0e7ff; color: #4338ca; }
.badge.Delivered { background: #dcfce7; color: var(--green); }
.badge.Completed { background: #d1fae5; color: var(--green); }
.badge.Cancelled { background: #fee2e2; color: var(--red); }
.badge.Pending { background: #fef3c7; color: var(--amber); }
.badge.Approved { background: #dbeafe; color: var(--accent); }
.badge.Paid { background: #dcfce7; color: var(--green); }
.doc-progress { display: inline-flex; align-items: center; gap: 6px; }
.doc-progress .bar { width: 60px; height: 6px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.doc-progress .fill { height: 100%; background: var(--green); }

/* ---------- Detail page ---------- */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.detail-header h2 { margin: 0 0 4px; }
.section { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; margin-bottom: 16px; }
.section h3 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.important-note { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 12px; border-radius: 6px; font-weight: 600; margin-bottom: 16px; }
.doc-table td, .doc-table th { white-space: normal; }
.doc-status { font-weight: 700; font-size: 12px; }
.doc-status.Pending { color: var(--amber); }
.doc-status.Uploaded { color: var(--green); }
.doc-status.NotApplicable { color: var(--muted); }
.remark-item { border-left: 3px solid var(--border); padding: 8px 10px; margin-bottom: 8px; font-size: 13px; background: #fafbfc; }
.remark-item.important { border-color: var(--amber); background: #fffbeb; }
.remark-meta { color: var(--muted); font-size: 11px; margin-top: 4px; }
.history-item { font-size: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs button { background: #fff; border: 1px solid var(--border); padding: 7px 14px; font-size: 13px; border-radius: 6px; }
.tabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 10px; width: 480px; max-width: 92vw; padding: 22px; max-height: 88vh; overflow: auto; }
.modal h3 { margin-top: 0; }
.row-actions { display: flex; gap: 8px; margin-top: 16px; }
.small { font-size: 12px; color: var(--muted); }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 8px; font-size: 13px; z-index: 100; box-shadow: 0 4px 20px rgba(0,0,0,.2); }
.toast.error { background: var(--red); }

/* ---------- Mobile responsiveness ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 8px; }
  .topbar .brand { font-size: 14px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .topbar nav button { white-space: nowrap; padding: 7px 10px; font-size: 12px; }
  .topbar .user { font-size: 12px; gap: 6px; }
  main { padding: 14px 10px 40px; }

  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .summary-card { padding: 10px; }
  .summary-card .num { font-size: 18px; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input, .toolbar select, .toolbar .btn, .toolbar a.btn { width: 100%; }
  .toolbar .spacer { display: none; }

  table { font-size: 12px; }
  th, td { padding: 7px 8px; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  .detail-header { flex-direction: column; align-items: stretch; }
  .detail-header > div:last-child { display: flex; flex-wrap: wrap; gap: 6px; }
  .detail-header select, .detail-header button { flex: 1; }

  .modal { width: 94vw; padding: 16px; }
  .login-card { width: 90vw; padding: 26px 22px; }

  .doc-table th, .doc-table td { font-size: 12px; }
  .toast { left: 12px; right: 12px; bottom: 12px; }
}

@media (max-width: 480px) {
  .summary-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .topbar .user span, .topbar .user b { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
}
