/* ═══════════════════════════════════════════════════════════════════════
   S4U — komponente. Metro / Modern UI, svijetla varijanta.
   Pravila koja se ne krše:
     · border-radius je 0, svuda
     · nema sjenke u sadržajnom sloju (samo modal / toast / lightbox / menu)
     · nema gradijenata i prozirnih ispuna preko sadržaja
     · hover = brightness(1.08), pritisak = scale(.96)
   ═══════════════════════════════════════════════════════════════════════ */

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

html { -webkit-text-size-adjust: 100%; }

/* [hidden] mora pobijediti display iz komponentnih klasa (.cluster, .list…). */
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  background: var(--bg-2);
  color: var(--text);
  font: 400 var(--fs-body)/var(--lh-body) var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-press); }

::selection { background: var(--accent); color: #fff; }

:focus-visible {
  outline: var(--border-w) solid var(--accent);
  outline-offset: 1px;
}

/* Ikona je inline-block da ne lomi red kad stoji uz tekst; u flex
   kontejnerima (dugme, chip, red) se svejedno ponasa kao flex stavka. */
.icon { flex: none; display: inline-block; vertical-align: middle;
        fill: none; stroke: currentColor; stroke-width: 1.5;
        stroke-linecap: round; stroke-linejoin: round; }

.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;
}

.mono { font-family: var(--font-mono); font-size: var(--fs-mono); user-select: all; }

/* ── Tipografska skala (§3) ─────────────────────────────────────────── */

.t-display    { font: var(--fw-display) var(--fs-display)/1.08 var(--font-sans); letter-spacing: var(--ls-display); }
.t-display-sm { font: var(--fw-display) var(--fs-display-sm)/1.15 var(--font-sans); letter-spacing: var(--ls-display); }
.t-title      { font: 400 var(--fs-title)/1.3 var(--font-sans); }
.t-section    { font: 700 var(--fs-section)/1.2 var(--font-sans); letter-spacing: var(--ls-section);
                text-transform: uppercase; color: var(--text-muted); }
.t-label      { font: 600 var(--fs-section)/1.2 var(--font-sans); letter-spacing: var(--ls-section);
                text-transform: uppercase; color: var(--text-muted); }
.t-body-sm    { font-size: var(--fs-body-sm); color: var(--text-muted); }
.t-meta       { font-size: var(--fs-meta); letter-spacing: .02em; color: var(--text-muted); }
.t-micro      { font: 700 var(--fs-micro)/1.2 var(--font-sans); letter-spacing: var(--ls-section);
                text-transform: uppercase; color: var(--text-muted); }

/* ── Layout ─────────────────────────────────────────────────────────── */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.container {
  width: 100%; max-width: var(--container); margin-inline: auto;
  padding: 18px 14px calc(var(--navbar-h) + var(--space-7));
}

.main { flex: 1; }

