/* ─── Variables ──────────────────────────────────────────── */
:root {
  --bg: #f5f9ff;
  --bg2: #edf3ff;
  --surface: rgba(255,255,255,0.82);
  --surface-raised: rgba(255,255,255,0.96);
  --border: rgba(162,180,212,0.38);
  --border-strong: rgba(120,150,195,0.55);
  --text: #172033;
  --muted: #5a6b88;
  --accent: #0fb797;
  --accent-dark: #09a786;
  --danger: #d95050;
  --danger-bg: rgba(217,80,80,0.1);
  --warning: #d97316;
  --shadow-sm: 0 2px 8px rgba(28,46,84,0.06);
  --shadow: 0 12px 32px rgba(28,46,84,0.1);
  --shadow-lg: 0 24px 56px rgba(28,46,84,0.14);
  --radius: 22px;
  --radius-sm: 14px;
  --sidebar-w: 220px;
}

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

body {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
  color: var(--text);
  font-family: Manrope, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }

/* ─── Background glows ───────────────────────────────────── */
.bg-glows { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.glow { position: absolute; border-radius: 50%; filter: blur(80px); }
.glow-tl { top: -80px; left: -80px; width: 400px; height: 320px; background: radial-gradient(circle, rgba(69,164,255,0.14), transparent 65%); }
.glow-br { bottom: -80px; right: -60px; width: 360px; height: 280px; background: radial-gradient(circle, rgba(76,224,179,0.18), transparent 65%); }

/* ─── Login screen ───────────────────────────────────────── */
.login-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.login-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.login-title {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}

.login-desc {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}

.login-form { display: grid; gap: 16px; }

.input-wrap { position: relative; }
.input-wrap .field-input { padding-right: 42px; }

.eye-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--muted);
  width: 22px;
  height: 22px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.eye-btn:hover { color: var(--text); }
.eye-btn svg { width: 16px; height: 16px; }

/* ─── App shell ──────────────────────────────────────────── */
.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 12px;
  border-right: 1px solid var(--border);
  background: rgba(255,255,255,0.62);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(15,183,151,0.18), rgba(69,164,255,0.14));
  border: 1px solid rgba(15,183,151,0.22);
  color: var(--accent-dark);
  flex-shrink: 0;
}

.brand-name { font-weight: 800; font-size: 14px; letter-spacing: -0.01em; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: left;
  width: 100%;
}
.nav-item:hover { background: rgba(15,183,151,0.07); color: var(--text); }
.nav-item.active { background: rgba(15,183,151,0.12); color: var(--accent-dark); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  padding: 4px 10px;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.3s;
}
.status-dot.online { background: var(--accent); box-shadow: 0 0 0 3px rgba(15,183,151,0.2); }

.logout-btn { margin: 0 6px; width: calc(100% - 12px); }

/* ─── Main content ───────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 24px 28px;
  overflow-x: hidden;
}

.tab-panel { display: flex; flex-direction: column; gap: 20px; }
.tab-panel.hidden { display: none; }

/* ─── Page header ────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: clamp(20px,3vw,28px); font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.page-header p { margin-top: 4px; font-size: 13px; color: var(--muted); }

/* ─── Stats ──────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.stat-card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
}
.stat-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stat-value { display: block; margin-top: 8px; font-size: 28px; font-weight: 800; line-height: 1; }
.stat-active { color: var(--accent-dark); }
.stat-revoked { color: var(--danger); }

/* ─── Panels ─────────────────────────────────────────────── */
.panels-row { display: grid; grid-template-columns: 340px minmax(0,1fr); gap: 18px; align-items: start; }
.card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); backdrop-filter: blur(18px); box-shadow: var(--shadow); padding: 22px; }
.card-header { margin-bottom: 18px; }
.card-kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent-dark); }
.card-title { margin-top: 6px; font-size: 20px; font-weight: 800; line-height: 1.1; }

/* ─── Forms ──────────────────────────────────────────────── */
.create-form { display: grid; gap: 14px; }
.field-group { display: grid; gap: 6px; }
.field-label { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text); }

