:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #16232d;
  --muted: #63748a;
  --line: #dfe5ec;
  --brand: #008970;
  --brand-dark: #00705c;
  --warn: #b4530a;
  --danger: #b3261e;
  --ok: #17794c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: var(--brand-dark); }

header.topbar {
  background: var(--brand);
  color: #eafff9;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  min-height: 46px;
}
header.topbar h1 { font-size: 15px; margin: 0; font-weight: 700; letter-spacing: .3px; }

/* Hard caps: an uploaded logo is arbitrary, so it must never drive the header
   height. height+max-width with object-fit contain keeps any aspect ratio. */
header.topbar .brandlogo {
  height: 28px;
  max-height: 28px;
  width: auto;
  max-width: 150px;
  display: block;
  object-fit: contain;
  border-radius: 3px;
}
header.topbar .brandtext { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
header.topbar .tagline { font-size: 11px; opacity: .85; font-weight: 400; }

@media (max-width: 560px) {
  header.topbar { gap: 10px; padding: 8px 14px; }
  header.topbar .brandlogo { height: 24px; max-height: 24px; max-width: 110px; }
  header.topbar h1 { font-size: 14px; }
  header.topbar .who { font-size: 11px; width: 100%; margin-left: 0; }
}

/* Sign-in screen */
main.loginwrap { max-width: 360px; margin: 44px auto; padding: 0 16px; }
main.loginwrap .panel { padding: 20px; }
main.loginwrap h2 { font-size: 14px; margin-bottom: 14px; }
main.loginwrap form { display: flex; flex-direction: column; gap: 12px; }
main.loginwrap label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
main.loginwrap input { min-width: 0; width: 100%; }
main.loginwrap button { margin-top: 2px; }
header.topbar .who { margin-left: auto; font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Portal session state. Green when the link to idmsonline.in is live, red when
   it is disabled or the session has gone idle. Links through to Settings. */
.statuspill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 11px; border-radius: 12px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  text-decoration: none; border: 1px solid transparent; white-space: nowrap;
}
.statuspill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.statuspill.ok     { background: #d6f5e5; color: #10633f; border-color: #a9e5c8; }
.statuspill.ok:hover     { background: #c3f0d9; }
.statuspill.danger { background: #fbdcd9; color: #9f1f18; border-color: #f3bab4; }
.statuspill.danger:hover { background: #f8ccc7; }
/* The live indicator should read as live. */
.statuspill.ok .dot { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .statuspill.ok .dot { animation: none; } }

nav.tabs { background: var(--brand-dark); padding: 0 20px; display: flex; gap: 2px; flex-wrap: wrap; }
nav.tabs a {
  color: #cdeee6; text-decoration: none; padding: 10px 16px; font-size: 13px; font-weight: 600;
}
nav.tabs a.active { background: var(--bg); color: var(--brand-dark); }
nav.tabs a:hover:not(.active) { background: rgba(255,255,255,.12); color: #fff; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 16px; margin-bottom: 18px;
}
.panel h2 { margin: 0 0 12px; font-size: 15px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 6px; padding: 14px 16px; }
.card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.card .sub { font-size: 12px; color: var(--muted); }
.card.warn { border-left-color: var(--warn); }
.card.danger { border-left-color: var(--danger); }

form.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
form.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
input[type=text], input[type=date], select {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; background: #fff; color: var(--ink);
  min-width: 150px;
}
button, .btn {
  padding: 8px 16px; border: 0; border-radius: 4px; background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: var(--brand-dark); }
button.secondary, .btn.secondary { background: #5a6b7d; }
button.secondary:hover, .btn.secondary:hover { background: #46545f; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  background: var(--brand); color: #eafff9; text-align: left; padding: 9px 10px; font-weight: 600;
  position: sticky; top: 0;
}
table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr:nth-child(even) td { background: #fafcfd; }
table.grid tr:hover td { background: #edf7f4; }
table.grid td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }

.tablewrap { overflow-x: auto; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.tag.ok { background: #dcf3e7; color: var(--ok); }
.tag.warn { background: #fdeedd; color: var(--warn); }
.tag.danger { background: #fbe3e1; color: var(--danger); }
.tag.muted { background: #e8edf2; color: var(--muted); }

.pager { display: flex; gap: 6px; align-items: center; margin-top: 14px; flex-wrap: wrap; font-size: 13px; }
.pager a { padding: 6px 11px; border: 1px solid var(--line); border-radius: 4px; background: #fff; text-decoration: none; }
.pager a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager .info { color: var(--muted); margin-left: auto; }

.flash { padding: 11px 14px; border-radius: 5px; margin-bottom: 16px; font-size: 13px; }
.flash.ok { background: #dcf3e7; color: var(--ok); border: 1px solid #b3e2cb; }
.flash.err { background: #fbe3e1; color: var(--danger); border: 1px solid #f0c0bc; }
.flash.info { background: #e4f0fb; color: #1b5a8f; border: 1px solid #bdd9f0; }

.empty { padding: 34px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.reasons { margin: 0; padding-left: 16px; }
.reasons li { margin-bottom: 2px; }
code { background: #eef2f6; padding: 1px 5px; border-radius: 3px; font-size: 12px; }

/* Copy-to-clipboard controls (API tab) */
.copyrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.copyrow code { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

.run-btn {
  padding: 4px 11px; font-size: 12px; font-weight: 600; line-height: 1.6;
  border: 1px solid var(--brand); border-radius: 4px; background: var(--brand); color: #fff;
  cursor: pointer; white-space: nowrap; flex: 0 0 auto;
}
.run-btn:hover:not(:disabled) { background: var(--brand-dark); }
.run-btn:disabled { opacity: .6; cursor: default; }

.copy-btn, .reveal-btn {
  padding: 4px 11px; font-size: 12px; font-weight: 600; line-height: 1.6;
  border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--brand-dark);
  cursor: pointer; white-space: nowrap; flex: 0 0 auto;
}
.copy-btn:hover, .reveal-btn:hover { background: #edf7f4; border-color: var(--brand); }
.copy-btn.copied { background: var(--ok); border-color: var(--ok); color: #fff; }
.copy-btn.failed { background: var(--danger); border-color: var(--danger); color: #fff; }

.keycell { font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }

pre.code {
  background: #eef2f6; padding: 14px; border-radius: 5px; overflow-x: auto; margin: 0;
}
.codeblock { position: relative; }
.codeblock .copy-btn { position: absolute; top: 8px; right: 8px; }

dl.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
dl.kv dd { margin: 0; font-weight: 600; }