/* Gornja traka (§7.9) — 54px, bez sjenke, sticky */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg);
  border-bottom: 0;
}
.topbar__inner {
  height: var(--topbar-h);
  max-width: var(--container); margin-inline: auto;
  padding: 0 14px;
  display: flex; align-items: center; gap: var(--space-2);
}
.topbar__brand {
  font: 600 15px/1 var(--font-sans);
  letter-spacing: var(--ls-brand); text-transform: uppercase;
  color: var(--text); white-space: nowrap;
}
.topbar__brand:hover { color: var(--text); }
.topbar__title {
  font: 600 15px/1.2 var(--font-sans);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.topbar__spacer { flex: 1; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--touch-min); height: var(--touch-min);
  background: none; border: 0; border-radius: var(--radius);
  color: var(--text); cursor: pointer;
  transition: background var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
.iconbtn:hover  { background: var(--surface-2); }
.iconbtn:active { transform: var(--press); }
.iconbtn[disabled] { color: var(--line); cursor: not-allowed; }

/* Traka boja (§5.1) — tačno jednom po ekranu, uz donju ivicu gornje trake */
.brandbar {
  display: grid; grid-template-columns: repeat(6, 1fr); height: 3px;
}
.brandbar > i:nth-child(1) { background: var(--mod-dashboard); }
.brandbar > i:nth-child(2) { background: var(--mod-lists); }
.brandbar > i:nth-child(3) { background: var(--mod-bookmarks); }
.brandbar > i:nth-child(4) { background: var(--mod-galleries); }
.brandbar > i:nth-child(5) { background: var(--mod-credentials); }
.brandbar > i:nth-child(6) { background: var(--mod-settings); }

/* Globalna pretraga u gornjoj traci — od 900px */
.topsearch { display: none; position: relative; flex: 1; max-width: 420px; }
.topsearch .input { height: 36px; font-size: var(--fs-body-sm); padding-left: 38px; border-width: 1px; }
.topsearch .icon  { position: absolute; left: 11px; top: 9px; color: var(--text-muted); }

/* Navigacija (§7.10) — donja traka na mobilnom, lijeva vertikalna od 900px */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  height: var(--navbar-h);
  display: flex; background: var(--bg); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav__item {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: var(--touch-min);
  color: var(--text-muted); background: none; border: 0; cursor: pointer;
  transition: background var(--dur-2) var(--ease);
}
.nav__item:hover  { background: var(--surface-2); color: var(--text); }
.nav__item:active { background: var(--surface-3); }
.nav__item:focus-visible { outline-offset: -2px; }
.nav__label { font: 700 var(--fs-micro)/1.2 var(--font-sans);
              letter-spacing: var(--ls-section); text-transform: uppercase; }
.nav__item[aria-current="page"] { color: var(--c); }
.nav__item[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0;
  height: var(--tab-ind); background: var(--c);
}
.nav__badge {
  position: absolute; top: 6px; left: 50%; margin-left: 4px;
  min-width: 16px; height: 16px; padding: 0 3px;
  display: grid; place-items: center;
  background: var(--c); color: #fff;
  font: 700 10px/1 var(--font-sans);
}

/* ── Dugme (§7.1) ───────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--btn-h); padding: 0 18px;
  border: var(--border-w) solid currentColor; border-radius: var(--radius);
  background: transparent; color: var(--text);
  font: 600 var(--fs-section)/1 var(--font-sans);
  text-transform: uppercase; letter-spacing: var(--ls-section);
  white-space: nowrap; cursor: pointer;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
.btn:hover  { background: currentColor; }
.btn:hover > .btn__t, .btn:hover > .icon { color: var(--bg); }
.btn:active { transform: var(--press); }
.btn[disabled], .btn[aria-disabled="true"] { color: var(--line); cursor: not-allowed; background: transparent; }
.btn[disabled]:hover { background: transparent; }

.btn--primary {
  background: var(--accent); border-color: var(--accent); color: var(--text-on-accent);
}
.btn--primary:hover  { background: var(--accent); filter: var(--lighten); }
.btn--primary:active { background: var(--accent-press); transform: var(--press); }
.btn--primary:focus-visible { outline-color: var(--text); }
.btn--primary[disabled] { background: var(--surface-3); border-color: transparent; color: var(--text-weak); filter: none; }

.btn--accent { color: var(--accent); }
.btn--accent:focus-visible { outline-color: var(--text); }
.btn--danger { color: var(--danger); }
.btn--danger:focus-visible { outline-color: var(--text); }

.btn--ghost { border-color: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--ghost:hover > .icon { color: var(--text); }
.btn--ghost:active { background: var(--surface-3); transform: var(--press); }

.btn--sm    { height: var(--btn-h-sm); padding: 0 var(--space-3); font-size: var(--fs-meta); position: relative; }
.btn--sm::before { content: ""; position: absolute; inset: -6px -2px; }  /* 44px dodirna zona */
.btn--block { width: 100%; height: var(--btn-h-block); }

/* Plutajuće dugme "dodaj" — kvadrat, bez radiusa, bez sjenke u sadržaju */
.fab {
  position: fixed; right: 14px; bottom: calc(var(--navbar-h) + 14px); z-index: 35;
  width: 56px; height: 56px;
  display: grid; place-items: center;
  background: var(--c, var(--accent)); color: #fff;
  border: 0; cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: filter var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
.fab:hover  { filter: var(--lighten); }
.fab:active { transform: var(--press); }
.fab:focus-visible { outline: var(--border-w) solid var(--text); outline-offset: 1px; }
.fab--light { color: var(--text-on-light-accent); }

/* ── Polja (§7.2 – 7.5) ─────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; margin-bottom: var(--space-4); }
.field > .t-label { margin-bottom: var(--space-3); }
.field__help  { font-size: var(--fs-section); color: var(--text-muted); margin-top: 6px; }
.field__error { display: flex; align-items: center; gap: 6px;
                font-size: var(--fs-section); color: var(--danger); margin-top: 6px; }

.input, .textarea, .select {
  width: 100%; height: var(--control-h); padding: 0 var(--space-3);
  border: var(--border-w) solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: 400 var(--fs-input)/1.4 var(--font-sans);
  caret-color: var(--accent);
  transition: border-color var(--dur-2) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-weak); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--line-strong-hover); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input:disabled, .textarea:disabled, .select:disabled {
  background: var(--surface-2); border-color: var(--surface-3); color: var(--text-weak);
}
.input[readonly] { background: var(--surface-2); border-color: var(--line); user-select: all; }

.textarea {
  height: auto; min-height: 112px; padding: var(--space-3);
  line-height: var(--lh-body); resize: vertical;
}
.textarea--tall { min-height: 320px; font-family: var(--font-mono); font-size: var(--fs-mono); }

.counter { font-size: var(--fs-meta); color: var(--text-weak); text-align: right; margin-top: 4px; }
.counter.is-over { color: var(--danger); font-weight: 600; }

.select { appearance: none; padding-right: 40px; cursor: pointer;
          background-image: none; }
.select-wrap { position: relative; }
.select-wrap > .icon { position: absolute; right: 12px; top: 13px; pointer-events: none; color: var(--text-muted); }

.input-wrap { position: relative; }
.input-wrap > .icon--lead { position: absolute; left: 12px; top: 13px; color: var(--text-muted); }
.input-wrap--lead .input { padding-left: 40px; }
.input-wrap > .input-action {
  position: absolute; right: 2px; top: 2px; height: 40px; width: 40px;
  display: grid; place-items: center; background: none; border: 0;
  color: var(--text-muted); cursor: pointer;
}
.input-wrap > .input-action:hover { color: var(--text); background: var(--surface-2); }

/* Checkbox / radio — kvadrat 20×20, radio je isto kvadrat (§7.5) */
.check {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--touch-min); padding: 0 4px; cursor: pointer;
  transition: background var(--dur-2) var(--ease);
}
.check:hover { background: var(--surface-2); }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check__box {
  flex: none; width: 20px; height: 20px;
  border: var(--border-w) solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease),
              transform var(--dur-1) var(--ease);
}
.check:hover .check__box { border-color: var(--line-strong-hover); }
.check input:checked + .check__box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .check__box::after {
  content: ""; width: 10px; height: 6px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}
