/* ============ Design tokens ============ */
:root {
  --bg: #F3F5FB;
  --surface: #FFFFFF;
  --surface-alt: #F8F9FE;
  --border: #E6E8F2;
  --text: #14172B;
  --text-mute: #676C82;
  --text-faint: #9498AC;

  --primary: #4338CA;
  --primary-600: #372FB0;
  --primary-light: #6D5CE7;
  --primary-bg: #EEECFD;

  --success: #0F9D68;
  --success-bg: #E4F8EE;
  --warning: #C2760A;
  --warning-bg: #FCF1DE;
  --danger: #D6423A;
  --danger-bg: #FBE7E6;
  --neutral-bg: #EEF0F6;

  --sidebar-bg: #14132B;
  --sidebar-bg-2: #1D1B3F;
  --sidebar-text: #C6C4E6;
  --sidebar-text-dim: #8886B3;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(20, 23, 43, 0.06);
  --shadow-md: 0 8px 24px -8px rgba(20, 23, 43, 0.16);
  --shadow-lg: 0 24px 48px -16px rgba(20, 23, 43, 0.28);

  --gradient-hero: linear-gradient(120deg, #4338CA 0%, #5B3FD6 45%, #7C3AED 100%);

  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0E0F1C;
  --surface: #171932;
  --surface-alt: #1E2040;
  --border: #2C2E52;
  --text: #F1F1FA;
  --text-mute: #A6A8C6;
  --text-faint: #74769C;

  --primary-bg: #26235E;
  --success-bg: #12332A;
  --warning-bg: #3A2C10;
  --danger-bg: #3A1B1F;
  --neutral-bg: #23253F;

  --sidebar-bg: #0A0A1A;
  --sidebar-bg-2: #14132B;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

h1, h2, h3 {
  font-family: "Lexend", "Inter", sans-serif;
  margin: 0;
  letter-spacing: -0.01em;
}

p { margin: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button { font-family: inherit; cursor: pointer; }

/* ============ Layout ============ */
.app {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 26, 0.5);
  z-index: 30;
}
.overlay.show { display: block; }

/* ============ Sidebar ============ */
.sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 100%);
  color: var(--sidebar-text);
  padding: 1.5rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.35rem;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--gradient-hero);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 16px -4px rgba(93, 63, 214, 0.6);
}
.brand-name {
  color: #fff;
  font-family: "Lexend", sans-serif;
  font-weight: 500;
  font-size: 1.05rem;
}
.brand-name strong { font-weight: 700; }
.sidebar-close { display: none; margin-left: auto; color: #fff; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text-dim);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { width: 18px; height: 18px; opacity: 0.9; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(109,92,231,0.35), rgba(109,92,231,0.08));
  color: #fff;
  box-shadow: inset 2px 0 0 var(--primary-light);
}
.nav-badge {
  margin-left: auto;
  background: var(--primary-light);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.sidebar-footer { margin-top: auto; }
.help-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 1rem;
}
.help-title { color: #fff; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
.help-text { color: var(--sidebar-text-dim); font-size: 0.8rem; margin-bottom: 0.8rem; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--gradient-hero);
  color: #fff;
  box-shadow: 0 10px 20px -8px rgba(67, 56, 202, 0.55);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 26px -8px rgba(67, 56, 202, 0.65); }

.btn-ghost {
  background: transparent;
  color: var(--text-mute);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-alt); }

.btn-ghost-light {
  background: rgba(255,255,255,0.14);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  backdrop-filter: blur(4px);
}
.btn-ghost-light:hover { background: rgba(255,255,255,0.22); }

