*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f14;
  --surface: #161a23;
  --surface2: #1e2330;
  --border: #2a3040;
  --accent: #5b8dee;
  --accent-dim: #3a5fa8;
  --danger: #e05b5b;
  --success: #3ecf70;
  --text: #d4d8e2;
  --text-dim: #7a8299;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

/* ── Login ── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 360px;
}

.login-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.login-card p  { color: var(--text-dim); margin-bottom: 28px; font-size: 13px; }

/* ── Main layout ── */
#app { display: none; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo { font-weight: 700; font-size: 1.1rem; color: var(--accent); letter-spacing: .5px; }

nav { display: flex; gap: 4px; }
nav button {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, color .15s;
}
nav button.active, nav button:hover { background: var(--surface2); color: var(--text); }

main { max-width: 960px; margin: 0 auto; padding: 32px 24px; }

/* ── Cards & tables ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-header h2 { font-size: 1rem; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--text-dim); font-size: 12px; font-weight: 500;
     padding: 8px 12px; border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: .5px; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ── Forms ── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }

input, select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ── */
.btn, button.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }

.btn-primary  { background: var(--accent);      color: #fff; }
.btn-danger   { background: var(--danger);       color: #fff; }
.btn-ghost    { background: var(--surface2);     color: var(--text); border: 1px solid var(--border); }
.btn-success  { background: var(--success);      color: #111; }
.btn-sm       { padding: 5px 10px; font-size: 12px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-on  { background: rgba(62,207,112,.15); color: var(--success); }
.badge-off { background: rgba(224,91,91,.15);  color: var(--danger); }
.badge-type { background: rgba(91,141,238,.15); color: var(--accent); }
.badge-cat { background: rgba(162,116,230,.15); color: #b388ff; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 480px;
  max-width: 95vw;
  padding: 28px;
}
.modal h3 { font-size: 1rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Misc ── */
.hidden { display: none !important; }
.text-dim { color: var(--text-dim); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-4 { margin-top: 16px; }

.key-reveal {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: monospace;
  font-size: 13px;
  word-break: break-all;
  margin-top: 12px;
  color: var(--success);
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 12px;
}
.alert-error   { background: rgba(224,91,91,.12); border: 1px solid rgba(224,91,91,.3); color: var(--danger); }
.alert-success { background: rgba(62,207,112,.12); border: 1px solid rgba(62,207,112,.3); color: var(--success); }

.modal-wide { width: 760px; max-height: 80vh; overflow-y: auto; }

.label-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.label-link:hover { color: var(--accent-dim); }

.text-link { color: var(--accent); text-decoration: none; font-size: 12px; }
.text-link:hover { text-decoration: underline; }

/* ── Login tabs ── */
.login-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.ltab {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.ltab.active { color: var(--accent); border-bottom-color: var(--accent); }
.ltab:hover { color: var(--text); }

/* ── Balance display ── */
.balance-amount {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
}