.check input:indeterminate + .check__box { background: var(--accent); border-color: var(--accent); }
.check input:indeterminate + .check__box::after {
  content: ""; width: 10px; height: 2px; background: #fff; border: 0; transform: none;
}
.check input:focus-visible + .check__box { outline: var(--border-w) solid var(--accent); outline-offset: 1px; }
.check input:checked:focus-visible + .check__box { outline-color: var(--text); }
.check input:active + .check__box { transform: var(--press); }
.check input:disabled + .check__box { background: var(--surface-2); border-color: var(--surface-3); }
.check__label { font-size: var(--fs-body); }

.radio .check__box { }
.radio input:checked + .check__box::after {
  content: ""; width: 10px; height: 10px; background: #fff; border: 0; transform: none;
}

/* ── Chip (§7.6) ────────────────────────────────────────────────────── */

.chipbar {
  display: flex; gap: var(--space-2); margin-bottom: var(--space-4);
  overflow-x: auto; scrollbar-width: none; padding-bottom: 2px;
}
.chipbar::-webkit-scrollbar { display: none; }

.chip {
  position: relative; flex: none;
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: var(--btn-h-sm); padding: 0 var(--space-3);
  border: var(--border-w) solid var(--c); border-radius: var(--radius);
  color: var(--c); background: transparent;
  font: 600 var(--fs-meta)/1 var(--font-sans);
  text-transform: uppercase; letter-spacing: var(--ls-section);
  white-space: nowrap; cursor: pointer;
  transition: filter var(--dur-2) var(--ease), background var(--dur-2) var(--ease),
              color var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
.chip::before { content: ""; position: absolute; inset: -6px -2px; }  /* 44px zona */
.chip:hover   { filter: var(--lighten); color: var(--c); }
.chip:active  { transform: var(--press); }
.chip:focus-visible { outline: var(--border-w) solid var(--text); outline-offset: 1px; }
.chip.is-selected { background: var(--c); color: #fff; }
.chip.is-selected.chip--light { color: var(--text-on-light-accent); }
.chip[aria-disabled="true"] { border-color: var(--line); color: var(--line); pointer-events: none; }

/* ── Kartica i stavka liste (§7.7) ──────────────────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--line);
  padding: var(--space-4);
  transition: border-color var(--dur-2) var(--ease);
}
.card--link:hover  { border-color: var(--line-strong); }
.card--link:active { background: var(--surface-2); }
.card.is-selected  { border: var(--border-w) solid var(--accent); }
.card__head { display: flex; align-items: center; justify-content: space-between;
              gap: var(--space-3); margin-bottom: var(--space-3); }

.list { background: var(--surface); border: 1px solid var(--line); }

.row {
  position: relative;
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 56px; padding: var(--space-3) var(--space-3) var(--space-3) calc(var(--space-3) + var(--spine-w));
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  transition: background var(--dur-2) var(--ease);
}
.row:last-child { border-bottom: 0; }
.row::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--spine-w); background: var(--c, var(--line));
  transition: width var(--dur-2) var(--ease);
}
.row:hover        { background: var(--surface-2); }
.row:hover::before{ width: 6px; }
.row:active       { background: var(--surface-3); }
.row.is-selected  { background: var(--surface-3); }
.row:focus-within { outline: var(--border-w) solid var(--accent); outline-offset: -2px; }

.row__main  { flex: 1; min-width: 0; }
.row__title { font: 400 var(--fs-body)/1.35 var(--font-sans);
              overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.row__meta  { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
              font-size: var(--fs-meta); color: var(--text-muted); margin-top: 3px; }
.row__actions { display: flex; align-items: center; gap: 2px; flex: none; }
.row__actions .iconbtn { width: 36px; height: 36px; }
.row--dragging { opacity: .6; }
.row__grip { cursor: grab; touch-action: none; color: var(--text-weak); }
.row__grip:active { cursor: grabbing; }

.favicon {
  flex: none; width: 20px; height: 20px; object-fit: contain;
  background: var(--surface-2);
}
.favicon--letter {
  display: grid; place-items: center;
  background: var(--c, var(--steel)); color: #fff;
  font: 700 11px/1 var(--font-sans); text-transform: uppercase;
}

/* ── Tile (§7.8) ────────────────────────────────────────────────────── */

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--grid-gap); }