.btn-quiet {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-quiet:hover:not(:disabled) { background: var(--neutral-bg); }

.btn-light { background: #fff; color: var(--primary-600); }
.btn-light:hover { background: #f0efff; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.82rem; }

.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none;
  background: transparent;
  border-radius: 10px;
  color: var(--text-mute);
  position: relative;
  transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--surface-alt); }
.icon-btn svg { width: 19px; height: 19px; }
.dot-badge {
  position: absolute;
  top: 8px; right: 9px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid var(--surface);
}

.lang-btn {
  font-family: "Lexend", sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  width: auto;
  height: 40px;
  padding: 0 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* Theme toggle icons */
.icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: block; }

/* ============ Topbar ============ */
.topbar {
  height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.hamburger { display: none; }

.search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  color: var(--text-faint);
}
.search svg { width: 17px; height: 17px; flex-shrink: 0; }
.search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.88rem;
  color: var(--text);
  width: 100%;
  font-family: inherit;
}
.search input::placeholder { color: var(--text-faint); }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--gradient-hero);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  margin-left: 0.3rem;
}

/* ============ Content ============ */
.content {
  padding: 1.75rem;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

/* ---- Hero ---- */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--gradient-hero);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.hero-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(10px);
  opacity: 0.35;
  pointer-events: none;
}
.blob-a { width: 260px; height: 260px; background: #A78BFA; top: -120px; right: 60px; }
.blob-b { width: 200px; height: 200px; background: #22D3EE; bottom: -110px; right: -40px; opacity: 0.25; }

.hero-text { position: relative; z-index: 1; max-width: 560px; }
.hero-eyebrow {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.75);
  margin-bottom: 0.6rem;
}
.hero-text h1 {
  font-size: 1.7rem;
  font-weight: 600;
  margin-bottom: 0.65rem;
}
.hero-sub {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.88);
  max-width: 46ch;
  margin-bottom: 1.4rem;
}
.hero-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; }

