/* ============================================================
   SecureVault — Design System
   Elevated dark theme · Law firm authority · Bloomberg × Clio
   Mobile-first · WCAG 2.1 AA
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Backgrounds ──────────────────────────────────────────
     +50% brightness on each RGB channel vs prior values.
     Deep navy — midnight, not void. Surfaces read clearly.   */
  --bg-void:      #0B0E17;   /* absolute base — auth page, outermost */
  --bg-base:      #121824;   /* app canvas                           */
  --bg-surface:   #1F2D40;   /* cards, panels — lifted ~13% for float */
  --bg-raised:    #233048;   /* inputs, nested panels                */
  --bg-overlay:   #2C3C60;   /* dropdowns, hover panels              */
  --bg-hover:     #334872;   /* interactive hover                    */

  /* ── Borders ──────────────────────────────────────────────
     Alpha ×1.5 — now visible without being heavy.            */
  --border-subtle:  rgba(180,195,220,.13);   /* mid-tone rhythm — was .10 */
  --border-default: rgba(180,195,220,.22);   /* mid-tone rhythm — was .18 */
  --border-strong:  rgba(180,195,220,.36);

  /* ── Accent — old-money gold ──────────────────────────────
     Brightened ×1.15 to stay warm amber, not go neon.        */
  --gold-dim:    #957220;
  --gold:        #D4A030;
  --gold-bright: #E2B848;
  --gold-pale:   #EDD580;
  --gold-glow:   rgba(212,160,48,.22);

  /* ── Status ───────────────────────────────────────────────*/
  --green:   #34BF8A;
  --red:     #D94536;
  --amber:   #E2B020;
  --blue:    #5EA8F8;

  /* ── Text ─────────────────────────────────────────────────
     Primary: brighter near-white. Secondary & muted get
     large lifts — they were too close to bg.                 */
  --text-primary:   #ECF1FA;
  --text-secondary: #A0B4CC;
  --text-mid:       #7A96B4;   /* mid-tone — inactive steps, auth footer */
  --text-muted:     #5C7090;
  --text-inverse:   #0B0E17;

  /* ── Typography ───────────────────────────────────────────*/
  --font-serif: 'Georgia', 'Times New Roman', serif;
  --font-sans:  -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:  'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* ── Sizing ───────────────────────────────────────────────*/
  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* ── Elevation ────────────────────────────────────────────
     Lighter backgrounds need proportionally lighter shadows.  */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.40);
  --shadow:     0 4px 14px rgba(0,0,0,.44), 0 1px 4px rgba(0,0,0,.30);
  --shadow-lg:  0 12px 36px rgba(0,0,0,.52), 0 4px 12px rgba(0,0,0,.30);
  --shadow-xl:  0 24px 64px rgba(0,0,0,.60), 0 8px 24px rgba(0,0,0,.38);
  /* Note: inset shimmer applied inline as box-shadow layer on panels/cards */

  /* ── Transitions ──────────────────────────────────────────*/
  --ease: cubic-bezier(.16,1,.3,1);
  --t-fast: 130ms var(--ease);
  --t-base: 230ms var(--ease);
  --t-slow: 400ms var(--ease);

  /* ── Layout ───────────────────────────────────────────────*/
  --sidebar-w:   264px;
  --header-h:    62px;
  --content-max: 1240px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ───────────────────────────────────────────── */
h1,h2,h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--text-primary);
  line-height: 1.2;
}
h4 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  line-height: 1.4;
}

h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.55rem); }
h3 { font-size: 1.1rem; }

p { color: var(--text-secondary); font-size: .9rem; line-height: 1.75; }
a { color: var(--gold-bright); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--gold-pale); }

code, pre {
  font-family: var(--font-mono);
  font-size: .82rem;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}
code { padding: 2px 7px; color: var(--gold-bright); }

/* ── Form Elements ────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; }

label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-muted);
}

input[type=text],
input[type=email],
input[type=password],
input[type=search],
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-raised);
  border: 1px solid rgba(180,195,220,.32);  /* visible container — was .18 via --border-default */
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: .9rem;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  appearance: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

textarea {
  resize: vertical;
  min-height: 100px;
}

/* Chevron stroke updated to match new --text-secondary #A0B4CC */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23A0B4CC' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none; }

