/* IG Analiza – stilovi (bez eksternih zavisnosti) */

:root {
  color-scheme: light;
  --bg: #f4f4f7;
  --surface: #ffffff;
  --surface-2: #f3f3f6;
  --surface-3: #e9e9ee;
  --border: #e3e3e9;
  --text: #15151a;
  --muted: #6a6a76;
  --accent: #d62976;
  --accent-hover: #bb1f64;
  --accent-soft: #fde8f0;
  --good: #15803d;
  --good-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(20, 20, 26, 0.05), 0 4px 16px rgba(20, 20, 26, 0.05);
  --radius: 14px;
  --series-1: #2a78d6; /* pratioci */
  --series-2: #eb6834; /* pratim */
  --grid: #e1e0d9;
  --axis: #c3c2b7;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0f0f12;
    --surface: #1c1c1f;
    --surface-2: #25252a;
    --surface-3: #2f2f35;
    --border: #2d2d34;
    --text: #f1f1f4;
    --muted: #9c9ca8;
    --accent: #ec4f88;
    --accent-hover: #f36ea0;
    --accent-soft: #3a1a29;
    --good: #4ade80;
    --good-soft: #14321f;
    --bad: #f87171;
    --bad-soft: #3b1c1c;
    --info: #7cb0ff;
    --info-soft: #1a2a4a;
    --warn: #fbbf24;
    --warn-soft: #3a2a0f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.35);
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2c2c2a;
    --axis: #383835;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f12;
  --surface: #1c1c1f;
  --surface-2: #25252a;
  --surface-3: #2f2f35;
  --border: #2d2d34;
  --text: #f1f1f4;
  --muted: #9c9ca8;
  --accent: #ec4f88;
  --accent-hover: #f36ea0;
  --accent-soft: #3a1a29;
  --good: #4ade80;
  --good-soft: #14321f;
  --bad: #f87171;
  --bad-soft: #3b1c1c;
  --info: #7cb0ff;
  --info-soft: #1a2a4a;
  --warn: #fbbf24;
  --warn-soft: #3a2a0f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.35);
  --series-1: #3987e5;
  --series-2: #d95926;
  --grid: #2c2c2a;
  --axis: #383835;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 6px; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
.h3, h3 { font-size: 16px; font-weight: 650; }
p { margin: 0 0 10px; }
code, kbd, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
kbd { background: var(--surface-3); border: 1px solid var(--border); border-bottom-width: 2px; padding: 0 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.pad { padding: 18px 20px; }
.pad-h { padding: 0 20px; }
.inline { display: inline; }
.link { font-weight: 600; }

/* ---------- raspored ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px;
  flex: 0 0 256px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  gap: 8px;
}
.main { flex: 1; min-width: 0; padding: 28px 32px 48px; max-width: 1280px; }
.menu-btn { display: none; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 750; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px;
  background: linear-gradient(135deg, #f9ce34 0%, #ee2a7b 50%, #6228d7 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}
.brand-lg { justify-content: center; font-size: 20px; padding-bottom: 20px; }
.brand-lg .brand-mark { width: 36px; height: 36px; border-radius: 11px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; color: var(--text); font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav-item .ico { width: 18px; height: 18px; flex: 0 0 18px; opacity: 0.85; }
.nav-item .count { margin-left: auto; font-size: 12px; font-weight: 650; color: var(--muted); background: var(--surface-2); padding: 1px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.nav-item.active .count { background: rgba(255, 255, 255, 0.5); color: var(--accent); }
:root[data-theme="dark"] .nav-item.active .count { background: rgba(0, 0, 0, 0.25); }
.ico { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dot-live { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.5); } 100% { box-shadow: 0 0 0 8px rgba(21, 128, 61, 0); } }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.account { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.account-text { min-width: 0; }
.account-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-sub { font-size: 12px; color: var(--muted); }
.account-invalid .account-sub { color: var(--bad); }
.sidebar-actions { display: flex; justify-content: space-between; gap: 8px; }

/* ---------- zaglavlje stranice ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.person-head { display: flex; gap: 16px; align-items: center; }

/* ---------- kartice ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-soft { background: var(--surface-2); box-shadow: none; }
.card-table { padding: 0; overflow: hidden; }
.card-table .card-head { padding: 16px 20px 6px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.empty { text-align: center; padding: 48px 24px; }
.empty h2, .empty h1 { margin-bottom: 8px; }
.empty p { max-width: 520px; margin: 0 auto 16px; }
.grid { display: grid; gap: 18px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.grid-main { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }

/* ---------- statistike ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; color: var(--text); box-shadow: var(--shadow); transition: transform 0.12s ease, border-color 0.12s ease; }
.stat:hover { text-decoration: none; transform: translateY(-1px); border-color: var(--accent); }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; margin: 2px 0; }
.stat-delta { font-size: 13px; }
.stat-accent { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.stat-selected { outline: 2px solid var(--accent); }
.delta-up { color: var(--good); font-weight: 650; }
.delta-down { color: var(--bad); font-weight: 650; }

/* ---------- obaveštenja i bedževi ---------- */
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; border: 1px solid transparent; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.alert-success { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.alert-error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 650; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-muted { background: var(--surface-3); color: var(--muted); }
.badge-warn-text { color: var(--warn); }
.verified { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--info); color: #fff; font-size: 10px; font-weight: 800; vertical-align: middle; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 10px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 6px 3px 12px; font-size: 13px; }
.chip-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.chip-x:hover { color: var(--bad); }

/* ---------- dugmad i forme ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background 0.12s ease, border-color 0.12s ease; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn .ico { width: 16px; height: 16px; }
.form { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.form .btn { align-self: flex-start; }
.field { display: flex; flex-direction: column; gap: 6px; width: 100%; font-weight: 600; font-size: 14px; }
.field .muted { font-weight: 400; }
.input { width: 100%; font: inherit; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
textarea.input { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.input-code { font-size: 22px; letter-spacing: 0.2em; text-align: center; max-width: 220px; }
.input-search { max-width: 280px; }
select.input { width: auto; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.details { margin-top: 10px; width: 100%; }
.details summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; }
.details[open] summary { margin-bottom: 10px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; }
.list-plain, .list-steps { padding-left: 20px; margin: 0; display: flex; flex-direction: column; gap: 8px; }

/* ---------- traka sa alatima ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-count { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- tabele ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; border-top: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { border-top: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: var(--surface-2); }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions-col { text-align: right; width: 1%; }
.table .actions-col form { display: inline; }
.table-compact th, .table-compact td { padding: 6px 10px; font-size: 13px; }
.card-table .table thead th:first-child { padding-left: 20px; }
.card-table .table td:first-child { padding-left: 20px; }
.card-table .table th:last-child, .card-table .table td:last-child { padding-right: 20px; }

.user-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-text { min-width: 0; }
.user-name { font-weight: 650; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.user-link { color: var(--text); }
.user-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }

/* ---------- avatar ---------- */
.avatar { position: relative; width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto; overflow: hidden; background: var(--surface-3); display: inline-grid; place-items: center; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.avatar-initials { font-size: 13px; font-weight: 700; color: var(--muted); }
.avatar-sm { width: 30px; height: 30px; }
.avatar-sm .avatar-initials { font-size: 11px; }
.avatar-lg { width: 72px; height: 72px; }
.avatar-lg .avatar-initials { font-size: 22px; }

/* ---------- događaji ---------- */
.event-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.event { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.event:first-child { border-top: 0; }
.event-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.event-text .user-link { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-text .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-time { white-space: nowrap; }
.timeline { display: flex; flex-direction: column; gap: 16px; }
.timeline-group .card-head { margin-bottom: 4px; }

/* ---------- sinhronizacija ---------- */
.progress-rows { display: flex; gap: 24px; margin-bottom: 12px; }
.progress-row { display: flex; flex-direction: column; }
.progress-row span { font-size: 13px; color: var(--muted); }
.progress-row strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.progress-bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-bottom: 12px; }
.progress-bar span { display: block; height: 100%; width: 40%; background: var(--accent); border-radius: 999px; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
.log { background: var(--surface-2); border-radius: 10px; padding: 12px; max-height: 240px; overflow: auto; font-size: 12px; margin: 0; white-space: pre-wrap; }

/* ---------- grafikon ---------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-dot { stroke: var(--surface); stroke-width: 2; }
.chart .series-label { font-size: 12px; font-weight: 650; fill: var(--text); }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.chart-legend { display: flex; gap: 18px; font-size: 13px; color: var(--muted); margin: 4px 0 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 18px; height: 0; border-top: 2px solid; border-radius: 2px; }
.chart-tooltip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 10px; padding: 8px 10px; font-size: 12px; opacity: 0; transition: opacity 0.1s; z-index: 3; min-width: 150px; }
.chart-tooltip .tt-date { color: var(--muted); margin-bottom: 4px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.chart-tooltip .tt-row i { width: 14px; height: 0; border-top: 2px solid; }
.chart-tooltip .tt-row strong { font-variant-numeric: tabular-nums; margin-left: auto; }

/* ---------- prijava ---------- */
.layout-auth { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow); }
.auth-card h1 { text-align: center; }
.auth-card > p { text-align: center; }
.auth-card .form { margin-top: 16px; }

/* ---------- profili ---------- */
.account-switch { display: flex; align-items: center; gap: 8px; padding: 0 4px 10px; }
.account-switch-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.account-switch select { flex: 1; min-width: 0; padding: 6px 8px; font-size: 14px; font-weight: 600; }
.profiles { display: flex; flex-direction: column; gap: 10px; }
.profile-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.profile-row.active { border-color: var(--accent); }
.profile-main { flex: 1; min-width: 180px; }
.profile-main strong { display: block; }
.profile-row form { display: inline; }
.profile-row .input { width: 160px; padding: 5px 8px; font-size: 13px; }

/* ---------- tempo zahteva ---------- */
.pace-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; width: 100%; }
.pace-estimate { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; width: 100%; line-height: 1.5; }
.pace-estimate strong { color: var(--text); }

/* ---------- API tokeni ---------- */
.card-wide { grid-column: 1 / -1; }
.form-row { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.form-row .field { width: auto; min-width: 240px; }
.token-reveal { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: start; margin-bottom: 18px; }
.token-reveal textarea { font-size: 13px; }
.qr { text-align: center; }
.qr svg { width: 220px; height: 220px; background: #fff; border-radius: 12px; padding: 8px; border: 1px solid var(--border); }
@media (max-width: 700px) { .token-reveal { grid-template-columns: 1fr; } }

/* ---------- tabovi ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -4px 0 18px; }
.tab { padding: 8px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { text-decoration: none; color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 20px 16px 40px; }
  .shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 20; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; position: fixed; top: 12px; left: 12px; z-index: 21; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 18px; cursor: pointer; align-items: center; justify-content: center; color: var(--text); }
  .page-head { padding-left: 52px; }
  .page-head.no-offset { padding-left: 0; }
  .user-sub { max-width: 200px; }
  .stat-value { font-size: 26px; }
  #user-table th:nth-child(2), #user-table td:nth-child(2) { display: none; }
}
@media (max-width: 560px) {
  .toolbar-count { margin-left: 0; }
  .input-search { max-width: none; }
  .progress-rows { gap: 16px; }
}