.hero-progress {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 140px; height: 140px;
  display: flex; align-items: center; justify-content: center;
}
.ring { width: 140px; height: 140px; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(255,255,255,0.22); stroke-width: 10; }
.ring-fill {
  fill: none;
  stroke: #fff;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 377;
  stroke-dashoffset: 377;
  transition: stroke-dashoffset 1.2s cubic-bezier(.4,0,.2,1);
}
.ring-label {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.ring-pct { font-size: 1.6rem; font-weight: 700; font-family: "Lexend", sans-serif; }
.ring-caption { font-size: 0.75rem; color: rgba(255,255,255,0.8); }

/* ---- Stats ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  animation: rise 0.5s ease forwards;
  animation-delay: calc(var(--d) * 80ms + 60ms);
}
.stat-icon {
  width: 42px; height: 42px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.icon-indigo { background: var(--primary-bg); color: var(--primary); }
.icon-green { background: var(--success-bg); color: var(--success); }
.icon-amber { background: var(--warning-bg); color: var(--warning); }
.icon-rose { background: var(--danger-bg); color: var(--danger); }

.stat-value { font-size: 1.5rem; font-weight: 700; font-family: "Lexend", sans-serif; line-height: 1.1; }
.stat-label { font-size: 0.82rem; color: var(--text-mute); margin-top: 0.15rem; }

/* ---- Content grid: documents + activity ---- */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.panel-header h2 { font-size: 1.15rem; font-weight: 600; }
.panel-sub { font-size: 0.85rem; color: var(--text-mute); margin-top: 0.2rem; }

.tabs {
  display: flex;
  gap: 0.3rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.25rem;
  flex-wrap: wrap;
}
.tab {
  border: none;
  background: transparent;
  color: var(--text-mute);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab span { font-size: 0.7rem; opacity: 0.75; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ---- Document rows ---- */
.doc-list { display: flex; flex-direction: column; gap: 0.7rem; }
.doc-row {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.doc-row:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: transparent; }
.doc-row.urgent { border-color: rgba(214, 66, 58, 0.35); }

.doc-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.doc-icon svg { width: 19px; height: 19px; }
.status-approved { background: var(--success-bg); color: var(--success); }
.status-pending { background: var(--warning-bg); color: var(--warning); }
.status-rejected { background: var(--danger-bg); color: var(--danger); }
.status-missing { background: var(--neutral-bg); color: var(--text-faint); }

.doc-info { flex: 1; min-width: 0; }
.doc-info h3 {
  font-size: 0.96rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.doc-info p { font-size: 0.84rem; color: var(--text-mute); margin-top: 0.25rem; max-width: 48ch; }
.doc-note { color: var(--danger); }
.doc-urgent-note { color: var(--danger); font-weight: 600; }
.req-chip {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-faint);
  background: var(--neutral-bg);
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.badge {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-approved { background: var(--success-bg); color: var(--success); }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-missing { background: var(--neutral-bg); color: var(--text-faint); }

/* ---- Activity panel ---- */
.activity-panel h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 1.1rem; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.1rem; }
.timeline li { display: flex; gap: 0.75rem; }
.timeline p { font-size: 0.84rem; }
.tl-time { color: var(--text-faint); font-size: 0.76rem; margin-top: 0.15rem; }
.tl-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-top: 0.35rem;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--surface-alt);
}
.tl-green { background: var(--success); }
.tl-amber { background: var(--warning); }
.tl-rose { background: var(--danger); }
.tl-indigo { background: var(--primary); }

.mini-card {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.mini-card-title { font-size: 0.78rem; color: var(--text-mute); }
.mini-card-value { font-size: 1.15rem; font-weight: 700; font-family: "Lexend", sans-serif; margin-top: 0.2rem; }
.mini-bar { height: 6px; background: var(--neutral-bg); border-radius: 999px; margin-top: 0.6rem; overflow: hidden; }
.mini-bar-fill { height: 100%; background: var(--gradient-hero); border-radius: 999px; }

/* ---- Footer ---- */
.page-footer {
  margin-top: 2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-faint);
}
.page-footer-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------- Amethyst Nexalune credit badge ---------- */
.page-footer-credit {
  margin-top: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.an-credit-label { font-size: 0.76rem; color: var(--text-faint); }
.an-credit {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.an-credit:hover { transform: translateY(-1px); filter: brightness(1.14); }
.an-credit-logo {
  width: 30px; height: 30px; flex: 0 0 30px;
  object-fit: contain;
  filter: drop-shadow(0 0 9px rgba(140, 84, 214, 0.5));
}
.an-credit-text { display: flex; flex-direction: column; align-items: center; line-height: 1.25; }
.an-credit-name {
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  font-size: 0.76rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; white-space: nowrap;
  color: #5b9fe8;
  padding-bottom: 3px;
  border-bottom: 2px solid #d8b765;
}
.an-credit-tagline {
  align-self: center; width: fit-content; margin-top: 4px;
  font-size: 0.56rem; font-weight: 500; letter-spacing: 0.14em;
  text-transform: uppercase; text-align: center;
  color: #c7c2d6;
  text-decoration-line: underline;
  text-decoration-color: #146fd1;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* ============ Modal ============ */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 26, 0.55);
  justify-content: center;
  z-index: 50;
  padding: 1rem;
  backdrop-filter: blur(2px);
  /* a modal taller than the screen must scroll, not get clipped off the top */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.22s cubic-bezier(.2,.9,.3,1.2);
  /* auto margins centre it when it fits and collapse to top-aligned when it doesn't */
  margin: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.modal-head h3 { font-size: 1.1rem; font-weight: 600; }
.modal-sub { font-size: 0.85rem; color: var(--text-mute); margin-bottom: 1.2rem; }

.intro-modal { position: relative; max-width: 420px; text-align: center; }
.intro-lang-btn { position: absolute; top: 1rem; left: 1rem; }
.intro-close-btn {
  position: absolute; top: 1rem; right: 1rem;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1.7rem; line-height: 1;
  color: var(--text);
}
.intro-tag {
  display: inline-block;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em;
  color: var(--primary);
  background: var(--primary-bg);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.8rem;
}
.intro-brand {
  font-family: "Lexend", sans-serif;
  font-size: 1.4rem; font-weight: 600;
  letter-spacing: -0.01em; line-height: 1.15;
  color: var(--primary);
  margin-bottom: 0.35rem;
}
.intro-brand strong { font-weight: 700; }
.intro-tagline { font-size: 0.92rem; font-weight: 600; color: var(--text-mute); margin-bottom: 1rem; }
.intro-body { font-size: 0.88rem; color: var(--text-mute); line-height: 1.55; margin-bottom: 1.4rem; }
.intro-contact { margin-top: 1rem; font-size: 0.82rem; color: var(--text-mute); }
.intro-contact a { color: inherit; text-decoration: none; }
.intro-contact a strong { color: var(--primary); font-weight: 600; }
.intro-contact a:hover strong { text-decoration: underline; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  padding: 2.2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--primary); background: var(--primary-bg); }
.dropzone input { display: none; }
.dz-icon { width: 30px; height: 30px; color: var(--primary); margin-bottom: 0.3rem; }
.dz-primary { font-weight: 600; font-size: 0.92rem; }
.dz-secondary { font-size: 0.8rem; color: var(--text-faint); }

.upload-progress { display: none; margin-top: 1rem; }
.upload-progress.show { display: block; }
.upload-file-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; margin-bottom: 0.5rem; }
.upload-file-row svg { width: 17px; height: 17px; color: var(--primary); }
.upload-file-row span:first-of-type { flex: 1; }
#uploadPct { color: var(--text-mute); font-size: 0.78rem; }
.progress-track { height: 7px; background: var(--neutral-bg); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--gradient-hero); border-radius: 999px; transition: width 0.18s ease; }

.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.4rem; }

/* ============ Toasts ============ */
.toast-stack {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 60;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  min-width: 240px;
  animation: slideIn 0.25s ease;
  color: var(--text);
}
.toast strong { display: block; margin-bottom: 0.1rem; }

/* ============ Animations ============ */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.94) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============ Responsive ============ */
.main, .content, .content-grid > *, .panel { min-width: 0; }

