/* ============================================================
   Cal Hono Customer Portal — design system
   ============================================================ */
:root {
  --navy: #0e2a47;
  --navy-2: #123c63;
  --accent: #0e7c6b;
  --bg: #f2f5f8;
  --card: #ffffff;
  --line: #dde3ea;
  --text: #22303e;
  --muted: #6a7684;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 34, 53, .08), 0 4px 14px rgba(16, 34, 53, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14.5px;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 60px 1fr auto;
  grid-template-areas: "sidebar topbar" "sidebar content" "sidebar footer";
}
a { color: #155e9c; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- sidebar ---------- */
.sidebar {
  grid-area: sidebar; background: var(--navy); color: #cfd9e4;
  display: flex; flex-direction: column; padding: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark { background: var(--accent); color: #fff; font-weight: 700; border-radius: 8px; padding: 7px 9px; font-size: 14px; }
.brand-name { font-weight: 600; color: #fff; font-size: 15px; line-height: 1.15; }
.brand-name small { display: block; font-weight: 400; color: #93a5b8; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.sidebar nav { display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; color: #c3cfdb; padding: 10px 12px;
  border-radius: 8px; font-weight: 500; text-decoration: none;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--navy-2); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar nav .ico { width: 18px; text-align: center; opacity: .85; }
.sidebar-foot { margin-top: auto; padding: 16px 18px; font-size: 11.5px; color: #7f90a3; border-top: 1px solid rgba(255,255,255,.1); line-height: 1.5; }

/* ---------- topbar ---------- */
.topbar {
  grid-area: topbar; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px;
}
.topsearch { display: flex; gap: 8px; flex: 0 1 460px; }
.topsearch input { flex: 1; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; }
.topsearch input:focus { outline: 2px solid #bcd6ee; border-color: #7fb0dc; }
.userchip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy-2); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.uname { font-size: 13px; font-weight: 600; line-height: 1.2; }
.uname small { display: block; font-weight: 400; color: var(--muted); }
.logout { font-size: 12.5px; margin-left: 6px; color: var(--muted); }

/* ---------- content ---------- */
.content { grid-area: content; padding: 24px 28px; }
.pagefoot { grid-area: footer; padding: 14px 28px; color: var(--muted); font-size: 12px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-head h1 { margin: 0; font-size: 21px; color: var(--navy); }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.breadcrumb { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.card-head h2 { margin: 0; font-size: 15px; color: var(--navy); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.kpi .n { font-size: 26px; font-weight: 700; color: var(--navy); }
.kpi .t { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi .hint { font-size: 11.5px; color: var(--accent); margin-top: 6px; }

/* ---------- tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 10px 14px; background: #f7f9fb; color: #51606f;
  border-bottom: 1px solid var(--line); font-weight: 600; font-size: 12.5px;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
table.data tr:hover td { background: #f6f9fc; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: Consolas, "Courier New", monospace; letter-spacing: .02em; }
.empty { padding: 34px; text-align: center; color: var(--muted); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.st-grey   { background: #e8ebef; color: #4a5560; }
.st-blue   { background: #dcebfd; color: #1d5c9e; }
.st-indigo { background: #e0e5fb; color: #3d4d9e; }
.st-amber  { background: #fdeeda; color: #9a6112; }
.st-purple { background: #ece0f8; color: #6d3a9c; }
.st-green  { background: #d9f0e4; color: #1a7a44; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-block; background: var(--navy-2); color: #fff; border: 1px solid transparent;
  padding: 8px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--navy); text-decoration: none; }
.btn-accent { background: var(--accent); } .btn-accent:hover { background: #0a6254; }
.btn-ghost { background: #fff; color: var(--navy-2); border-color: var(--line); }
.btn-ghost:hover { background: #f2f6fa; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field input, .field select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; background: #fff; min-width: 140px;
}
.field input:focus, .field select:focus { outline: 2px solid #bcd6ee; border-color: #7fb0dc; }
.result-line { color: var(--muted); font-size: 12.5px; margin: 12px 2px; }

/* ---------- timeline ---------- */
.timeline { display: flex; padding: 6px 4px 2px; overflow-x: auto; }
.tstep { flex: 1 1 0; min-width: 120px; text-align: center; position: relative; padding-top: 26px; }
.tstep::before { content: ""; position: absolute; top: 9px; left: 0; right: 0; height: 3px; background: #dfe5ec; }
.tstep:first-child::before { left: 50%; }
.tstep:last-child::before { right: 50%; }
.tstep .dot {
  position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
  width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid #cfd8e1;
}
.tstep.done::before { background: var(--accent); }
.tstep.done .dot { background: var(--accent); border-color: var(--accent); }
.tstep.current .dot { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px rgba(14,124,107,.18); }
.tstep .lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.tstep.done .lbl, .tstep.current .lbl { color: var(--text); }
.tstep .dt { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- detail meta grid ---------- */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 24px; }
.meta-item .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.meta-item .v { margin-top: 3px; font-size: 14px; }

/* ---------- documents list ---------- */
.doclist { display: flex; flex-direction: column; }
.docrow { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border-bottom: 1px solid #eef1f5; }
.docrow:last-child { border-bottom: none; }
.doc-ico { width: 40px; height: 40px; border-radius: 8px; background: #fdeaea; color: #b33; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.docrow .dmeta { flex: 1; }
.docrow .dmeta .dt { font-weight: 600; }
.docrow .dmeta .ds { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.docrow.pending .doc-ico { background: #e8ebef; color: #8a95a1; }
.docrow.pending .dmeta .dt { color: var(--muted); }

/* ---------- pager ---------- */
.pager { display: flex; gap: 6px; margin: 14px 2px; flex-wrap: wrap; }
.pgbtn { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 6px 11px; cursor: pointer; font-size: 13px; }
.pgbtn.cur { background: var(--navy-2); color: #fff; border-color: var(--navy-2); }
.pgbtn:disabled { opacity: .4; cursor: default; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(10, 22, 35, .55); display: none; align-items: center; justify-content: center; z-index: 50; padding: 24px; }
.modal.open { display: flex; }
.modal-card { background: #fff; border-radius: 12px; width: min(920px, 100%); height: min(86vh, 860px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-title { font-weight: 600; color: var(--navy); }
.modal-actions { display: flex; gap: 8px; }
.modal iframe { flex: 1; border: none; width: 100%; background: #525659; border-radius: 0 0 12px 12px; }

/* ---------- login ---------- */
body.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #0e2a47 0%, #123c63 55%, #0e7c6b 130%); grid-template-columns: none; }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.4); width: 400px; max-width: 92vw; padding: 34px 34px 26px; }
.login-card .brand { border: none; padding: 0 0 18px; align-items: center; }
.login-card .brand-name { color: var(--navy); font-size: 18px; }
.login-card .brand-name small { color: var(--muted); }
.login-card h2 { margin: 4px 0 2px; font-size: 19px; color: var(--navy); }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-card .field { margin-bottom: 14px; }
.login-card .field input { width: 100%; }
.login-card .btn { width: 100%; text-align: center; padding: 11px; }
.login-err { display: none; background: #fdecec; color: #a12622; border: 1px solid #f3c4c2; border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.demo-box { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 14px; font-size: 12.5px; color: var(--muted); }
.demo-box code { background: #f1f4f8; border-radius: 5px; padding: 2px 6px; font-size: 12px; color: var(--text); }
.demo-box .btn-sm { margin-top: 8px; margin-right: 6px; }

/* ---------- utility ---------- */
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  body { grid-template-columns: 1fr; grid-template-areas: "topbar" "content" "footer"; }
  .sidebar { display: none; }
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ---------- bar chart: orders per month ---------- */
.barchart { display: flex; align-items: flex-end; gap: 26px; padding: 30px 10px 0; height: 190px; }
.bargroup { display: flex; flex-direction: column; align-items: center; flex: 1; max-width: 96px; height: 100%; justify-content: flex-end; }
.bargroup .v { font-weight: 700; color: var(--navy); margin-bottom: 5px; font-size: 13.5px; }
.bargroup .bar { width: 62%; background: linear-gradient(180deg, #1a4f7e, var(--navy-2)); border-radius: 6px 6px 0 0; min-height: 4px; }
.bargroup .m { margin-top: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.chart-note { font-size: 12px; color: var(--muted); padding: 0 18px 14px; }

/* wide tables scroll on small screens */
.card-body.tight { overflow-x: auto; }

/* ---------- company logo ---------- */
.brand-mark-img { width: 42px; height: 42px; border-radius: 8px; background: transparent; }
.login-card .brand-mark-img { width: 54px; height: 54px; }
.small .brand-mark-img, .userchip .brand-mark-img { width: 30px; height: 30px; }

/* ===== admin console ===== */
.admin-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px;
  background: #223142; color: #fff; border: 1px solid #ffd23f; border-left-width: 5px;
  border-radius: 6px; padding: 12px 16px; margin: 0 0 18px; font-size: 13.5px; }
.admin-banner .ab-actions { display: flex; gap: 8px; flex: none; }
.admin-banner .btn { background: #ffd23f; border-color: #d9b62f; color: #223142; font-weight: 600; }
.admin-shell { max-width: 1100px; margin: 0 auto; padding: 26px 20px 40px; }
.admin-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.admin-head img { width: 44px; height: 44px; }
.admin-head h1 { margin: 0; color: var(--navy, #223142); font-size: 21px; }
.admin-head .sub { color: #67727e; font-size: 13px; }
.admin-head .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* ---------- admin sign-in (centered card, all-blue theme) ---------- */
body.login-page.admin-login {
  grid-template-columns: none;
  grid-template-rows: none;
  grid-template-areas: none;
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #0e2a47 0%, #123c63 50%, #1a4f7e 100%);
}
body.login-page.admin-login .login-card { border-top: 4px solid #1a4f7e; }
body.login-page.admin-login .login-card .btn-accent { background: #1a4f7e; }
body.login-page.admin-login .login-card .btn-accent:hover { background: #143f66; }
body.login-page.admin-login .pagefoot { display: none; }
.admin-login-tag { display: inline-block; background: #1a4f7e; color: #fff; border-radius: 999px;
  padding: 3px 12px; font-size: 11.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; margin-bottom: 10px; }

/* remember-password checkbox */
.remember-line { display: flex !important; gap: 8px; align-items: center; cursor: pointer;
  margin: 8px 0 20px; font-size: 12.5px !important; font-weight: 500 !important; color: #4a5561 !important;
  text-transform: none !important; letter-spacing: 0 !important; }
.remember-line input[type=checkbox] { width: 15px; height: 15px; accent-color: #1a4f7e; cursor: pointer; }
.remember-note { font-size: 11px; color: #8a94a0; margin: -6px 0 12px; }

/* company selector for multi-company logins */
.cosel { margin-left: 14px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--navy); font-size: 13px; font-weight: 600; max-width: 260px; }

/* warehouse stock lot drill-down */
.stock-card { height: auto; max-height: 88vh; max-width: 1000px; }
.stock-body { padding: 16px 18px; overflow: auto; }
.stock-sec { margin: 18px 0 8px; font-size: 14px; color: var(--navy); }
.badge.st-on { background: #e0f2ec; color: #0a6254; }
.badge.st-out { background: #e8edf4; color: #1a4f7e; }
