:root {
  --navy-900: #0b1b33;
  --navy-800: #12284a;
  --navy-700: #1b3763;
  --blue-600: #1d4ed8;
  --blue-50: #eef3fe;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e3e7ee;
  --line-2: #eef1f5;
  --bg: #f3f5f8;
  --card: #ffffff;
  --green: #047857; --green-bg: #e7f6ef;
  --amber: #92400e; --amber-bg: #fdf3d8;
  --red: #b42318; --red-bg: #fde8e6;
  --orange: #c2410c;
  --slate-bg: #eef1f5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --font: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- Shell ---------- */
.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; }
.brand { padding: 18px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; gap: 10px; align-items: center; min-height: 72px; }
.brand .logo { width: 40px; height: 40px; border-radius: 8px; background: #fff; display: grid; place-items: center; overflow: hidden; flex: none; }
.brand .logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand .logo .initials { color: var(--navy-900); font-weight: 700; font-size: 15px; }
.brand .co { color: #fff; font-weight: 600; font-size: 14px; line-height: 1.25; }
.brand .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; }
.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); text-decoration: none; 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 a { color: #8ea3c4; }

.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: 5; }
.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; }
.content { padding: 24px 28px 48px; max-width: 1480px; width: 100%; }

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Controls ---------- */
.btn { font: inherit; font-weight: 500; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #c7cfdc; background: #fafbfc; text-decoration: none; }
.btn.primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn.primary:hover { background: #1a44c2; }
.btn.green { background: #077a4b; border-color: #077a4b; color: #fff; }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; justify-content: center; padding: 11px 14px; font-weight: 600; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }

label.fl { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], input[type=email], select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #d5dbe5; border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(29,78,216,.25); border-color: var(--blue-600); }
textarea { resize: vertical; min-height: 72px; }
.filters { display: grid; grid-template-columns: 180px 200px 1fr; gap: 10px; margin-bottom: 16px; }
.filters label { font-size: 11.5px; font-weight: 600; color: var(--ink-2); display: block; margin-bottom: 4px; }

/* ---------- Cards & KPIs ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card h3 { font-size: 15px; font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { padding: 14px 16px; }
.kpi .k { font-size: 12.5px; color: var(--ink-2); }
.kpi .v { font-family: var(--mono); font-size: 26px; font-weight: 700; margin: 6px 0 2px; }
.kpi .h { font-size: 11.5px; color: var(--muted); }
.v.red { color: var(--red); } .v.orange { color: var(--orange); } .v.green { color: var(--green); } .v.blue { color: var(--blue-600); }

.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.slate { background: var(--slate-bg); color: var(--ink-2); }
.pill.blue { background: var(--blue-50); color: var(--blue-600); }
.prio { display: inline-block; color: #fff; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 5px; }
.prio.critical { background: #b42318; } .prio.high { background: #c2410c; } .prio.medium { background: #475467; } .prio.low { background: #98a2b3; }

/* ---------- Today ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.list-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.list-head h2 { font-size: 16px; }
.po-card { padding: 14px 16px; margin-bottom: 10px; cursor: pointer; transition: border-color .12s; }
.po-card:hover { border-color: #b9c4d6; }
.po-card.selected { border: 2px solid var(--blue-600); background: #f6f9ff; padding: 13px 15px; }
.po-card.done { opacity: .62; }
.po-card .top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.split > * { min-width: 0; }
.po-card .vname { font-weight: 700; font-size: 15px; }
.po-card .pono { font-family: var(--mono); color: var(--muted); font-size: 12.5px; }
.po-card .top .right { margin-left: auto; display: flex; gap: 6px; }
.po-grid { display: grid; grid-template-columns: 1.4fr .9fr 1.1fr 1.3fr 1.1fr; gap: 12px; }
.po-grid .lbl { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.po-grid .val { font-weight: 600; }
.po-grid .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.po-grid .act { color: var(--blue-600); font-weight: 600; }
.bar { height: 5px; background: var(--line-2); border-radius: 4px; overflow: hidden; display: flex; margin-top: 6px; }
.bar span { display: block; height: 100%; }
.bar .g { background: #0e9f6e; } .bar .b { background: var(--blue-600); } .bar .o { background: #e8730c; } .bar .s { background: #9aa4b5; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.note-line { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.panel { position: sticky; top: 72px; padding: 18px 20px; }
.panel .eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.panel h3 { font-size: 18px; margin-top: 4px; }
.radio-list { display: flex; flex-direction: column; gap: 6px; }
.radio { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; cursor: pointer; }
.radio:hover { border-color: #c7cfdc; }
.radio input { margin: 0; accent-color: var(--blue-600); width: 16px; height: 16px; }
.radio.on { border-color: var(--blue-600); background: var(--blue-50); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.history { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.history h4 { margin: 0 0 8px; font-size: 13px; }
.h-item { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line-2); }
.h-item:last-child { border-bottom: 0; }
.h-item .d { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.h-item .r { font-weight: 600; font-size: 13px; }
.h-item .t { font-size: 12.5px; color: var(--ink-2); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { font-family: var(--font); text-align: left; font-size: 11.5px; font-weight: 600; color: var(--ink-2); background: #f8f9fb; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: #fafbfd; }
table.grid tr.sel td { background: var(--blue-50); }
table.grid tfoot td { font-weight: 700; background: #f8f9fb; border-top: 1px solid var(--line); }
table.grid th.num, table.grid td.num { text-align: right; }
table.grid .po { font-family: var(--mono); font-weight: 600; }
table.grid .sub { font-size: 11.5px; color: var(--muted); }
.c-transit { color: var(--blue-600); } .c-pending { color: var(--orange); } .c-grpo { color: var(--green); }
.clickable { cursor: pointer; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.fulfil .bar { height: 10px; }
.defs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.defs .card { padding: 14px 16px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
.defs b { color: var(--ink); display: block; margin-bottom: 4px; }

/* ---------- Vendor / WhatsApp ---------- */
.wa-box textarea { min-height: 300px; font-size: 13px; background: #f3fbf6; line-height: 1.5; }

/* ---------- Settings ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--blue-600); border-color: var(--blue-600); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.form-card { max-width: 680px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.logo-preview { width: 120px; height: 72px; border: 1px dashed #c7cfdc; border-radius: 8px; display: grid; place-items: center; background: #fff; overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
table.grid input, table.grid select { padding: 5px 7px; font-size: 13px; }
table.grid input.rule { width: 64px; text-align: right; font-family: var(--mono); }
.err-list { background: var(--red-bg); color: var(--red); border-radius: 8px; padding: 10px 14px; font-size: 12.5px; margin-top: 12px; max-height: 240px; overflow: auto; }
.ok-box { background: var(--green-bg); color: var(--green); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-top: 12px; }

/* ---------- Modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(11,27,51,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; padding: 20px 22px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy-900); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13.5px; z-index: 60; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
#toast.err { background: var(--red); }

/* ---------- Login ---------- */
.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 h2 { color: #fff; font-size: 30px; line-height: 1.2; max-width: 440px; }
.login-side p { max-width: 420px; line-height: 1.6; color: #b5c3da; }
.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-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; }
.login-box .err { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .split, .split[style] { grid-template-columns: 1fr !important; }
  .panel { position: static; }
  .po-grid { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 240px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .shell { background: none; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar .sync { display: none; }
  .split[style] { grid-template-columns: 1fr !important; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px 40px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters > :last-child { grid-column: 1 / -1; }
  .po-grid { grid-template-columns: 1fr 1fr; }
  .defs { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .form-grid { grid-template-columns: 1fr; }
}
