/* ============================================================
   EB-2 NIW Case Manager — Stylesheet
   frontend/css/styles.css
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600&family=DM+Sans:wght@300;400;500&family=DM+Mono&display=swap');

:root {
  --navy:       #0f1729;
  --navy-light: #1a2744;
  --gold:       #c9a84c;
  --gold-light: #e8c97a;
  --gold-pale:  #fdf4e0;
  --cream:      #fdf9f4;
  --text-primary:   #1a1a2e;
  --text-secondary: #4a5568;
  --text-muted:     #718096;
  --border:         #e6ddd0;
  --white:          #ffffff;
  --bg-secondary:   #ffffff;
  --bg-tertiary:    #f7f3ee;
  --bg-card:        #ffffff;
  --sidebar-width:  244px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(201,168,76,0.18);
}
.sidebar-logo h1 {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  color: var(--gold);
  letter-spacing: 0.3px;
  line-height: 1.4;
}
.sidebar-logo p {
  font-size: 9px;
  color: rgba(255,255,255,0.35);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1.8px;
}

.nav-section {
  padding: 16px 16px 6px;
  font-size: 9px;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  margin: 1px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  transition: all 0.15s;
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
  font-family: 'DM Sans', sans-serif;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.85); }
.nav-item.active { background: rgba(201,168,76,0.14); color: var(--gold-light); }
.nav-icon { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.65; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.case-badge {
  background: rgba(201,168,76,0.09);
  border: 1px solid rgba(201,168,76,0.18);
  border-radius: 8px;
  padding: 10px 12px;
}
.cb-label { font-size: 9px; color: rgba(255,255,255,0.28); text-transform: uppercase; letter-spacing: 1.5px; }
.cb-value { font-size: 12px; color: var(--gold-light); margin-top: 3px; font-family: 'DM Mono', monospace; }

/* ── Main area ───────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.topbar-title { font-family: 'Playfair Display', serif; font-size: 19px; color: var(--text-primary); }
.topbar-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.stage-pill {
  background: var(--gold-pale);
  border: 1px solid rgba(201,168,76,0.35);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 11px;
  color: #8a6200;
  font-weight: 500;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  background: var(--navy);
  color: var(--gold-light);
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--navy-light); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { background: var(--cream); border-color: var(--gold); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── Panels ──────────────────────────────────────────────── */
.panel {
  flex: 1;
  overflow-y: auto;
  padding: 26px;
  display: none;
}
.panel.active { display: block; }
.chat-panel { display: none; padding: 0; }
.chat-panel.active { display: flex; flex-direction: column; }

/* ── Chat ────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message { display: flex; gap: 10px; }
.message.user { flex-direction: row-reverse; align-self: flex-end; max-width: 75%; }
.message.ai   { max-width: 85%; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
}
.avatar.ai   { background: var(--navy); color: var(--gold); font-family: 'Playfair Display', serif; }
.avatar.user { background: var(--gold-pale); color: #8a6200; }

.bubble {
  padding: 11px 15px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.65;
}
.bubble.ai   { background: var(--white); border: 1px solid var(--border); color: var(--text-primary); border-radius: 3px 12px 12px 12px; }
.bubble.user { background: var(--navy); color: rgba(255,255,255,0.92); border-radius: 12px 3px 12px 12px; }
.bubble p         { margin-bottom: 7px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h3        { font-family: 'Playfair Display', serif; font-size: 14px; margin: 10px 0 5px; color: var(--navy); }
.bubble.user h3   { color: var(--gold-light); }
.bubble strong    { font-weight: 500; }
.bubble ul, .bubble ol { margin: 6px 0 6px 18px; }
.bubble li        { margin-bottom: 3px; }
.disclaimer { font-size: 11px; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 8px; margin-top: 10px; font-style: italic; line-height: 1.5; }
.bubble.user .disclaimer { color: rgba(255,255,255,0.45); border-top-color: rgba(255,255,255,0.15); }

.chat-input-area {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 14px 26px;
  flex-shrink: 0;
}
.quick-actions { display: flex; gap: 7px; margin-bottom: 11px; flex-wrap: wrap; }
.qa-btn {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 5px 13px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
}
.qa-btn:hover { background: var(--gold-pale); border-color: rgba(201,168,76,0.4); color: #8a6200; }

.input-row { display: flex; gap: 9px; align-items: flex-end; }
.chat-textarea {
  flex: 1;
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--cream);
  resize: none;
  min-height: 42px;
  max-height: 120px;
  outline: none;
  line-height: 1.5;
}
.chat-textarea:focus { border-color: var(--gold); background: var(--white); }

.send-btn {
  width: 42px; height: 42px;
  background: var(--navy);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.send-btn:hover { background: var(--navy-light); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cards & Sections ───────────────────────────────────── */
