/* SMS Centrala — izgled. Svijetla i tamna tema (prati sistem; data-theme ih može prisiliti). */

:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --surface-3: #e4e7ee;
  --text: #0d1321;
  --text-2: #394256;
  --muted: #697287;
  --faint: #9aa2b3;
  --border: rgba(13, 19, 33, .08);
  --border-strong: rgba(13, 19, 33, .15);
  --brand: #5046e5;
  --brand-2: #8b5cf6;
  --brand-grad: linear-gradient(135deg, #5b50f0 0%, #8b5cf6 100%);
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --bubble-in: #e9ecf2;
  --bubble-in-text: #0d1321;
  --header-bg: rgba(243, 244, 248, .84);
  --sheet-bg: #ffffff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 22px rgba(16, 24, 40, .07);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, .22);
  --radius: 18px;
  --blur: saturate(180%) blur(18px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --c: var(--brand);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07090f;
    --surface: #10141d;
    --surface-2: #171c28;
    --surface-3: #202636;
    --text: #eef1f7;
    --text-2: #c5ccd9;
    --muted: #8b95a9;
    --faint: #5f687b;
    --border: rgba(255, 255, 255, .07);
    --border-strong: rgba(255, 255, 255, .13);
    --bubble-in: #1b2130;
    --bubble-in-text: #eef1f7;
    --header-bg: rgba(7, 9, 15, .8);
    --sheet-bg: #121722;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 26px rgba(0, 0, 0, .35);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07090f;
  --surface: #10141d;
  --surface-2: #171c28;
  --surface-3: #202636;
  --text: #eef1f7;
  --text-2: #c5ccd9;
  --muted: #8b95a9;
  --faint: #5f687b;
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .13);
  --bubble-in: #1b2130;
  --bubble-in-text: #eef1f7;
  --header-bg: rgba(7, 9, 15, .8);
  --sheet-bg: #121722;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 26px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
a { color: var(--brand); }
.ic { display: inline-grid; place-items: center; flex: none; line-height: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- raspored */
#app {
  height: var(--app-h, 100dvh);
  display: grid;
  grid-template-columns: 1fr;
}
.pane {
  height: var(--app-h, 100dvh);
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
body[data-view="list"] #pane-main { display: none; }
body:not([data-view="list"]) #pane-list { display: none; }
body[data-view="boot"] #app { visibility: hidden; }

@media (min-width: 900px) {
  #app { grid-template-columns: minmax(340px, 400px) 1fr; }
  #pane-list, #pane-main { display: flex !important; }
  #pane-list { background: var(--surface); border-right: 1px solid var(--border); }
  body[data-view="auth"] #app { grid-template-columns: 1fr; }
  body[data-view="auth"] #pane-list { display: none !important; }
  .fab { right: 22px; }
}
@media (max-width: 899px) {
  .pane.enter { animation: slideIn .3s cubic-bezier(.2, .8, .2, 1); }
  .pane.back { animation: slideBack .28s cubic-bezier(.2, .8, .2, 1); }
}
@keyframes slideIn { from { transform: translateX(28%); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes slideBack { from { transform: translateX(-12%); opacity: .6; } to { transform: none; opacity: 1; } }

.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; transition: opacity .3s; }
body:not([data-view="boot"]) .boot { opacity: 0; pointer-events: none; }
.boot .logo { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.94); opacity: .8; } }

/* ---------------------------------------------------------------- zaglavlja */
.hdr {
  position: relative;
  z-index: 5;
  flex: none;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  background: var(--header-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.hdr.line { border-bottom-color: var(--border); }
#pane-list .hdr { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; padding-left: 16px; padding-right: 12px; }
@media (max-width: 899px) { #pane-list .hdr { background: var(--header-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); } }
.hdr-row { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.hdr h1 { font-size: 31px; font-weight: 800; letter-spacing: -.025em; margin: 0; flex: 1; }
.hdr h2 { font-size: 17px; font-weight: 700; margin: 0; flex: 1; text-align: center; letter-spacing: -.01em; }
.hdr .spacer { width: 40px; flex: none; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  display: grid; place-items: center;
  flex: none;
  color: var(--text);
  transition: background .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.brand { color: var(--brand); }
.me-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center; background: none; }

.search {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
}
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 16px; color: var(--text); }
.search input::placeholder { color: var(--faint); }
.search .clear { border: 0; background: none; color: var(--faint); padding: 4px; display: grid; }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 10px -12px 0 -16px; padding: 0 12px 2px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-weight: 650;
  font-size: 13.5px;
  transition: background .15s, color .15s;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.on .dot { box-shadow: 0 0 0 2px var(--bg); }
.chip .cnt { font-size: 11.5px; font-weight: 800; background: var(--c); color: #fff; border-radius: 9px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 5px; }

/* ---------------------------------------------------------------- lista razgovora */
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.threads { list-style: none; margin: 0; padding: 4px 8px calc(104px + var(--safe-bottom)); }
.trow {
  --c: var(--brand);
  display: grid;
  grid-template-columns: 50px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 10px;
  border-radius: 16px;
  cursor: pointer;
  position: relative;
  transition: background .15s;
  user-select: none;
}
.trow:hover { background: var(--surface-2); }
.trow.active { background: color-mix(in srgb, var(--c) 13%, transparent); }
.trow .txt { min-width: 0; }
.trow .top { display: flex; align-items: baseline; gap: 8px; }
.trow .name { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.trow .prev {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.32;
  margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.trow .prev .st { display: inline-flex; vertical-align: -3px; margin-right: 3px; }
.trow .prev .st.err { color: var(--danger); }
.trow.unread .name { font-weight: 800; }
.trow.unread .prev { color: var(--text-2); }
.trow .side { align-self: start; display: flex; flex-direction: column; align-items: flex-end; gap: 7px; padding-top: 3px; }
.trow .time { font-size: 12.5px; color: var(--faint); white-space: nowrap; }
.trow.unread .time { color: var(--c); font-weight: 700; }
.badge { min-width: 21px; height: 21px; padding: 0 6px; border-radius: 11px; background: var(--c); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.ltag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; color: var(--muted); white-space: nowrap; }
.ltag i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }

.av {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .01em;
  flex: none;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .12);
}
.av.sm { width: 36px; height: 36px; font-size: 14px; }
.av.lg { width: 72px; height: 72px; font-size: 26px; }
.av .ln { position: absolute; right: -2px; bottom: -2px; width: 15px; height: 15px; border-radius: 50%; background: var(--c); border: 2.5px solid var(--surface); }
@media (max-width: 899px) { .av .ln { border-color: var(--bg); } }

.fab {
  position: absolute;
  right: 18px;
  bottom: calc(18px + var(--safe-bottom));
  width: 60px; height: 60px;
  border-radius: 21px;
  border: 0;
  background: var(--brand-grad);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 12px 28px rgba(80, 70, 229, .38), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .15s, box-shadow .15s;
  z-index: 6;
}
.fab:hover { transform: translateY(-1px); }
.fab:active { transform: scale(.93); }

/* ---------------------------------------------------------------- trake (upozorenja) i uvod */
.banner {
  margin: 6px 12px 2px;
  padding: 10px 12px;
  border-radius: 14px;
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--text);
  background: color-mix(in srgb, var(--warn) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent);
}
.banner .ic { color: var(--warn); margin-top: 1px; }
.banner.err { background: color-mix(in srgb, var(--danger) 11%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 26%, transparent); }
.banner.err .ic { color: var(--danger); }
.banner.info { background: color-mix(in srgb, var(--brand) 10%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 24%, transparent); }
.banner.info .ic { color: var(--brand); }
.banner b { font-weight: 700; }
.th-banner { margin: 8px 12px 0; }
.sheet-note { display: flex; gap: 6px; align-items: flex-start; color: var(--muted); font-size: 12.5px; line-height: 1.4; margin: 8px 2px 2px; }
.sheet-note .ic { color: var(--ok); margin-top: 1px; flex: none; }
.pbcard {
  margin: 8px 12px 6px;
  padding: 12px 8px 12px 12px;
  border-radius: 18px;
  display: flex; gap: 12px; align-items: center;
  background: color-mix(in srgb, #f97316 9%, var(--surface));
  border: 1px solid color-mix(in srgb, #f97316 24%, transparent);
}
.pbcard .pbic { width: 38px; height: 38px; border-radius: 12px; background: #f97316; color: #fff; display: grid; place-items: center; flex: none; }
.pbcard .grow { flex: 1; min-width: 0; }
.pbcard b { display: block; font-size: 14.5px; }
.pbcard small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
.pbcard .x { width: 32px; height: 32px; }

.onb {
  margin: 8px 12px 6px;
  padding: 16px;
  border-radius: 20px;
  background:
    radial-gradient(420px 160px at 100% 0%, color-mix(in srgb, var(--brand-2) 18%, transparent), transparent),
    color-mix(in srgb, var(--brand) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 20%, transparent);
  position: relative;
}
.onb h4 { margin: 0 28px 4px 0; font-size: 16px; letter-spacing: -.01em; }
.onb p { margin: 0 0 10px; color: var(--muted); font-size: 13.5px; }
.onb .x { position: absolute; top: 8px; right: 8px; }
.step { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.step + .step { border-top: 1px dashed var(--border-strong); }
.step .n { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12.5px; font-weight: 800; display: grid; place-items: center; flex: none; }
.step.done .n { background: var(--ok); }
.step .t { flex: 1; font-size: 14px; font-weight: 600; }
.step .t small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.step.done .t { color: var(--muted); }

/* ---------------------------------------------------------------- prazno i kosturi */
.empty { flex: 1; display: grid; place-items: center; text-align: center; padding: 40px 28px; color: var(--muted); }
.empty .ill {
  width: 92px; height: 92px;
  border-radius: 30px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 11%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 16%, transparent);
}
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 18px; letter-spacing: -.01em; }
.empty p { margin: 0 auto; max-width: 320px; font-size: 14px; }
.skel { display: grid; grid-template-columns: 50px 1fr; gap: 12px; padding: 12px 18px; align-items: center; }
.skel .a, .skel .l1, .skel .l2 { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
.skel .a { width: 48px; height: 48px; border-radius: 50%; }
.skel .l1 { height: 13px; width: 45%; margin-bottom: 8px; }
.skel .l2 { height: 11px; width: 80%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- razgovor */
.th-head { display: flex; align-items: center; gap: 6px; min-height: 48px; }
.th-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 4px 6px; border-radius: 12px; text-align: left; }
.th-title:hover { background: var(--surface-2); }
.th-title .nm { display: block; font-size: 16.5px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-title .sub { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.th-title .sub .sep { opacity: .5; }
.th-title > div { min-width: 0; }

.msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 10px 12px 18px;
  display: flex;
  flex-direction: column;
}
.msgs .more { align-self: center; margin: 6px 0 4px; }
.day {
  align-self: center;
  margin: 16px 0 6px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  background: var(--surface-2);
  padding: 4px 11px;
  border-radius: 999px;
}
.msg { display: flex; flex-direction: column; max-width: min(80%, 560px); margin-top: 10px; }
.msg.cont { margin-top: 2px; }
.msg.in { align-self: flex-start; align-items: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.who { font-size: 11.5px; font-weight: 650; color: var(--muted); margin: 0 10px 3px; }
.bubble {
  padding: 9px 13px 9px;
  border-radius: 20px;
  font-size: 15.5px;
  line-height: 1.38;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  position: relative;
}
.msg.in .bubble { background: var(--bubble-in); color: var(--bubble-in-text); border-bottom-left-radius: 7px; }
.msg.out .bubble {
  background: var(--c);
  background-image: linear-gradient(160deg, color-mix(in srgb, var(--c) 78%, #fff) -30%, var(--c) 70%);
  color: #fff;
  border-bottom-right-radius: 7px;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--c) 22%, transparent);
}
.msg.in.cont .bubble { border-top-left-radius: 7px; }
.msg.out.cont .bubble { border-top-right-radius: 7px; }
.msg.in.more-below .bubble { border-bottom-left-radius: 7px; }
.msg.out.pending .bubble { opacity: .72; }
.msg.out.failed .bubble, .msg.out.unknown .bubble {
  background: var(--surface);
  background-image: none;
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--danger);
}
.msg.out.unknown .bubble { box-shadow: inset 0 0 0 1.5px var(--warn); }
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.msg.in .bubble a { color: var(--brand); }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 6px; font-size: 11.5px; color: var(--muted); margin: 4px 8px 0; }
.msg.out .meta { justify-content: flex-end; text-align: right; }
.meta > span, .meta > button { white-space: nowrap; }
.meta > span.why { white-space: normal; }
.meta .ic { opacity: .9; }
.meta .ok { color: var(--ok); }
.meta .err { color: var(--danger); font-weight: 650; }
.meta .unk { color: var(--warn); font-weight: 650; }
.meta button { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 700; font-size: 11.5px; }
.otp {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 0;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.otp code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .08em; }
.pop { animation: pop .26s cubic-bezier(.2, .9, .3, 1.15); }
@keyframes pop { from { transform: translateY(8px) scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }

.jump {
  position: absolute;
  right: 16px;
  bottom: calc(92px + var(--safe-bottom));
  border: 0;
  border-radius: 999px;
  padding: 8px 14px 8px 11px;
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  z-index: 6;
  animation: pop .25s;
}

.composer {
  flex: none;
  padding: 6px 10px calc(8px + var(--safe-bottom));
  background: var(--header-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 5;
}
.cmp-hint { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px 8px; font-size: 12px; color: var(--muted); padding: 2px 6px 6px; }
.cmp-hint:empty { display: none; }
.cmp-hint .grow { flex: 1; }
.cmp-hint .warn { color: var(--warn); font-weight: 650; }
.cmp-hint .err { color: var(--danger); font-weight: 700; }
.hint-chip { border: 0; background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; box-shadow: var(--shadow-sm); }
.cmp-row { display: flex; align-items: flex-end; gap: 8px; }
.cmp-box {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 0 14px;
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
.cmp-box:focus-within { border-color: color-mix(in srgb, var(--c) 60%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 13%, transparent); }
.cmp-box textarea {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
  color: var(--text);
  max-height: 160px;
  padding: 11px 0 10px;
  height: 43px;
}
.cmp-box textarea::placeholder { color: var(--faint); }
.send-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--c);
  color: #fff;
  display: grid; place-items: center;
  flex: none;
  transition: transform .15s, opacity .2s, filter .2s;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 35%, transparent);
}
.send-btn:disabled { opacity: .32; box-shadow: none; filter: grayscale(.4); }
.send-btn:not(:disabled):active { transform: scale(.9); }
.readonly-note { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: 13.5px; padding: 12px; text-align: center; }

/* ---------------------------------------------------------------- stranice (postavke, admin, nova poruka) */
.page { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px calc(28px + var(--safe-bottom)); }
.page-inner { max-width: 660px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.sec-title { font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 12px 6px -4px; display: flex; align-items: center; gap: 8px; }
.sec-title .grow { flex: 1; }
.sec-note { font-size: 12.5px; color: var(--muted); margin: -6px 6px 0; line-height: 1.4; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 54px; }
.row + .row { border-top: 1px solid var(--border); }
.row.tap { cursor: pointer; transition: background .15s; }
.row.tap:hover { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .ttl { font-weight: 650; font-size: 15px; }
.row .sub { color: var(--muted); font-size: 13px; margin-top: 1px; overflow-wrap: anywhere; }
.row .chev { color: var(--faint); }
.row .ricon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: var(--brand); flex: none; }
.profile { display: flex; align-items: center; gap: 14px; padding: 18px 16px; }
.profile .nm { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.profile .sub { color: var(--muted); font-size: 13.5px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.admin { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.tag.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.tag.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.tag.off { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: transform .22s cubic-bezier(.2, .8, .2, 1); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .5; }

.btn {
  height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  border: 0;
  font-weight: 700;
  font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .1s, filter .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }
a.btn { text-decoration: none; }
.sheet-lead { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 0 0 6px; }
/* "Aplikacija za Android": šta se instalira i šta smije (prije koraka Preuzmi / Poveži) */
.app-what { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; margin: 6px 0 8px; color: var(--text-2); font-size: 13px; line-height: 1.45; }
.app-what p { margin: 0; }
.app-what p + p { margin-top: 6px; }
.app-what b { color: var(--text); font-weight: 650; }
.btn.primary { background: var(--brand-grad); color: #fff; box-shadow: 0 8px 20px rgba(80, 70, 229, .3), inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn.soft { background: var(--surface-2); color: var(--text); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.danger { background: color-mix(in srgb, var(--danger) 11%, transparent); color: var(--danger); }
.btn.sm { height: 34px; padding: 0 12px; border-radius: 10px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn .spin { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btns { display: flex; gap: 10px; margin-top: 16px; }
.btns .btn { flex: 1; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; flex: none; }
.seg button { border: 0; background: transparent; padding: 6px 11px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--muted); transition: background .15s, color .15s; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button.on.rd { color: var(--c); }
.seg button.on.wr { background: var(--c); color: #fff; }
.bell { width: 36px; height: 36px; border-radius: 10px; border: 0; display: grid; place-items: center; background: var(--surface-2); color: var(--faint); flex: none; }
.bell.on { color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
.bell:disabled { opacity: .35; }

.ucard .uhead { display: flex; align-items: center; gap: 12px; padding: 14px 16px 10px; }
.ucard .uhead .grow { flex: 1; min-width: 0; }
.ucard .nm { font-weight: 750; font-size: 16px; }
.ucard .sub { color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 2px; }
.acc { display: flex; align-items: center; gap: 10px; padding: 8px 16px; }
.acc .grow { flex: 1; min-width: 0; }
.acc .ln { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 14.5px; }
.acc .ln i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.acc .ln span { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.acc .ln small { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ucard .sub2 { color: var(--faint); font-size: 12px; margin-top: 4px; }
.ufoot { display: flex; gap: 8px; padding: 10px 16px 14px; flex-wrap: wrap; }
.ucard.off { opacity: .6; }

.lcard .lhead { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.lcard .sw { width: 40px; height: 40px; border-radius: 12px; background: var(--c); display: grid; place-items: center; color: #fff; flex: none; box-shadow: 0 6px 14px color-mix(in srgb, var(--c) 30%, transparent); }
.lcard .lead { width: 20px; display: grid; place-items: center; color: var(--muted); flex: none; }
.mailset { border-radius: 14px; background: var(--surface-2); padding: 14px 14px 4px; margin: 4px 0 14px; }
.mailset .btn { margin: -4px 0 12px; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.sig { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.sig i { width: 3.5px; border-radius: 1.5px; background: var(--surface-3); }
.sig i:nth-child(1) { height: 30%; } .sig i:nth-child(2) { height: 52%; } .sig i:nth-child(3) { height: 75%; } .sig i:nth-child(4) { height: 100%; }
.sig i.on { background: var(--ok); }
.sig.weak i.on { background: var(--warn); }
.sdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--faint); }
.sdot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.sdot.bad { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.sdot.warn { background: var(--warn); }

.audit { font-size: 12.5px; }
.audit .row { min-height: 0; padding: 9px 16px; align-items: flex-start; }
.audit .when { color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- forme */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.field .help { font-size: 12.5px; color: var(--muted); }
.input {
  height: 50px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 0 15px;
  font: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
textarea.input { height: auto; min-height: 74px; padding: 12px 15px; line-height: 1.4; resize: vertical; }
.input.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; }
.pw { position: relative; }
.pw .input { padding-right: 48px; }
.pw button { position: absolute; right: 4px; top: 5px; }
.form-error { color: var(--danger); font-size: 14px; font-weight: 600; margin: -4px 2px 12px; }
.form-error:empty { display: none; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); margin: 2px 0 16px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; font-weight: 600; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border-strong); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25); }
.swatches button.on { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); }
.linkbox { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; overflow-wrap: anywhere; user-select: all; }

.pick { display: grid; gap: 8px; }
.pick button {
  display: flex; align-items: center; gap: 12px;
  text-align: left;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 16px;
  padding: 12px 14px;
  transition: border-color .15s, background .15s;
}
.pick button.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, var(--surface)); }
.pick .dotbig { width: 14px; height: 14px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent); }
.pick .grow { flex: 1; min-width: 0; }
.pick b { display: block; font-size: 15px; }
.pick small { color: var(--muted); font-size: 12.5px; }
.sugg { display: flex; flex-direction: column; margin-top: 4px; }
.sugg button { display: flex; align-items: center; gap: 12px; border: 0; background: none; padding: 9px 6px; border-radius: 12px; text-align: left; }
.sugg button:hover { background: var(--surface-2); }
.sugg .grow { flex: 1; min-width: 0; }
.sugg b { display: block; font-size: 14.5px; }
.sugg small { color: var(--muted); font-size: 12.5px; }

/* ---------------------------------------------------------------- prijava */
.auth {
  flex: 1;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(900px 480px at 15% -10%, color-mix(in srgb, var(--brand) 20%, transparent), transparent 70%),
    radial-gradient(700px 420px at 110% 110%, color-mix(in srgb, var(--brand-2) 16%, transparent), transparent 70%),
    var(--bg);
}
.auth-card { width: min(410px, 100%); background: var(--surface); border-radius: 28px; box-shadow: var(--shadow-lg); padding: 30px 24px 24px; border: 1px solid var(--border); }
.logo {
  width: 64px; height: 64px;
  border-radius: 20px;
  background: var(--brand-grad);
  display: grid; place-items: center;
  color: #fff;
  margin: 0 auto 16px;
  box-shadow: 0 14px 30px rgba(80, 70, 229, .38), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.logo { background: url(icon.svg) center / cover no-repeat; }
.logo.big { width: 84px; height: 84px; border-radius: 26px; }
.auth h1 { text-align: center; font-size: 25px; font-weight: 800; letter-spacing: -.025em; margin: 0 0 4px; }
.auth .lead { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 14.5px; }
.auth .foot { text-align: center; color: var(--faint); font-size: 12px; margin-top: 18px; }

/* ---------------------------------------------------------------- listovi (sheet), potvrde, obavijesti */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(8, 10, 18, .45); z-index: 50; opacity: 0; transition: opacity .22s; }
.sheet-backdrop.show { opacity: 1; }
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(560px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--sheet-bg);
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-lg);
  z-index: 51;
  padding: 6px 20px calc(20px + var(--safe-bottom));
  transform: translate(-50%, 102%);
  transition: transform .3s cubic-bezier(.2, .85, .2, 1);
}
.sheet.show { transform: translate(-50%, 0); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 6px auto 14px; }
.sheet h3 { margin: 0 0 14px; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.sheet p { color: var(--text-2); margin: 0 0 8px; line-height: 1.45; }
.sheet .confirm p { font-size: 16px; font-weight: 600; color: var(--text); margin-top: 6px; }
@media (min-width: 700px) {
  .sheet { bottom: auto; top: 50%; border-radius: 26px; transform: translate(-50%, -46%) scale(.97); opacity: 0; transition: transform .25s cubic-bezier(.2, .85, .2, 1), opacity .2s; }
  .sheet.show { transform: translate(-50%, -50%); opacity: 1; }
  .sheet .grab { visibility: hidden; margin-bottom: 4px; }
}
.list-actions { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.list-actions button { display: flex; align-items: center; gap: 12px; border: 0; background: none; padding: 12px 8px; border-radius: 12px; font-size: 15.5px; font-weight: 600; text-align: left; }
.list-actions button:hover { background: var(--surface-2); }
.list-actions button .ic { color: var(--brand); }
.list-actions button.danger, .list-actions button.danger .ic { color: var(--danger); }

#toast-root { position: fixed; left: 0; right: 0; bottom: calc(26px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 70; pointer-events: none; padding: 0 16px; }
.toast { background: var(--text); color: var(--bg); padding: 11px 17px; border-radius: 16px; font-weight: 650; font-size: 14px; box-shadow: var(--shadow-lg); max-width: min(92vw, 440px); text-align: center; animation: toastIn .28s cubic-bezier(.2, .9, .3, 1.2); }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }

.offline-pill { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--safe-top) + 6px); z-index: 20; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px; box-shadow: var(--shadow); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
