/* ZAK Key Vault — brand: orange #ee8a4f, pink #ec4f9a, dark #0e0b0a */
:root {
  --bg: #0e0b0a;
  --bg2: #141010;
  --panel: #1a1412;
  --panel2: #221a16;
  --line: #2e2420;
  --text: #f2ece8;
  --muted: #a0948c;
  --faint: #6e635c;
  --orange: #ee8a4f;
  --pink: #ec4f9a;
  --green: #34c273;
  --red: #f0524f;
  --amber: #e8b64c;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px; line-height: 1.5; overflow: hidden;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
input { font: inherit; color: inherit; }

/* ---------- login ---------- */
#login {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 500px at 50% -10%, rgba(238,138,79,0.09), transparent 60%), var(--bg);
}
#login .box {
  width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px; text-align: center;
}
#login .mark {
  width: 46px; height: 46px; border-radius: 12px; margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 23px; color: #1a0d08;
}
#login h1 { font-size: 17px; letter-spacing: 0.3px; }
#login .sub { color: var(--muted); font-size: 12px; margin-bottom: 18px; letter-spacing: 1.2px; text-transform: uppercase; }
#login input {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); outline: none; text-align: center; letter-spacing: 1px;
}
#login input:focus { border-color: rgba(238,138,79,0.5); }
#login .err { color: var(--red); font-size: 12.5px; min-height: 18px; margin-top: 9px; }

/* ---------- app shell ---------- */
#app { display: flex; height: 100vh; }
#sidebar {
  width: 208px; min-width: 208px; background: var(--bg2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 4px;
}
#brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
#brand .mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #1a0d08;
}
#brand b { font-size: 14.5px; display: block; }
#brand span { display: block; font-size: 10px; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 13.5px; border: 1px solid transparent;
  transition: background 0.12s, color 0.12s; white-space: nowrap;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(238,138,79,0.16), rgba(236,79,154,0.10)); color: var(--orange); border-color: rgba(238,138,79,0.25); }
#sidebar .spacer { flex: 1; }
#side-foot { padding: 10px 8px; font-size: 11px; color: var(--faint); line-height: 1.5; }
#side-foot button { color: var(--muted); font-size: 12px; font-weight: 600; padding: 6px 0; }
#side-foot button:hover { color: var(--red); }

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 24px;
  border-bottom: 1px solid var(--line); background: rgba(20,16,16,0.7); backdrop-filter: blur(8px);
}
#topbar h1 { font-size: 17px; font-weight: 700; }
#topbar .sub { color: var(--muted); font-size: 12px; }
#topbar .actions { margin-left: auto; display: flex; gap: 10px; }
#content { flex: 1; overflow-y: auto; padding: 20px 24px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel2);
  color: var(--text); text-decoration: none;
  font-weight: 600; font-size: 13px; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--line); }
