:root {
  /* Same palette as PO follow-up */
  --navy-900: #0b1b33;
  --navy-800: #12284a;
  --navy-700: #1b3763;
  --bg: #f3f5f8;
  --card: #ffffff;
  --line: #e3e7ee;
  --line-2: #eef1f5;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --primary: #1d4ed8;
  --primary-ink: #ffffff;
  --primary-soft: #eef3fe;
  --red: #b42318;
  --red-soft: #fde8e6;
  --amber: #92400e;
  --amber-soft: #fdf3d8;
  --green: #047857;
  --green-soft: #e7f6ef;
  --slate: #475467;
  --slate-soft: #eef1f5;
  --wa: #077a4b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --sans: 'IBM Plex Sans', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a.btn { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- Shell: navy sidebar + white top bar (as PO follow-up) ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--navy-900) 232px, transparent 232px); }
.sidebar { background: var(--navy-900); color: #c9d4e6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 18px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; gap: 10px; align-items: center; min-height: 72px; }
.sidebar .logo { width: 40px; height: 40px; border-radius: 8px; background: #fff; display: grid; place-items: center; overflow: hidden; flex: none; }
.sidebar .logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sidebar .logo .initials { color: var(--navy-900); font-weight: 700; font-size: 15px; }
.sidebar .co { color: #fff; font-weight: 600; font-size: 14px; line-height: 1.25; }
.sidebar .app { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #8ea3c4; margin-top: 2px; }
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav .section { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #6f84a6; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px; color: #c9d4e6; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--navy-700); color: #fff; }
.nav a .badge { margin-left: auto; background: #d92d20; color: #fff; font-size: 11px; font-weight: 600; border-radius: 10px; padding: 1px 7px; }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.side-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot .role { color: #8ea3c4; text-transform: capitalize; }
.side-foot button { background: none; border: 0; padding: 0; color: #8ea3c4; cursor: pointer; font-size: 12px; }
.side-foot button:hover { color: #fff; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 28px; gap: 16px; position: sticky; top: 0; z-index: 20; }
.topbar .crumb { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.topbar .spacer { flex: 1; }
.topbar .sync { font-size: 12px; color: var(--muted); }
.topbar .menu-btn { display: none; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 9px; cursor: pointer; }
.scrim { display: none; }

/* ---------- Page ---------- */
.page { padding: 24px 28px 48px; max-width: 1480px; width: 100%; }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.page-head .eyebrow { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
h1 { font-size: 24px; font-weight: 700; margin: 2px 0 2px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 8px; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { background: #1a44c2; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.wa:hover { background: #066a41; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn.block { width: 100%; justify-content: center; padding: 11px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

select.filter { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--card); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .lbl { font-size: 12.5px; color: var(--ink-2); }
.kpi .val { font-family: var(--mono); font-size: 26px; font-weight: 700; margin: 2px 0; letter-spacing: -.02em; }
.kpi .note { font-size: 12px; color: var(--muted); }
.kpi .val.red { color: var(--red); } .kpi .val.green { color: var(--green); } .kpi .val.blue { color: var(--primary); } .kpi .val.slate { color: var(--slate); }

/* ---------- Layout ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px; align-items: start; }
.split > * { min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; gap: 10px; flex-wrap: wrap; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 8px; gap: 10px; flex-wrap: wrap; }
.sticky { position: sticky; top: 72px; }

/* ---------- Call cards ---------- */
.calls { display: flex; flex-direction: column; gap: 8px; }
.call { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; transition: border-color .12s, background .12s; }
.call:hover { border-color: #c7d2fe; }
.call.sel { border: 1.5px solid var(--primary); background: var(--primary-soft); }
.call.done { opacity: .62; }
.call-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.call-grid > div { min-width: 0; overflow-wrap: anywhere; }
.call-top .nm { font-weight: 600; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.call-grid .k { font-size: 11.5px; color: var(--muted); }
.call-grid .v { font-weight: 500; }
.call-grid .v.amt { font-family: var(--mono); color: var(--red); font-weight: 600; font-size: 15px; }
.call-grid .s { font-size: 11.5px; color: var(--slate); }

.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 5px; color: #fff; white-space: nowrap; }
.tag.promise, .tag.cheque { background: var(--primary); }
.tag.escalate, .tag.broken { background: var(--red); }
.tag.callback, .tag.overdue { background: var(--slate); }
.tag.done { background: var(--green); }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.pill.ok, .pill.good { background: var(--green-soft); color: var(--green); }
.pill.muted { background: var(--slate-soft); color: var(--slate); }
.pill.blue { background: #dbeafe; color: var(--primary); }
.chip { display: inline-block; font-size: 12px; background: var(--slate-soft); color: var(--ink-2); padding: 5px 10px; border-radius: 7px; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { font-size: 11.5px; font-weight: 600; color: var(--ink-2); text-align: left; padding: 10px 12px; background: #f8f9fb; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr.total td { font-weight: 700; background: #f8fafc; border-bottom: 0; font-family: var(--mono); }
tr.total td:first-child { font-family: var(--sans); }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: #fafbff; }
.amt-blue { color: var(--primary); } .amt-amber { color: #b45309; } .amt-red { color: var(--red); font-weight: 700; }
.tbl-mini th, .tbl-mini td { padding: 7px 8px; font-size: 12.5px; white-space: nowrap; }
.tbl-note { font-size: 12px; color: var(--muted); padding: 10px 14px; border-top: 1px solid var(--line-2); }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field > label, .lbl-strong { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 5px; color: var(--ink-2); }
.input, input[type=text], input[type=number], input[type=date], input[type=password], input[type=tel], input[type=email], select.input, textarea {
  width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 10px; background: #fff; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 78, 216, .12); }
textarea { resize: vertical; min-height: 64px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.opts { display: flex; flex-direction: column; gap: 6px; }
.opt { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; cursor: pointer; }
.opt:hover { background: #fafafa; }
.opt input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.opt.on { border-color: var(--primary); background: var(--primary-soft); }
.extra { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 8px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.err { color: var(--red); font-size: 12.5px; margin-top: 6px; }

/* ---------- Log panel ---------- */
.panel-title { font-size: 18px; font-weight: 700; margin: 2px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 12px; }
.history { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.hrow { display: grid; grid-template-columns: 54px 1fr; gap: 8px; margin-bottom: 9px; font-size: 12.5px; }
.hrow .d { font-family: var(--mono); color: var(--slate); }
.hrow .t { font-weight: 600; }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); }

/* ---------- Reminders ---------- */
.schedule { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.stage { border-radius: 8px; padding: 10px 12px; font-size: 12.5px; }
.stage b { display: block; margin-bottom: 3px; }
.stage.s1 { background: #eef4ff; color: #1e3a8a; } .stage.s1 span { color: var(--ink-2); }
.stage.s2 { background: var(--amber-soft); color: var(--amber); } .stage.s2 span { color: var(--ink-2); }
.stage.s3 { background: var(--red-soft); color: var(--red); } .stage.s3 span { color: var(--ink-2); }
.rem { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 11px 14px; margin-bottom: 8px; cursor: pointer; }
.rem.sel { border-color: var(--primary); background: var(--primary-soft); }
.rem input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
.rem .info { flex: 1; min-width: 0; }
.rem .nm { font-weight: 600; }
.rem .amt { font-family: var(--mono); font-weight: 600; font-size: 15px; }
.msg { font-family: var(--sans); background: #f0fdf4; border-color: #bbf7d0; min-height: 330px; white-space: pre-wrap; }
.queue { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; background: var(--navy-900); color: #fff; padding: 10px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100% - 32px); flex-wrap: wrap; }

/* ---------- Modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(11, 27, 51, .45); display: flex; align-items: flex-start; justify-content: center; z-index: 60; padding: 40px 16px; overflow-y: auto; }
.modal { background: var(--card); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 22px; background: var(--navy-900); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 70; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 360px; }
.toast.bad { background: var(--red); }

/* ---------- Login (split layout as PO follow-up) ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side { background: linear-gradient(160deg, var(--navy-900), var(--navy-700)); color: #dbe4f3; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-side .co-top { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: #8ea3c4; }
.login-side h2 { color: #fff; font-size: 30px; line-height: 1.2; max-width: 440px; margin: 0 0 12px; }
.login-side p { max-width: 420px; line-height: 1.6; color: #b5c3da; margin: 0; }
.login-side ul { padding: 0; list-style: none; margin: 26px 0 0; display: grid; gap: 12px; }
.login-side li { display: flex; gap: 10px; align-items: flex-start; color: #dbe4f3; }
.login-side li::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: #5b8def; margin-top: 6px; flex: none; }
.login-side .foot { font-size: 12px; color: #8ea3c4; }
.login-main { display: grid; place-items: center; padding: 32px; background: #fff; }
.login-box { width: 100%; max-width: 360px; }
.login-box .logo-lg { height: 64px; margin-bottom: 18px; display: flex; align-items: center; }
.login-box .logo-lg img { max-height: 64px; max-width: 220px; object-fit: contain; }
.login-box h1 { font-size: 22px; margin: 0; }
.login-box .err { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- Settings ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.stack > * + * { margin-top: 16px; }
.logo-prev { height: 56px; max-width: 220px; object-fit: contain; border: 1px dashed var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.imp-card .result { margin-top: 10px; font-size: 13px; }
.imp-card .result ul { margin: 6px 0 0; padding-left: 18px; color: var(--red); max-height: 160px; overflow: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .schedule { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 240px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(11, 27, 51, .45); z-index: 35; }
  .topbar { padding: 0 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar .sync { display: none; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { display: none; }
}
@media (max-width: 760px) {
  .page { padding: 18px 16px 40px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .val { font-size: 21px; }
  .call-grid { grid-template-columns: 1fr 1fr; }
  .grid2, .row3 { grid-template-columns: 1fr; }
  .schedule { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 22px; }
  .head-actions a.btn { display: none; }
  .call-top .nm { flex-basis: 100%; order: 2; white-space: normal; }
}
