/* Command Centre — Monarch staff control room.
   Deep blue-ink base, monarch-wing amber for "where you are" and the one primary action per screen.
   System fonts only (no outside downloads). Numbers use tabular figures so columns line up. */
:root {
  --ink: #101a26;
  --panel: #172334;
  --panel-2: #1e2c40;
  --line: #2b3b52;
  --text: #e8edf3;
  --muted: #91a0b3;
  --amber: #f2a23a;
  --amber-ink: #2a1a05;
  --red: #e5645c;
  --green: #4cbf91;
  --yellow: #e3c25b;
  --blue: #6fa8e8;
  --radius: 10px;
  --radius-sm: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink); color: var(--text); font-family: var(--font);
  font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.num, td.n, .card .v { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 20px 18px 14px; display: flex; align-items: center; gap: 10px; }
.brand .mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--amber); color: var(--amber-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.brand .t { font-weight: 700; font-size: 15px; }
.brand .s { font-size: 11px; color: var(--muted); }
.nav { padding: 6px 10px 16px; flex: 1; }
.nav .group { font-size: 11px; color: var(--muted); padding: 14px 10px 6px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text);
}
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.on { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--amber); }
.nav a.soon { color: var(--muted); }
.nav .pill { font-size: 11px; color: var(--muted); }
.nav .count { font-size: 11px; background: var(--red); color: #fff; border-radius: 99px; padding: 0 7px; }
.who { border-top: 1px solid var(--line); padding: 14px 18px; }
.who .n { font-weight: 600; }
.who .r { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.who .row { display: flex; gap: 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; gap: 14px; padding: 16px 28px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--ink); z-index: 5;
}
.top .title { font-weight: 600; font-size: 15px; }
.top .date { color: var(--muted); }
.top .spacer { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-size: 12px; }
.live::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live::before { animation: none; } }
.menu-btn { display: none; }
.page { padding: 24px 28px 60px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- building blocks ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.card .l { color: var(--muted); font-size: 12px; }
.card .v { font-size: 26px; font-weight: 650; margin-top: 4px; line-height: 1.1; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card.hot .v { color: var(--red); }
.card.money .v { color: var(--amber); }
.card.link { cursor: pointer; }
.card.link:hover { border-color: var(--muted); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.panel + .panel, .grid2 + .panel, .panel + .grid2, .grid3 + .panel, .grid2 + .grid2 { margin-top: 16px; }
.grid2 > .panel, .grid3 > .panel { margin-top: 0; }
.panel-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.n, th.n { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge.green { color: var(--green); border-color: rgba(76, 191, 145, .45); }
.badge.red { color: var(--red); border-color: rgba(229, 100, 92, .45); }
.badge.yellow { color: var(--yellow); border-color: rgba(227, 194, 91, .45); }
.badge.amber { color: var(--amber); border-color: rgba(242, 162, 58, .5); }
.badge.blue { color: var(--blue); border-color: rgba(111, 168, 232, .45); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }

.btn {
  font: inherit; font-size: 13px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); font-weight: 600; }
.btn.danger { color: var(--red); }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn.ghost { background: transparent; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 10px; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--amber); }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 150px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  font: inherit; background: none; border: 0; color: var(--muted); padding: 9px 12px; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--amber); }

.empty { color: var(--muted); padding: 22px 0; text-align: center; }
.error-box { border: 1px solid rgba(229, 100, 92, .5); color: var(--red); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.note { border-left: 3px solid var(--amber); padding: 8px 12px; background: var(--panel-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--muted); margin-bottom: 16px; }
.loading { color: var(--muted); padding: 30px 0; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 12px; }

/* alerts */
.alert { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.alert:last-child { border-bottom: 0; }
.alert .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.alert.critical .dot { background: var(--red); }
.alert.warning .dot { background: var(--yellow); }
.alert .m { flex: 1; }

/* bar chart (pure CSS) */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 6px; }
.bars .b { flex: 1; background: var(--amber); border-radius: 2px 2px 0 0; min-height: 1px; opacity: .85; }
.bars .b:hover { opacity: 1; }
.bars-x { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 6px; }

/* feed */
.feed-row { display: grid; grid-template-columns: 96px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed-row:last-child { border-bottom: 0; }
.feed-row .t { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; }
.login .brand { padding: 0 0 22px; }
.login .panel { padding: 22px; }
.login h1 { margin-bottom: 4px; }
.login p { color: var(--muted); margin: 0 0 18px; }
.login .btn.primary { width: 100%; padding: 10px; margin-top: 4px; }
.linkbtn { background: none; border: 0; color: var(--blue); cursor: pointer; font: inherit; padding: 0; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(5, 10, 16, .7); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal h2 { margin-bottom: 14px; }
.modal .actions { justify-content: flex-end; margin-top: 8px; }

/* toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--green); padding: 10px 14px; border-radius: var(--radius-sm); max-width: 360px; }
.toast.bad { border-left-color: var(--red); }

/* add client people rows */
.person-row { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.seat-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.seat-line select { width: auto; }
.ad-img { max-width: 160px; max-height: 80px; border-radius: 4px; border: 1px solid var(--line); background: var(--ink); }

/* ---------- small screens ---------- */
@media (max-width: 1000px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(5, 10, 16, .6); }
  .menu-btn { display: inline-block; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .page { padding: 18px 16px 50px; }
  .top { padding: 12px 16px; }
  .top .date { display: none; }
}

/* ---------- client apps: light theme + extras ---------- */
[data-theme="light"] {
  --ink: #f3f5f8; --panel: #ffffff; --panel-2: #eef1f5; --line: #d9dee6;
  --text: #17202b; --muted: #5d6b7c; --amber: #d9861a; --amber-ink: #ffffff;
  --red: #c6423a; --green: #24865f; --yellow: #9c7a12; --blue: #2f6fbf;
}
[data-theme="light"] .modal-bg { background: rgba(20, 30, 45, .45); }
.co-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.co-card .top-line { display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 34px; height: 34px; border-radius: 8px; background: var(--panel-2); display: grid; place-items: center; font-weight: 700; color: var(--amber); flex: none; }
.co-card .name { font-weight: 600; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 16px; margin-top: 10px; }
.fields .k { color: var(--muted); font-size: 12px; }
.fields .v { word-break: break-word; }
.locked { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
.chip.on { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); font-weight: 600; }
.sub-list { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.sub-item { padding: 8px 0 8px 12px; border-left: 2px solid var(--line); margin: 6px 0; }
.rank { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rank:last-child { border-bottom: 0; }
.rank .pos { font-weight: 700; color: var(--muted); text-align: center; }
.rank.me { background: var(--panel-2); border-radius: var(--radius-sm); }
.rank .meter { height: 6px; background: var(--panel-2); border-radius: 99px; margin-top: 4px; overflow: hidden; }
.rank .meter i { display: block; height: 100%; background: var(--amber); }
.rival { font-size: 18px; font-weight: 600; margin: 4px 0 10px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.product { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 8px; min-height: 170px; }
.product .pn { font-size: 17px; font-weight: 700; }
.product .grow { flex: 1; }
.product.dim { opacity: .7; }
.portal-top { display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-bottom: 1px solid var(--line); }
.portal-top .spacer { flex: 1; }
.portal-main { max-width: 1100px; margin: 0 auto; padding: 28px; }
.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 30px 0; }