/* Primary — warm gold, dark text */
.btn-primary {
  background: linear-gradient(150deg, var(--gold-bright) 0%, var(--gold) 100%);
  color: #0A0800;
  box-shadow: 0 2px 8px rgba(212,160,48,.40), 0 1px 3px rgba(0,0,0,.30);
  border: 1px solid rgba(220,180,75,.45);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(150deg, var(--gold-pale) 0%, var(--gold-bright) 100%);
  box-shadow: 0 4px 18px rgba(212,160,48,.55), 0 1px 6px rgba(0,0,0,.30);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-raised);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Danger */
.btn-danger {
  background: rgba(192,57,43,.18);
  color: #F08080;
  border: 1px solid rgba(192,57,43,.42);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(192,57,43,.33);
  border-color: rgba(192,57,43,.65);
  color: #F89090;
}

/* Icon */
.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius);
}
.btn-icon:hover:not(:disabled) {
  background: var(--bg-raised);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-sm { padding: 7px 15px; font-size: .8rem; }
.btn-lg { padding: 13px 30px; font-size: 1rem; }
.btn-full { width: 100%; }

/* Loading spinner */
.btn.loading { pointer-events: none; }
.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Utility ──────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.text-center { text-align: center; }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
}
.alert-error   { background: rgba(192,57,43,.15);  border-color: rgba(192,57,43,.40);  color: #F28080; }
.alert-success { background: rgba(42,157,111,.15); border-color: rgba(42,157,111,.40); color: #6DD4AA; }
.alert-info    { background: rgba(74,143,232,.15); border-color: rgba(74,143,232,.38); color: #92C4F8; }
.alert-warn    { background: rgba(212,160,28,.15); border-color: rgba(212,160,28,.40); color: #E2B855; }

/* ── Toast Notifications ──────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  padding: 13px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideUp .28s var(--ease) forwards;
  pointer-events: auto;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.out { animation: fadeOut .22s ease forwards; }
.toast-success { background: #143624; border: 1px solid rgba(42,157,111,.52); color: #6DD4AA; }
.toast-error   { background: #3F1714; border: 1px solid rgba(192,57,43,.60);  color: #F28080; }
.toast-info    { background: #142D48; border: 1px solid rgba(74,143,232,.52); color: #92C4F8; }

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 22px 0;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.badge-gold   { background: rgba(212,160,48,.24); color: var(--gold-pale);  border: 1px solid rgba(212,160,48,.45); }
.badge-green  { background: rgba(42,157,111,.22); color: #6DD4AA;           border: 1px solid rgba(42,157,111,.42); }
.badge-red    { background: rgba(192,57,43,.22);  color: #F28080;           border: 1px solid rgba(192,57,43,.42); }
.badge-blue   { background: rgba(74,143,232,.22); color: #92C4F8;           border: 1px solid rgba(74,143,232,.38); }
.badge-gray   { background: rgba(126,142,164,.15); color: var(--text-secondary); border: 1px solid var(--border-subtle); }

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.085);
}
.card-sm { padding: 18px; border-radius: var(--radius); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .18s ease;
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl), inset 0 1px 0 rgba(255,255,255,.085);
  animation: scaleIn .22s var(--ease);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-body   { padding: 26px; }
.modal-footer {
  padding: 18px 26px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: var(--bg-void);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut  { to { opacity: 0; transform: translateY(8px); } }
@keyframes slideUp  { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn  { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes shimmer  { from { background-position: -200% 0; } to { background-position: 200% 0; } }

/* ── Skeleton loader ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-raised) 25%, var(--bg-overlay) 50%, var(--bg-raised) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   AUTH PAGE  (index.html)
   ============================================================ */

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(ellipse 90% 55% at 50% -5%, rgba(212,160,48,.14) 0%, transparent 65%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(30,64,130,.11) 0%, transparent 60%),
    var(--bg-void);
}

.auth-container {
  width: 100%;
  max-width: 430px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 44px;
}

.auth-logo .logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px; height: 60px;
  background: linear-gradient(150deg, var(--gold-dim) 0%, var(--gold) 60%, var(--gold-bright) 100%);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow:
    0 8px 28px rgba(212,160,48,.42),
    0 2px 8px rgba(0,0,0,.38),
    inset 0 1px 0 rgba(255,255,255,.22);
}

.auth-logo .logo-mark svg {
  width: 28px; height: 28px;
  color: #0A0800;
}

.auth-logo h1 {
  font-size: 1.55rem;
  color: var(--text-primary);
  letter-spacing: -.025em;
}

.auth-logo p {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .16em;
  margin-top: 5px;
}

.auth-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 36px;
  box-shadow: var(--shadow-xl), inset 0 1px 0 rgba(255,255,255,.085);
}

.auth-panel h2 {
  font-size: 1.1rem;
  margin-bottom: 5px;
}

.auth-panel .auth-subtitle {
  font-size: .875rem;
  color: var(--text-secondary);
  margin-bottom: 26px;
  line-height: 1.6;
}

.auth-form { display: flex; flex-direction: column; gap: 20px; }

.auth-footer {
  text-align: center;
  margin-top: 22px;
  font-size: .8rem;
  color: var(--text-mid);   /* mid-tone rhythm — was text-muted */
  letter-spacing: .02em;
}

/* 2FA TOTP inputs */
.totp-input-group {
  display: flex;
  gap: 9px;
  justify-content: center;
  margin: 10px 0;
}

.totp-digit {
  width: 46px;
  height: 54px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 0;
  caret-color: var(--gold);
  letter-spacing: .05em;
}

.qr-container {
  text-align: center;
  padding: 20px;
  background: var(--bg-raised);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  margin: 14px 0;
}

.qr-container canvas { border-radius: var(--radius-sm); }

.secret-code {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--gold-bright);
  background: var(--bg-void);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  word-break: break-all;
  text-align: center;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  letter-spacing: .05em;
}
.secret-code:hover { background: var(--bg-raised); border-color: var(--gold-dim); }