.section-header { margin-bottom: 22px; }
.section-header h2 { font-family: 'Playfair Display', serif; font-size: 21px; color: var(--navy); margin-bottom: 5px; }
.section-header p  { font-size: 13px; color: var(--text-muted); }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
}

/* ── Document Vault ─────────────────────────────────────── */
.vault-wrap { overflow-x: auto; }
.vault-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 700px; }
.vault-table th {
  background: var(--navy);
  color: rgba(255,255,255,0.65);
  padding: 9px 13px;
  text-align: left;
  font-weight: 400;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.vault-table th:first-child { border-radius: 7px 0 0 7px; }
.vault-table th:last-child  { border-radius: 0 7px 7px 0; }
.vault-table td { padding: 9px 13px; border-bottom: 1px solid var(--border); color: var(--text-secondary); vertical-align: middle; }
.vault-table tr:hover td { background: rgba(201,168,76,0.04); }

.doc-id  { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--navy); font-weight: 500; white-space: nowrap; }
.cat-tag { display: inline-block; padding: 2px 7px; border-radius: 9px; font-size: 10px; font-weight: 500; font-family: 'DM Mono', monospace; background: var(--navy); color: var(--gold-light); }

.status-badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; }
.s-strong    { background: #d4edda; color: #155724; }
.s-draft     { background: #fff3cd; color: #6d4f00; }
.s-missing   { background: #f8d7da; color: #721c24; }
.s-sent      { background: #d1ecf1; color: #0c5460; }
.s-confirmed { background: #d4edda; color: #155724; }
.s-needs     { background: #fff3cd; color: #6d4f00; }

/* ── Prong bars ─────────────────────────────────────────── */
.prong-track { height: 7px; background: var(--border); border-radius: 4px; overflow: hidden; }
.prong-fill  { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--navy) 0%, var(--gold) 100%); transition: width 1s ease; }

/* ── Case Stages ─────────────────────────────────────────── */
.stage-list { display: flex; flex-direction: column; }
.stage-item { display: flex; gap: 14px; padding: 14px 0; position: relative; }
.stage-item:not(:last-child)::after { content:''; position:absolute; left:14px; top:42px; bottom:0; width:2px; background:var(--border); }
.stage-item.done::after { background: var(--navy); }
.stage-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-muted);
  flex-shrink: 0; z-index: 1;
}
.stage-item.done    .stage-dot { background: var(--navy); border-color: var(--navy); color: var(--gold); }
.stage-item.current .stage-dot { background: var(--gold-pale); border-color: var(--gold); color: #8a6200; font-weight: 600; }
.stage-title { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.stage-desc  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── CV Textarea ─────────────────────────────────────────── */
.cv-textarea {
  width: 100%;
  min-height: 200px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--cream);
  resize: vertical;
  outline: none;
  line-height: 1.65;
}
.cv-textarea:focus { border-color: var(--gold); background: var(--white); }

/* ── Letter & Email cards ────────────────────────────────── */
.letter-type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.letter-card {
  background: var(--white); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; cursor: pointer; transition: border-color 0.2s;
}
.letter-card:hover { border-color: var(--gold); }
.lc-type  { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 7px; }
.lc-title { font-family: 'Playfair Display', serif; font-size: 15px; color: var(--navy); margin-bottom: 5px; }
.lc-desc  { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.lc-link  { margin-top: 10px; font-size: 12px; color: var(--gold); }

.email-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 13px; margin-bottom: 22px; }
.email-card {
  background: var(--white); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; cursor: pointer; transition: border-color 0.2s;
}
.email-card:hover { border-color: var(--gold); }
.ec-title { font-size: 13px; font-weight: 500; color: var(--navy); margin: 8px 0 4px; }
.ec-desc  { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state svg { margin-bottom: 14px; opacity: 0.28; }
.empty-state h3  { font-family: 'Playfair Display', serif; font-size: 18px; color: var(--navy); margin-bottom: 7px; }
.empty-state p   { font-size: 13px; }

/* ── Typing indicator ────────────────────────────────────── */
.typing-indicator { display: flex; gap: 4px; padding: 11px 15px; background: var(--white); border: 1px solid var(--border); border-radius: 3px 12px 12px 12px; width: fit-content; }
.typing-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); animation: blink 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,60%,100%{opacity:0.3;transform:scale(0.9)} 30%{opacity:1;transform:scale(1.1)} }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* ── Profile Modal ───────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,41,0.65); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-box { background: var(--white); border-radius: 14px; padding: 26px; width: 420px; max-width: 92vw; }
.modal-title { font-family: 'Playfair Display', serif; font-size: 19px; color: var(--navy); margin-bottom: 18px; }
.field-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; display: block; margin-bottom: 5px; }
.field-input {
  width: 100%; padding: 9px 13px; border: 1px solid var(--border); border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: 14px; outline: none;
  background: var(--cream); color: var(--text-primary);
}
.field-input:focus { border-color: var(--gold); background: var(--white); }
.field-group { margin-bottom: 13px; }