.field-input {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}
.field-input:focus { border-color: rgba(15,183,151,0.55); }
.field-input::placeholder { color: #8fa0ba; }

.field-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 7L11 1' stroke='%235a6b88' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

.field-textarea { height: auto; padding: 10px 14px; resize: vertical; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.search-input { height: 36px; font-size: 13px; padding: 0 12px; width: 180px; }

.new-key-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(15,183,151,0.28);
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(15,183,151,0.09), rgba(69,164,255,0.05));
}
.new-key-box.hidden { display: none; }
.new-key-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.key-code { display: block; margin-top: 10px; padding: 12px 14px; border-radius: 14px; background: rgba(13,27,44,0.06); font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.new-key-warn { margin-top: 10px; font-size: 12px; color: var(--warning); font-weight: 600; }

.form-status { margin-top: 8px; font-size: 13px; min-height: 18px; font-weight: 600; }
.form-status.success { color: var(--accent-dark); }
.form-status.error { color: var(--danger); }

/* ─── Lists ──────────────────────────────────────────────── */
.list-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.list-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.keys-list { display: grid; gap: 10px; max-height: 560px; overflow-y: auto; padding-right: 2px; }
.keys-list::-webkit-scrollbar { width: 4px; }
.keys-list::-webkit-scrollbar-thumb { background: rgba(15,183,151,0.28); border-radius: 99px; }

.empty-state { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; font-weight: 500; }

/* ─── Key card ───────────────────────────────────────────── */
.key-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,0.62);
  display: grid;
  gap: 8px;
}

.key-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.key-title { font-size: 14px; font-weight: 800; line-height: 1.2; }
.key-meta { margin-top: 3px; font-size: 12px; color: var(--muted); }

.key-bottom { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.key-hint { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; font-weight: 700; color: var(--text); letter-spacing: 0.04em; }
.key-btns { display: flex; gap: 6px; flex-wrap: wrap; }

.device-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(15,183,151,0.1);
  color: var(--accent-dark);
}
.device-badge.unbound { background: rgba(90,107,136,0.1); color: var(--muted); }

/* ─── Wallet card ────────────────────────────────────────── */
.wallet-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,0.62);
  display: grid;
  gap: 8px;
}
.wallet-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.wallet-chain { font-size: 12px; font-weight: 800; letter-spacing: 0.1em; color: var(--accent-dark); text-transform: uppercase; }
.wallet-key-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.wallet-amount { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13px; font-weight: 700; }
.wallet-seed { font-size: 11px; color: var(--muted); word-break: break-all; font-family: "IBM Plex Mono", ui-monospace, monospace; }
.wallet-bottom { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ─── Pill ───────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; justify-content: center; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 10px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; flex-shrink: 0; }
.pill-active { background: rgba(15,183,151,0.12); color: var(--accent-dark); }
.pill-revoked { background: rgba(217,80,80,0.12); color: var(--danger); }

/* ─── Buttons ────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 14px; cursor: pointer; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; transition: transform 0.12s, opacity 0.12s, box-shadow 0.12s; white-space: nowrap; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.btn-primary { height: 44px; padding: 0 20px; font-size: 11px; background: linear-gradient(135deg, rgba(76,224,179,0.96), rgba(15,183,151,0.92)); color: #f5fffd; box-shadow: 0 10px 24px rgba(76,224,179,0.24); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 32px rgba(76,224,179,0.32); }
.btn-ghost { height: 36px; padding: 0 14px; font-size: 10px; border: 1px solid var(--border-strong); background: rgba(255,255,255,0.7); color: var(--text); }
.btn-danger { height: 30px; padding: 0 12px; font-size: 10px; background: var(--danger-bg); color: var(--danger); }
.btn-warn { height: 30px; padding: 0 12px; font-size: 10px; background: rgba(217,115,22,0.1); color: var(--warning); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 11px; }
.btn-full { width: 100%; }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(14,24,42,0.48); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-overlay.hidden { display: none; }
.modal-box { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 28px; max-width: 380px; width: 100%; }
.modal-title { font-size: 18px; font-weight: 800; margin-bottom: 10px; }
.modal-message { font-size: 14px; color: var(--muted); margin-bottom: 20px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Spinner ────────────────────────────────────────────── */
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Utilities ──────────────────────────────────────────── */
.hidden { display: none !important; }
code { font-family: "IBM Plex Mono", ui-monospace, monospace; }
.glass-card { border: 1px solid var(--border); background: var(--surface); backdrop-filter: blur(18px); border-radius: var(--radius); box-shadow: var(--shadow-lg); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .panels-row { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(3,1fr); }
  .page-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .search-input { width: 120px; }
}
