:root {
  --bg: #06080d;
  --bg-2: #0d1320;
  --panel: #151d2b;
  --panel-2: #1c2740;
  --ink: #edf4ff;
  --ink-soft: #9caec7;
  --brand: #f2b84b;
  --brand-2: #4fc7ff;
  --brand-glow: rgba(79, 199, 255, 0.16);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --line: #2b3853;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 18% 0%, rgba(242, 184, 75, 0.18), transparent 52%),
    radial-gradient(ellipse at 82% 100%, rgba(79, 199, 255, 0.14), transparent 52%),
    var(--bg);
  min-height: 100vh;
}

h1, h2, h3, h4, .nav-btn {
  font-family: 'Sora', sans-serif;
}

/* ── Unlock screen ── */
.screen {
  width: 100%;
  min-height: 100vh;
}

.screen.active {
  display: flex;
}

#screen-unlock {
  align-items: center;
  justify-content: center;
}

.unlock-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 42px 40px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow), 0 0 60px rgba(79, 199, 255, 0.12);
  text-align: center;
}

.unlock-box .input-field {
  background: rgba(15, 17, 23, 0.92);
  border-color: rgba(79, 199, 255, 0.32);
}

.unlock-box .input-field::placeholder {
  color: #848aa6;
}

.unlock-box .btn-ghost {
  border-color: rgba(79, 199, 255, 0.28);
  color: var(--ink);
  background: rgba(79, 199, 255, 0.08);
}

.brand-logo-frame {
  width: min(100%, 230px);
  margin: 0 auto 16px;
  padding: 10px;
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(242, 184, 75, 0.22), rgba(79, 199, 255, 0.12)),
    rgba(10, 14, 22, 0.92);
  border: 1px solid rgba(242, 184, 75, 0.32);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.36);
}

.brand-logo-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 22px;
}

.unlock-box h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  color: var(--ink);
}

.brand-sub {
  color: var(--ink-soft);
  font-size: 0.88rem;
  margin: 0 0 28px;
}

.unlock-mode-text,
.install-help {
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.5;
  margin: 0 0 14px;
}

.install-help {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.08);
}

/* ── App shell ── */
#screen-app {
  display: grid !important;
  width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--line);
}

.sidebar-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid rgba(242, 184, 75, 0.28);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
}

.brand h1 {
  margin: 0;
  font-size: 1rem;
  color: var(--ink);
}

.brand p {
  margin: 0;
  font-size: 0.7rem;
  color: var(--ink-soft);
}

.nav-list {
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  flex: 1;
}

.mobile-nav {
  display: none;
}

.nav-btn {
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: var(--ink-soft);
  padding: 11px 20px;
  text-align: left;
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.15s;
}

.nav-btn:hover {
  background: var(--brand-glow);
  color: var(--ink);
}

.nav-btn.active {
  background: linear-gradient(90deg, var(--brand-glow), transparent);
  color: var(--brand-2);
  border-left-color: var(--brand);
}

.lock-btn {
  margin: 16px;
  padding: 10px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.15s;
}

.lock-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Content ── */
.content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(21, 29, 43, 0.76);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h2 {
  margin: 0;
  font-size: 1.2rem;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.vault-badge {
  font-size: 0.75rem;
  color: var(--ink-soft);
  background: var(--panel-2);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
}

/* ── Pages ── */
.page {
  display: none;
  padding: 24px 28px;
  overflow-y: auto;
}

.page.active {
  display: block;
}

/* ── Cards ── */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 24px;
  margin-bottom: 16px;
}

.card h3 {
  margin: 0 0 16px;
  font-size: 1rem;
  color: var(--ink);
}

/* ── Stats ── */
.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(180px, 240px);
  gap: 20px;
  align-items: center;
  background:
    radial-gradient(circle at top left, rgba(242, 184, 75, 0.16), transparent 44%),
    radial-gradient(circle at bottom right, rgba(79, 199, 255, 0.18), transparent 40%),
    linear-gradient(145deg, rgba(21, 29, 43, 0.98), rgba(15, 20, 32, 0.92));
}

.hero-kicker {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--brand);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.dashboard-hero h3 {
  margin: 0 0 10px;
  font-size: 1.35rem;
}

.dashboard-hero p {
  margin: 0;
  color: var(--ink-soft);
  max-width: 46ch;
  line-height: 1.55;
}

.dashboard-hero-logo {
  width: min(100%, 220px);
  justify-self: end;
  border-radius: 26px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 16px;
  text-align: center;
}

.stat-num {
  font-size: 2.4rem;
  font-weight: 800;
  font-family: 'Sora', sans-serif;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 4px;
}

/* ── App breakdown chips ── */
.app-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 14px;
}

.chip-name {
  font-size: 0.82rem;
  color: var(--ink);
}

.chip-count {
  font-size: 0.72rem;
  background: var(--brand);
  color: white;
  border-radius: 10px;
  padding: 1px 7px;
  font-weight: 700;
}