.tile {
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: var(--tile-min); padding: var(--space-4);
  border: 0; border-radius: var(--radius);
  background: var(--c, var(--accent));
  color: var(--text-on-accent); text-align: left; cursor: pointer;
  transition: filter var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
.tile:hover  { filter: var(--lighten); color: var(--text-on-accent); }
.tile:active { transform: var(--press); transform-origin: center; }
.tile:focus-visible { outline: var(--border-w) solid var(--text); outline-offset: 1px; }
.tile--light { color: var(--text-on-light-accent); }
.tile--light:hover { color: var(--text-on-light-accent); }
.tile--light:focus-visible { outline-color: var(--text); }
.tile--dark:focus-visible { outline-color: #fff; }
.tile--wide { grid-column: span 2; }
.tile__name { font: 600 var(--fs-section)/1.2 var(--font-sans);
              text-transform: uppercase; letter-spacing: var(--ls-section); }
.tile__meta { font-size: var(--fs-meta); opacity: .92; margin-top: 3px; }
.tile__num  { font: var(--fw-display) var(--fs-display)/1 var(--font-sans);
              letter-spacing: var(--ls-display); }

/* ── Badge, status (§7.14) ──────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 var(--space-2);
  font: 700 var(--fs-micro)/1 var(--font-sans);
  letter-spacing: var(--ls-section); text-transform: uppercase; white-space: nowrap;
}
.badge--solid   { background: var(--c); color: #fff; }
.badge--light   { color: var(--text-on-light-accent); }
.badge--outline { border: 1px solid var(--c); color: var(--c); background: transparent; }
.badge--num     { min-width: 20px; justify-content: center; padding: 0 5px; }

.status { display: inline-flex; align-items: center; gap: 6px;
          font: 700 var(--fs-micro)/1 var(--font-sans);
          letter-spacing: var(--ls-section); text-transform: uppercase; color: var(--c); }
.status__dot { width: 8px; height: 8px; background: var(--c); flex: none; }

/* ── Modal (§7.11) ──────────────────────────────────────────────────── */

.backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: var(--backdrop);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade var(--dur-2) var(--ease);
}
.modal {
  position: relative;
  width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  background: var(--surface); box-shadow: var(--shadow-2);
  padding: var(--space-5);
  animation: rise 160ms var(--ease);
}
.modal--wide { max-width: 640px; }
.modal__head { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-4); }
.modal__title { flex: 1; font: var(--fw-display) var(--fs-display-sm)/1.15 var(--font-sans);
                letter-spacing: var(--ls-display); }
