/* AI Mail Assistant — Modern UI v2 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* === Design tokens === */
:root {
  /* Brand */
  --brand-50:  #eff4ff;
  --brand-100: #dbe6fe;
  --brand-200: #bfd2fe;
  --brand-300: #93b4fd;
  --brand-400: #608cfa;
  --brand-500: #3a6bf5;
  --brand-600: #2451e8;
  --brand-700: #1d40d6;
  --brand-800: #1e36ad;
  --brand-900: #1e3389;

  /* Neutrali — light theme defaults */
  --bg:          #f7f8fb;
  --bg-elev:    #ffffff;
  --bg-soft:    #f0f2f7;
  --bg-hover:   #f0f2f7;
  --border:     #e3e6ee;
  --border-strong: #d0d5e0;
  --text:       #0f172a;
  --text-muted: #5b6478;
  --text-subtle: #8a93a6;

  /* Accent palete */
  --ok-bg:    #dcfce7; --ok-fg:    #166534; --ok-border:    #86efac;
  --warn-bg:  #fef3c7; --warn-fg:  #92400e; --warn-border:  #fcd34d;
  --error-bg: #fee2e2; --error-fg: #991b1b; --error-border: #fca5a5;
  --info-bg:  #dbeafe; --info-fg:  #1e40af; --info-border: #93c5fd;
  --neutral-bg: #f1f5f9; --neutral-fg: #475569; --neutral-border: #cbd5e1;

  /* Prio */
  --prio-high-bg: #fee2e2;   --prio-high-fg: #991b1b;
  --prio-medium-bg: #fef3c7; --prio-medium-fg: #92400e;
  --prio-low-bg: #dcfce7;    --prio-low-fg: #166534;

  /* Spacing & sizing */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow:    0 2px 4px rgba(15, 23, 42, .04), 0 4px 8px rgba(15, 23, 42, .04);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, .08), 0 4px 8px rgba(15, 23, 42, .04);

  /* Layout */
  --topbar-height: 56px;
  --sidebar-width: 260px;
  --max-content: 1400px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
}

[data-theme="dark"] {
  --bg:          #0b1220;
  --bg-elev:    #131b2e;
  --bg-soft:    #1a2238;
  --bg-hover:   #1f2a44;
  --border:     #243049;
  --border-strong: #324063;
  --text:       #e6ebf5;
  --text-muted: #a0aac3;
  --text-subtle: #6e7892;

  --ok-bg:    #052e16; --ok-fg:    #86efac; --ok-border:    #166534;
  --warn-bg:  #422006; --warn-fg:  #fcd34d; --warn-border:  #92400e;
  --error-bg: #450a0a; --error-fg: #fca5a5; --error-border: #991b1b;
  --info-bg:  #172554; --info-fg:  #93c5fd; --info-border: #1e40af;
  --neutral-bg: #1e293b; --neutral-fg: #cbd5e1; --neutral-border: #334155;

  --prio-high-bg: #450a0a;   --prio-high-fg: #fca5a5;
  --prio-medium-bg: #422006; --prio-medium-fg: #fcd34d;
  --prio-low-bg: #052e16;    --prio-low-fg: #86efac;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow:    0 2px 4px rgba(0, 0, 0, .25), 0 4px 8px rgba(0, 0, 0, .2);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .35), 0 4px 8px rgba(0, 0, 0, .2);
}

/* === Resetovanje i osnovni stilovi === */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }
[data-theme="dark"] a { color: var(--brand-400); }
[data-theme="dark"] a:hover { color: var(--brand-300); }

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 22px; line-height: 1.3; }
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-subtle); font-weight: 600; }

p { margin: 0; }
small { font-size: 12px; }
code { font-family: var(--font-mono); font-size: 12px; background: var(--bg-soft); padding: 1px 6px; border-radius: 4px; color: var(--text-muted); }

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }

/* === Forme === */
input, select, textarea {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  background: var(--bg-elev);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(58, 107, 245, .15);
}
input[type="checkbox"], input[type="radio"] { width: auto; display: inline-block; cursor: pointer; }
textarea { font-family: var(--font-mono); font-size: 13px; line-height: 1.6; resize: vertical; min-height: 80px; }

label {
  display: block;
  margin: 0 0 4px 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}
.field { margin-bottom: 14px; }
.field label { font-weight: 500; }

/* === Dugmad === */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  font-size: 13px;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}
button:hover, .btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-subtle);
  text-decoration: none;
}
button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; }

button.primary, .btn.primary {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: white;
}
button.primary:hover, .btn.primary:hover {
  background: var(--brand-700);
  border-color: var(--brand-700);
  color: white;
}
button.danger, .btn.danger {
  background: var(--bg-elev);
  color: var(--error-fg);
  border-color: var(--error-border);
}
button.danger:hover, .btn.danger:hover {
  background: var(--error-bg);
}
button.ghost, .btn.ghost {
  border-color: transparent;
  background: transparent;
}
button.ghost:hover, .btn.ghost:hover { background: var(--bg-hover); }
button.icon, .btn.icon { padding: 8px; min-width: 34px; min-height: 34px; }
button.small, .btn.small { padding: 5px 10px; font-size: 12px; }
button.large, .btn.large { padding: 11px 18px; font-size: 14px; }
button.full, .btn.full { width: 100%; }
button.link {
  border: none; background: transparent; color: var(--brand-600);
  padding: 0; font-weight: 500;
}
button.link:hover { text-decoration: underline; background: transparent; }

/* === Kartice === */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card-lg { padding: 20px; border-radius: var(--radius-lg); }
.card.hover { transition: all .15s; cursor: pointer; }
.card.hover:hover { border-color: var(--text-subtle); box-shadow: var(--shadow); transform: translateY(-1px); }

/* === Badges & chips === */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip.ok    { background: var(--ok-bg);    color: var(--ok-fg);    border-color: var(--ok-border); }
.chip.warn  { background: var(--warn-bg);  color: var(--warn-fg);  border-color: var(--warn-border); }
.chip.error { background: var(--error-bg); color: var(--error-fg); border-color: var(--error-border); }
.chip.info  { background: var(--info-bg);  color: var(--info-fg);  border-color: var(--info-border); }
.chip.brand { background: var(--brand-100); color: var(--brand-800); border-color: var(--brand-200); }
[data-theme="dark"] .chip.brand { background: rgba(58, 107, 245, .15); color: var(--brand-300); border-color: rgba(58, 107, 245, .3); }

.chip.lg { padding: 4px 10px; font-size: 12px; }

/* Prioritet pills */
.prio { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.prio.prio-high   { background: var(--prio-high-bg);   color: var(--prio-high-fg); }
.prio.prio-medium { background: var(--prio-medium-bg); color: var(--prio-medium-fg); }
.prio.prio-low    { background: var(--prio-low-bg);    color: var(--prio-low-fg); }
.prio.prio-na     { background: var(--neutral-bg);     color: var(--neutral-fg); }
.prio::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }

