/* Copyright © 2026 Innovation Tech Solutions. All rights reserved. */
:root {
  --bg: #f5f6f8; --panel: #fff; --ink: #1c2230; --muted: #667085; --line: #e3e6ec; --line2: #f0f2f5;
  --accent: #2a5591; --accent-soft: #e7edf6; --hover: #f7f9fc; --sel: #eef3ff;
  --null-bg: #f1f0f7; --null-ink: #7a6fa8; --empty-bg: #fff6e5; --empty-ink: #a26a00;
  --err-bg: #fdecec; --err-ink: #a8231b; --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12151c; --panel: #1a1e27; --ink: #e6e9ef; --muted: #98a2b3; --line: #2b313d; --line2: #222733;
    --accent: #8db0e8; --accent-soft: #233149; --hover: #20252f; --sel: #26314a;
    --null-bg: #2a2740; --null-ink: #b3a9e6; --empty-bg: #3a2e14; --empty-ink: #f0c060; --err-bg: #3d1b1a; --err-ink: #ffb4ab; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 "Segoe UI", system-ui, sans-serif; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.app { display: grid; grid-template-columns: 250px minmax(0, 1fr) auto; height: 100vh; }

/* sidebar */
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { padding: 14px 14px 10px; font-weight: 700; font-size: 16px; }
.brand span { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
#tableSearch { margin: 0 10px 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
#tableList { overflow-y: auto; flex: 1; padding: 0 6px 8px; }
#tableList h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 10px 8px 4px; font-weight: 600; }
#tableList a { display: flex; justify-content: space-between; gap: 8px; padding: 4px 8px; border-radius: 5px; color: var(--ink); text-decoration: none; font-size: 13px; }
#tableList a:hover { background: var(--hover); }
#tableList a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#tableList a .n { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }
#tableList a.zero { color: var(--muted); }
.about-link { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13px; }

/* main */
main { overflow: auto; padding: 16px 20px 24px; min-width: 0; display: flex; flex-direction: column; }
.menu { display: none; }
h1 { font-size: 20px; margin: 0; }
.subtitle { color: var(--muted); margin: 2px 0 12px; font-size: 13px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.toolbar input[type=search] { min-width: 240px; flex: 0 1 320px; }
.toolbar input, .toolbar select, .btn { padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.btn { cursor: pointer; }
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.filterbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.filterform { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12px; }
.chip code { font-family: var(--mono); }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; }
.msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 8px; }
.msg.error { background: var(--err-bg); color: var(--err-ink); }

/* grid */
.gridwrap { position: relative; flex: 1; min-height: 200px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: 5px 10px; border-bottom: 1px solid var(--line2); border-right: 1px solid var(--line2); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.grid th { position: sticky; top: 0; z-index: 2; background: var(--panel); border-bottom: 1px solid var(--line); font-weight: 600; font-size: 12px; cursor: pointer; user-select: none; }
.grid th .t { display: block; font-weight: 400; color: var(--muted); font-size: 10.5px; font-family: var(--mono); }
.grid th:hover { background: var(--hover); }
.grid th.sorted { color: var(--accent); }
.grid .rn { position: sticky; left: 0; z-index: 1; background: var(--panel); color: var(--muted); text-align: right; font-size: 11px; cursor: default; }
.grid th.rn { z-index: 3; }
.grid td.pk { font-weight: 600; }
.grid td.num { text-align: right; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover td { background: var(--hover); }
.grid tbody tr.sel td { background: var(--sel); }
.v-null { display: inline-block; font-size: 10.5px; font-family: var(--mono); padding: 0 5px; border-radius: 3px; background: var(--null-bg); color: var(--null-ink); letter-spacing: .03em; }
.v-empty { display: inline-block; font-size: 10.5px; font-family: var(--mono); padding: 0 5px; border-radius: 3px; background: var(--empty-bg); color: var(--empty-ink); }
.ws { color: var(--empty-ink); }
.overlay { position: absolute; inset: 0; background: color-mix(in srgb, var(--panel) 65%, transparent); display: flex; align-items: center; justify-content: center; z-index: 5; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.state { padding: 30px 16px; color: var(--muted); text-align: center; }
.pager { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 13px; }
.pager .ctl { display: flex; gap: 6px; align-items: center; }
.pager input { width: 70px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.legend { font-size: 12px; color: var(--muted); }

/* detail */
.detail { width: 420px; background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 14px 16px; }
.detail header { display: flex; justify-content: space-between; align-items: start; gap: 8px; margin-bottom: 10px; }
.detail h2 { font-size: 16px; margin: 0; }
.detail dl { margin: 0; }
.detail .f { padding: 6px 0; border-bottom: 1px solid var(--line2); }
.detail dt { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.detail dt code { font-family: var(--mono); font-size: 10.5px; }
.detail dd { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 13px; }
.detail .nav { margin-top: 4px; font-size: 12px; }

/* summary page */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 12px 0 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.plain { border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.plain th, .plain td { padding: 5px 10px; border-bottom: 1px solid var(--line2); text-align: left; }
.plain td.num, .plain th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ok { color: #23854a; font-weight: 600; } .bad { color: var(--err-ink); font-weight: 600; }

@media (max-width: 1100px) {
  .detail { position: fixed; right: 0; top: 0; bottom: 0; z-index: 20; width: min(420px, 100vw); box-shadow: -8px 0 30px rgba(0,0,0,.2); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 8px 0 30px rgba(0,0,0,.25); }
  .menu { display: inline-block; align-self: flex-start; margin-bottom: 8px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
  main { padding: 12px 16px; }
  .toolbar input[type=search] { min-width: 0; flex: 1 1 100%; }
}

/* multi-user: signed-in bar and login page */
.userbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.userbar b { color: var(--ink); font-weight: 600; }
.userbar .btn { padding: 3px 8px; font-size: 12px; }
.msg.note { background: var(--accent-soft); color: var(--ink); }
body.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 20px 18px; display: flex; flex-direction: column; gap: 6px; }
.login .brand { padding: 10px 0 8px; }
.login label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.login input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.login .btn { margin-top: 10px; padding: 8px; }
.login .legend { margin: 6px 0 0; }
.login-page { grid-auto-flow: row; align-content: center; gap: 14px; }
.legal { font-size: 11px; color: var(--muted); text-align: center; max-width: 360px; margin: 0; }

/* the hidden attribute always wins over component display rules (e.g. .filterform { display: flex }) */
[hidden] { display: none !important; }

/* sign-in steps: code, new password, authenticator set-up, recovery codes */
.login[hidden] { display: none; }
.login .step-help { font-size: 13px; line-height: 1.45; margin: 2px 0 4px; color: var(--ink); }
.login .step-list { font-size: 13px; line-height: 1.45; margin: 0 0 4px; padding-left: 18px; }
.login .step-list li { margin: 3px 0; }
.login .code-input { font-size: 20px; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; }
.login .qr { width: 180px; height: 180px; align-self: center; margin: 4px 0; image-rendering: pixelated; border-radius: 6px; }
.login .key-box { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12.5px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.login .key-box span { color: var(--muted); }
.login .key-box b { word-break: break-all; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.login .codes { columns: 2; font-size: 14px; margin: 4px 0; padding-left: 22px; line-height: 1.7; }
.login .code-actions { display: flex; gap: 6px; }
.login .code-actions .btn { margin-top: 0; padding: 5px 10px; flex: 1; }
.login .chk { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 13px; margin-top: 8px; }
.login .chk input { width: auto; }
.login.wide { max-width: 380px; }
@media print { body.login-page > *:not(#codesForm) { display: none !important; } #codesForm .btn, #codesForm .chk { display: none !important; } }