.modal__close { flex: none; margin: -10px -10px 0 0; }
.modal__body { font-size: var(--fs-body); }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--space-2);
               margin-top: var(--space-5); flex-wrap: wrap; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Toast (§7.12) ──────────────────────────────────────────────────── */

.toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--navbar-h) + 16px); z-index: 95;
  display: flex; flex-direction: column; gap: var(--space-2);
  width: calc(100% - 28px); max-width: 420px;
}
.toast {
  position: relative;
  display: flex; align-items: center; gap: var(--space-3);
  min-width: 280px; padding: 14px var(--space-4) 14px calc(var(--space-4) + var(--spine-w));
  background: var(--text); color: #fff;
  font-size: var(--fs-body-sm); box-shadow: var(--shadow-1);
  animation: rise var(--dur-2) var(--ease);
}
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0;
                 width: var(--spine-w); background: var(--c, var(--info)); }
.toast--ok     { --c: var(--ok); }
.toast--warn   { --c: var(--warn); }
.toast--danger { --c: var(--danger); }
.toast--info   { --c: var(--info); }
.toast__text   { flex: 1; }
.toast__action {
  background: none; border: 0; color: var(--c); cursor: pointer;
  font: 700 var(--fs-meta)/1 var(--font-sans);
  letter-spacing: var(--ls-section); text-transform: uppercase;
}
.toast.is-leaving { opacity: 0; transition: opacity var(--dur-1) var(--ease); }

/* ── Prazno stanje (§7.13) ──────────────────────────────────────────── */

.empty { display: flex; flex-direction: column; align-items: center; text-align: center;
         padding: var(--space-7) var(--space-5); }
.empty__mark { width: 64px; height: 64px; display: grid; place-items: center;
               background: var(--c, var(--accent)); color: #fff; margin-bottom: var(--space-5); }
.empty__mark--light { color: var(--text-on-light-accent); }
.empty__title { font: var(--fw-display) var(--fs-display-sm)/1.15 var(--font-sans);
                letter-spacing: var(--ls-display); margin-bottom: var(--space-2); }
.empty__text  { font-size: var(--fs-body-sm); color: var(--text-muted); max-width: 42ch;
                margin-bottom: var(--space-5); }

/* ── Skeleton ───────────────────────────────────────────────────────── */

.skel { background: var(--surface-3); animation: pulse 1200ms var(--ease) infinite alternate; }
.skel--row { height: 56px; margin-bottom: 1px; }
.skel--line { height: 14px; }
@keyframes pulse { from { background: var(--surface-3); } to { background: var(--surface-2); } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ── Sekcije ekrana ─────────────────────────────────────────────────── */

.screen__head { margin: var(--space-5) 0 var(--space-4); }
.screen__title { font: var(--fw-display) var(--fs-display)/1.08 var(--font-sans);
                 letter-spacing: var(--ls-display); }
.screen__sub   { font-size: var(--fs-body-sm); color: var(--text-muted); margin-top: 6px; }

.section { margin-top: var(--space-6); }
.section__head { display: flex; align-items: center; justify-content: space-between;
                 gap: var(--space-3); margin-bottom: var(--space-4); }
.section__head .t-section { display: flex; align-items: center; gap: 10px; }
.section__head .t-section::before { content: ""; width: 10px; height: 10px; flex: none;
                                    background: var(--c, var(--accent)); }

.toolbar { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap;
           margin-bottom: var(--space-4); }
.toolbar > form { display: contents; }
.toolbar__grow { flex: 1; min-width: 180px; }

.stack  { display: flex; flex-direction: column; gap: var(--space-5); }
.stack--tight { gap: var(--space-3); }
.cluster{ display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.grid2  { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--grid-gap); }
.split  { display: grid; grid-template-columns: 1fr; gap: var(--space-4); }

/* ── Tabele ─────────────────────────────────────────────────────────── */

.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-body-sm); }
.table th {
  text-align: left; padding: 10px var(--space-3);
  background: var(--surface-2); border-bottom: var(--border-w) solid var(--line);
  font: 600 var(--fs-section)/1.2 var(--font-sans);
  letter-spacing: var(--ls-section); text-transform: uppercase; color: var(--text-muted);
  white-space: nowrap;
}
.table td { padding: 10px var(--space-3); border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table__num { text-align: right; font-variant-numeric: tabular-nums; }

.kv { display: grid; grid-template-columns: minmax(140px, auto) 1fr; gap: 6px var(--space-4); font-size: var(--fs-body-sm); }
.kv dt { color: var(--text-muted); }
.kv dd { color: var(--text); font-family: var(--font-mono); font-size: var(--fs-mono); }

/* ── Markdown izlaz ─────────────────────────────────────────────────── */

.md { font-size: var(--fs-body); line-height: var(--lh-body); }
.md > * + * { margin-top: var(--space-3); }
.md-h { font-weight: 600; line-height: 1.3; margin-top: var(--space-5); }
.md h2.md-h { font-size: 20px; }
.md h3.md-h { font-size: 17px; }
.md h4.md-h, .md h5.md-h, .md h6.md-h { font-size: 15px; }
.md-list { padding-left: 22px; }
.md-list li + li { margin-top: 4px; }
.md-task { list-style: none; display: flex; align-items: flex-start; gap: var(--space-2); margin-left: -22px; }
.md-task.is-done { color: var(--text-muted); text-decoration: line-through; }
.md-box { flex: none; width: 16px; height: 16px; margin-top: 3px;
          border: var(--border-w) solid var(--line-strong); }
.md-box.is-checked { background: var(--ok); border-color: var(--ok); }
.md-quote { border-left: var(--spine-w) solid var(--line); padding-left: var(--space-3); color: var(--text-muted); }
.md-pre { background: var(--surface-2); padding: var(--space-3); overflow-x: auto;
          font-family: var(--font-mono); font-size: var(--fs-mono); }
.md-code { background: var(--surface-2); padding: 1px 5px;
           font-family: var(--font-mono); font-size: var(--fs-mono); }
.md-tablewrap { overflow-x: auto; }
.md-table { width: 100%; border-collapse: collapse; font-size: var(--fs-body-sm); }
.md-table th, .md-table td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.md-table th { border-bottom: var(--border-w) solid var(--line); font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-5) 0; }
mark { background: var(--amber); color: var(--text-on-light-accent); padding: 0 2px; }