/* Status pills */
.status { display: inline-flex; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.status.status-new          { background: var(--info-bg);    color: var(--info-fg); }
.status.status-analyzing    { background: var(--warn-bg);    color: var(--warn-fg); }
.status.status-analyzed     { background: var(--info-bg);    color: var(--info-fg); }
.status.status-draft_ready  { background: var(--ok-bg);      color: var(--ok-fg); }
.status.status-needs_input  { background: var(--warn-bg);    color: var(--warn-fg); }
.status.status-copied       { background: var(--brand-100);  color: var(--brand-800); }
[data-theme="dark"] .status.status-copied { background: rgba(58, 107, 245, .15); color: var(--brand-300); }
.status.status-reviewed     { background: var(--neutral-bg); color: var(--neutral-fg); }
.status.status-done         { background: var(--ok-bg);      color: var(--ok-fg); }
.status.status-ignored      { background: var(--neutral-bg); color: var(--text-subtle); }
.status.status-error        { background: var(--error-bg);   color: var(--error-fg); }

/* === Topbar === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--topbar-height);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(8px);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -.01em;
}
.topbar .brand a { color: var(--text); display: flex; align-items: center; gap: 10px; }
.topbar .brand a:hover { text-decoration: none; }
.topbar .brand .logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(58, 107, 245, .35);
}
.topbar .nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.topbar .nav a {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
}
.topbar .nav a:hover { background: var(--bg-hover); text-decoration: none; color: var(--text); }
.topbar .nav a.active { background: var(--bg-soft); color: var(--text); font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 6px; }
.topbar .user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  background: var(--bg-soft);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.topbar .user-chip .avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-400), var(--brand-700));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
}

/* === Container === */
.container, main.container {
  padding: 20px 24px;
  max-width: var(--max-content);
  margin: 0 auto;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { display: flex; align-items: center; gap: 10px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* === Layout sa sidebarom === */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: 18px;
  align-items: start;
}

.sidebar {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  position: sticky;
  top: calc(var(--topbar-height) + 14px);
  box-shadow: var(--shadow-sm);
}
.sidebar h3 {
  margin: 4px 6px 8px;
  font-size: 11px;
}
.sidebar h3:not(:first-child) { margin-top: 18px; }

.nav-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1px; }
.nav-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
}
.nav-list a:hover { background: var(--bg-hover); text-decoration: none; color: var(--text); }
.nav-list a.active {
  background: var(--brand-100);
  color: var(--brand-800);
}
[data-theme="dark"] .nav-list a.active {
  background: rgba(58, 107, 245, .18);
  color: var(--brand-300);
}
.nav-list .label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nav-list .label .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-subtle); flex-shrink: 0; }
.nav-list a.active .dot { background: var(--brand-600); }
.nav-list .count {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: var(--bg-soft);
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--text-subtle);
  font-weight: 600;
  min-width: 22px;
  text-align: center;
}
.nav-list a.active .count { background: white; color: var(--brand-700); }
[data-theme="dark"] .nav-list a.active .count { background: rgba(0, 0, 0, .25); color: var(--brand-300); }

.content { min-width: 0; }

/* === Filteri === */
.filters-form { display: flex; flex-direction: column; gap: 10px; padding: 0 4px; }
.filters-form label { font-size: 11px; }
.filters-form button { width: 100%; }
.filters-form .field { margin: 0; }

/* === Footer === */
.footer {
  text-align: center;
  color: var(--text-subtle);
  padding: 24px;
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 30px;
}

/* === Auth stranica === */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(58, 107, 245, .12), transparent),
    radial-gradient(1000px 500px at 90% 110%, rgba(58, 107, 245, .08), transparent),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.auth-card .brand {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin-bottom: 20px; text-align: center;
}
.auth-card .brand .logo {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800;
  box-shadow: 0 8px 20px rgba(58, 107, 245, .35);
}
.auth-card .brand h1 { font-size: 20px; }
.auth-card .brand .tag { font-size: 13px; color: var(--text-muted); }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.auth-card .hint {
  text-align: center; color: var(--text-subtle);
  font-size: 12px; margin-top: 18px;
}

/* === Flash poruke (legacy) i Toasts === */
.flash {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin: 14px 0;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px;
}
.flash.ok    { background: var(--ok-bg);    color: var(--ok-fg);    border-color: var(--ok-border); }
.flash.warn  { background: var(--warn-bg);  color: var(--warn-fg);  border-color: var(--warn-border); }
.flash.error { background: var(--error-bg); color: var(--error-fg); border-color: var(--error-border); }

