:root {
  --bg: #f5f6f8; --panel: #fff; --text: #1d2330; --muted: #677085; --line: #e3e6ec;
  --brand: #2f5bea; --brand-soft: #e8eefd; --ok: #1a8a4c; --ok-soft: #e4f5ea;
  --warn: #b26a00; --warn-soft: #fdf1dc; --bad: #c2352b; --bad-soft: #fbe7e5;
  --radius: 10px; font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }

.layout { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: #141a2a; color: #cdd3e1; padding: 18px 12px; }
.side .logo { color: #fff; font-weight: 700; font-size: 1.15rem; padding: 4px 10px 18px; }
.side a { display: block; color: #cdd3e1; padding: 8px 10px; border-radius: 8px; }
.side a:hover, .side a.on { background: #263050; color: #fff; text-decoration: none; }
.side .sep { border-top: 1px solid #2a3350; margin: 12px 0; }
.main { padding: 24px 28px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { margin: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: inherit; }
.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat .n { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .85rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: #fafbfd; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap;
  background: #eef0f4; color: #444c5e; }
.st-new { background: var(--warn-soft); color: var(--warn); }
.st-verified { background: var(--brand-soft); color: var(--brand); }
.st-booked { background: #efe8fd; color: #6a3fd1; }
.st-in_transit { background: #e3f3f7; color: #0f7287; }
.st-delivered { background: var(--ok-soft); color: var(--ok); }
.st-rto, .st-cancelled { background: var(--bad-soft); color: var(--bad); }
.low { color: var(--bad); font-weight: 600; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font-size: .9rem; }
.tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tabs a:hover { text-decoration: none; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; font-size: .92rem; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: #c5cad6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

form p { margin: 0 0 12px; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #cfd4de; border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.inline input, .inline select { width: auto; }
.helptext { display: block; font-size: .8rem; color: var(--muted); margin-top: 3px; }
.errorlist { color: var(--bad); margin: 4px 0; padding-left: 18px; font-size: .85rem; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.fields .full { grid-column: 1 / -1; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 8px; margin-bottom: 6px; background: var(--brand-soft); }
.messages .success { background: var(--ok-soft); color: #0f5a32; }
.messages .error { background: var(--bad-soft); color: #8a221b; }
.messages .warning { background: var(--warn-soft); color: #7a4900; }

dl.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .88rem; }
dl.kv dd { margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 110px; }
.bars div { flex: 1; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars-x { display: flex; gap: 4px; font-size: .7rem; color: var(--muted); }
.bars-x span { flex: 1; text-align: center; }
.meter { height: 6px; background: #eef0f4; border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand); }
.copybox { display: flex; gap: 6px; }
.copybox input { font-size: .85rem; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; }
  .side .logo { width: 100%; padding-bottom: 6px; }
  .side .sep { display: none; }
  .main { padding: 16px; }
  .g2, .g3, .g-side, .fields { grid-template-columns: 1fr; }
}

/* Subscription */
.subnote { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; }
.subnote.sub-expiring { background: var(--warn-soft); color: #7a4900; }
.subnote.sub-grace, .subnote.sub-locked { background: var(--bad-soft); color: #8a221b; }
.badge.sub-active { background: var(--ok-soft); color: var(--ok); }
.badge.sub-expiring { background: var(--warn-soft); color: var(--warn); }
.badge.sub-grace, .badge.sub-locked { background: var(--bad-soft); color: var(--bad); }
.stat.sub-active .n { color: var(--ok); }
.stat.sub-expiring .n { color: var(--warn); }
.stat.sub-grace .n, .stat.sub-locked .n { color: var(--bad); }
.subbar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.subbar > div { height: 100%; background: var(--ok); }
.subbar > .sub-expiring { background: var(--warn); }
.subbar > .sub-grace, .subbar > .sub-locked { background: var(--bad); }
.side .subdays { float: right; font-size: .78rem; opacity: .8; }
.side .subdays.warn { color: #ffcf7a; opacity: 1; }
