/* Smartfin KYC Explorer: Smartfin's navy / mint / gold palette in a Norton-Commander-era shell. */

:root {
  --navy: #031f30;
  --navy-2: #06293f;
  --navy-3: #0b3753;
  --line: #2a5a75;
  --fg: #d9e7ef;
  --dim: #8aa6b6;
  --mint: #9de3b6;
  --mint-dim: #5fae86;
  --gold: #e6c65a;
  --red: #ff8a7a;
  --serif: 'Newsreader', 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --pixel: 'VT323', 'IBM Plex Mono', monospace;
  --fs: 13px;
  --row: 26px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--navy);
  color: var(--fg);
  font: 400 var(--fs)/1.45 var(--mono);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
::selection { background: var(--mint); color: var(--navy); }
.hidden { display: none !important; }

/* ── CRT effect (F9) ─────────────────────────────────────────── */
body.crt::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.45) 100%);
}
body.crt { text-shadow: 0 0 2px rgba(157, 227, 182, 0.35); }

/* ── Layout ──────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px 8px;
  background:
    radial-gradient(120% 220% at 100% 0%, rgba(230, 198, 90, 0.38), transparent 45%),
    radial-gradient(90% 260% at 85% 120%, rgba(157, 227, 182, 0.45), transparent 50%),
    var(--navy);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-mark {
  font: 500 26px/1 var(--serif);
  letter-spacing: -0.01em;
  color: #fff;
}
.brand-sub {
  font: 20px/1 var(--pixel);
  color: var(--mint);
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.topbar-meta {
  margin-left: auto;
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--dim);
  font-size: 12px;
  white-space: nowrap;
}
.env-pill {
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: 999px;
  padding: 1px 9px;
  letter-spacing: 0.08em;
  font-size: 11px;
}
.key-chip { cursor: pointer; border-bottom: 1px dotted var(--dim); }
.clock { color: var(--mint); font-variant-numeric: tabular-nums; }

/* menu / tabs bar: inverse like a DOS menu line */
.menubar {
  display: flex;
  gap: 2px;
  background: var(--mint);
  color: var(--navy);
  padding: 0 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.menubar button {
  border: 0;
  background: transparent;
  padding: 3px 12px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
}
.menubar button .hot { text-decoration: underline; }
.menubar button[aria-selected='true'] { background: var(--navy); color: var(--mint); }
.menubar .spacer { flex: 1; }
.menubar .search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
}
.menubar input {
  background: var(--navy);
  color: var(--mint);
  border: 0;
  padding: 2px 8px;
  width: 220px;
  outline: none;
}
.menubar input::placeholder { color: var(--dim); }

