:root {
  color-scheme: dark;
  --bg: #09090b;
  --panel: #101014;
  --panel-2: #16161c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e7e7ea;
  --muted: #8f8f9c;
  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.16);
  --ok: #34d399;
  --err: #f87171;
  --warn: #fbbf24;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* Author `display` rules below would otherwise override the UA [hidden] rule
   and leave the modal/toast permanently visible. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-soft); }

button {
  font-family: inherit;
  font-size: 14px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
button:hover:not(:disabled) { background: #1d1d24; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: linear-gradient(180deg, #8b5cf6, #6d28d9);
  border-color: rgba(139, 92, 246, 0.65);
  font-weight: 600;
}
button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #976bf8, #7c3aed); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, 0.05); }

input {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: #0c0c10;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 10px 12px;
  outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: #5b5b66; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 280px;
  flex: 0 0 280px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  font-weight: 700; font-size: 15px; color: #fff;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
}
.brand-title { font-weight: 650; letter-spacing: 0.2px; }
.brand-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; padding-right: 2px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 9px 11px; border-radius: 9px;
  color: var(--muted); cursor: pointer; border: 1px solid transparent;
  font-size: 14px;
}
.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.nav-item.active {
  color: var(--text); background: var(--accent-soft);
  border-color: rgba(139, 92, 246, 0.35);
  font-weight: 600;
}
.nav-count { font-size: 12px; color: var(--muted); background: rgba(255, 255, 255, 0.06); border-radius: 999px; padding: 1px 8px; }

.sidebar-foot {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 6px 2px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px;
}
.foot-actions { display: flex; align-items: center; gap: 10px; }
.ghost-link { color: var(--muted); text-decoration: none; font-size: 13px; }
.ghost-link:hover { color: var(--text); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  max-width: 640px;
}
.card h2 { margin: 0 0 6px; font-size: 17px; }
.card .muted { margin: 0 0 16px; }
.pill {
  display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px;
  border: 1px solid; vertical-align: middle; margin-left: 8px;
}
.pill.on { color: #bbf7d0; background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.35); }
.pill.off { color: var(--muted); background: rgba(255, 255, 255, 0.05); border-color: var(--border-strong); }
button.danger { background: linear-gradient(180deg, #ef4444, #dc2626); border-color: rgba(239, 68, 68, 0.6); font-weight: 600; }
button.danger:hover:not(:disabled) { background: linear-gradient(180deg, #f87171, #ef4444); }

.content { flex: 1; padding: 28px 32px 60px; max-width: 1060px; }
.content-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.content-head h1 { font-size: 21px; margin: 0; font-weight: 650; }
.muted { color: var(--muted); font-size: 13.5px; }

.search { margin-bottom: 4px; }
.search input { font-size: 14px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 16px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.row:hover { border-color: var(--border-strong); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; }
.row-key { font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin-top: 3px; word-break: break-all; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 12px; color: #c4b5fd; background: var(--accent-soft);
  border: 1px solid rgba(139, 92, 246, 0.3); border-radius: 999px; padding: 2px 9px;
}
.row-note { color: var(--muted); font-size: 12.5px; max-width: 240px; text-align: right; }

.empty { color: var(--muted); text-align: center; padding: 48px 0; }

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 9px;
  border: 1px solid;
  vertical-align: middle;
  white-space: nowrap;
}
.badge.warning { color: #fcd34d; border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.08); }
.badge.critical { color: #fca5a5; border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.1); }

.reveal { display: flex; align-items: center; gap: 10px; }
.reveal-value {
  flex: 1;
  min-height: 41px;
  font-family: var(--mono);
  font-size: 13.5px;
  word-break: break-all;
  background: #0c0c10;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 10px 12px;
}
.eye { padding: 9px 11px; line-height: 0; }
.eye svg { vertical-align: middle; }
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 14px;
  font-size: 13px;
  color: #fcd34d;
  line-height: 1.45;
}
.check input { width: auto; margin-top: 2px; }
.key-inline { font-family: var(--mono); color: #c4b5fd; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.66);
  display: grid; place-items: center; padding: 18px; z-index: 40;
  backdrop-filter: blur(3px);
}
.modal {
  width: 100%; max-width: 560px; background: var(--panel-2);
  border: 1px solid var(--border-strong); border-radius: 16px;
  padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal .key { font-family: var(--mono); color: var(--muted); font-size: 12.5px; word-break: break-all; }
.field { margin-top: 16px; }
.field label, .field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; line-height: 1.45; }
.warning {
  margin-top: 14px; font-size: 13px; color: #fcd34d;
  background: rgba(251, 191, 36, 0.08); border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 10px; padding: 10px 12px; line-height: 1.45;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.status { margin-top: 16px; font-size: 14px; border-radius: 10px; padding: 12px 14px; line-height: 1.5; }
.status.ok { color: #bbf7d0; background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.3); }
.status.err { color: #fecaca; background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.3); }
.status.work { color: #ddd6fe; background: var(--accent-soft); border: 1px solid rgba(139, 92, 246, 0.3); }
.status ul { margin: 6px 0 0; padding-left: 18px; }

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  background: var(--panel-2); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 12px 16px; font-size: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 50% -10%, rgba(124, 58, 237, 0.18), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 16px; padding: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.auth-card .brand { padding: 0; margin-bottom: 20px; }
.auth-card h1 { font-size: 19px; margin: 0 0 6px; }
.auth-card p { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; line-height: 1.5; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card button { width: 100%; padding: 11px; }
.auth-error {
  color: #fecaca; background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3); border-radius: 9px;
  padding: 10px 12px; font-size: 13.5px;
}
.qr { display: grid; place-items: center; margin: 16px 0; }
.qr img { width: 220px; height: 220px; background: #fff; border-radius: 12px; padding: 10px; }
.secret-key {
  font-family: var(--mono); font-size: 13px; word-break: break-all; text-align: center;
  background: #0c0c10; border: 1px dashed var(--border-strong); border-radius: 9px; padding: 10px;
  color: #c4b5fd;
}

.loading { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }

@media (max-width: 840px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: relative;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 14px 14px 12px; gap: 12px;
  }
  .nav { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .nav-item { white-space: nowrap; }
  .sidebar-foot { margin-top: 0; }
  .content { padding: 18px 14px 60px; }
  .row { flex-direction: column; align-items: stretch; gap: 10px; }
  .row-note { text-align: left; max-width: none; }
}
