/* Finansije — Saša Huremović, Orbilix, https://sasahuremovic.rs.
   Razmaci, tipografija i hijerarhija prate priložene principe dizajna. */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --ink: #202b3b;
  --muted: #5d6a7c;
  --blue: #2859b5;
  --line: #e1e6ed;
  --white: #fff;
  --green: #187153;
  --red: #b53140;
  --sh-soft: #edf3ff;
  --sh-radius: 12px;
  --sh-shadow: 0 2px 8px rgba(32, 43, 59, .025);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, a, input, select, textarea, summary { touch-action: manipulation; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid #6e97e4; outline-offset: 3px; }
h1, h2, h3, p { overflow-wrap: break-word; }
h1 { margin: 0; font-size: 32px; font-weight: 750; letter-spacing: -.035em; line-height: 1.2; }
h2 { margin: 0 0 16px; font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.35; }
h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
p { margin: 0 0 16px; }
small { font-size: 12px; }
.muted { color: var(--muted); }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .055em; line-height: 1.5; }
.sh-cell-note { display: block; margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inline { display: inline; }

/* Navigacija ostaje mirna kako bi podaci i glavna akcija imali prednost. */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 32px;
  height: 100vh;
  overflow-y: auto;
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 32px 16px 24px;
}
.brand {
  position: relative;
  display: block;
  min-height: 44px;
  padding: 0 8px 0 52px;
  color: var(--ink);
  font-size: 23px;
  font-weight: 750;
  letter-spacing: -.04em;
  line-height: 1.25;
}
.brand:hover { color: var(--ink); text-decoration: none; }
.brand small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .025em; white-space: nowrap; }
.sh-brand-icon { position: absolute; left: 8px; top: 2px; display: grid; place-items: center; width: 34px; height: 38px; background: var(--blue); border-radius: 9px; color: white; font-size: 23px; font-weight: 750; }
.nav { display: grid; gap: 32px; }
.sh-nav-label { margin: 0 12px 8px; color: var(--muted); font-size: 12px; font-weight: 650; }
.nav a { display: flex; align-items: center; min-height: 44px; margin: 4px 0; border-radius: 8px; padding: 8px 12px; color: #4b596d; font-weight: 500; }
.nav a:hover { background: #f4f6fa; color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--sh-soft); color: #224f9b; font-weight: 700; box-shadow: inset 3px 0 var(--blue); }
.side-bottom { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: auto; border-top: 1px solid var(--line); padding: 24px 8px 0; font-size: 12px; color: var(--muted); }
.side-bottom form { margin: 0; }
.sh-menu-toggle { display: none !important; }
.sh-skip { position: fixed; top: -100px; left: 16px; z-index: 100; border: 2px solid var(--blue); border-radius: 8px; padding: 12px 16px; background: white; }
.sh-skip:focus { top: 16px; }

/* Prvo naziv stranice i namera, zatim filteri i sadržaj. */
.main { width: 100%; max-width: 1600px; min-width: 0; margin: 0 auto; padding: 32px 40px 48px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.top .eyebrow { margin-bottom: 8px; }
.top > .btn { flex-shrink: 0; }
.top > .toolbar { margin: 0; }
.sh-page-description { max-width: 680px; margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.footer { margin-top: 40px; border-top: 1px solid var(--line); padding-top: 24px; color: var(--muted); font-size: 12px; }
.footer a { color: inherit; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.toolbar h2 { margin: 0; }
.sh-section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin: 32px 0 16px; }
.sh-section-heading h2 { margin: 0; }
.sh-section-heading p { margin: 8px 0 0; font-size: 13px; }
.sh-section-heading > a { flex-shrink: 0; font-weight: 600; }
.sh-section { margin: 32px 0 16px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.sh-overview, .sh-invoice-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sh-invoice-summary { display: grid; gap: 16px; }
.card { min-width: 0; margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--sh-radius); padding: 24px; background: var(--white); box-shadow: var(--sh-shadow); }
.grid > .card, .sh-invoice-summary > .card { margin-bottom: 0; }
.grid { margin-bottom: 24px; }
.metric { margin: 12px 0 8px; font-size: 28px; font-weight: 750; line-height: 1.2; letter-spacing: -.035em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric.small { font-size: 24px; }
.card > .muted { font-size: 13px; }

/* Jedna jasna glavna akcija, ostale su tiše. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 1px solid transparent; border-radius: 8px; padding: 10px 16px; background: var(--blue); color: white; font-size: 14px; font-weight: 650; line-height: 1.4; text-align: center; text-decoration: none; cursor: pointer; }
.btn:hover { background: #204b9d; color: white; text-decoration: none; }
.btn.secondary { border-color: #d9e0e9; background: white; color: #43546d; }
.btn.secondary:hover { border-color: #b8c8df; background: #f4f7fc; color: #234579; }
.btn.danger { border-color: transparent; background: #fff2f3; color: #a32a39; }
.btn.danger:hover { background: #fce5e8; color: #922232; }
.btn.tiny { min-height: 36px; padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: wait; }
.badge { display: inline-block; border-radius: 6px; padding: 4px 8px; background: #edf2fc; color: #3b5592; font-size: 12px; font-weight: 650; white-space: nowrap; }
.badge.red { background: #fff0f1; color: #a52f3d; }
.badge.green { background: #e9f6ef; color: #176a4e; }
.badge.orange { background: #fff4e4; color: #8b5712; }

/* Mesec i vidljivi filteri ostaju povezani u jednu grupu. */
.sh-filters { gap: 8px; padding: 12px 16px; box-shadow: none; }
.sh-filters label { margin: 0 8px 0 0; font-size: 13px; }
.sh-filters input[type=month] { width: 176px; font-weight: 600; }
.sh-filters .btn[aria-label] { width: 44px; padding-left: 8px; padding-right: 8px; }
.sh-filters > a:last-child:not(.btn) { margin-left: auto; font-size: 13px; font-weight: 600; }
.sh-tabs { gap: 8px; margin-bottom: 16px; }
.sh-tabs .btn { min-height: 40px; }
.sh-tabs [aria-current=true] { box-shadow: none; }
.sh-month-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 16px 0 24px; }
.sh-month-actions p { margin: 0; }

/* Kratki obrasci imaju jedan smer čitanja i dovoljno prostora za svako polje. */
.sh-form-title { max-width: 680px; margin-bottom: 24px; }
.sh-form-title > a { display: inline-block; margin-bottom: 24px; font-size: 13px; font-weight: 600; }
.sh-form-title h2 { margin: 0 0 8px; font-size: 24px; }
.sh-form-title p { margin: 0; font-size: 13px; }
form.card:has(> .form-grid) { max-width: 680px; padding: 32px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.form-grid .wide, .form-grid .full { grid-column: 1 / -1; min-width: 0; }
.form-grid > .full:last-child:has(> .btn) { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); padding-top: 24px; }
.field { min-width: 0; }
label { display: block; margin-bottom: 8px; color: #435066; font-size: 13px; font-weight: 650; }
input, select, textarea { max-width: 100%; min-height: 44px; border: 1px solid #c7d0dd; border-radius: 8px; padding: 10px 12px; background: white; color: var(--ink); font-size: 14px; line-height: 1.5; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #6d7989; opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: #99abc3; }
input:focus, select:focus, textarea:focus { border-color: #4a78c8; outline: 3px solid #dce8fb; outline-offset: 0; }
.field input, .field select, .field textarea { width: 100%; }
.field > small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.6; }
input[type=checkbox], input[type=radio] { flex-shrink: 0; width: 20px; min-height: 20px; height: 20px; padding: 0; accent-color: var(--blue); cursor: pointer; }
.check { display: flex; align-items: flex-start; gap: 12px; padding-top: 0; }
.check input { margin: 0; }
.check label { margin: 0; font-size: 14px; font-weight: 500; cursor: pointer; }
.sh-details { border-top: 1px solid var(--line); padding-top: 16px; }
.sh-details > summary { padding: 8px 0; color: #4a5b75; font-size: 13px; font-weight: 600; cursor: pointer; }
.sh-details > .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-top: 24px; }
.sh-details .check { grid-column: 1 / -1; }
.sh-details p { margin: 0; }
.sh-details[open] > summary { color: var(--blue); }
.alert { margin-bottom: 24px; border: 1px solid #cbe7d9; border-radius: 8px; padding: 16px; background: #edf8f2; color: #216347; }
.alert-danger { border-color: #f2d0d5; background: #fff1f2; color: #a12e3c; }

/* Godišnji plan ističe jedan jasan mesečni iznos. */
.sh-annual-hero { margin-bottom: 24px; border: 1px solid #d4e1f6; border-radius: var(--sh-radius); padding: 32px; background: #edf3ff; }
.sh-annual-hero .eyebrow { color: #405e8c; font-size: 14px; }
.sh-annual-number { margin: 12px 0; color: #204e9e; font-size: clamp(32px, 3.6vw, 48px); font-weight: 750; letter-spacing: -.04em; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sh-annual-hero p { margin: 0; color: #4c6180; font-size: 14px; }
.sh-formula { display: inline-block; margin-top: 24px; border-top: 1px solid #cfddf1; padding-top: 16px; color: #50627d; font-size: 13px; }
.sh-reserve-banner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 24px; margin-bottom: 32px; border: 1px solid #d9e4f5; border-radius: var(--sh-radius); padding: 24px; background: #f0f5fe; }
.sh-reserve-banner h2 { margin: 8px 0; color: #254b84; font-size: 24px; font-variant-numeric: tabular-nums; }
.sh-reserve-banner h2 small { margin-left: 6px; font-size: 14px; font-weight: 500; color: #526682; }
.sh-reserve-banner p { margin: 0; color: #586b86; font-size: 13px; }
.sh-reserve-banner > .btn { flex-shrink: 0; }
.sh-live-saving { display: grid; gap: 8px; border: 1px solid #d8e4f6; border-radius: 8px; padding: 24px; background: #f0f5fe; }
.sh-live-saving > span { color: #4e6382; font-size: 13px; }
.sh-live-saving > strong { color: #24549e; font-size: 28px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.sh-live-saving > small { color: #566b89; line-height: 1.5; }

/* Tabela sme da se pomera unutar svog okvira, nikada cela stranica. */
.table-wrap { overflow: auto; overscroll-behavior-x: contain; padding: 0 16px 8px; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; z-index: 1; border-bottom: 1px solid var(--line); padding: 16px 12px; background: white; color: #607087; font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; }
td { border-bottom: 1px solid #edf0f4; padding: 16px 12px; color: #435166; vertical-align: middle; }
td strong { color: var(--ink); font-weight: 650; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
td.num { color: var(--ink); }
.actions { text-align: right; white-space: nowrap; }
.actions form { display: inline; margin-right: 6px; }
.actions > .btn, .actions > form { vertical-align: top; }
.sh-table-search { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.sh-table-search label { margin: 0; color: var(--muted); font-size: 12px; }
.sh-table-search input { width: 240px; min-height: 40px; }
.sh-table-search span { font-size: 12px; }
.sh-row-menu { display: inline-block; margin-left: 8px; max-width: 240px; text-align: left; white-space: normal; vertical-align: top; }
.sh-row-menu > summary { display: flex; align-items: center; justify-content: center; min-height: 36px; border: 1px solid #d9e0e9; border-radius: 8px; padding: 6px 12px; background: white; color: #43546d; font-size: 12px; font-weight: 600; cursor: pointer; list-style: none; }
.sh-row-menu > summary::-webkit-details-marker { display: none; }
.sh-row-menu > summary::after { content: '⌄'; margin-left: 8px; }
.sh-row-menu[open] > summary { background: #f2f5fa; }
.sh-row-menu > :not(summary) { margin-top: 8px; }
.sh-row-menu form { display: block; }
.sh-row-menu .btn { width: 100%; justify-content: flex-start; white-space: normal; text-align: left; }
.empty { padding: 40px 24px; color: var(--muted); text-align: center; }
.empty h2 { color: var(--ink); }
.empty p { max-width: 600px; margin: 12px auto; line-height: 1.7; }
.sh-empty-help { display: block; margin-top: 16px; }
.bar { height: 8px; overflow: hidden; border-radius: 8px; background: #e7edf5; }
.bar span { display: block; height: 100%; background: var(--blue); }
.search-field { position: relative; }
.search-results { position: absolute; z-index: 20; left: 0; right: 0; max-height: 260px; overflow: auto; margin-top: 8px; border: 1px solid #c9d4e4; border-radius: 8px; background: white; box-shadow: 0 8px 24px #243d651a; }
.search-results:empty { display: none; }
.search-option { display: block; width: 100%; min-height: 44px; border: 0; padding: 12px; background: white; color: var(--ink); text-align: left; font: inherit; cursor: pointer; }
.search-option:hover, .search-option:focus, .search-option[aria-selected=true] { background: var(--sh-soft); color: #214f9c; }
.search-empty { padding: 16px; color: var(--muted); font-size: 13px; }
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login .card { width: min(100%, 440px); padding: 32px; }
.login h1 { margin: 8px 0 12px; }
.login input { width: 100%; margin-bottom: 24px; }
.login .muted { margin-bottom: 24px; }

@media (max-width: 1200px) {
  .main { padding: 32px 24px 40px; }
  .metric { font-size: 24px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sh-overview .eyebrow { font-size: 12px; }
}
@media (max-width: 1000px) {
  .shell { grid-template-columns: 208px minmax(0, 1fr); }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .brand { font-size: 21px; padding-left: 48px; }
  .brand small { font-size: 9px; }
  .top { align-items: flex-start; }
  .top > .btn { margin-top: 8px; }
  .sh-overview, .grid.sh-overview, .sh-invoice-summary { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .sh-overview > .card, .sh-invoice-summary > .card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 4px 16px; padding: 20px 24px; }
  .sh-overview .metric, .sh-invoice-summary .metric { grid-column: 2; grid-row: 1 / span 2; margin: 0; text-align: right; }
  .sh-overview .muted, .sh-invoice-summary .muted { grid-column: 1; }
}
@media (max-width: 700px) {
  body { font-size: 14px; }
  .shell { display: block; }
  .sidebar { position: static; display: flex; flex-direction: row; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; height: auto; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; }
  .brand { min-height: 44px; padding: 0 0 0 48px; font-size: 22px; }
  .brand small { margin-top: 4px; font-size: 10px; }
  .sh-brand-icon { left: 0; }
  .sh-menu-toggle { display: inline-flex !important; }
  .nav, .side-bottom { display: none; }
  .sh-menu-open .nav { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
  .sh-nav-label { margin-left: 12px; font-size: 12px; }
  .nav a { margin: 4px 0; font-size: 13px; }
  .sh-menu-open .side-bottom { display: flex; justify-content: space-between; width: 100%; margin-top: 0; padding: 16px 0 0; }
  .main { padding: 24px 16px 32px; }
  .top { align-items: flex-start; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
  .top > div { width: 100%; }
  .top > .btn { margin: 0; }
  .top .eyebrow { margin-bottom: 8px; font-size: 12px; }
  h1 { font-size: 28px; }
  h2 { font-size: 20px; }
  .sh-page-description { font-size: 14px; }
  .card { padding: 24px; }
  .grid, .grid.two { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .grid.sh-overview { grid-template-columns: minmax(0, 1fr); }
  .metric { font-size: 26px; }
  .sh-overview > .card, .sh-invoice-summary > .card { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 24px; }
  .sh-overview .metric, .sh-invoice-summary .metric { grid-column: auto; grid-row: auto; text-align: left; }
  .sh-overview .muted, .sh-invoice-summary .muted { grid-column: auto; }
  .btn, .btn.tiny, .sh-tabs .btn, .sh-row-menu > summary { min-height: 44px; }
  .btn.tiny { padding: 10px 12px; font-size: 13px; }
  .sh-filters { gap: 8px; padding: 12px; }
  .sh-filters label { width: 100%; margin: 0; }
  .sh-filters input[type=month] { flex: 1; width: 128px; min-width: 0; }
  .sh-filters > button { width: 100%; }
  .sh-filters > a:last-child:not(.btn) { margin-left: 0; padding: 8px 0; }
  .sh-tabs .btn { flex: 1 1 auto; padding: 10px 12px; text-align: center; }
  .sh-section-heading { align-items: flex-start; margin-top: 32px; }
  .sh-section-heading p { font-size: 13px; }
  .sh-reserve-banner { gap: 16px; padding: 24px; }
  .sh-reserve-banner h2 { font-size: 26px; }
  .sh-reserve-banner h2 small { display: block; margin-top: 8px; }
  .sh-reserve-banner > .btn { width: 100%; }
  .sh-annual-hero { padding: 24px; }
  .sh-annual-number { font-size: 36px; }
  .sh-formula { margin-top: 24px; }
  .sh-form-title { margin-bottom: 24px; }
  .sh-form-title > a { margin-bottom: 24px; }
  .sh-form-title h2 { font-size: 24px; }
  form.card:has(> .form-grid) { padding: 24px; }
  .form-grid, .sh-details > .form-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  input, select, textarea { font-size: 16px; }
  .form-grid > .full:last-child:has(> .btn) > .btn { flex: 1; }
  .sh-live-saving { padding: 16px; }
  .sh-live-saving > strong { font-size: 28px; }
  .table-wrap { padding: 0 8px 8px; }
  th, td { padding-left: 12px; padding-right: 12px; }
  .sh-table-search { padding: 16px 8px; gap: 8px; }
  .sh-table-search label { width: 100%; }
  .sh-table-search input { width: 100%; }
  .empty { padding: 32px 24px; }
  .footer { margin-top: 32px; padding-top: 24px; font-size: 12px; }
  .login { padding: 16px; }
  .login .card { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Zbir je deo iste tabele i prati izabrani prikaz. */
.sh-table-totals th, .sh-table-totals td {
  position: static;
  border-top: 1px solid #cad7ea;
  border-bottom: 0;
  padding: 16px 12px;
  background: #edf3ff;
  color: #203f70;
  font-size: 13px;
  font-weight: 700;
}
.sh-table-totals th { white-space: normal; min-width: 160px; }
.sh-table-totals small { font-weight: 500; color: var(--muted); }
.sh-table-totals tr + tr th, .sh-table-totals tr + tr td { border-top: 1px solid #dce5f2; }

/* Procena pokrića godišnjeg troška. */
.sh-funding-status { min-width: 180px; max-width: 240px; }
.sh-funding-status .badge { white-space: normal; }
.sh-funding-status .sh-cell-note { line-height: 1.5; }

/* Kategorija prati filtere mesečnog pregleda. */
.sh-category-filter { align-items: flex-end; margin-bottom: 24px; }
.sh-category-filter .field { width: min(100%, 300px); }
.sh-category-help { margin: -8px 0 0; font-size: 12px; }
.sh-category-badge { font-weight: 500; }
@media (max-width: 700px) {
  .sh-category-filter .field { width: 100%; }
  .sh-category-filter > .btn { width: 100%; }
}