.btn.primary { background: linear-gradient(135deg, var(--orange), var(--pink)); color: #1a0d08; border: none; font-weight: 800; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- stats ---------- */
#stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; }
.stat .label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.stat .value { font-size: 25px; font-weight: 800; margin-top: 2px; letter-spacing: -0.5px; }
.stat .value.ok { color: var(--green); }
.stat .value.acc { color: var(--orange); }
.stat .value.warn { color: var(--amber); }

/* ---------- layout ---------- */
#split { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 13px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card .head { display: flex; align-items: center; gap: 10px; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.card .head b { font-size: 14px; }
.card .head .sub { color: var(--muted); font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--faint); font-weight: 700; padding: 9px 13px; border-bottom: 1px solid var(--line); }
td { padding: 10px 13px; border-bottom: 1px solid rgba(46,36,32,0.55); font-size: 13.5px; }
tbody tr { cursor: pointer; transition: background 0.1s; }
tbody tr:hover { background: rgba(34,26,22,0.6); }
tbody tr.sel { background: linear-gradient(90deg, rgba(238,138,79,0.12), transparent); }
td .id { font-weight: 700; white-space: nowrap; }
td .em { color: var(--muted); font-size: 12px; }
.pw-cell, .chip { white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.chip.mailbox { color: var(--amber); background: rgba(232,182,76,0.10); border: 1px solid rgba(232,182,76,0.25); }
.chip.mailbox::before { background: var(--amber); }
.chip.registered { color: var(--blue, #6fa8dc); background: rgba(111,168,220,0.10); border: 1px solid rgba(111,168,220,0.25); }
.chip.registered::before { background: #6fa8dc; }
.chip.ready, .chip.assigned { color: var(--green); background: rgba(52,194,115,0.10); border: 1px solid rgba(52,194,115,0.25); }
.chip.ready::before, .chip.assigned::before { background: var(--green); }
.chip.assigned { color: var(--orange); background: rgba(238,138,79,0.10); border-color: rgba(238,138,79,0.25); }
.chip.assigned::before { background: var(--orange); }

/* ---------- detail ---------- */
#detail .tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.tab { padding: 11px 12px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }
.tabpane { padding: 15px; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 7px 12px; font-size: 13px; margin-bottom: 13px; }
.kv dt { color: var(--faint); font-weight: 600; }
.kv dd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; word-break: break-all; }
.note { font-size: 12px; color: var(--muted); line-height: 1.55; }
.note b { color: var(--text); }
.actions-row { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 13px; }

.mailrow { display: flex; gap: 12px; align-items: flex-start; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel2); margin-bottom: 9px; }
.mailrow .ico { font-size: 15px; margin-top: 1px; }
.mailrow .from { font-weight: 700; font-size: 13px; }
.mailrow .subj { color: var(--muted); font-size: 12.5px; }
.mailrow .time { margin-left: auto; color: var(--faint); font-size: 11px; white-space: nowrap; }
.mailbody { padding: 4px 12px 12px; }
.mailbody pre { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; max-height: 220px; overflow-y: auto; }
.linkbox { display: flex; align-items: center; gap: 10px; background: rgba(52,194,115,0.07); border: 1px dashed rgba(52,194,115,0.35); border-radius: 9px; padding: 8px 12px; font-size: 12.5px; margin-top: 8px; }
.linkbox .url { font-family: ui-monospace, monospace; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.linkbox.dim { background: rgba(46,36,32,0.4); border-color: var(--line); }
.badge-auto { font-size: 10.5px; font-weight: 800; letter-spacing: 0.8px; color: var(--green); border: 1px solid rgba(52,194,115,0.35); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }

.text-input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); outline: none; font-size: 13px;
}
.text-input:focus { border-color: rgba(238,138,79,0.5); }
.text-input.mono { font-family: ui-monospace, monospace; letter-spacing: 0.5px; }

/* ---------- provision wizard ---------- */
#provision-card { margin-top: 13px; }
.step { display: flex; gap: 13px; padding: 12px 15px; border-bottom: 1px solid rgba(46,36,32,0.55); align-items: flex-start; }
.step:last-child { border-bottom: none; }
.step .num { width: 28px; height: 28px; min-width: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); margin-top: 1px; }
.step.done .num { background: rgba(52,194,115,0.15); border-color: rgba(52,194,115,0.4); color: var(--green); }
.step.active .num { background: linear-gradient(135deg, var(--orange), var(--pink)); color: #1a0d08; border: none; }
.step .t { font-weight: 700; font-size: 13.5px; }
.step .d { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin-top: 2px; }
.step .out { margin-top: 7px; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.step .out .ok-line { color: var(--green); }
.step.waiting .d { color: var(--amber); }

/* ---------- history ---------- */
.hist { padding: 4px 15px 12px; }
.hist-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(46,36,32,0.5); font-size: 13px; align-items: baseline; }
.hist-row:last-child { border-bottom: none; }
.hist-row .when { color: var(--faint); font-size: 11px; white-space: nowrap; }
.hist-row .what { color: var(--muted); }
.hist-row .what b { color: var(--text); }

#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(90px);
  background: var(--panel2); border: 1px solid rgba(238,138,79,0.4); color: var(--text);
  padding: 11px 18px; border-radius: 12px; font-size: 13px; font-weight: 600;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5); transition: transform 0.25s; z-index: 50;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { border-color: rgba(240,82,79,0.5); }

@media (max-width: 980px) {
  #sidebar { display: none; }
  #split { grid-template-columns: 1fr; }
  #stats { grid-template-columns: repeat(2, 1fr); }
}