/* ── Status bar ──────────────────────────────────────────── */
#status-bar {
  position: fixed; bottom: 0; left: var(--sidebar-width); right: 0;
  background: var(--navy-light); color: rgba(255,255,255,0.7);
  font-size: 11px; padding: 6px 22px; z-index: 100; display: none;
  font-family: 'DM Mono', monospace;
}

/* ── Memory tags ─────────────────────────────────────────── */
.mem-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 9px;
  font-family: 'DM Mono', monospace;
  background: var(--cream);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ── Folder tree ─────────────────────────────────────────── */
.folder-item {
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.folder-item:hover { background: var(--gold-pale); }
.folder-item.active { background: var(--gold-pale); color: var(--navy); font-weight: 500; }

/* ── File cards ──────────────────────────────────────────── */
.file-card { transition: box-shadow 0.15s; }
.file-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state h3 { font-family: 'Playfair Display', serif; color: var(--navy); margin-bottom: 8px; font-size: 16px; }
.empty-state p { font-size: 13px; max-width: 400px; margin: 0 auto; line-height: 1.6; }

/* ── Progress bar ────────────────────────────────────────── */
.progress-bar { height: 6px; background: #eee; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }

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

/* ── Command Palette (Ctrl+K) ───────────────────────────── */
.cmd-palette-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,41,0.55); z-index: 9999;
  align-items: flex-start; justify-content: center;
  padding-top: 18vh;
  backdrop-filter: blur(2px);
}
.cmd-palette-overlay.open { display: flex; }
.cmd-palette {
  background: var(--white); border-radius: 14px;
  width: 520px; max-width: 92vw;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  overflow: hidden;
}
.cmd-palette-input {
  width: 100%; padding: 16px 20px;
  border: none; border-bottom: 1px solid var(--border);
  font-family: 'DM Sans', sans-serif; font-size: 16px;
  color: var(--text-primary); background: transparent;
  outline: none;
}
.cmd-palette-input::placeholder { color: var(--text-muted); }
.cmd-palette-list {
  max-height: 360px; overflow-y: auto;
  padding: 6px;
}
.cmd-palette-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 8px;
  cursor: pointer; transition: background 0.1s;
  font-size: 14px; color: var(--text-primary);
}
.cmd-palette-item:hover, .cmd-palette-item.active {
  background: var(--gold-pale);
}
.cmd-palette-item .cmd-icon {
  width: 20px; text-align: center; font-size: 14px; flex-shrink: 0;
}
.cmd-palette-item .cmd-title { flex: 1; }
.cmd-palette-item .cmd-shortcut {
  font-size: 10px; color: var(--text-muted);
  font-family: 'DM Mono', monospace;
  background: var(--cream); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 4px;
}
.cmd-palette-hint {
  padding: 8px 14px; font-size: 11px; color: var(--text-muted);
  border-top: 1px solid var(--border);
  display: flex; gap: 16px; justify-content: center;
}
.cmd-palette-hint kbd {
  font-family: 'DM Mono', monospace; font-size: 10px;
  background: var(--cream); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 3px;
}

/* ── Badge Pulse Animation ──────────────────────────────── */
@keyframes badgePulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.badge-pulse { animation: badgePulse 0.4s ease-out; }

/* ── Undo Toast ─────────────────────────────────────────── */
.undo-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: rgba(255,255,255,0.9);
  padding: 10px 20px; border-radius: 10px; z-index: 9999;
  font-size: 13px; font-family: 'DM Sans', sans-serif;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  animation: toastIn 0.3s ease-out;
}
.undo-toast button {
  background: var(--gold); color: var(--navy);
  border: none; border-radius: 6px; padding: 4px 12px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}
