:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #0f1f33;
  --muted: #5f6f82;
  --line: #e3e8ef;
  --navy: #143b5c;
  --gold: #f2b705;
  --blue: #1a73e8;
  --blue-soft: #eaf2fe;
  --green: #137a3d;
  --green-soft: #e6f4ea;
  --amber: #8a5a00;
  --amber-soft: #fff4d6;
  --red: #b3261e;
  --radius: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }
.screen { min-height: 100vh; }
.center { display: flex; align-items: center; justify-content: center; padding: 16px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--navy); }
.logo { display: block; width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.auth .brand { flex-direction: column; align-items: flex-start; gap: 12px; }
.auth .logo { width: 88px; height: 88px; border-radius: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 30px rgba(15,31,51,.06); }
.auth { width: 100%; max-width: 420px; padding: 28px; display: grid; gap: 14px; }
.auth h1 { margin: 6px 0 0; font-size: 22px; }
.auth p { margin: 0; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
input[type=password], input[type=text], input[type=search] {
  width: 100%; padding: 11px 12px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; outline: none;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,115,232,.18); }
.warn { background: var(--amber-soft); color: #5c3d00; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.error { color: var(--red); min-height: 1.2em; font-size: 14px; }

.btn { border: 1px solid transparent; border-radius: 8px; padding: 9px 14px; font-weight: 600; cursor: pointer; background: #eef2f7; }
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.small { padding: 5px 10px; font-size: 13px; }

.topbar { height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top-actions { display: flex; gap: 8px; }
.panes { display: grid; grid-template-columns: 360px 1fr; height: calc(100vh - 60px); }
.list-pane { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.search { padding: 14px 14px 8px; }
.tabs { display: flex; gap: 4px; padding: 0 14px 10px; border-bottom: 1px solid var(--line); }
.tab { flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--blue-soft); color: var(--blue); }
.tab span { font-weight: 500; }
.client-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.client-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; border-left: 4px solid transparent; }
.client-list li:hover { background: #f8fafc; }
.client-list li.selected { background: #f1f7fe; border-left-color: var(--blue); }
.client-list .name { font-weight: 650; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-list .meta { display: flex; align-items: center; gap: 8px; justify-content: flex-end; color: var(--muted); font-size: 13px; }
.client-list .sub { grid-column: 1 / -1; font-size: 13px; }
.empty { padding: 30px 18px; color: var(--muted); text-align: center; }

.star { border: 0; background: transparent; cursor: pointer; padding: 2px; line-height: 0; }
.star svg { width: 22px; height: 22px; fill: #d5dbe4; transition: transform .1s; }
.star.on svg { fill: var(--gold); }
.star:hover svg { transform: scale(1.12); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.chip.ok { background: var(--green-soft); color: var(--green); }
.chip.wait { background: var(--amber-soft); color: var(--amber); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.detail-pane { overflow-y: auto; padding: 36px 48px 60px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.detail-head h1 { font-size: 34px; line-height: 1.15; margin: 0 0 6px; color: var(--navy); }
.detail-head .star svg { width: 34px; height: 34px; }
.section { margin-top: 28px; }
.section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
.login-card { padding: 18px 20px; display: grid; gap: 12px; max-width: 640px; }
.cred { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 12px; }
.cred .label { color: var(--muted); font-weight: 600; font-size: 14px; }
.cred .value { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; overflow-wrap: anywhere; }
.cred .actions { display: flex; gap: 6px; }
.raw { white-space: pre-wrap; }
.login-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.steps li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.steps .icon { width: 16px; text-align: center; font-weight: 700; color: var(--muted); }
.steps li.done .icon { color: var(--green); }
.steps li.bad .icon, .steps li.bad strong { color: var(--red); }
.edit-form { display: grid; gap: 10px; }
.edit-form .row { display: flex; gap: 8px; }
.answers { display: grid; gap: 18px; max-width: 760px; }
.answer .q { color: #6b6fa8; font-size: 15px; margin-bottom: 4px; }
.answer .a { font-size: 17px; white-space: pre-wrap; overflow-wrap: anywhere; }
.danger-link { margin-top: 40px; border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: all .2s; font-weight: 600; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.back { display: none; }
@media (max-width: 860px) {
  .panes { grid-template-columns: 1fr; }
  .panes.show-detail .list-pane { display: none; }
  .panes:not(.show-detail) .detail-pane { display: none; }
  .detail-pane { padding: 18px 16px 40px; }
  .detail-head h1 { font-size: 26px; }
  .back { display: inline-block; margin-bottom: 12px; }
  .cred { grid-template-columns: 1fr; gap: 4px; }
  .topbar { padding: 0 16px; }
}

/* ---------- background switch: white or logo navy (theme.js) ---------- */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; margin-right: 6px; user-select: none; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.switch .track { position: relative; width: 40px; height: 22px; border-radius: 999px; background: #cbd5e1; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--gold); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(26,115,232,.35); }

html[data-theme="white"] { --bg: #ffffff; }
html[data-theme="navy"] { --bg: #153c82; }
html[data-theme="navy"] .topbar { background: #153c82; border-bottom-color: rgba(255,255,255,.14); }
html[data-theme="navy"] .topbar .brand { color: #fff; }
html[data-theme="navy"] .topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.35); }
html[data-theme="navy"] .topbar .btn.ghost:hover { background: rgba(255,255,255,.1); filter: none; }
html[data-theme="navy"] .switch { color: #fff; }
html[data-theme="navy"] .switch .track { background: rgba(255,255,255,.3); }
html[data-theme="navy"] .switch input:checked + .track { background: var(--gold); }
html[data-theme="navy"] .list-pane { border-right-color: transparent; }
html[data-theme="navy"] .detail-pane { color: #fff; }
html[data-theme="navy"] .detail-pane .card { color: var(--ink); }
html[data-theme="navy"] .detail-head h1 { color: #fff; }
html[data-theme="navy"] .detail-pane > .empty,
html[data-theme="navy"] .detail-head .muted,
html[data-theme="navy"] .section h2,
html[data-theme="navy"] .section > p.muted,
html[data-theme="navy"] .answer .q,
html[data-theme="navy"] .danger-link { color: #c3d0e8; }
html[data-theme="navy"] .detail-head .star:not(.on) svg { fill: rgba(255,255,255,.4); }
html[data-theme="navy"] .detail-pane .back { color: #fff; border-color: rgba(255,255,255,.35); }
html[data-theme="navy"] .spinner { border-color: rgba(255,255,255,.25); border-top-color: #fff; }
html[data-theme="navy"] .auth { border-color: transparent; box-shadow: 0 14px 44px rgba(0,0,0,.28); }
@media (max-width: 860px) {
  .switch-text { display: none; }
  .switch { margin-right: 2px; }
  .topbar .brand { white-space: nowrap; font-size: 15px; }
  .top-actions { gap: 6px; }
  .topbar .btn { padding: 7px 10px; }
}

/* ---------- copy buttons: name, email, each answer, "Copy for Claude" ---------- */
.copy-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.copy-line h1 { margin-bottom: 4px; }
.email-line { font-size: 15px; margin-bottom: 4px; }
.head-actions { margin-top: 12px; }
.copy-btn { border: 1px solid var(--line); background: #fff; color: var(--blue); border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 600; cursor: pointer; line-height: 1.6; flex: none; }
.copy-btn:hover { background: var(--blue-soft); }
.answer .q { display: flex; align-items: center; gap: 10px; }
html[data-theme="navy"] .copy-btn { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.35); }
html[data-theme="navy"] .copy-btn:hover { background: rgba(255,255,255,.22); }
html[data-theme="navy"] .head-actions .btn.primary { background: var(--gold); color: #0f1f33; }

/* ---------- navy client list ---------- */
html[data-theme="navy"] .list-pane { background: #153c82; color: #fff; border-right-color: rgba(255,255,255,.14); }
html[data-theme="navy"] .search input { border-color: transparent; }
html[data-theme="navy"] .tabs { border-bottom-color: rgba(255,255,255,.14); }
html[data-theme="navy"] .tab { color: #c3d0e8; }
html[data-theme="navy"] .tab.active { background: rgba(255,255,255,.16); color: #fff; }
html[data-theme="navy"] .client-list li { border-bottom-color: rgba(255,255,255,.12); }
html[data-theme="navy"] .client-list li:hover { background: rgba(255,255,255,.07); }
html[data-theme="navy"] .client-list li.selected { background: rgba(255,255,255,.14); border-left-color: var(--gold); }
html[data-theme="navy"] .client-list .meta,
html[data-theme="navy"] .list-pane .empty { color: #c3d0e8; }
html[data-theme="navy"] .client-list .star:not(.on) svg { fill: rgba(255,255,255,.35); }

/* ---------- two-step remove ---------- */
.confirm-remove { margin-top: 40px; max-width: 640px; padding: 16px 18px; border: 1px solid #f1c0bb; background: #fdecea; color: #5c1a15; border-radius: 10px; display: grid; gap: 12px; }
.confirm-remove p { margin: 0; }
.confirm-remove .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
html[data-theme="navy"] .detail-pane .confirm-remove { color: #5c1a15; }

/* ---------- bigger logo in the top bar (3x: 44px -> 132px) ---------- */
.topbar { height: 156px; }
.topbar .logo { width: 132px; height: 132px; border-radius: 16px; }
.topbar .brand { gap: 16px; font-size: 20px; }
.panes { height: calc(100vh - 156px); }
@media (max-width: 860px) {
  .topbar { height: 112px; }
  .topbar .logo { width: 88px; height: 88px; border-radius: 12px; }
  .topbar .brand { gap: 10px; font-size: 15px; }
  .panes { height: calc(100vh - 112px); }
}
@media (max-width: 400px) {
  .topbar .brand { font-size: 0; gap: 0; }
}

/* ---------- Backup button (desktop only; the nightly backup covers phones) ---------- */
@media (max-width: 860px) { #btn-backup { display: none; } }