@media (max-width: 1080px) {
  .content-grid { grid-template-columns: minmax(0, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: 280px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-flex; }
  .hamburger { display: inline-flex; }
  .search { max-width: none; min-width: 0; }
  .search input { min-width: 0; }
}

@media (max-width: 720px) {
  .hero { flex-direction: column; align-items: flex-start; padding: 1.75rem 1.4rem; }
  .hero-progress { align-self: center; }
  .content { padding: 1.1rem; }
  .topbar { padding: 0 1rem; gap: 0.6rem; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
  .doc-row { flex-wrap: wrap; }
  .doc-meta { flex-direction: row; align-items: center; width: 100%; justify-content: space-between; margin-top: 0.4rem; }
  .panel { padding: 1.1rem; }
  .page-footer-row { flex-direction: column; }
}

@media (max-width: 480px) {
  .hero-text h1 { font-size: 1.35rem; }
  .search input::placeholder { font-size: 0.8rem; }
  .brand-name { font-size: 0.95rem; }
}

/* Small phones (≤ 440px): the decorative search box is dropped so the
   topbar can never force the page wider than the screen, and the stat
   tiles stack icon-over-text so long labels ("dokumentum") fit. */
@media (max-width: 440px) {
  .search { display: none; }
  .topbar-actions { gap: 0.25rem; }
  .lang-btn { height: 38px; padding: 0 0.7rem; }
  .content { padding: 0.9rem; }
  .hero { padding: 1.5rem 1.15rem; }
  .hero-actions .btn { width: 100%; justify-content: center; }
  .stats-grid { gap: 0.6rem; }
  .stat-card { flex-direction: column; align-items: flex-start; gap: 0.6rem; padding: 0.95rem; }
  .doc-info p { max-width: none; }
  .panel { padding: 1rem; }
}