/* ── Galerija ───────────────────────────────────────────────────────── */

.gallery { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--grid-gap); }
.shot { position: relative; aspect-ratio: 1; background: var(--surface-2);
        border: 0; padding: 0; cursor: pointer; overflow: hidden; }
.shot img { width: 100%; height: 100%; object-fit: cover; }
.shot:hover img { filter: var(--lighten); }
.shot:active { transform: var(--press); }
.shot:focus-visible { outline: var(--border-w) solid var(--accent); outline-offset: -2px; }
.shot__cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px;
             background: var(--text); color: #fff; font-size: var(--fs-meta);
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lightbox {
  position: fixed; inset: 0; z-index: 100; background: var(--text);
  display: flex; flex-direction: column;
}
.lightbox__bar { display: flex; align-items: center; gap: var(--space-2);
                 height: var(--topbar-h); padding: 0 8px; color: #fff; }
.lightbox__bar .iconbtn { color: #fff; }
.lightbox__bar .iconbtn:hover { background: rgba(255,255,255,.14); }
.lightbox__stage { flex: 1; display: grid; place-items: center; overflow: hidden;
                   touch-action: pan-y; }
.lightbox__stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox__meta { padding: var(--space-3) var(--space-4); background: #000; color: #fff; }
.lightbox__count { font-size: var(--fs-meta); color: rgba(255,255,255,.7); }

/* ── Upload traka napretka ──────────────────────────────────────────── */

.progress { height: 4px; background: var(--surface-3); overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--c, var(--accent));
                 transition: width var(--dur-2) linear; }

.droparea {
  border: var(--border-w) dashed var(--line-strong); background: var(--surface);
  padding: var(--space-6) var(--space-4); text-align: center; cursor: pointer;
  transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.droparea:hover, .droparea.is-over { border-color: var(--accent); background: var(--surface-2); }
.droparea input[type="file"] { display: none; }

/* ── Prijava ────────────────────────────────────────────────────────── */

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-5); background: var(--bg-2); }
.login__panel { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); }
.login__body { padding: var(--space-6) var(--space-5) var(--space-5); }
.login__brand { font: 600 15px/1 var(--font-sans); letter-spacing: var(--ls-brand);
                text-transform: uppercase; color: var(--text-muted); }
.login__title { font: var(--fw-display) var(--fs-display)/1.08 var(--font-sans);
                letter-spacing: var(--ls-display); margin: var(--space-3) 0 var(--space-5); }