.auth-steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 30px;
}

.auth-step {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .78rem;
  color: var(--text-mid);   /* was text-muted (~30%) — now mid-tone (~50%) */
  font-weight: 600;
  letter-spacing: .02em;
}

.auth-step.active { color: var(--gold-bright); }
.auth-step.done   { color: var(--green); }

.auth-step .step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: .72rem;
  font-weight: 700;
}

.auth-step-sep {
  width: 32px;
  height: 1px;
  background: var(--border-default);
  align-self: center;
}

/* Login / Register toggle */
.auth-toggle {
  display: flex;
  background: var(--bg-raised);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 26px;
  border: 1px solid var(--border-subtle);
}

.auth-toggle button {
  flex: 1;
  padding: 9px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);   /* was text-muted — reads as disabled, not unselected */
  transition: all var(--t-fast);
}

.auth-toggle button.active {
  background: var(--bg-overlay);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   DASHBOARD  (dashboard.html)
   ============================================================ */

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-void);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-logo .logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 33px; height: 33px;
  background: linear-gradient(150deg, var(--gold-dim) 0%, var(--gold) 100%);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(212,160,48,.38), inset 0 1px 0 rgba(255,255,255,.18);
}

.sidebar-logo .logo-icon svg { width: 16px; height: 16px; color: #0A0800; }

.sidebar-logo .logo-text {
  font-family: var(--font-serif);
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
  line-height: 1.15;
}

.sidebar-logo .logo-sub {
  font-size: .62rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-family: var(--font-sans);
  font-weight: 700;
}

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

.nav-section { margin-top: 24px; }
.nav-section:first-child { margin-top: 0; }

.nav-section-label {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--text-muted);
  padding: 0 10px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1px solid transparent;
  user-select: none;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
}

/* Active state: gold pill on left edge + warm tint */
.nav-item.active {
  background: var(--gold-glow);
  color: var(--gold-bright);
  border-color: rgba(212,160,48,.28);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-item .nav-badge {
  margin-left: auto;
  font-size: .66rem;
  font-weight: 700;
  background: rgba(212,160,48,.28);
  color: var(--gold-bright);
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: .02em;
}

.sidebar-footer {
  padding: 16px 14px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--t-fast);
}
.user-info:hover { background: var(--bg-raised); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--gold-dim) 0%, var(--gold) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #0A0800;
  flex-shrink: 0;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(212,160,48,.33);
}