#toasts {
  position: fixed;
  bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  font-size: 13px;
  min-width: 240px;
  max-width: 380px;
  display: flex; align-items: center; gap: 10px;
  pointer-events: auto;
  animation: toast-in .2s ease-out;
}
.toast.ok    { border-color: var(--ok-border);    color: var(--ok-fg); }
.toast.warn  { border-color: var(--warn-border);  color: var(--warn-fg); }
.toast.error { border-color: var(--error-border); color: var(--error-fg); }
.toast .icon { font-size: 16px; }
.toast.fading { animation: toast-out .25s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* === Search bar i filterski toolbar (lista) === */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar .search {
  flex: 1; min-width: 220px;
  position: relative;
}
.toolbar .search input {
  padding-left: 36px;
}
.toolbar .search::before {
  content: '🔍';
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: .55;
  pointer-events: none;
}
.toolbar .quick-filters {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.toolbar select { width: auto; min-width: 140px; }

/* === Lista mailova kao kartice === */
.email-list {
  display: flex; flex-direction: column;
  gap: 8px;
}
.email-item {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all .15s;
  position: relative;
  overflow: hidden;
}
.email-item:hover {
  text-decoration: none;
  border-color: var(--text-subtle);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.email-item .accent {
  background: var(--text-subtle);
  border-radius: 4px;
  margin: -14px 0 -14px -16px;
  width: 4px;
}
.email-item.prio-high .accent   { background: var(--prio-high-fg); }
.email-item.prio-medium .accent { background: var(--prio-medium-fg); }
.email-item.prio-low .accent    { background: var(--prio-low-fg); }

.email-item .body { min-width: 0; }
.email-item .row1 {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.email-item .from {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}
.email-item .from-email {
  color: var(--text-subtle);
  font-size: 12px;
}
.email-item .row2 {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 6px;
}
.email-item .subject {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.email-item .summary {
  color: var(--text-muted);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
}
.email-item .meta {
  display: flex; gap: 6px; align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}
.email-item .meta .dot { color: var(--text-subtle); }
.email-item .right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  min-width: 110px;
  text-align: right;
}
.email-item .date {
  font-size: 12px; color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.email-item.unread .from, .email-item.unread .subject { font-weight: 700; }
.email-item.unread::after {
  content: '';
  position: absolute;
  top: 18px; right: 14px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand-500);
}

/* Empty state */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty .icon { font-size: 36px; margin-bottom: 10px; opacity: .5; }
.empty h3 { color: var(--text); font-size: 15px; text-transform: none; letter-spacing: 0; margin-bottom: 6px; }

/* === Detalj maila === */
.detail-shell { display: flex; flex-direction: column; gap: 16px; }

.detail-toolbar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 20;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 4px;
}
.detail-toolbar .top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.detail-toolbar .breadcrumb {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-subtle); font-size: 12px;
}
.detail-toolbar .breadcrumb a { color: var(--text-muted); }
.detail-toolbar h1 {
  font-size: 18px; line-height: 1.4;
  margin-top: 4px;
  word-break: break-word;
}
.detail-toolbar .meta-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-top: 6px;
  color: var(--text-muted); font-size: 12px;
}
.detail-toolbar .meta-row .from-name { font-weight: 600; color: var(--text); font-size: 13px; }
.detail-toolbar .actions {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  margin-top: 12px;
}
.detail-toolbar .actions form { display: inline; }
.detail-toolbar .actions select { width: auto; min-width: 150px; }

/* Klasifikacija strip (chips ispod toolbar-a) */
.classify-strip {
  display: flex; gap: 8px; flex-wrap: wrap;
  align-items: center;
}

/* === Tabovi === */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 10px;
  width: fit-content;
}
.tab-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  border-radius: 7px;
  cursor: pointer;
}
.tab-btn:hover { background: var(--bg-hover); color: var(--text); }
.tab-btn.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fade-in .15s; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Sekcija sa headerom */
.section {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-wrap: wrap;
}
.section-header h2 {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600;
}
.section-header .actions { display: flex; gap: 6px; }
.section-body { padding: 16px; }
.section-body.tight { padding: 12px 16px; }