.login .input { font-family: var(--font-mono); letter-spacing: .3em; text-align: center; }

.notice { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4);
          border-left: var(--spine-w) solid var(--c, var(--info)); background: var(--surface-2);
          font-size: var(--fs-body-sm); }
.notice--warn   { --c: var(--warn); }
.notice--danger { --c: var(--danger); }
.notice--ok     { --c: var(--ok); }

/* ── Detalj panel (master–detail od 900px) ──────────────────────────── */

.detail { background: var(--surface); border: 1px solid var(--line); padding: var(--space-4); }
.detail__head { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-4); }
.detail__title { flex: 1; font: var(--fw-display) var(--fs-display-sm)/1.15 var(--font-sans);
                 letter-spacing: var(--ls-display); }

/* ── Menu / dropdown ────────────────────────────────────────────────── */

.menu {
  position: absolute; z-index: 60; min-width: 200px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  animation: dropIn var(--dur-2) var(--ease);
}
@keyframes dropIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu__item {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%; height: 40px; padding: 0 var(--space-3);
  background: none; border: 0; text-align: left; cursor: pointer;
  font-size: var(--fs-body); color: var(--text);
}
.menu__item:hover { background: var(--surface-2); }
.menu__item:focus-visible { outline: var(--border-w) solid var(--text); outline-offset: -2px; }
.menu__item--danger { color: var(--danger); }
.menu__sep { height: 1px; background: var(--line-soft); }

/* ── Indikator jačine lozinke ───────────────────────────────────────── */

.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; margin-top: 8px; }
.strength > i { height: 4px; background: var(--surface-3); }
.strength[data-score="1"] > i:nth-child(-n+1) { background: var(--red); }
.strength[data-score="2"] > i:nth-child(-n+2) { background: var(--amber); }
.strength[data-score="3"] > i:nth-child(-n+3) { background: var(--lime); }
.strength[data-score="4"] > i { background: var(--ok); }

/* ── Offline / update indikator ─────────────────────────────────────── */

.offline-dot { display: none; }
body.is-offline .offline-dot { display: inline-flex; }

/* ── Ispod 720px: stavka liste ide u dva reda ───────────────────────── */
/* Na 375px cetiri akcije i naslov ne stanu u isti red; akcije se prelamaju
   u svoj red umjesto da guse naslov na tri znaka (§9). */

@media (max-width: 719px) {
  .row { flex-wrap: wrap; row-gap: var(--space-2); }
  .row__main { flex: 1 1 60%; }
  .row__actions { margin-left: auto; }
  .listfoot .input--date { width: 132px; }
  .detail__head { flex-wrap: wrap; }
  .title-input { flex: 1 1 100%; }
}

/* ── Breakpoint 720px ───────────────────────────────────────────────── */