.user-details { flex: 1; min-width: 0; }
.user-name  { font-size: .82rem; font-weight: 600; color: var(--text-primary); }
.user-email { font-size: .71rem; color: var(--text-muted); margin-top: 1px; }

.user-info > svg { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }

/* ── Header ───────────────────────────────────────────────── */
.app-header {
  grid-area: header;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 30px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: inset 0 -1px 0 var(--border-subtle);
}

.header-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--text-primary);
  flex: 1;
  letter-spacing: -.01em;
}

.header-search {
  position: relative;
  flex: 0 1 320px;
}

.header-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.header-search input {
  padding-left: 36px;
  font-size: .875rem;
  height: 37px;
  background: var(--bg-raised);
}

.header-actions { display: flex; align-items: center; gap: 8px; }

/* Hamburger (mobile) */
.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
}
.menu-toggle svg { width: 22px; height: 22px; }

/* ── Main Content ─────────────────────────────────────────── */
.app-main {
  grid-area: main;
  overflow-y: auto;
  padding: 32px;
  max-width: var(--content-max);
  width: 100%;
}

/* Views */
.view { display: none; }
.view.active { display: block; }

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title { }
.page-title h2 { margin-bottom: 5px; }
.page-title p  { font-size: .875rem; }

/* ── Stats Row ────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.075);
}
.stat-card:hover { border-color: var(--border-default); box-shadow: var(--shadow); }

.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); font-weight: 700; }
.stat-value { font-size: 2rem; font-weight: 700; font-family: var(--font-serif); color: var(--text-primary); line-height: 1; margin-top: 4px; }
.stat-trend { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* ── Data Table ───────────────────────────────────────────── */
.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.06);
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.table-toolbar h3 {
  font-family: var(--font-serif);
  font-size: .95rem;
  flex: 1;
  color: var(--text-primary);
}

.search-box {
  position: relative;
  flex: 0 1 240px;
}
.search-box svg {
  position: absolute;
  left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-box input {
  padding-left: 32px;
  height: 35px;
  font-size: .82rem;
  background: var(--bg-raised);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  padding: 11px 22px;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0,0,0,.25);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--t-fast);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-raised); }

tbody td {
  padding: 15px 22px;
  vertical-align: middle;
  color: var(--text-secondary);
}

tbody td:first-child { color: var(--text-primary); font-weight: 500; }

.table-empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}
.table-empty svg { width: 40px; height: 40px; margin-bottom: 14px; opacity: .28; }
.table-empty p   { font-size: .875rem; line-height: 1.6; }

.table-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0,0,0,.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--text-muted);
}

.pagination { display: flex; gap: 4px; }
.pagination button {
  padding: 5px 11px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: .78rem;
  cursor: pointer;
  transition: all var(--t-fast);
}
.pagination button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-bright); }
.pagination button.active { background: var(--gold-glow); border-color: var(--gold); color: var(--gold-bright); font-weight: 700; }
.pagination button:disabled { opacity: .35; cursor: not-allowed; }

/* ── Client Detail ────────────────────────────────────────── */
.detail-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.detail-avatar {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--gold-dim) 0%, var(--gold) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: #0A0800;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(212,160,48,.38);
}

.detail-meta h2 { margin-bottom: 5px; }
.detail-meta p  { font-size: .875rem; color: var(--text-secondary); }

.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 28px;
}

.tab-btn {
  padding: 12px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: -1px;
  transition: all var(--t-fast);
  letter-spacing: .01em;
}
.tab-btn:hover  { color: var(--text-primary); }
.tab-btn.active { color: var(--gold-bright); border-bottom-color: var(--gold); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Document List ────────────────────────────────────────── */
.doc-list { display: flex; flex-direction: column; gap: 8px; }

.doc-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.doc-item:hover { border-color: var(--border-default); box-shadow: var(--shadow-sm); }

.doc-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(212,160,48,.18);
  border: 1px solid rgba(212,160,48,.32);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--gold);
}
.doc-icon svg { width: 16px; height: 16px; }

.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: .875rem; font-weight: 500; color: var(--text-primary); }
.doc-meta { font-size: .75rem; color: var(--text-muted); margin-top: 3px; }