/* Mail body kao readable area */
.mail-body {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  max-height: 460px;
  overflow: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
}

/* Skica (textarea) */
.draft-area {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  padding: 0;
  overflow: hidden;
}
.draft-area textarea {
  border: none;
  border-radius: 0;
  padding: 14px 16px;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  min-height: 220px;
}
.draft-area textarea:focus { box-shadow: none; }

/* Klasifikacija kao kv-grid */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.kv-grid .kv-item {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.kv-grid .kv-item .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-subtle);
  font-weight: 600;
  margin-bottom: 3px;
}
.kv-grid .kv-item .value {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

/* Two-col grid */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* Missing info banner */
.banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-fg);
}
.banner .icon { font-size: 18px; line-height: 1; }
.banner h3 { color: var(--warn-fg); text-transform: none; letter-spacing: 0; font-size: 13px; margin-bottom: 6px; }
.banner ul { margin: 0; padding-left: 18px; font-size: 13px; }
.banner ul li { margin: 2px 0; }

/* === Settings === */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.settings-section {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 18px;
  overflow: hidden;
}
.settings-section > .section-body { padding: 16px; }
.settings-table {
  width: 100%;
  border-collapse: collapse;
}
.settings-table th, .settings-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.settings-table th {
  font-weight: 600;
  color: var(--text-subtle);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--bg-soft);
}
.settings-table tr:last-child td { border-bottom: none; }
.settings-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.settings-table .actions form { display: inline; }

details.collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 8px 0;
  background: var(--bg-elev);
  overflow: hidden;
}
details.collapsible summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 500;
  font-size: 13px;
  list-style: none;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
details.collapsible summary::-webkit-details-marker { display: none; }
details.collapsible summary::before { content: '▶'; font-size: 9px; transition: transform .15s; color: var(--text-subtle); }
details.collapsible[open] summary::before { transform: rotate(90deg); }
details.collapsible[open] summary { border-bottom: 1px solid var(--border); }
details.collapsible .body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
details.collapsible .body .row { display: flex; gap: 6px; flex-wrap: wrap; }

.add-card {
  background: linear-gradient(135deg, rgba(58, 107, 245, .04), rgba(58, 107, 245, .08));
  border: 1px dashed var(--brand-300);
}
[data-theme="dark"] .add-card {
  background: rgba(58, 107, 245, .08);
  border-color: rgba(58, 107, 245, .3);
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .span2 { grid-column: 1 / -1; }
.narrow { max-width: 420px; }

/* === Responsive === */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .two-col { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .container, main.container { padding: 14px; }
  .topbar { padding: 0 14px; }
  .topbar .nav a { padding: 6px 9px; font-size: 12px; }
  .topbar .user-chip { display: none; }
  .email-item { grid-template-columns: 4px 1fr; }
  .email-item .right { display: none; }
  .email-item .meta .badge-date { display: inline-block; }
  .auth-card { padding: 24px; }
  .detail-toolbar h1 { font-size: 16px; }
}

/* === Theme toggle === */
.theme-toggle { width: 34px; height: 34px; border-radius: 50%; padding: 0; }
.theme-toggle::before { content: '🌙'; }
[data-theme="dark"] .theme-toggle::before { content: '☀️'; }

/* === Helper utility classes === */
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row.gap-md { gap: 10px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack.gap-md { gap: 12px; }
.stack.gap-lg { gap: 18px; }
.divider { height: 1px; background: var(--border); margin: 8px 0; }
.spacer { flex: 1; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* === Print overrides === */
@media print {
  .topbar, .sidebar, .detail-toolbar .actions, .footer { display: none; }
  .layout { grid-template-columns: 1fr; }
  body { background: white; }
  .section { box-shadow: none; border-color: #ccc; }
}
