/* Evidencija – custom stylesheet (no framework) */

:root {
  --brand: #C33538;
  --brand-dark: #9f2a2f;
  --brand-soft: #fbeaea;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e3e6ea;
  --border-strong: #cfd4da;
  --success: #1f7a4d;
  --success-soft: #e6f4ec;
  --danger: #c33538;
  --danger-soft: #fbeaea;
  --warning: #b7791f;
  --warning-soft: #fdf3e1;
  --info: #2b5fb3;
  --info-soft: #e8eef9;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.15);
  --sidebar-w: 250px;
  --topbar-h: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
p { margin: 0 0 .75rem; }
img { max-width: 100%; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; vertical-align: -4px; }
.icon-sm { width: 15px; height: 15px; vertical-align: -3px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.app-main { display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; padding: 24px; max-width: 1280px; width: 100%; }
.app-footer { padding: 12px 24px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); padding: 0 16px; border-bottom: 1px solid var(--border); }
.brand-link { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; }
.brand-link:hover { text-decoration: none; }
.brand-icon { width: 30px; height: 30px; }
.sidebar .sidebar-close { display: none; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-group-title { padding: 4px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 500;
}
.nav-link:hover { background: var(--bg); text-decoration: none; }
.nav-item.is-active > .nav-link { background: var(--brand-soft); color: var(--brand-dark); box-shadow: inset 3px 0 0 var(--brand); }
.nav-icon { color: var(--muted); }
.nav-item.is-active .nav-icon { color: var(--brand); }
.nav-sub { list-style: none; margin: 2px 0 4px; padding: 0 0 0 30px; display: none; }
.nav-item.is-active .nav-sub { display: block; }
.nav-sublink { display: block; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--muted); }
.nav-sublink:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.nav-sublink.is-active { color: var(--brand-dark); font-weight: 600; }
.sidebar-footer { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); }
.sidebar-user { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px; border-radius: var(--radius-sm); color: var(--text); }
.sidebar-user:hover, .sidebar-user.is-active { background: var(--bg); text-decoration: none; }
.sidebar-user-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--muted); }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 24px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.topbar .topbar-menu { display: none; }
.topbar-title { font-size: 18px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user-name { font-weight: 500; }
.nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }

/* Avatar */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 13px; position: relative; flex: 0 0 auto;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.is-online::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--success); border: 2px solid #fff; }