.doc-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ── Upload Zone ──────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-base);
  background: var(--bg-raised);
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--gold);
  background: var(--gold-glow);
}
.upload-zone svg { width: 32px; height: 32px; color: var(--text-muted); margin-bottom: 12px; }
.upload-zone p { font-size: .875rem; color: var(--text-secondary); }
.upload-zone span { font-size: .8rem; color: var(--text-muted); margin-top: 4px; display: block; }
.upload-zone input[type=file] { display: none; }

.upload-progress {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.progress-bar {
  height: 3px;
  background: var(--bg-overlay);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-bright));
  border-radius: 2px;
  transition: width .3s ease;
}

/* ── Audit Log ────────────────────────────────────────────── */
.audit-list { display: flex; flex-direction: column; }

.audit-item {
  display: flex;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}
.audit-item:last-child { border-bottom: none; }

.audit-timeline {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  padding-top: 5px;
}

.audit-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(212,160,48,.60);
}

.audit-line {
  width: 1px;
  flex: 1;
  background: var(--border-subtle);
  margin-top: 5px;
  min-height: 24px;
}

.audit-content { flex: 1; min-width: 0; }
.audit-action  { font-size: .875rem; font-weight: 500; color: var(--text-primary); }
.audit-detail  { font-size: .82rem; color: var(--text-secondary); margin-top: 3px; }
.audit-time    { font-size: .74rem; color: var(--text-muted); margin-top: 5px; }

/* ── Search Results ───────────────────────────────────────── */
.search-results { display: flex; flex-direction: column; gap: 10px; }

.search-result-item {
  padding: 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  transition: all var(--t-fast);
  cursor: pointer;
}
.search-result-item:hover {
  border-color: var(--gold);
  background: var(--bg-raised);
  box-shadow: var(--shadow-sm);
}
.search-result-item h4 { font-family: var(--font-sans); font-size: .875rem; font-weight: 600; color: var(--text-primary); text-transform: none; letter-spacing: 0; margin-bottom: 5px; }
.search-result-item p  { font-size: .82rem; color: var(--text-secondary); }
.search-result-item .result-meta { display: flex; gap: 10px; margin-top: 10px; }

/* ── Vault Keys ───────────────────────────────────────────── */
.vault-key-panel {
  background: var(--bg-void);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.key-field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: 11px 14px;
}
.key-value {
  flex: 1;
  font-family: var(--font-mono);
  font-size: .77rem;
  color: var(--gold-bright);
  word-break: break-all;
  letter-spacing: .03em;
}

/* ── Info Grid ────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.info-field { }
.info-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--text-muted); margin-bottom: 5px; }
.info-value { font-size: .9rem; color: var(--text-primary); line-height: 1.5; }

/* ── Notification dot ─────────────────────────────────────── */
.notif-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--gold);
  position: absolute;
  top: 8px; right: 8px;
  animation: pulse 2.5s ease infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(212,160,48,.65); }
  50%      { box-shadow: 0 0 0 5px rgba(212,160,48,.0); }
}

/* ── Mobile overlay sidebar ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 199;
  backdrop-filter: blur(3px);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas:
      "header"
      "main";
  }

  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--t-base);
    height: 100vh;
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }

  .menu-toggle { display: flex; align-items: center; }

  .app-main { padding: 22px 18px; }

  .header-search { flex: 0 1 200px; }

  .info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  :root { --header-h: 56px; }

  .app-main { padding: 16px 14px; }

  .stats-row { grid-template-columns: 1fr 1fr; }

  .header-search { display: none; }

  .page-header { flex-direction: column; align-items: flex-start; }

  .table-toolbar { flex-direction: column; align-items: flex-start; }
  .search-box { flex: none; width: 100%; }

  .modal { margin: 0; max-height: 100vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; align-self: flex-end; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-footer { border-radius: 0; }

  .auth-panel { padding: 26px 20px; }

  .totp-digit { width: 38px; height: 48px; font-size: 1.15rem; }

  thead { display: none; }
  tbody td { display: flex; align-items: center; }
  tbody td::before {
    content: attr(data-label);
    font-size: .67rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--text-muted);
    font-weight: 700;
    min-width: 90px;
    flex-shrink: 0;
  }
  tbody tr { display: flex; flex-direction: column; padding: 8px 0; }
}