.undo-toast button:hover { background: var(--gold-light); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Auto-Save Indicator ────────────────────────────────── */
.autosave-indicator {
  position: fixed; bottom: 12px; right: 16px;
  font-size: 11px; color: var(--text-muted);
  font-family: 'DM Mono', monospace;
  background: var(--white); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 6px; z-index: 100;
  opacity: 0; transition: opacity 0.3s;
  pointer-events: none;
}
.autosave-indicator.visible { opacity: 1; }
.autosave-indicator.saving { color: var(--gold); }
.autosave-indicator.saved  { color: #28a745; }

/* ══════════════════════════════════════════════════════════════
   PRIORITY 3 — UI/UX POLISH
   ══════════════════════════════════════════════════════════════ */

/* ── U1: Standardize card padding to 16px ─────────────────── */
.card { padding: 16px; }

/* ── U2: Consistent border-radius — cards 12px, inputs 6px ── */
.card { border-radius: 12px; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="url"],
textarea,
select {
  border-radius: 6px;
}

/* ── U3: Reusable utility classes ────────────────────────────  */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; align-items: center; }
.flex-gap-6   { gap: 6px; }
.flex-gap-8   { gap: 8px; }
.flex-gap-12  { gap: 12px; }
.flex-wrap    { flex-wrap: wrap; }
.text-muted   { color: var(--text-muted); }
.text-navy    { color: var(--navy); }
.text-11      { font-size: 11px; }
.text-12      { font-size: 12px; }
.text-13      { font-size: 13px; }
.fw-600       { font-weight: 600; }
.mb-4         { margin-bottom: 4px; }
.mb-8         { margin-bottom: 8px; }
.mb-12        { margin-bottom: 12px; }
.mb-16        { margin-bottom: 16px; }
.mt-8         { margin-top: 8px; }
.mt-12        { margin-top: 12px; }
.mt-16        { margin-top: 16px; }
.p-12         { padding: 12px; }

/* ── U4: Skeleton screens ────────────────────────────────────  */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f0ece6 25%, #e8e2da 50%, #f0ece6 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
  display: block;
}
.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 12px; }
.skeleton-btn   { height: 36px; width: 120px; border-radius: 8px; }
.skeleton-card  { height: 100px; border-radius: 12px; margin-bottom: 12px; }
.skeleton-sm    { height: 10px; width: 40%; }

/* ── U5: Button hover with lift animation ───────────────────  */
.btn-primary, .btn-secondary {
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15,23,41,0.18);
}
.btn-secondary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}
.btn-primary:active:not(:disabled),
.btn-secondary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

/* ── U6: Panel fade transition ──────────────────────────────  */
@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.panel.active {
  animation: panelFadeIn 0.2s ease-out;
}

/* ── U7: CSS-only tooltips ──────────────────────────────────  */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: rgba(255,255,255,0.92);
  font-size: 11px;
  font-family: 'DM Sans', sans-serif;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9000;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── U8: Sortable table — sticky headers + sort indicators ───  */
.vault-table thead { position: sticky; top: 0; z-index: 2; }
.vault-table th.sortable { cursor: pointer; user-select: none; }
.vault-table th.sortable:hover { background: var(--navy-light); }
.sort-asc::after  { content: ' ▲'; font-size: 9px; opacity: 0.7; }
.sort-desc::after { content: ' ▼'; font-size: 9px; opacity: 0.7; }

/* ── U9: Modal entrance animation ───────────────────────────  */
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-overlay .modal,
.modal-overlay .modal-box {
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
/* Generic .modal class for dynamically created modals */
.modal {
  background: var(--white);
  border-radius: 14px;
  padding: 24px;
  width: 560px;
  max-width: 94vw;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

/* ── U10: Consistent empty states ───────────────────────────  */
.empty-state-icon { font-size: 48px; margin-bottom: 14px; opacity: 0.5; display: block; text-align: center; }
.empty-state-title { font-family: 'Playfair Display', serif; font-size: 17px; color: var(--navy); margin-bottom: 8px; text-align: center; }
.empty-state-sub { font-size: 12px; color: var(--text-muted); text-align: center; max-width: 320px; margin: 0 auto 16px; line-height: 1.6; }

/* ── U11: Collapsible sidebar on tablet (<1024px) ────────────  */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 12px;
  z-index: 300;
  background: var(--navy);
  color: var(--gold);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
@media (max-width: 1024px) {
  .sidebar-toggle { display: flex; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    height: 100vh;
    z-index: 250;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 240;
  }
  .sidebar-backdrop.open { display: block; }
  .main { margin-left: 0 !important; }
  body { overflow: auto; }
}

/* ── U12: Stack form grids on mobile (<768px) ────────────────  */
@media (max-width: 768px) {
  .letter-type-grid { grid-template-columns: 1fr; }
  .email-grid { grid-template-columns: 1fr 1fr; }
  .section-header { flex-direction: column !important; align-items: flex-start !important; gap: 10px; }
  .topbar { padding: 10px 16px; }
  .panel { padding: 16px; }
  /* Stack any inline flex rows of buttons */
  .section-header > div:last-child { flex-wrap: wrap; }
  /* Dashboard 2-col grids → 1 col */
  #dashboard-stats > div,
  #dashboard-heatmap > div { flex-direction: column !important; }
}

/* ── U13: Minimum 44px touch targets ─────────────────────────  */
@media (max-width: 1024px) {
  .btn-primary, .btn-secondary {
    min-height: 44px;
    min-width: 44px;
  }
  .btn-sm {
    min-height: 36px;
    padding: 8px 14px;
  }
  .nav-item {
    min-height: 44px;
  }
  .send-btn {
    width: 44px;
    height: 44px;
  }
}
