/* ANTC Network - shared portal styles. Colours sampled from the ANTC logo. */
:root {
  --navy: #0b2c66;
  --navy-2: #12397f;
  --navy-3: #1b4a9a;
  --blue: #1a73d9;
  --teal: #0e8f9e;
  --green: #4db82b;
  --green-2: #74c829;
  --brand-grad: linear-gradient(135deg, #1a73d9 0%, #0e8f9e 55%, #4db82b 100%);
  --bg: #f3f6fb;
  --card: #ffffff;
  --line: #e2e8f2;
  --line-2: #eef2f8;
  --text: #13213f;
  --muted: #5d6c87;
  --faint: #8d9ab1;
  --ok: #24914a;
  --ok-bg: #e5f5ea;
  --warn: #b7700b;
  --warn-bg: #fdf1dc;
  --bad: #c73a3a;
  --bad-bg: #fbe7e7;
  --info: #1a63c2;
  --info-bg: #e5effc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 33, 70, .05), 0 4px 16px rgba(16, 33, 70, .05);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-brand { background: var(--navy); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-brand::after { content: ""; position: absolute; width: 520px; height: 520px; right: -180px; bottom: -200px; border-radius: 50%; background: var(--brand-grad); opacity: .28; }
.auth-brand .logo-plate { background: #fff; border-radius: 16px; padding: 18px 22px; width: max-content; max-width: 100%; }
.auth-brand .logo-plate img { display: block; width: 300px; max-width: 100%; height: auto; }
.auth-brand h1 { font-size: 30px; margin: 36px 0 12px; max-width: 460px; position: relative; z-index: 1; }
.auth-brand p { color: #c9d6ef; max-width: 460px; position: relative; z-index: 1; }
.auth-points { list-style: none; padding: 0; margin: 24px 0 0; position: relative; z-index: 1; }
.auth-points li { padding: 8px 0 8px 28px; position: relative; color: #e4ecfa; }
.auth-points li::before { content: ""; position: absolute; left: 0; top: 13px; width: 14px; height: 8px; border-left: 2.5px solid var(--green-2); border-bottom: 2.5px solid var(--green-2); transform: rotate(-45deg); }
.auth-brand .foot { color: #93a6cb; font-size: 12.5px; position: relative; z-index: 1; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h2 { font-size: 24px; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 26px; }
.auth-mobile-logo { display: none; width: 210px; margin: 0 auto 24px; }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.role-pick label { border: 1.5px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; background: #fff; display: block; }
.role-pick input { position: absolute; opacity: 0; pointer-events: none; }
.role-pick strong { display: block; font-size: 14px; }
.role-pick span { color: var(--muted); font-size: 12.5px; }
.role-pick label:has(input:checked) { border-color: var(--blue); background: var(--info-bg); }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-mobile-logo { display: block; }
}

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 6px; color: #2a3a5c; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], input[type=month], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid #cfd8e6; border-radius: 9px; padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26, 115, 217, .15); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); }
.check input { margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13.5px; border-radius: 9px; padding: 9px 16px; border: 1px solid #cfd8e6; background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s; }
.btn:hover { background: #f5f8fc; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.btn.primary:hover { background: var(--navy-3); }
.btn.green { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.green:hover { background: #1f7f40; }
.btn.danger { color: var(--bad); border-color: #efc3c3; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.block { width: 100%; padding: 11px 16px; }
.btn.link { border: none; background: none; color: var(--blue); padding: 0; }
.alert-box { border-radius: 9px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.alert-box.error { background: var(--bad-bg); color: #8f2424; }
.alert-box.ok { background: var(--ok-bg); color: #1b6b37; }
.alert-box.info { background: var(--info-bg); color: #164f9a; }
.alert-box.warn { background: var(--warn-bg); color: #84520a; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--navy); color: #d6e0f3; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; color: #fff; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.brand:hover { text-decoration: none; }
.brand img { width: 42px; height: 42px; border-radius: 10px; background: #fff; padding: 3px; }
.brand strong { display: block; font-size: 19px; letter-spacing: .02em; line-height: 1.1; }
.brand span { display: block; font-size: 10.5px; letter-spacing: .32em; color: #9fb3d9; }
.portal-tag { margin: 14px 20px 6px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: #8ea3cc; }
.nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; color: #d6e0f3; padding: 9px 12px; border-radius: 8px; font-weight: 500; position: relative; }
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.nav a.active { background: rgba(255, 255, 255, .1); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand-grad); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .count { margin-left: auto; background: var(--green); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding: 14px 20px; font-size: 12.5px; }
.sidebar-foot .who { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .mail { color: #93a6cb; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 8px; }
.sidebar-foot button { background: none; border: 1px solid rgba(255, 255, 255, .18); color: #d6e0f3; border-radius: 7px; padding: 5px 10px; font: inherit; cursor: pointer; }
.sidebar-foot button:hover { background: rgba(255, 255, 255, .08); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px; background: var(--bg); position: sticky; top: 0; z-index: 5; border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--line); background: rgba(243, 246, 251, .92); backdrop-filter: blur(6px); }
.topbar h1 { font-size: 21px; }
.topbar .crumb { color: var(--muted); font-size: 12.5px; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; cursor: pointer; }
.content { padding: 4px 28px 40px; }
.content > div > * + * { margin-top: 16px; }
.section-gap { margin-top: 16px; }
input.w-auto { width: 90px; }
.neg { color: var(--bad); }
.stat .value.small-value { font-size: 15px; padding-top: 6px; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Cards, stats, grids ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.wide-left { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1180px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .grid.cols-2, .grid.cols-3, .grid.wide-left { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .grid.cols-4 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
a.card { color: inherit; transition: border-color .15s; }
a.card:hover { text-decoration: none; border-color: #b9c8e0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-h h3 { font-size: 14.5px; }
.card-h .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-b { padding: 16px 18px; }
.card-b.flush { padding: 0; }

.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 25px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.stat .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.accent { background: var(--navy); border-color: var(--navy); color: #fff; position: relative; overflow: hidden; }
.stat.accent::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: var(--brand-grad); opacity: .45; }
.stat.accent .label, .stat.accent .meta { color: #c3d1ec; }
.stat.accent > * { position: relative; z-index: 1; }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfe; white-space: nowrap; }
table.t td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: none; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f7f9fd; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; border-radius: 20px; padding: 2px 9px; background: #edf1f7; color: #44536f; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.plain::before { display: none; }

/* ---------- Tabs / filters ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: none; font: inherit; font-weight: 600; color: var(--muted); padding: 9px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.active { color: var(--navy-2); border-bottom-color: var(--blue); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; min-width: 150px; padding: 7px 10px; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--blue); }
.chart .bar.alt { fill: var(--green); }
.chart .bar:hover { opacity: .8; }
.chart .axis { stroke: var(--line); }
.chart .lbl { fill: var(--faint); font-size: 10.5px; font-family: var(--font); }
.chart .val { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.blue { background: var(--blue); }
.legend i.green { background: var(--green); }
.meter { height: 8px; background: var(--line-2); border-radius: 6px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--brand-grad); border-radius: 6px; }
.meter.hot > i { background: linear-gradient(90deg, #e59a1a, #c73a3a); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--faint); }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(77, 184, 43, .18); }

/* ---------- Modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(11, 26, 56, .45); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 820px; }
.modal-h { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal-h h3 { font-size: 16px; }
.modal-h .x { margin-left: auto; background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-b { padding: 18px 20px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-2); background: #fafbfe; border-radius: 0 0 14px 14px; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: 380px; font-size: 13px; animation: toast-in .2s ease-out; }
.toast.error { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.secret { background: #0f1f3d; color: #d8f5c8; font-family: var(--mono); font-size: 12.5px; border-radius: 9px; padding: 12px 14px; word-break: break-all; white-space: pre-wrap; }
pre.result { background: #f6f8fc; border: 1px solid var(--line); border-radius: 9px; padding: 12px; font-family: var(--mono); font-size: 12px; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.timeline li::after { content: ""; position: absolute; left: 7.5px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .when { color: var(--faint); font-size: 12px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -4px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.sched-row { display: grid; grid-template-columns: 110px 70px 1fr 1fr; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.sched-row:last-child { border-bottom: none; }
@media print {
  body > .app, .toasts, .modal-f, .modal-h .x { display: none !important; }
  .modal-back { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; max-width: none; }
}
.page-404 { min-height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; text-align: center; padding: 24px; }
.page-404 img { width: 160px; }

/* live update indicator (SignalR) */
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #9aa3b5; margin-right: 10px; vertical-align: middle; }
.live-dot[data-state="live"] { background: #1a9f5c; box-shadow: 0 0 0 3px rgba(26,159,92,.2); }
.live-dot[data-state="reconnecting"] { background: #d98a00; }
.live-dot[data-state="offline"] { background: #d6343c; }