/* ── Keys list ── */
.keys-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.key-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  gap: 12px;
  transition: border-color 0.15s;
}

.key-row:hover {
  border-color: var(--brand);
}

.key-info {
  flex: 1;
  min-width: 0;
}

.key-name {
  display: block;
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--brand-2);
  font-weight: 500;
}

.key-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.badge-app {
  background: rgba(79, 199, 255, 0.14);
  color: var(--brand-2);
}

.badge-cat {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
}

.key-notes {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.key-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.key-value {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Icon buttons ── */
.icon-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--ink-soft);
  transition: all 0.15s;
}

.icon-btn:hover {
  border-color: var(--brand);
  color: var(--ink);
}

.icon-btn.danger-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Toolbar / filters ── */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
}

.select-field {
  min-width: 160px;
}

/* ── Form ── */
.form-card {
  max-width: 560px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.input-field {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 14px;
  color: var(--ink);
  font-size: 0.9rem;
  font-family: 'Manrope', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}

.input-field:focus {
  border-color: var(--brand);
}

.input-field.mono {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.mono-inline {
  font-family: var(--mono);
  font-size: 0.85em;
}

select.input-field {
  appearance: none;
  cursor: pointer;
}

.textarea-field {
  resize: vertical;
  min-height: 80px;
}

#importText {
  min-height: 220px;
}

.value-row {
  display: flex;
  gap: 8px;
}

.value-row .input-field {
  flex: 1;
}

.toggle-vis-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--ink-soft);
  transition: border-color 0.15s;
}

.toggle-vis-btn:hover {
  border-color: var(--brand);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin-top: 4px;
}

.checkbox-row input {
  accent-color: var(--brand);
}

.file-input {
  padding-block: 12px;
}

/* ── Buttons ── */
.btn-primary {
  display: block;
  width: 100%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: none;
  border-radius: 9px;
  padding: 12px 24px;
  color: white;
  font-family: 'Sora', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  margin-top: 8px;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-primary.inline-btn {
  width: auto;
  display: inline-block;
}

.btn-ghost {
  display: block;
  width: 100%;
  background: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 20px;
  color: var(--ink-soft);
  font-family: 'Sora', sans-serif;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 10px;
}

.btn-ghost:hover {
  border-color: var(--brand);
  color: var(--ink);
}

.btn-ghost.inline {
  width: auto;
  display: inline-block;
  margin-top: 0;
}

.btn-ghost.small {
  width: auto;
  margin: 0;
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-danger {
  background: none;
  border: 1px solid var(--danger);
  border-radius: 9px;
  padding: 10px 20px;
  color: var(--danger);
  font-family: 'Sora', sans-serif;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* ── Messages ── */
.error-msg {
  color: var(--danger);
  font-size: 0.82rem;
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 7px;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.success-msg {
  color: var(--success);
  font-size: 0.82rem;
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(34, 197, 94, 0.1);
  border-radius: 7px;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.hint-text {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0 0 16px;
}

.warning-text {
  color: var(--warning) !important;
}

.empty-msg {
  color: var(--ink-soft);
  font-size: 0.85rem;
  padding: 12px 0;
  text-align: center;
}

/* ── Export ── */
.export-card {
  background: var(--bg-2);
}

.export-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.export-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.export-toolbar h3 {
  margin: 0;
}

.export-pre {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: #a3e635;
  background: #060908;
  border: 1px solid #1a2a1a;
  border-radius: 10px;
  padding: 16px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0 0 12px;
}

/* ── Danger card ── */
.danger-card {
  border-color: rgba(239, 68, 68, 0.3);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .unlock-box {
    max-width: calc(100% - 24px);
    padding: 28px 18px;
  }

  .dashboard-hero {
    grid-template-columns: 1fr;
  }

  .dashboard-hero-logo {
    justify-self: center;
    width: min(100%, 180px);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-num {
    font-size: 2rem;
  }

  .page {
    padding: 16px 16px 92px;
  }

  .topbar {
    padding: 14px 16px;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
  }

  .toolbar,
  .form-actions,
  .value-row,
  .export-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .export-toolbar-actions {
    justify-content: stretch;
  }

  .export-toolbar-actions .btn-ghost.small {
    width: 100%;
  }

  .key-row {
    flex-direction: column;
  }

  .key-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .key-value {
    max-width: 100%;
    flex: 1 0 100%;
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    background: rgba(30, 35, 51, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-nav .nav-btn {
    border-left: none;
    border-top: 3px solid transparent;
    text-align: center;
    padding: 10px 4px 12px;
    font-size: 0.74rem;
    min-height: 58px;
  }

  .mobile-nav .nav-btn.active {
    border-left-color: transparent;
    border-top-color: var(--brand);
    background: linear-gradient(180deg, var(--brand-glow), transparent);
  }

  .checkbox-row {
    align-items: flex-start;
  }
}

@media (max-width: 420px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .mobile-nav .nav-btn {
    font-size: 0.7rem;
  }
}