@media (min-width: 720px) {
  .container  { padding: 24px 22px calc(var(--navbar-h) + var(--space-7)); }
  .topbar__inner { padding: 0 22px; }
  .tiles      { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gallery    { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .chipbar    { flex-wrap: wrap; overflow: visible; }
  .backdrop   { align-items: center; }
  .modal      { max-height: 86vh; }
  .toasts     { max-width: 420px; }
}

/* ── Breakpoint 900px: lijeva vertikalna traka ──────────────────────── */

@media (min-width: 900px) {
  .container { padding: 26px 30px var(--space-7); }
  .topbar__inner { padding: 0 30px; }

  .app { padding-left: var(--rail-w); }
  .topbar { padding-left: var(--rail-w); }

  .nav {
    top: 0; bottom: 0; right: auto; width: var(--rail-w);
    height: auto; flex-direction: column;
    border-top: 0; border-right: 1px solid var(--line);
    padding-top: var(--topbar-h); padding-bottom: 0;
    z-index: 50;
  }
  .nav__item { flex: none; height: 64px; }
  .nav__item[aria-current="page"]::before {
    top: 0; bottom: 0; right: auto; left: 0;
    width: var(--tab-ind); height: auto;
  }
  .nav__badge { top: 10px; left: 50%; }

  .topsearch { display: block; }
  .fab { right: 30px; bottom: 30px; }
  .toasts { left: auto; right: 16px; transform: none; bottom: 16px; }

  .split { grid-template-columns: 1fr 380px; align-items: start; }
  .split--notes { grid-template-columns: 340px 1fr; }
  .split--wide  { grid-template-columns: 260px 1fr; }

  .gallery { grid-template-columns: repeat(6, minmax(0,1fr)); }

  .lightbox__stage { padding: var(--space-4); }
  .lightbox--meta { display: grid; grid-template-columns: 1fr 320px; grid-template-rows: auto 1fr; }
  .lightbox--meta .lightbox__bar  { grid-column: 1 / -1; }
  .lightbox--meta .lightbox__meta { overflow: auto; }
}

@media (min-width: 1200px) {
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ── Print ──────────────────────────────────────────────────────────── */

@media print {
  .nav, .topbar, .fab, .toasts, .chipbar, .toolbar { display: none !important; }
  .app { padding: 0; }
  body { background: #fff; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Paleta kao klase i sitne pomoćne klase.

   CSP je strog (style-src 'self'), pa u dokumentu NEMA style atributa —
   boja modula i taga se nosi klasom, ne inline varijablom. Paleta je ionako
   zatvoren skup od 14 boja (§2.3), pa klase pokrivaju sve slučajeve.
   ═══════════════════════════════════════════════════════════════════════ */

.c-cobalt  { --c: var(--cobalt); }
.c-indigo  { --c: var(--indigo); }
.c-violet  { --c: var(--violet); }
.c-magenta { --c: var(--magenta); }
.c-crimson { --c: var(--crimson); }
.c-red     { --c: var(--red); }
.c-orange  { --c: var(--orange); }
.c-amber   { --c: var(--amber); }
.c-lime    { --c: var(--lime); }
.c-emerald { --c: var(--emerald); }
.c-teal    { --c: var(--teal); }
.c-cyan    { --c: var(--cyan); }
.c-mauve   { --c: var(--mauve); }
.c-steel   { --c: var(--steel); }
.c-line    { --c: var(--surface-4); }

/* Tekst u boji — nikad kao jedini nosilac značenja (§10). */
.tx-c       { color: var(--c); }
.tx-danger  { color: var(--danger); }
.tx-warn    { color: var(--warn); }
.tx-ok      { color: var(--ok); }
.tx-muted   { color: var(--text-muted); }
.tx-strike  { text-decoration: line-through; color: var(--text-muted); }

/* Kvadratić u boji uz naslov liste */
.dot { width: 10px; height: 10px; flex: none; background: var(--c); }

/* Razmaci po skali iz §4 */
.u-mt-2 { margin-top: var(--space-2); }
.u-mt-3 { margin-top: var(--space-3); }
.u-mt-4 { margin-top: var(--space-4); }
.u-mt-5 { margin-top: var(--space-5); }
.u-mt-6 { margin-top: var(--space-6); }
.u-mb-3 { margin-bottom: var(--space-3); }
.u-mb-4 { margin-bottom: var(--space-4); }
.u-mb-5 { margin-bottom: var(--space-5); }
.u-mt-1 { margin-top: var(--space-1); }

.u-flex1    { flex: 1; }
.u-contents { display: contents; }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.u-break    { word-break: break-all; }
.u-between  { justify-content: space-between; }
.u-selectable { user-select: auto; }
.u-center   { display: grid; place-items: center; min-height: 240px; }
.u-pull     { margin-left: -10px; }

/* Varijante komponenti koje su prije bile inline */
.card--flush   { padding: 0; }
.list--flush   { border: 0; }
.list--bleed   { border: 0; margin: 0 calc(var(--space-4) * -1) calc(var(--space-4) * -1); }
.iconbtn--sm   { width: 32px; height: 32px; }
.iconbtn--row  { width: 36px; height: 36px; }
.check--bare   { min-height: 0; padding: 0; }
.select--sm    { height: var(--btn-h-sm); font-size: var(--fs-meta); }
.input--sm     { height: var(--btn-h); }
.input--grow   { flex: 1; min-width: 140px; height: var(--btn-h); }
.input--date   { width: 150px; height: var(--btn-h); }
.sentinel      { height: 1px; }

.bulkbar {
  background: var(--surface-3);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
}

.listhead {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); margin: 0;
  border-bottom: 1px solid var(--line-soft);
}
.listhead__name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.listfoot {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line-soft);
}

/* Naslov bilješke se uređuje u mjestu, ali izgleda kao display-sm naslov */
.title-input {
  border: 0; padding: 0; height: auto; background: none;
  font: var(--fw-display) var(--fs-display-sm)/1.15 var(--font-sans);
  letter-spacing: var(--ls-display);
}
.title-input:focus { outline: var(--border-w) solid var(--accent); outline-offset: 2px; }