/* Dropdown (details) */
.dropdown { position: relative; }
.dropdown-toggle { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 6px; border-radius: var(--radius-sm); }
.dropdown-toggle::-webkit-details-marker { display: none; }
.dropdown-toggle:hover { background: var(--bg); }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 6px; z-index: 50;
}
.dropdown-header { display: flex; flex-direction: column; padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dropdown-header small { color: var(--muted); }
.dropdown-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border: 0; background: none; border-radius: var(--radius-sm);
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.dropdown-item:hover { background: var(--bg); text-decoration: none; }

/* ---------- Page ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { font-size: 20px; }
.page-lead { color: var(--muted); margin: 2px 0 0; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-narrow { max-width: 640px; }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 15px; }
.card-body { padding: 18px; }
.card > .form { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); }
.card-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.filter-bar { row-gap: 10px; }

/* KPI tiles */
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi--success { border-left: 4px solid var(--success); }
.kpi--success .kpi-value { color: var(--success); }
.kpi--danger { border-left: 4px solid var(--danger); }
.kpi--danger .kpi-value { color: var(--danger); }
.kpi--warning { border-left: 4px solid var(--warning); }
.kpi--warning .kpi-value { color: var(--warning); }
.kpi-row--compact .kpi { padding: 10px 12px; }
.kpi-row--compact .kpi-value { font-size: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 500; line-height: 1.2; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 6px; }
.btn-icon .icon { width: 18px; height: 18px; }
.btn-block { width: 100%; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.badge-sm { font-size: 10px; padding: 1px 6px; vertical-align: middle; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

/* ---------- Forms ---------- */
.form-field { margin-bottom: 16px; }
.form-field > label { display: block; font-weight: 600; margin-bottom: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 18px; }
.form-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.form-inline > span { color: var(--muted); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(195,53,56,.15); }
.input[readonly], .input:disabled { background: var(--bg); color: var(--muted); }
.input-sm, .select-sm { padding: 5px 8px; font-size: 13px; }
.form-inline .input, .form-inline .select { width: auto; }
.input-group { display: flex; gap: 6px; }
.input-group .input { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.error { font-size: 12px; color: var(--danger); margin-top: 4px; font-weight: 500; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }
.form-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.form-actions--full { grid-column: 1 / -1; }
.search-box { display: inline-flex; align-items: center; gap: 6px; }
.search-box .icon { color: var(--muted); }
.search-box .input { width: 220px; }

.checkbox { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--brand); }
.checkbox.is-disabled { color: var(--muted); cursor: not-allowed; }
.checkbox-list { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.perm-group + .perm-group { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.perm-group-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.perm-page { margin-bottom: 10px; }
.perm-page-title { font-weight: 600; margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.perm-group--super { background: var(--warning-soft); padding: 12px; border-radius: var(--radius-sm); border-top: 0 !important; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 40px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: 0 0 auto; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .switch-track { background: var(--success); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--info); outline-offset: 2px; }

.range-row { display: flex; align-items: center; gap: 14px; }
.range { flex: 1; accent-color: var(--brand); }
.range-output { font-weight: 600; min-width: 190px; font-variant-numeric: tabular-nums; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid; margin: 8px 0 16px; }
.alert-info { background: var(--info-soft); border-color: #c6d5f2; color: #1f3f78; }

.copy-field { display: flex; gap: 4px; align-items: center; max-width: 420px; }
.copy-field .input { font-family: var(--mono); font-size: 12px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { position: sticky; top: 0; background: var(--bg); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; z-index: 1; }
.table tbody tr:hover { background: #fafbfc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .actions form { display: inline; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--text); }
.table th[data-sort]::after { content: " ↕"; opacity: .35; }
.table th[data-sort].sort-asc::after { content: " ↑"; opacity: 1; color: var(--brand); }
.table th[data-sort].sort-desc::after { content: " ↓"; opacity: 1; color: var(--brand); }
.row-expense td, .row-expense th.sticky-col { background: var(--danger-soft) !important; }
.row-inactive { opacity: .6; }
.empty-state { text-align: center; color: var(--muted); padding: 28px !important; }
.user-cell { display: inline-flex; align-items: center; gap: 8px; }
.table-compact th, .table-compact td { padding: 6px 8px; font-size: 13px; }
.table-log .log-message { min-width: 320px; }

.table-matrix th.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 2; min-width: 150px; font-weight: 600; text-align: left; }
.table-matrix thead th.sticky-col { z-index: 3; background: var(--bg); }
.table-matrix td { white-space: nowrap; }
.table-matrix .cell-paid { color: var(--text); }
.table-matrix .cell-empty { background: repeating-linear-gradient(135deg, transparent, transparent 4px, rgba(0,0,0,.025) 4px, rgba(0,0,0,.025) 8px); }
.table-matrix .cell-total { font-weight: 700; background: var(--bg); }
.table-matrix th.is-current { color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.page-link { padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 13px; }
.page-link:hover { background: var(--bg); text-decoration: none; }
.page-link.is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-link.is-disabled { opacity: .4; pointer-events: none; }
.page-gap { padding: 0 4px; color: var(--muted); }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(520px, calc(100% - 28px)); pointer-events: none; }
.toast { pointer-events: auto; padding: 11px 16px; border-radius: var(--radius-sm); background: var(--text); color: #fff; box-shadow: var(--shadow-lg); font-weight: 500; border-left: 4px solid var(--info); cursor: pointer; animation: toast-in .2s ease-out; word-break: break-word; }
.toast--success { border-left-color: #4ade80; }
.toast--danger { border-left-color: #f87171; }
.toast--warning { border-left-color: #fbbf24; }
.toast--info { border-left-color: #60a5fa; }
.toast.is-hiding { opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Confirm dialog ---------- */
.confirm { border: 0; border-radius: var(--radius); padding: 0; box-shadow: var(--shadow-lg); max-width: min(440px, calc(100% - 32px)); width: 100%; }
.confirm::backdrop { background: rgba(0,0,0,.45); }
.confirm-inner { padding: 20px 22px; margin: 0; }
.confirm-title { font-size: 16px; margin-bottom: 8px; }
.confirm-body { color: var(--muted); margin-bottom: 18px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Auth ---------- */
.auth-body { background: var(--bg); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.auth-logo { text-align: center; margin-bottom: 18px; }
.auth-logo img { height: 56px; }
.auth-title { font-size: 20px; text-align: center; }
.auth-lead { text-align: center; color: var(--muted); margin-bottom: 18px; }
.auth-footer { margin-top: 16px; color: var(--muted); font-size: 12px; }

/* ---------- Error page ---------- */
.error-page { text-align: center; padding: 40px 20px; }
.error-code { font-size: 64px; font-weight: 800; color: var(--brand); line-height: 1; margin-bottom: 8px; }
.error-page h2 { margin-bottom: 8px; }
.error-page p { color: var(--muted); }

/* ---------- Month grid ---------- */
.month-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.month-cell { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 6px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.month-name { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.month-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.month-cell.is-paid { background: var(--success-soft); border-color: #bfe3cd; color: var(--success); }
.month-cell.is-empty .month-amount { color: var(--muted); }
.month-cell.is-current { box-shadow: 0 0 0 2px var(--brand); }
.year-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.year-tab { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.year-tab:hover { background: var(--bg); text-decoration: none; }
.year-tab.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .form-two-col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; width: min(var(--sidebar-w), 85vw); transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.nav-open .nav-overlay { display: block; }
  .sidebar .sidebar-close { display: inline-flex; }
  .topbar .topbar-menu { display: inline-flex; }
  .topbar { padding: 0 14px; }
  .content { padding: 16px 14px; }
  .topbar-user-name { display: none; }
  .kpi-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .search-box .input { width: 160px; }
  .month-grid { grid-template-columns: repeat(4, 1fr); }
  .range-row { flex-direction: column; align-items: stretch; }
  .range-output { min-width: 0; }
}
@media (max-width: 480px) {
  .month-grid { grid-template-columns: repeat(3, 1fr); }
  .page-title { font-size: 18px; }
}