/* stats line */
.stats {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
  background: var(--navy-2);
}
.stat {
  padding: 6px 14px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.stat b { font: 22px/1 var(--pixel); color: var(--mint); margin-left: 6px; }
.stat.warn b { color: var(--gold); }
.stat.bad b { color: var(--red); }
.stat span { color: var(--dim); font-size: 11px; letter-spacing: 0.08em; }

/* main: list panel + detail panel, side by side like a dual-pane file manager */
.main {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(380px, 1fr);
  gap: 8px;
  padding: 8px;
  min-height: 0;
}
.panel {
  position: relative;
  border: 3px double var(--line);
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--navy);
}
.panel.focus { border-color: var(--mint-dim); }
.panel-title {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  padding: 0 8px;
  color: var(--mint);
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-body { overflow: auto; flex: 1; min-height: 0; padding-top: 6px; }
.panel-foot {
  border-top: 1px solid var(--line);
  padding: 2px 8px;
  color: var(--dim);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
}
.detail-back { display: none; }

/* ── Grid ────────────────────────────────────────────────────── */
table.grid {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.grid th {
  position: sticky;
  top: 0;
  background: var(--navy-2);
  color: var(--gold);
  text-align: left;
  font-weight: 500;
  padding: 3px 8px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  z-index: 1;
}
.grid th:last-child, .grid td:last-child { border-right: 0; }
.grid th .arrow { color: var(--mint); }
.grid td {
  padding: 0 8px;
  height: var(--row);
  border-right: 1px solid rgba(42, 90, 117, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover td { background: var(--navy-3); }
.grid tbody tr.sel td { background: var(--mint); color: var(--navy); }
.grid tbody tr.sel .muted, .grid tbody tr.sel .badge { color: var(--navy); border-color: var(--navy); }
.grid td.num { text-align: right; }
.grid td.primary { max-width: 230px; }
.muted { color: var(--dim); }
.mono-id { color: var(--dim); }

.badge {
  display: inline-block;
  border: 1px solid currentColor;
  padding: 0 6px;
  line-height: 17px;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.b-ok { color: var(--mint); }
.b-warn { color: var(--gold); }
.b-bad { color: var(--red); }
.b-dim { color: var(--dim); }
.flag { display: inline-block; min-width: 14px; text-align: center; }
.flag.on { color: var(--mint); }
.flag.off { color: var(--line); }

.empty, .loading {
  padding: 28px 16px;
  color: var(--dim);
  text-align: center;
}
.loading::after { content: '_'; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ── Detail ──────────────────────────────────────────────────── */
.detail { padding: 6px 12px 16px; }
.detail h2 {
  font: 500 24px/1.15 var(--serif);
  color: #fff;
  margin: 6px 0 2px;
}
.detail .subline { color: var(--dim); margin-bottom: 12px; }
.box {
  position: relative;
  border: 1px solid var(--line);
  padding: 12px 10px 8px;
  margin: 16px 0 6px;
}
.box > .box-title {
  position: absolute;
  top: -10px;
  left: 10px;
  background: var(--navy);
  padding: 0 6px;
  color: var(--gold);
  letter-spacing: 0.06em;
}
dl.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 1px 14px;
  margin: 0;
}
dl.kv dt { color: var(--dim); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.box table.grid td { height: 22px; }
.box table.grid th { position: static; }
.ubo-bar {
  display: inline-block;
  height: 8px;
  background: var(--mint);
  vertical-align: middle;
  margin-right: 6px;
}
.photo {
  float: right;
  width: 96px;
  margin: 0 0 8px 12px;
  border: 1px solid var(--line);
  image-rendering: auto;
  filter: grayscale(0.2) contrast(1.05);
}
details.raw { margin-top: 18px; }
details.raw summary { cursor: pointer; color: var(--mint); }
details.raw pre {
  margin: 8px 0 0;
  padding: 10px;
  background: #021623;
  border: 1px solid var(--line);
  max-height: 360px;
  overflow: auto;
  font-size: 11.5px;
  color: #b9d6c3;
}
.quip { color: var(--dim); font-style: italic; margin-top: 4px; }

/* ── Function-key bar ────────────────────────────────────────── */
.fkeys {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: var(--safe-bottom);
  background: var(--navy);
  border-top: 1px solid var(--line);
}
.fkeys button {
  border: 0;
  background: transparent;
  padding: 3px 0;
  cursor: pointer;
  display: flex;
  flex: 1 0 auto;
  white-space: nowrap;
}
.fkeys .n { color: var(--fg); padding: 0 3px 0 8px; }
.fkeys .l { background: var(--mint); color: var(--navy); padding: 0 8px; flex: 1; text-align: left; }
.fkeys button:hover .l { background: #c4f0d3; }

/* ── Dialogs ─────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 12, 20, 0.72);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}
.dialog {
  width: min(560px, 100%);
  background: var(--mint);
  color: var(--navy);
  padding: 6px;
  box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.55);
}
.dialog-inner {
  border: 3px double var(--navy);
  padding: 18px 18px 14px;
  position: relative;
}
.dialog-title {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--mint);
  padding: 0 8px;
  font-weight: 600;
  white-space: nowrap;
}
.dialog p { margin: 0 0 10px; }
.dialog input {
  width: 100%;
  background: var(--navy);
  color: var(--mint);
  border: 0;
  padding: 8px 10px;
  outline: none;
  margin: 4px 0 6px;
}
.dialog .err { color: #8b1c10; font-weight: 600; min-height: 1.4em; }
.dialog .small { font-size: 11.5px; opacity: 0.85; }
.dialog .actions { display: flex; justify-content: center; gap: 18px; margin-top: 10px; }
.dialog .actions button {
  background: var(--navy);
  color: var(--mint);
  border: 0;
  padding: 4px 16px;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
}
.dialog .actions button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45); }
.dialog .actions button.secondary { background: transparent; color: var(--navy); box-shadow: none; text-decoration: underline; }
.help-grid { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; }
.help-grid kbd { font-weight: 600; }

/* ── Boot screen ─────────────────────────────────────────────── */
.boot {
  position: fixed;
  inset: 0;
  background: #000;
  color: var(--mint);
  font: 19px/1.25 var(--pixel);
  padding: 22px;
  z-index: 60;
  overflow: hidden;
  cursor: pointer;
}
.boot .line { white-space: pre-wrap; }
.boot .ok { color: #fff; }
.boot .hint { position: absolute; bottom: calc(14px + var(--safe-bottom)); right: 18px; color: var(--dim); }

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --fs: 13.5px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand-mark { font-size: 22px; }
  .brand-sub { font-size: 17px; }
  .topbar-meta .clock, .topbar-meta .key-chip { display: none; }
  .menubar { flex-wrap: wrap; padding: 0; }
  .menubar [role='tab'] { flex: 1; padding: 6px 8px; }
  .menubar .search { order: 3; width: 100%; padding: 4px 8px 6px; }
  .menubar input { flex: 1; width: auto; min-width: 0; padding: 5px 8px; }
  .menubar .spacer { display: none; }
  .main { grid-template-columns: minmax(0, 1fr); padding: 6px; }
  #list-hint { display: none; }
  .grid td { max-width: 100%; }
  .panel.detail-panel {
    position: fixed;
    inset: 0;
    z-index: 40;
    border: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: var(--safe-bottom);
  }
  .panel.detail-panel .panel-title { position: static; transform: none; padding: 8px 12px 0; max-width: none; }
  .app:not(.show-detail) .panel.detail-panel { display: none; }
  .detail-back {
    display: block;
    border: 0;
    background: var(--mint);
    color: var(--navy);
    padding: 8px 12px;
    text-align: left;
    cursor: pointer;
    font-weight: 600;
  }

  /* rows become two-line records */
  .grid thead { display: none; }
  .grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
  .grid tbody tr {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
  }
  .grid td { height: auto; padding: 0; border: 0; max-width: none; width: auto; }
  .grid td.primary { width: 100%; font-weight: 600; color: #fff; white-space: normal; }
  .grid tbody tr.sel { background: var(--mint); }
  .grid tbody tr.sel td { background: transparent; }
  .grid tbody tr.sel td.primary { color: var(--navy); }
  .photo { width: 76px; }
  .detail .box { clear: both; }
  .grid td[data-label]:not(.primary)::before { content: attr(data-label) ' '; color: var(--dim); font-size: 11px; }
  .grid tbody tr.sel td[data-label]::before { color: var(--navy); }
  .grid td.opt { display: none; }
  .box table.grid tbody tr { padding: 6px 0; }
  dl.kv { grid-template-columns: 1fr; }
  dl.kv dt { margin-top: 6px; font-size: 11px; }
  .fkeys .n { padding-left: 4px; }
  .fkeys .l { padding: 4px 6px; }
  .fkeys .hide-mobile { display: none; }
}
