:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #dde1e6;
  --text: #1c2430;
  --text-dim: #64748b;
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --locked-bg: #e0e7ff;
  --locked: #3730a3;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--primary-dark);
  color: white;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar .brand { font-weight: 600; font-size: 16px; }
.topbar .brand small { font-weight: 400; opacity: 0.8; margin-left: 8px; }
.topbar nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.topbar nav a { color: white; opacity: 0.85; }
.topbar nav a.active { opacity: 1; font-weight: 600; border-bottom: 2px solid white; }
.topbar form { margin: 0; }
.topbar button.link-btn {
  background: none; border: none; color: white; opacity: 0.85; cursor: pointer;
  font-size: 14px; padding: 0;
}
.topbar button.link-btn:hover { opacity: 1; text-decoration: underline; }

.container { max-width: 1400px; margin: 0 auto; padding: 20px; }
.container.narrow { max-width: 560px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.subtitle { color: var(--text-dim); margin-bottom: 20px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.draft { background: var(--warn-bg); color: var(--warn); }
.badge.locked { background: var(--locked-bg); color: var(--locked); }
.badge.finished { background: var(--ok-bg); color: var(--ok); }

table { border-collapse: collapse; width: 100%; }
table.data th, table.data td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
table.data th { background: #f8f9fb; font-weight: 600; font-size: 12.5px; color: var(--text-dim); position: sticky; top: 0; z-index: 2; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* vertical rule where one column group ends and the next begins
   (Ugovoreno | Već izvedeno | Ova situacija | Ukupno izvedeno | Za naplatiti) */
table.data th.grp, table.data td.grp { border-left: 2px solid #c9d2e0; }
/* title row of an item that has several measured lines - no shading, it is
   a plain heading, not a subtotal */
table.data tr.group-row td { font-weight: 600; padding-top: 10px; }
table.data tr.trade-row td {
  background: var(--primary-dark);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.03em;
  padding-top: 9px;
  padding-bottom: 9px;
}
/* closing subtotal of a work group, shown after its last item */
table.data tr.trade-total-row td {
  background: #dde5f3;
  font-weight: 700;
  border-top: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  padding-top: 8px;
  padding-bottom: 8px;
}
table.data tr.total-row td { background: #f0f4ff; font-weight: 700; border-top: 2px solid var(--border); }

/* The situacija table: fourteen columns of figures, so it is set tighter than
   the rest - smaller type, fixed widths, and the group headings centred over
   the columns they cover instead of hanging off their left edge. */
/* the fixed columns add up to 978 px; the description keeps at least 300 of
   its own, and on a narrow screen the wrapper scrolls instead of squeezing it
   down to nothing */
table.data.situacija { table-layout: fixed; min-width: 1280px; }
table.data.situacija th, table.data.situacija td { padding: 5px 7px; }
table.data.situacija thead th { text-align: center; vertical-align: middle; }
table.data.situacija thead tr:first-child th[colspan] { letter-spacing: .02em; }
table.data.situacija td.num, table.data.situacija th.num { text-align: right; }
/* opis takes what is left; everything else is measured to its content */
table.data.situacija col.c-opis { width: auto; }
table.data.situacija col.c-mjera { width: 46px; }
table.data.situacija col.c-broj { width: 76px; }
table.data.situacija col.c-novac { width: 92px; }
/* the column quantities are typed into: the box fills it, so a fixed
   layout cannot leave the input hanging over the cell next to it */
table.data.situacija col.c-unos { width: 104px; }
table.data.situacija .qty-input { width: 100%; box-sizing: border-box; }
table.data.situacija tr.trade-row td { font-size: 11px; padding-top: 6px; padding-bottom: 6px; }
table.data.situacija tr.trade-total-row td,
table.data.situacija tr.total-row td { padding-top: 5px; padding-bottom: 5px; }

.qty-input {
  width: 90px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.qty-input:disabled { background: #f4f5f7; color: var(--text-dim); }
.qty-input.err { border-color: var(--danger); background: var(--danger-bg); }

/* pre-wrap lives on the text elements, not the cell: on the cell it would
   also render the template's own indentation and push the content down */
.opis-cell { max-width: 480px; min-width: 280px; line-height: 1.45; }
/* a quantity the admin replaced during review: struck through in red, with
   the accepted figure below it */
.kolicina-korigirana { color: var(--danger); text-decoration: line-through; }
.kolicina-priznata { font-weight: 700; }
/* Item title sits above its description; the number stays with the title.
   Only the number is bold - the text of the item reads as plain text, the way
   it does in the troškovnik itself. */
.stavka-naslov { margin-bottom: 2px; white-space: pre-wrap; }
.stavka-opis { color: var(--text-dim); font-size: 12.5px; white-space: pre-wrap; }
.stavka-jedna { white-space: pre-wrap; }
.broj { font-weight: 700; color: var(--text); margin-right: 5px; }
/* the heading row of an item split over several lines: number bold, name not */
table.data tr.group-row td { font-weight: 400; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.btn:hover { background: #f4f5f7; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn.danger:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }

.actions-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 0;
  flex-wrap: wrap;
}

/* back to the top of a page that scrolls - sits in the corner, and only once
   there is enough page behind it to be worth the trip */
.na-vrh {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: none;
  box-shadow: 0 3px 12px rgba(15, 23, 42, .28);
  z-index: 60;
}
.na-vrh.vidljiv { display: block; }
.na-vrh:hover { background: var(--primary-dark); }

.toast {
  position: fixed;
  /* clear of the „back to top” button in the same corner */
  bottom: 76px;
  right: 20px;
  background: var(--text);
  color: white;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  z-index: 50;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.stat .value { font-size: 20px; font-weight: 700; margin-top: 4px; }

form.inline { display: inline; }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 6px 14px;
  margin-top: 4px;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 400;
  margin: 0;
  font-size: 13.5px;
  cursor: pointer;
}
.checkbox-item input { width: auto; margin: 0; }

.reorder-list { list-style: none; margin: 10px 0 0; padding: 0; max-width: 640px; }
.reorder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  margin-bottom: 6px;
  cursor: grab;
  user-select: none;
}
.reorder-item:hover { border-color: var(--primary); }
.reorder-item.dragging { opacity: 0.45; cursor: grabbing; }
.reorder-item.drop-target { border-color: var(--primary); box-shadow: inset 0 2px 0 var(--primary); }
.drag-handle { color: var(--text-dim); font-size: 15px; letter-spacing: -1px; }
.reorder-broj { color: var(--text-dim); min-width: 26px; font-variant-numeric: tabular-nums; }
.reorder-naziv { font-weight: 600; flex: 1; }

.tag {
  display: inline-block;
  background: #e8edf6;
  color: var(--primary-dark);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 600;
  margin-right: 4px;
  white-space: nowrap;
}

input[type=text], input[type=password], input[type=number] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
}
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 13px; }
.field-hint { color: var(--text-dim); font-size: 12px; margin-top: 3px; }

.error-box { background: var(--danger-bg); color: var(--danger); padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 13.5px; }
.ok-box { background: var(--ok-bg); color: var(--ok); padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 13.5px; }

.login-shell { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: 380px; }
.login-card h1 { text-align: center; }
.login-card .subtitle { text-align: center; }
.login-card button { width: 100%; margin-top: 16px; }

table.simple th, table.simple td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
table.simple th { color: var(--text-dim); font-size: 12.5px; }

.legend { display: flex; gap: 18px; margin-bottom: 16px; font-size: 12.5px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.dot-baseline { background: #16a34a; }
.dot-ova { background: #2563eb; }
.dot-preostalo { background: #d7dbe2; }
.dot-over { background: #dc2626; }

.progress-row {
  display: grid;
  grid-template-columns: minmax(140px, 240px) minmax(90px, 1fr) minmax(90px, 140px) 44px;
  gap: 10px 14px;
  align-items: center;
  margin-bottom: 8px;
}
.progress-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

@media (max-width: 640px) {
  .progress-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "label pct" "bar bar" "value value";
    row-gap: 4px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
  }
  .progress-label { grid-area: label; white-space: normal; }
  .progress-pct { grid-area: pct; }
  .progress-row > div:nth-child(2) { grid-area: bar; }
  .progress-value { grid-area: value; text-align: left; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  table.data th, table.data td { font-size: 12px; padding: 5px 6px; }
}
.progress-label a { color: var(--text); }
.progress-bar-track {
  display: flex;
  height: 20px;
  border-radius: 4px;
  overflow: hidden;
  background: #eef0f3;
  border: 1px solid var(--border);
}
.progress-bar-track .seg-baseline { background: #16a34a; height: 100%; }
.progress-bar-track .seg-ova { background: #2563eb; height: 100%; }
.progress-bar-track .seg-preostalo { background: transparent; height: 100%; }
.progress-bar-track.over .seg-baseline { background: #dc2626; }
.progress-bar-track.over .seg-ova { background: #f59e0b; }
.progress-value { font-size: 12px; color: var(--text-dim); text-align: right; white-space: nowrap; }
.progress-pct { font-size: 12px; font-weight: 700; text-align: right; }
.over-badge { color: #dc2626; font-weight: 700; font-size: 11.5px; }

.big-bar-track {
  display: flex;
  height: 34px;
  border-radius: 6px;
  overflow: hidden;
  background: #eef0f3;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.big-bar-track .seg-baseline { background: #16a34a; }
.big-bar-track .seg-ova { background: #2563eb; }
.big-bar-track .seg-preostalo { background: transparent; }
.big-bar-track span { display: flex; align-items: center; justify-content: center; color: white; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; }

/* Printing, and „save as PDF” which is the same thing: the tables here are
   wide - a situacija has fourteen columns - so the page is landscape A4 with
   ordinary margins, and everything is squeezed to the width of one page
   rather than spilling onto a second sheet nobody can line up with the first. */
@page {
  size: A4 landscape;
  margin: 12mm;
}

/* The cover is a form, not a table: it belongs on an upright sheet, and it has
   to be one sheet. It is set small enough to fit a landscape page too, for a
   browser that ignores named pages. */
@page naslovnica {
  size: A4 portrait;
  margin: 10mm 12mm;
}

/* the closing page of a printed situacija: on screen it is not there at all,
   unless it is opened for a look before printing */
.samo-ispis { display: none; }
.samo-ispis.prikazan { display: block; }
.samo-ispis.prikazan .pregled-natpis {
  display: block;
  margin: -4px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.pregled-natpis { display: none; }
.potpisi { display: flex; gap: 18mm; margin-top: 14mm; font-size: 9pt; }
.potpisi .crta { display: block; width: 62mm; border-bottom: 1px solid #333; margin-bottom: 2mm; }
.rekapitulacija-tablica { max-width: 120mm; }
.rekapitulacija-tablica td { font-size: 10pt; padding: 3px 8px; }
.rekapitulacija-tablica tr.total-row td { font-weight: 700; font-size: 11pt; }
/* the per-group recapitulation is a short table, so it may keep its width */
table.rekap-grupe { min-width: 0; width: 100%; margin-bottom: 6mm; }
table.rekap-grupe tr.trade-row td { font-weight: 700; }

/* The cover sheet. Unlike the recapitulation it opens the document rather than
   closing it, so it breaks after itself, not before - otherwise the print
   starts on a blank sheet. The page is landscape (the tables behind it are
   fourteen columns wide), so the cover keeps to the middle of it. */
.naslovnica-ispis { max-width: 180mm; margin: 0 auto; page: naslovnica; }
/* three signatures across the cover: fixed 62 mm lines add up to more than the
   page is wide, so here they share whatever width there is */
.naslovnica-ispis .potpisi { gap: 6mm; justify-content: space-between; }
.naslovnica-ispis .potpisi > div { flex: 1 1 0; min-width: 0; }
.naslovnica-ispis .potpisi .crta { width: auto; }
.naslovnica-zaglavlje { width: 100%; font-size: 9pt; }
.naslovnica-zaglavlje td { vertical-align: top; width: 50%; padding: 0 0 4mm; line-height: 1.5; }
.naslovnica-naslov { font-size: 15pt; text-align: center; margin: 4mm 0 5mm; letter-spacing: .5px; }
.naslovnica-podnaslov { font-size: 10.5pt; margin: 6mm 0 2mm; }
.naslovnica-podaci { font-size: 9pt; border-collapse: collapse; }
.naslovnica-podaci td { padding: 0.6mm 6mm 0.6mm 0; }
table.data.naslovnica-obracun { min-width: 0; width: 100%; font-size: 9.5pt; }
table.data.naslovnica-obracun col.c-novac { width: 32%; }
table.data.naslovnica-obracun td { padding: 1.1mm 2mm; border: none; }
table.data.naslovnica-obracun tr.osnovica td { padding-top: 2.6mm; }
table.data.naslovnica-obracun tr.pdv-red td { color: #555; }
table.data.naslovnica-obracun tr.ukupno-red td { font-weight: 700; border-top: 1px solid #333; border-bottom: 1px solid #333; }
.naslovnica-napomena { font-size: 8.5pt; line-height: 1.5; margin: 4mm 0 0; }

/* the foot: payment details to the left, the advance boxed off to the right */
.naslovnica-podnozje {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8mm;
  margin-top: 8mm;
}
/* the payment details take whatever width is left; the box keeps to its own
   corner and no more */
.naslovnica-podnozje .naslovnica-napomena { margin: 0; flex: 1 1 auto; min-width: 0; }
table.naslovnica-avans-box {
  border-collapse: collapse;
  border: 1.2pt solid #1b2a4a;
  font-size: 8.5pt;
  flex: 0 0 78mm;
  width: 78mm;
  margin-left: auto;
}
table.naslovnica-avans-box th {
  text-align: left;
  font-weight: 700;
  padding: 1mm 2mm;
  border-bottom: 1.2pt solid #1b2a4a;
  background: #eef2f7;
}
table.naslovnica-avans-box td { padding: .7mm 2mm; border: .5pt solid #8d9bb5; }
table.naslovnica-avans-box td.num {
  text-align: right;
  white-space: nowrap;
  width: 27mm;
}
table.naslovnica-avans-box tr.zadnji td { font-weight: 700; border-top: 1.2pt solid #1b2a4a; }

@media print {
  .topbar, .no-print { display: none !important; }
  /* the recapitulation closes the document, on a page of its own */
  .samo-ispis { display: block; break-before: page; page-break-before: always; }
  /* the cover opens it, so it breaks after itself instead */
  .naslovnica-ispis { break-before: auto; page-break-before: auto;
                      break-after: page; page-break-after: always; }

  /* One job, one orientation - which is all a printer driver offers. Each half
     of the document is printed on its own, and prints alone. */
  body.ispis-samo-naslovnica .container > *:not(.naslovnica-ispis),
  body.ispis-samo-naslovnica .rekapitulacija-ispis { display: none !important; }
  /* printed alone it is the last page too, so nothing follows it */
  body.ispis-samo-naslovnica .naslovnica-ispis {
    break-after: auto; page-break-after: auto;
  }
  body.ispis-bez-naslovnice .naslovnica-ispis { display: none !important; }
  .naslovnica-ispis .field-hint { font-size: 7pt; }

  /* All of it on one sheet: the whole form is set a size smaller on paper, so
     the seven blocks, the signatures and the advance box share one page. */
  .naslovnica-ispis { font-size: 8pt; }
  .naslovnica-zaglavlje { font-size: 8pt; }
  .naslovnica-zaglavlje td { padding-bottom: 2.5mm; line-height: 1.35; }
  .naslovnica-naslov { font-size: 12.5pt; margin: 2mm 0 3mm; }
  .naslovnica-podnaslov { font-size: 9.5pt; margin: 3.5mm 0 1mm; }
  .naslovnica-podaci { font-size: 8pt; }
  .naslovnica-podaci td { padding: .3mm 5mm .3mm 0; }
  table.data.naslovnica-obracun { font-size: 8pt; }
  table.data.naslovnica-obracun td { padding: .45mm 2mm; }
  table.data.naslovnica-obracun tr.osnovica td { padding-top: 1.4mm; }
  .naslovnica-napomena { font-size: 7.5pt; line-height: 1.35; margin-top: 2.5mm; }
  .naslovnica-ispis .potpisi { margin-top: 7mm; font-size: 8pt; }
  .naslovnica-ispis .potpisi .crta { margin-bottom: 1.2mm; }
  .naslovnica-podnozje { margin-top: 5mm; gap: 6mm; }
  table.naslovnica-avans-box { font-size: 7.5pt; flex-basis: 72mm; width: 72mm; }
  table.naslovnica-avans-box th { padding: .7mm 2mm; }
  table.naslovnica-avans-box td { padding: .45mm 2mm; }
  table.naslovnica-avans-box td.num { width: 25mm; }
  /* Folding is for reading on screen. On paper the situacija has to carry
     every line it covers, whatever was folded away when print was pressed. */
  #troskovnik-tablica tbody tr { display: table-row !important; }
  #troskovnik-tablica .gant-red { display: flex !important; }
  /* A situacija of 2300 contracted lines prints 60 pages, of which 59 are
     zeroes. On paper it carries what was actually built; the whole book stays
     on screen and in the Excel export. */
  tr.bez-radova,
  #troskovnik-tablica tbody tr.bez-radova { display: none !important; }
  body {
    background: white;
    font-size: 8.5pt;
    /* No fixed width. The tables are sized in shares of the page, so each sheet
       fills itself. A width in millimetres would be the width of the widest
       sheet, and the browser then shrinks the WHOLE document - cover included -
       until that width fits the narrowest one: with an upright cover in front
       of landscape tables that came to 68 %, which is the shrunken print. */
    width: auto;
    margin: 0;
  }
  .container, .container.siroko { max-width: none; width: 100%; padding: 0; margin: 0; }
  .card { border: none; padding: 0; margin: 0 0 6mm; box-shadow: none; }
  h1 { font-size: 14pt; margin: 0 0 2mm; }
  h2, h3 { font-size: 11pt; margin: 0 0 2mm; }
  .subtitle, .field-hint { font-size: 7.5pt; }

  /* a table is allowed to shrink its type, but not to run off the sheet */
  .tablica-scroll, [style*="overflow-x"] { overflow: visible !important; }
  table.data {
    width: 100% !important;
    table-layout: fixed;
    font-size: 7.5pt;
    border-collapse: collapse;
  }
  table.data th, table.data td {
    padding: 1mm 1.2mm;
    word-wrap: break-word;
    overflow-wrap: anywhere;
  }
  table.data thead { display: table-header-group; }   /* heading on every sheet */
  table.data.situacija { min-width: 0; font-size: 7.5pt; }   /* ≈ 10 px on paper */
  table.data.situacija th, table.data.situacija td { padding: 1mm 1.2mm; }
  table.data.situacija .stavka-opis { font-size: 7pt; line-height: 1.3; }
  /* The screen widths are pixels measured for a wide monitor; on a 273 mm page
     they add up to more than the sheet, and the description column is left
     with four millimetres - one letter per line. On paper the columns are
     shares of the page instead. */
  table.data.situacija col.c-opis { width: 22%; }
  table.data.situacija col.c-mjera { width: 3.5%; }
  table.data.situacija col.c-broj, table.data.situacija col.c-unos { width: 5%; }
  table.data.situacija col.c-novac { width: 7%; }
  table.rekap-grupe col.c-opis { width: 40%; }
  table.rekap-grupe col.c-novac { width: 12%; }
  table.data tr { page-break-inside: avoid; }
  .summary-grid { display: flex; flex-wrap: wrap; gap: 3mm; }
  .summary-grid .stat { flex: 1 1 auto; padding: 2mm 3mm; }
  .summary-grid .value { font-size: 10pt; }
  .stavka-opis { font-size: 7pt; }
}


/* work groups dragged around in the "Grupe radova" table */
.reorder-table .drag-handle { cursor: grab; text-align: center; user-select: none; }
.reorder-table .drag-handle:active { cursor: grabbing; }
.reorder-table tr.dragging { opacity: .45; }
.reorder-table tr.drop-target td { box-shadow: inset 0 2px 0 var(--primary); }
.reorder-table .grupa-broj { color: var(--text-dim); white-space: nowrap; }

/* filtering + collapsing the troškovnik overview */
.filter-bar {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.filter-bar select {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 220px;
}
.filter-bar .filter-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
tr.vrsta-row td {
  background: var(--primary-dark);
  color: #fff;
  font-weight: 700;
  letter-spacing: .3px;
}
tr.sazimljiv { cursor: pointer; }
tr.sazimljiv .caret { display: inline-block; width: 14px; opacity: .8; }
tr.sazeto td { opacity: .9; }

/* the gradiliste picker shown right after signing in */
.gradilista-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.gradiliste-kartica {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.gradiliste-kartica:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(29, 78, 216, .12);
  text-decoration: none;
}
.gradiliste-kartica h2 { margin: 0 0 6px; font-size: 17px; }
.gradiliste-podaci { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13px; color: var(--text-dim); }
.gradiliste-ulaz { display: inline-block; margin-top: 12px; color: var(--primary); font-weight: 600; font-size: 13.5px; }

/* objekt heading inside the troškovnik, between vrsta radova and grupa radova */
tr.objekt-row td {
  background: #e8edf7;
  font-weight: 700;
  color: var(--primary-dark);
  padding-left: 22px;
}

/* the objekt's own total, closing its block in the troškovnik */
tr.objekt-total-row td {
  background: #dbe4f5;
  font-weight: 700;
  color: var(--primary-dark);
  border-top: 1px solid var(--primary);
}

.reorder-item .reorder-strelice { display: flex; gap: 4px; margin-left: auto; }
.reorder-item .reorder-move { padding: 2px 8px; line-height: 1.2; }
.reorder-item.drop-target { outline: 2px dashed var(--primary); outline-offset: -2px; }
.reorder-item.dragging { opacity: .5; }

/* collapsible cards: the toggle sits in the card's top right corner, so it
   never runs into the heading text */
.card { position: relative; }
h2.kartica-naslov { cursor: pointer; user-select: none; padding-right: 44px; }
.kartica-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  padding: 0;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
}
.kartica-toggle:hover { border-color: var(--primary); color: var(--primary); }
.card.kartica-sazeta { padding-bottom: 10px; }
.card.kartica-sazeta > *:not(h2):not(.kartica-toggle) { display: none; }
.card.kartica-sazeta > h2 { margin-bottom: 0; }
.kartice-alat { padding-top: 0; }

/* subgroup heading, one step below the group */
tr.podgrupa-row td {
  background: #eef1f6;
  font-weight: 600;
  padding-left: 34px;
}

/* dragging items onto a heading */
#troskovnik-tablica tr[data-tip="stavka"] { cursor: grab; }
#troskovnik-tablica tr.dnd-vuce { opacity: .45; }
#troskovnik-tablica tr.dnd-cilj td {
  outline: 2px dashed var(--ok);
  outline-offset: -3px;
}

/* where the dragged items will land, relative to another item */
#troskovnik-tablica tr.dnd-iznad td { box-shadow: inset 0 3px 0 var(--ok); }
#troskovnik-tablica tr.dnd-ispod td { box-shadow: inset 0 -3px 0 var(--ok); }

/* + / x on a heading row: adding a group, and dropping an empty one */
.dodaj-grupu, .obrisi-praznu, .obrisi-grupu, .preimenuj, .obrisi-razinu {
  border: 1px solid rgba(255, 255, 255, .45);
  background: rgba(255, 255, 255, .15);
  color: inherit;
  border-radius: 4px;
  width: 20px;
  height: 20px;
  line-height: 1;
  padding: 0;
  margin-right: 6px;
  cursor: pointer;
  font-size: 13px;
}
.dodaj-grupu:hover, .obrisi-praznu:hover, .obrisi-grupu:hover,
.preimenuj:hover, .obrisi-razinu:hover { background: rgba(255, 255, 255, .35); }
tr.podgrupa-row .dodaj-grupu, tr.podgrupa-row .obrisi-praznu, tr.podgrupa-row .obrisi-grupu,
tr.podgrupa-row .preimenuj {
  border-color: var(--border);
  background: white;
  color: var(--text-dim);
}
.obrisi-praznu, .obrisi-grupu, .obrisi-razinu { margin-left: 8px; margin-right: 0; }
.preimenuj { margin-left: 8px; margin-right: 0; font-size: 12px; }

#troskovnik-tablica tr.trade-row.dnd-iznad td,
#troskovnik-tablica tr.podgrupa-row.dnd-iznad td { box-shadow: inset 0 3px 0 var(--ok); }
#troskovnik-tablica tr.trade-row.dnd-ispod td,
#troskovnik-tablica tr.podgrupa-row.dnd-ispod td { box-shadow: inset 0 -3px 0 var(--ok); }
#troskovnik-tablica tr.trade-row, #troskovnik-tablica tr.podgrupa-row { cursor: grab; }


/* ------------------------------------------------------- terminski plan -- */
.tablica-scroll { overflow-x: auto; }
.upute { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.65; color: var(--text); }
.upute code { background: #f1f3f6; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

.iznos-manjak { color: #dc2626; }
.iznos-visak { color: #16a34a; }

.upozorenje {
  border-left: 4px solid var(--text-dim);
  background: #f7f8fa;
  padding: 9px 13px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 8px;
}
.upozorenje-tekst { font-size: 13.5px; font-weight: 600; }
.upozorenje-detalj { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.upozorenje.razina-danger { border-color: #dc2626; background: var(--danger-bg); }
.upozorenje.razina-danger .upozorenje-tekst { color: #b91c1c; }
.upozorenje.razina-warn { border-color: #f59e0b; background: #fff7ed; }
.upozorenje.razina-ok { border-color: #16a34a; background: var(--ok-bg); }
.upozorenje.razina-info { border-color: #2563eb; background: #eff6ff; }

.stat-badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.stat-ok { background: var(--ok-bg); color: var(--ok); }
.stat-warn { background: var(--warn-bg); color: var(--warn); }
.stat-danger { background: var(--danger-bg); color: var(--danger); }
.stat-info { background: #eff6ff; color: #1d4ed8; }

.s-krivulja { min-width: 720px; display: block; }
.s-krivulja .mreza { stroke: #e6e9ef; stroke-width: 1; }
.s-krivulja .os { stroke: #b9bfca; stroke-width: 1; }
.s-krivulja .os-oznaka { font-size: 10.5px; fill: #6b7280; }
.s-krivulja .linija-plan { fill: none; stroke: #2563eb; stroke-width: 2.5; }
.s-krivulja .linija-ostvareno { fill: none; stroke: #16a34a; stroke-width: 2.5; }
.s-krivulja .linija-projekcija { fill: none; stroke: #f59e0b; stroke-width: 2; stroke-dasharray: 6 4; }
.s-krivulja .stupac-plan { fill: #c7d7f5; }
.s-krivulja .stupac-ost { fill: #b5e3c6; }
.s-krivulja .presjek-linija { stroke: #9ca3af; stroke-width: 1; stroke-dasharray: 3 3; }
.s-krivulja .linija-bazni { fill: none; stroke: #6b7280; stroke-width: 2; stroke-dasharray: 2 3; }
.dot-bazni { background: #6b7280; }
.dot-plan { background: #2563eb; }
.dot-ostvareno { background: #16a34a; }
.dot-projekcija { background: #f59e0b; }
.dot-plan-stupac { background: #c7d7f5; }
.dot-ost-stupac { background: #b5e3c6; }

.plan-tablica .mjesec-th { white-space: nowrap; font-size: 11.5px; }
.plan-tablica input.mini-input {
  margin: 0; padding: 4px 6px; font-size: 12.5px; width: 100%; min-width: 74px;
}
.plan-tablica select.mini-input { margin: 0; padding: 4px 6px; font-size: 12.5px; }
.plan-tablica input.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.redak-buduci td { color: var(--text-dim); background: #fafbfc; }
tr.redak-presjek td { box-shadow: inset 0 -2px 0 #9ca3af; }
.inline-form input[type=month] { max-width: 200px; }


/* ------------------------------- hierarchy inside the troškovnik overview -- */
/* One shade of blue per level, getting lighter as it goes deeper, and each
   level set in a little further than the one above it. The shade follows the
   depth, not the meaning, so it holds for both layouts (vrsta → objekt and
   objekt → vrsta). Item rows are left exactly as they were. */
#troskovnik-tablica tr[data-tip="r1"] > td {
  background: #16337a;
  color: #fff;
  font-weight: 700;
  letter-spacing: .04em;
}
#troskovnik-tablica tr[data-tip="r2"] > td {
  background: #2a58a5;
  color: #fff;
  font-weight: 700;
  letter-spacing: .03em;
}
#troskovnik-tablica tr[data-tip="grupa"] > td {
  background: #3a70bb;
  color: #fff;
  font-weight: 700;
  letter-spacing: .02em;
}
#troskovnik-tablica tr[data-tip="podgrupa"] > td {
  background: #a9c8ea;
  color: #10305f;
  font-weight: 600;
  letter-spacing: 0;
}

/* each step indented one notch further than the level above it */
#troskovnik-tablica tr[data-tip="r1"] > td:first-child { padding-left: 10px; }
#troskovnik-tablica tr[data-tip="r2"] > td:first-child { padding-left: 28px; }
#troskovnik-tablica tr[data-tip="grupa"] > td:first-child { padding-left: 46px; }
#troskovnik-tablica tr[data-tip="podgrupa"] > td:first-child { padding-left: 64px; }

/* the counts and the +/× buttons have to stay readable on the darker rows */
#troskovnik-tablica tr[data-tip="r1"] .field-hint,
#troskovnik-tablica tr[data-tip="r2"] .field-hint,
#troskovnik-tablica tr[data-tip="grupa"] .field-hint { color: rgba(255, 255, 255, .78); }
#troskovnik-tablica tr[data-tip="podgrupa"] .field-hint { color: #35548c; }
#troskovnik-tablica tr[data-tip="r1"] .dodaj-grupu,
#troskovnik-tablica tr[data-tip="r2"] .dodaj-grupu,
#troskovnik-tablica tr[data-tip="grupa"] .dodaj-grupu,
#troskovnik-tablica tr[data-tip="r1"] .obrisi-grupu,
#troskovnik-tablica tr[data-tip="r2"] .obrisi-grupu,
#troskovnik-tablica tr[data-tip="grupa"] .obrisi-grupu,
#troskovnik-tablica tr[data-tip="r1"] .preimenuj,
#troskovnik-tablica tr[data-tip="r2"] .preimenuj,
#troskovnik-tablica tr[data-tip="grupa"] .preimenuj,
#troskovnik-tablica tr[data-tip="r1"] .obrisi-razinu,
#troskovnik-tablica tr[data-tip="r2"] .obrisi-razinu {
  color: #fff;
  border-color: rgba(255, 255, 255, .55);
  background: rgba(255, 255, 255, .16);
}
#troskovnik-tablica tr[data-tip="podgrupa"] .dodaj-grupu,
#troskovnik-tablica tr[data-tip="podgrupa"] .obrisi-grupu,
#troskovnik-tablica tr[data-tip="podgrupa"] .preimenuj {
  color: #10305f;
  border-color: rgba(16, 48, 95, .35);
  background: rgba(255, 255, 255, .6);
}

/* on paper the levels are told apart by the same shades, not by guesswork */
@media print {
  #troskovnik-tablica tr[data-tip] > td {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}


/* ---------------------------------------------------- analiza troškovnika -- */
.analiza-graf { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.analiza-tablica { flex: 1; min-width: 320px; }
.pita { flex: 0 0 auto; }
.pita path { transition: opacity .12s; }
.pita path:hover { opacity: .75; }
.pita-glavni { font-size: 15px; font-weight: 700; fill: var(--text); }
.pita-manji { font-size: 10.5px; fill: var(--text-dim); }

.tocka { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }
.traka { background: #eef1f6; border-radius: 4px; height: 10px; overflow: hidden; }
.traka span { display: block; height: 100%; border-radius: 4px; }
/* the structure of the troškovnik in the analysis: one colour down every level */
.struktura-tablica .traka span { background: var(--primary); min-width: 1px; }
.struktura-tablica tr.trade-row .traka, .struktura-tablica tr.vrsta-row .traka { background: rgba(255,255,255,.25); }
.struktura-tablica tr.trade-row .traka span, .struktura-tablica tr.vrsta-row .traka span { background: #fff; }

.pareto { min-width: 420px; flex: 0 0 auto; }
.pareto .linija-pareto { fill: none; stroke: #1e3a8a; stroke-width: 2.5; }
.pareto .linija-jednoliko { fill: none; stroke: #b9bfca; stroke-width: 1.5; stroke-dasharray: 4 4; }

.nalaz {
  border-left: 4px solid var(--text-dim);
  background: #f7f8fa;
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  margin-bottom: 10px;
}
.nalaz.razina-danger { border-color: #dc2626; background: var(--danger-bg); }
.nalaz.razina-warn { border-color: #f59e0b; background: #fff7ed; }
.nalaz.razina-info { border-color: #2563eb; background: #eff6ff; }
.nalaz-zaglavlje { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; font-size: 13.5px; }
.nalaz-opis { font-size: 12.5px; color: var(--text-dim); margin: 4px 0 6px; }
.nalaz-opis em { color: var(--text); font-style: normal; }
.nalaz details summary { font-size: 12.5px; color: var(--primary); cursor: pointer; }
.nalaz details[open] summary { margin-bottom: 8px; }
.nalaz table.data { background: white; border-radius: 6px; }


/* rows ticked for a bulk action - and for dragging them all at once */
#troskovnik-tablica tr.redak-oznacen td,
#uredi-tablica tr.redak-oznacen td { background: #e8f0fd; }
#troskovnik-tablica tr.redak-oznacen td:first-child { box-shadow: inset 3px 0 0 var(--primary); }


/* a drop that copies instead of moving (Ctrl held) */
#troskovnik-tablica tr.dnd-kopira td {
  outline: 2px dashed var(--primary);
  outline-offset: -3px;
  background: #eaf1fd;
}
#troskovnik-tablica tr.dnd-kopira td:first-child::after {
  content: "+";
  color: var(--primary);
  font-weight: 700;
  margin-left: 4px;
}

/* ------------------------------------------------------------- ponude --- */
/* Offer totals as bars: name, bar, amount - read down the column, the way a
   comparison is read. */
.traka-red { display: grid; grid-template-columns: 210px 1fr 190px; gap: 10px;
             align-items: center; margin-bottom: 7px; font-size: 13px; }
.traka-red .traka { height: 14px; }
.traka-naziv { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.traka-iznos { text-align: right; font-variant-numeric: tabular-nums; }

/* the cheapest price of a row, and the offer that carries the most of them */
.cijena-najbolja { background: var(--ok-bg); font-weight: 600; }
.redak-najbolji > td { background: #f0fdf4; }
.oznaka-najbolja { background: var(--ok-bg); color: var(--ok); padding: 1px 6px; border-radius: 4px; }

/* a comparison grows a column per offer; the item stays readable, the numbers
   stay narrow */
table.usporedba td.opis-cell { max-width: 340px; }
table.usporedba input[type="number"] { width: 92px; text-align: right; }
table.usporedba th { vertical-align: bottom; }
.cijena-input { width: 100px; text-align: right; }

/* what the ponuditelj wrote next to his price - short on screen, whole in the
   tooltip */
.napomena-ponude { font-size: 11.5px; color: #92400e; text-align: left;
                   margin-top: 3px; line-height: 1.25; }

/* how much of a folded heading is already picked - so a closed group still
   says what it carries */
.oznaceno { margin-left: 10px; font-size: 11.5px; color: var(--ok);
            background: var(--ok-bg); padding: 1px 7px; border-radius: 4px; }

/* ------------------------------------------------------------- upute --- */
.uputa-trazilica { display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; }
.uputa-trazilica input { flex: 1; max-width: 520px; }

/* the contents: one glance over everything the manual covers */
.uputa-sadrzaj { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
                 gap: 6px 16px; margin-top: 8px; }
.uputa-sadrzaj a { font-size: 13.5px; color: var(--link, #1d4ed8); text-decoration: none;
                   padding: 3px 0; border-bottom: 1px dotted transparent; }
.uputa-sadrzaj a:hover { border-bottom-color: currentColor; }

section.uputa h2 { margin-top: 0; }
section.uputa p, section.uputa li, section.uputa dd { font-size: 14px; line-height: 1.55; }
section.uputa ol, section.uputa ul { padding-left: 20px; }
section.uputa li { margin-bottom: 5px; }
section.uputa code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
section.uputa kbd { background: #fff; border: 1px solid var(--border); border-bottom-width: 2px;
                    border-radius: 4px; padding: 1px 6px; font-size: 12px; }
section.uputa.istaknuto { box-shadow: 0 0 0 2px #1e3a8a33; }

/* an aside that says what to do when the ordinary path does not work */
.uputa-savjet { background: #eff6ff; border-left: 3px solid #2563eb; padding: 9px 13px;
                border-radius: 0 6px 6px 0; }

.uputa-pitanja dt { font-weight: 600; margin-top: 12px; }
.uputa-pitanja dd { margin: 3px 0 0 0; color: var(--muted, #4b5563); }

/* pointing at a heading the detection did not see */
.rucni-naslov { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
                margin: 14px 0 6px; padding: 12px 14px; background: #f8fafc;
                border: 1px solid var(--border); border-radius: 8px; }
.rucni-naslov label { display: block; font-size: 12.5px; margin-bottom: 4px; }

/* ------------------------------------------------- prijedlog plana --- */
.prijedlog-graf { max-width: 100%; }
.prijedlog-graf .os { stroke: #94a3b8; stroke-width: 1; }
.prijedlog-graf .mreza { stroke: #e2e8f0; stroke-width: 1; }
.prijedlog-graf .oznaka { font-size: 10.5px; fill: #64748b; }
.graf-legenda { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; margin: 8px 0 14px; }
.graf-legenda .tocka { margin-right: 5px; }

/* phases through time: name, bar in its place, dates */
.gantogram-red { display: grid; grid-template-columns: 230px 1fr 190px; gap: 12px;
                 align-items: center; margin-bottom: 6px; font-size: 13px; }
.gantogram-naziv { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantogram-traka { position: relative; height: 14px; background: #eef1f6; border-radius: 4px; }
.gantogram-traka span { position: absolute; top: 0; height: 100%; border-radius: 4px; opacity: .9; }
.gantogram-rok { text-align: right; color: var(--muted, #4b5563); font-size: 12px; }
tr.redak-upozorenje > td { background: #fff7ed; }

/* the troškovnik editor: rows are text until one is opened for editing */
#uredi-tablica td.c-opis { max-width: 420px; overflow: hidden; text-overflow: ellipsis;
                           white-space: nowrap; }
#uredi-tablica tr.uredi-aktivan > td { background: #eff6ff; }
#uredi-tablica tr.uredi-aktivan td.c-opis { max-width: none; white-space: normal; }
#uredi-tablica tbody tr:hover > td { background: #f8fafc; }
#uredi-tablica td.c-akcije { white-space: nowrap; }

/* a long troškovnik: the browser lays out only the rows it is showing */
#uredi-tablica tbody tr { content-visibility: auto; contain-intrinsic-size: 0 34px; }

/* start and end date of one plan row, next to its monthly figures */
.plan-tablica .datumi-th { min-width: 210px; }
.plan-tablica .datumi-td { white-space: nowrap; }
.plan-tablica .datumi-td input[type="date"] { width: 128px; margin-bottom: 2px; }

/* ------------------------------------------------- wide screens --- */
/* Screens built around a big table use the whole monitor: a troškovnik or a
   plan with twenty months of columns is read across, and every pixel spent on
   empty margins is a pixel of scrolling. Reading screens keep their measure. */
.container.siroko { max-width: 2600px; padding-left: 18px; padding-right: 18px; }

/* a sentence stays readable even when the card around it is 2000px wide */
.container.siroko .card > p,
.container.siroko .card > .subtitle,
.container.siroko .card > .field-hint,
.container.siroko .card > .ok-box,
.container.siroko .card > .error-box,
.container.siroko .card > .uputa-savjet { max-width: 1150px; }

/* on a wide monitor the description column may take the room it needs */
@media (min-width: 1700px) {
  /* the description takes what is left over: on a 1920 screen the troškovnik
     then fits without sideways scrolling at all */
  #uredi-tablica td.c-opis { max-width: 530px; }
  .opis-cell { max-width: 780px; }
  table.usporedba td.opis-cell { max-width: 560px; }
}
@media (min-width: 2200px) {
  #uredi-tablica td.c-opis { max-width: 900px; }
  .opis-cell { max-width: 1000px; }
}

/* A table wider than the screen still has to say which row you are on: the
   first column stays put while the months scroll past it. */
.plan-tablica th.stupac-broj,
.plan-tablica td.stupac-broj,
table.usporedba thead th:nth-child(2),
table.usporedba tbody td:nth-child(2) {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card, #fff);
  box-shadow: 1px 0 0 var(--border, #dfe5ee);
}
.plan-tablica thead th.stupac-broj,
.plan-tablica thead th.stupac-naziv { z-index: 3; }

/* the number and the name both stay put while the months scroll past */
.plan-tablica th.stupac-broj, .plan-tablica td.stupac-broj {
  width: 78px; min-width: 78px; font-variant-numeric: tabular-nums; font-size: 12px;
}
.plan-tablica th.stupac-naziv, .plan-tablica td.stupac-naziv {
  position: sticky; left: 78px; z-index: 2;
  background: var(--card, #fff); box-shadow: 1px 0 0 var(--border, #dfe5ee);
}
.plan-tablica tr.plan-naslov > td.stupac-broj,
.plan-tablica tr.plan-naslov > td.stupac-naziv { background: inherit; }
/* narrower month columns: twenty-odd of them add up, and an amount fits */
.plan-tablica .mjesec-th { padding-left: 6px; padding-right: 6px; }
.plan-tablica td.num { padding-left: 5px; padding-right: 5px; }
.plan-tablica input.mini-input.num { width: 70px; min-width: 62px; }

/* the plan, stacked the way the troškovnik is: a heading per level, in the
   same shades of blue the troškovnik overview uses */
.plan-tablica tr.plan-naslov > td { font-weight: 600; }
/* the sticky number and name columns must carry the colour of their own row,
   otherwise they would stay white while the row behind them is blue */
.plan-tablica tr.vrsta-row td.stupac-broj, .plan-tablica tr.vrsta-row td.stupac-naziv,
.plan-tablica tr.trade-row td.stupac-broj, .plan-tablica tr.trade-row td.stupac-naziv {
  background: var(--primary-dark); color: #fff;
}
.plan-tablica tr.objekt-row td.stupac-broj, .plan-tablica tr.objekt-row td.stupac-naziv {
  background: #e8edf7;
}
.plan-tablica tr.podgrupa-row td.stupac-broj, .plan-tablica tr.podgrupa-row td.stupac-naziv {
  background: #eef1f6;
}
/* a row drawn at the height of a level keeps its own fields readable */
.plan-tablica tr.vrsta-row input, .plan-tablica tr.trade-row input,
.plan-tablica tr.vrsta-row select, .plan-tablica tr.trade-row select {
  color: var(--text, #1c2430); background: #fff;
}
.plan-tablica tr.plan-naslov { cursor: pointer; }
.plan-tablica tr.plan-naslov .caret { display: inline-block; width: 14px; opacity: .85; }

/* building a plan by hand: the troškovnik with two dates next to every group */
#rucni-plan td.broj-celija { font-variant-numeric: tabular-nums; font-size: 12.5px;
                             white-space: nowrap; }
#rucni-plan tr.stavka-red td { color: var(--text-dim, #4b5563); font-size: 12.5px; }
#rucni-plan td.naziv-stavke { max-width: 620px; overflow: hidden; text-overflow: ellipsis;
                              white-space: nowrap; }
#rucni-plan input[type="date"] { width: 138px; padding: 3px 5px; font-size: 12.5px; }
#rucni-plan tr.naslijedeni-datum td.broj-celija { box-shadow: inset 3px 0 0 #2563eb; }
#rucni-plan tr.sazimljiv { cursor: pointer; }
#rucni-plan tr.sazimljiv .caret { display: inline-block; width: 14px; opacity: .85; }


/* the troškovnik items under a plan row: there to be read, not edited */
.plan-tablica tr.plan-stavka-troskovnika td { color: var(--text-dim, #4b5563); font-size: 12.5px; }
.plan-tablica tr.plan-stavka-troskovnika td.stupac-naziv { max-width: 620px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; background: var(--card, #fff); }
.plan-tablica tr.plan-stavka-troskovnika td.stupac-broj { background: var(--card, #fff); }

/* a plan row whose name comes from the troškovnik: read, not typed */
.plan-tablica .plan-naziv { font-weight: 600; }

/* ------------------------------------------------------------ gantogram --- */
/* The plan seen sideways: names on the left, one bar per row on a month axis.
   The name column stays put while the months scroll under it. */
.gant-omot { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.gant-tablica { min-width: 900px; }
.gant-red, .gant-zaglavlje { display: flex; align-items: stretch; }
/* the left block never moves: a long name is cut off rather than pushing the
   amount out of its column, so the figures line up all the way down */
.gant-nazivi { display: flex; flex: 0 0 700px; width: 700px; align-items: center; gap: 8px;
               position: sticky; left: 0; z-index: 2; background: var(--card, #fff);
               box-shadow: 1px 0 0 var(--border); }
.gant-naziv { flex: 1 1 auto; min-width: 0; font-size: 12.5px; padding: 5px 6px;
              overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gant-broj { font-variant-numeric: tabular-nums; color: var(--text-dim, #4b5563); margin-right: 4px; }
.gant-iznos { flex: 0 0 140px; width: 140px; text-align: right; padding-right: 12px;
              font-size: 12px; font-variant-numeric: tabular-nums;
              color: var(--text-dim, #4b5563); white-space: nowrap; }
.gant-datum { flex: 0 0 88px; width: 88px; text-align: center; font-size: 11.5px;
              font-variant-numeric: tabular-nums; color: var(--text-dim, #4b5563);
              white-space: nowrap; }
.gant-os, .gant-traka-prostor { flex: 1; min-width: 520px; position: relative; }
.gant-godine, .gant-mjeseci { display: flex; }
.gant-godina { text-align: center; font-weight: 700; font-size: 12px; padding: 4px 0;
               background: var(--primary-dark); color: #fff; border-right: 1px solid #ffffff33; }
.gant-mjesec { text-align: center; font-size: 11px; padding: 3px 0; color: var(--text-dim, #4b5563);
               border-right: 1px solid var(--border); background: #f8fafc; }
.gant-zaglavlje { position: sticky; top: 0; z-index: 3; }
.gant-zaglavlje .gant-nazivi { z-index: 4; }
.gant-celija-zaglavlje { flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: 12.5px;
                         padding: 12px 6px 4px; }
.gant-zaglavlje .gant-iznos.gant-celija-zaglavlje { flex: 0 0 140px; width: 140px;
                                                     color: var(--text, #1c2430); }
.gant-zaglavlje .gant-datum.gant-celija-zaglavlje { flex: 0 0 88px; width: 88px;
                                                     text-align: center;
                                                     color: var(--text, #1c2430); }

.gant-red { border-top: 1px solid #eef1f6; min-height: 26px; }
.gant-red:hover .gant-nazivi { background: #f8fafc; }
.gant-red.gant-naslov { cursor: pointer; }
.gant-red.gant-naslov .gant-naziv { font-weight: 700; }
.gant-red.razina-1 .gant-nazivi { background: var(--primary-dark); color: #fff; }
.gant-red.razina-1 .gant-iznos, .gant-red.razina-1 .gant-broj,
.gant-red.razina-1 .gant-datum { color: #dbe4f7; }
.gant-red.razina-2 .gant-nazivi { background: #e8edf7; }
.gant-red.razina-3.gant-naslov .gant-nazivi { background: #eef1f6; }

/* the month grid behind the bars, and the line of the current month */
.gant-crta { position: absolute; top: 0; bottom: 0; border-right: 1px solid #eef1f6; }
.gant-traka-prostor > .gant-crta:nth-child(1) { left: 0; }
/* today, on the day it falls - the line every bar is read against */
.gant-danas { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px;
              background: #dc2626; z-index: 1; }
.gant-danas-oznaka { position: absolute; top: 5px; transform: translateX(-50%);
                     font-size: 10.5px; font-weight: 700; line-height: 1.1;
                     padding: 1px 5px; border-radius: 3px; white-space: nowrap;
                     background: #dc2626; color: #fff; z-index: 5;
                     font-variant-numeric: tabular-nums; }

.gant-traka { position: absolute; top: 5px; height: 15px; border-radius: 4px; overflow: hidden;
              box-shadow: 0 1px 2px rgba(15, 23, 42, .25); }
.gant-traka-naslov { top: 8px; height: 9px; opacity: .85; border-radius: 3px; }
/* the darker part of a bar is what the situations have already billed */
.gant-napredak { display: block; height: 100%; background: rgba(0, 0, 0, .35); }
.gant-legenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; margin-bottom: 12px;
                align-items: center; }
.gant-legenda .tocka { margin-right: 5px; }

@media print {
  .gant-omot { overflow: visible; border: none; }
  .gant-tablica { min-width: 0; }
  .gant-danas { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* a level whose period comes from its own items no longer takes dates */
#rucni-plan tr.iz-stavaka input[type="date"] { background: #eef2f7; color: var(--text-dim, #4b5563);
                                               border-style: dashed; }
#rucni-plan tr.stavka-red input[type="date"] { width: 132px; }
#skupno-razdoblje { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
                    padding: 10px 14px; }

/* what a still-open heading already knows from the rows under it */
#rucni-plan .izracunato { margin-left: 10px; font-size: 11.5px; color: #1d4ed8;
                          background: #eff6ff; padding: 1px 7px; border-radius: 4px; }

/* the one question between filling in dates and having a plan */
.izbor-plana { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
               gap: 16px; margin: 16px 0; }
.izbor-kartica { border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px;
                 background: #f8fafc; }
.izbor-kartica h3 { margin: 0 0 8px; }

/* figures line up under each other: same width per digit, no wandering columns */
.plan-tablica td.num, .plan-tablica th.num,
table.data td.num, table.data th.num { font-variant-numeric: tabular-nums; }
/* every month column the same width, whatever stands in it */
.plan-tablica .mjesec-th, .plan-tablica td.mjesec-td, .plan-tablica th.mjesec-td {
  width: 104px; min-width: 104px; max-width: 104px;
}
.plan-tablica input.mini-input.num { width: 88px; min-width: 88px; }

/* dates of a plan row: text until somebody opens them for editing */
.plan-tablica .datumi-polja { display: none; white-space: nowrap; }
.plan-tablica.datumi-otvoreni .datumi-polja { display: inline; }
.plan-tablica.datumi-otvoreni .datumi-tekst { display: none; }
.plan-tablica .datumi-tekst { font-variant-numeric: tabular-nums; font-size: 12.5px;
                              white-space: nowrap; }

/* Long tables: the browser lays out only the rows on screen. Folding and
   unfolding a troškovnik of two thousand rows is otherwise a visible pause. */
#rucni-plan tbody tr, #izbor tbody tr, .plan-tablica tbody tr,
#troskovnik-tablica tbody tr {
  content-visibility: auto;
  contain-intrinsic-size: 0 32px;
}

/* a date field is a text box until it is clicked into - see rucni-plan.js */
#rucni-plan input.datum { width: 128px; padding: 3px 5px; font-size: 12.5px;
                          font-variant-numeric: tabular-nums; }
#rucni-plan input.datum[readonly] { background: #eef2f7; color: var(--text-dim, #4b5563);
                                    border-style: dashed; }

/* which S-curve is drawn: the whole plan, or only what has a duration */
.krivulja-izbor { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
                  margin: 6px 0 10px; }
