/* Evidencija rokova — vizuelni sistem.
   Boje signala preuzete su iz sigurnosnih znakova (zabrana/opasnost, upozorenje, sigurno, obaveza),
   ali prigušene za svakodnevni rad. Jedan font (Instrument Sans) s tabularnim brojevima. */
@font-face { font-family: "Instrument Sans"; font-style: normal; font-display: swap; font-weight: 400 700;
  src: url("fonts/instrument-sans-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-display: swap; font-weight: 400 700;
  src: url("fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --ink: #1b2a41;          /* tekst, gornja traka */
  --ink-2: #4a5a70;        /* sekundarni tekst */
  --ink-3: #7b889a;        /* pomoćni tekst */
  --line: #dde3ea;
  --line-soft: #ebeff4;
  --paper: #ffffff;
  --ground: #eef1f5;
  --blue: #1f4fa0;         /* obaveza / primarna radnja */
  --blue-ink: #173d7e;
  --blue-soft: #e8eef8;
  --red: #c7362b;          /* isteklo */
  --red-soft: #fbeceb;
  --amber: #c98400;        /* ističe uskoro */
  --amber-soft: #fdf3dc;
  --olive: #8a7d18;        /* 31–90 dana */
  --olive-soft: #f5f2dc;
  --green: #2e7d5b;        /* važi */
  --green-soft: #e5f2ec;
  --perm: #4f6fa8;         /* trajno */
  --perm-soft: #eaeff7;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 2px rgb(27 42 65 / .06), 0 8px 24px -12px rgb(27 42 65 / .18);
  font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--ground);
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 2rem; line-height: 1.15; letter-spacing: -.02em; font-weight: 650; margin-bottom: 6px; }
h2 { font-size: 1.2rem; line-height: 1.3; letter-spacing: -.01em; font-weight: 650; margin-bottom: 4px; }
h3 { font-size: 1rem; font-weight: 650; margin-bottom: 8px; }
.small { font-size: .82rem; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.eyebrow { display: block; font-size: .8rem; color: var(--ink-3); margin-bottom: 4px; }
.eyebrow:empty { display: none; }
mark { background: #fff1a8; color: inherit; border-radius: 2px; padding: 0 1px; }

/* Gornja traka */
.topbar { background: var(--ink); color: #fff; }
.topbar-inner { max-width: 1320px; margin: auto; min-height: 64px; padding: 10px 32px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; line-height: 1.2; }
.brand-mark { width: 30px; height: 30px; color: #9fc0f2; flex: none; }
.brand strong { display: block; font-size: 1rem; font-weight: 650; }
.brand span { display: block; font-size: .78rem; color: #a9b6c8; }
.user-bar { display: flex; align-items: center; gap: 14px; color: #cfd8e4; font-size: .85rem; }

/* Okvir stranice */
.shell { max-width: 1320px; margin: auto; padding: 32px 32px 64px; }
.notice { padding: 11px 14px; border-radius: var(--radius-s); margin: 0 0 20px; background: var(--blue-soft); color: var(--blue-ink); border: 1px solid #cddaf0; font-size: .9rem; }
.notice.error { background: var(--red-soft); color: #8f251d; border-color: #f0c9c5; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading p { color: var(--ink-2); margin: 0; }
.page-heading p::first-letter { text-transform: uppercase; }
.heading-actions, .dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Dugmad */
.button { border: 1px solid transparent; border-radius: var(--radius-s); padding: 9px 14px; font-size: .88rem; font-weight: 600; white-space: nowrap; line-height: 1.2; transition: background-color .12s, border-color .12s; }
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--blue-ink); }
.button-secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.button-secondary:hover:not(:disabled) { border-color: #b9c5d3; background: #f7f9fb; }
.button-light { background: transparent; color: #fff; border-color: #44556e; }
.button-light:hover { border-color: #8193ab; }
.full { width: 100%; margin: 18px 0 10px; }
.icon-button { background: none; border: 0; color: var(--ink-3); font-size: 26px; line-height: 1; padding: 0 4px; border-radius: var(--radius-s); }
.icon-button:hover { color: var(--ink); }
.row-button { border: 0; background: none; color: var(--blue); font-weight: 600; font-size: .85rem; padding: 6px 8px; border-radius: var(--radius-s); }
.row-button:hover { background: var(--blue-soft); }

/* Polja */
label { display: block; color: var(--ink-2); font-size: .82rem; font-weight: 600; margin: 0 0 5px; }
input, select, textarea { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 9px 11px; width: 100%; font-size: .92rem; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(31 79 160 / .14); }
input::placeholder { color: #9aa6b5; }
.search-input { padding-left: 34px; background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237b889a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") no-repeat 11px center; }
label.checkbox { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; font-weight: 500; color: var(--ink-2); }
label.checkbox input { width: auto; margin: 0; accent-color: var(--blue); }
.field-hint { margin: 6px 0 0; }

/* Traka stanja: glavni vizuelni element */
.status-board { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow); padding: 18px 18px 14px; margin-bottom: 22px; }
.status-strip { display: flex; gap: 3px; height: 14px; border-radius: 4px; overflow: hidden; margin-bottom: 14px; }
.status-strip .seg { flex: 1 1 0; min-width: 6px; }
.seg.expired { background: var(--red); }
.seg.due30 { background: var(--amber); }
.seg.due90 { background: #c7b44a; }
.seg.ok { background: var(--green); }
.seg.permanent { background: #9fb2d6; }
@media (prefers-reduced-motion: no-preference) {
  .status-strip.intro { animation: strip-in .7s cubic-bezier(.2, .7, .2, 1) both; transform-origin: left; }
  @keyframes strip-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}
.status-filters { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.filter-chip { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 0; text-align: left; background: none; border: 1px solid transparent; border-radius: var(--radius-s); padding: 8px 10px 8px 14px; color: var(--ink-2); transition: background-color .12s, border-color .12s; }
.filter-chip::before { content: ""; position: absolute; left: 4px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--line); }
.filter-chip.expired::before { background: var(--red); }
.filter-chip.due30::before { background: var(--amber); }
.filter-chip.due90::before { background: #c7b44a; }
.filter-chip.ok::before { background: var(--green); }
.filter-chip.permanent::before { background: #9fb2d6; }
.filter-chip.all::before { background: var(--ink); }
.filter-chip .number { font-size: 1.6rem; font-weight: 650; line-height: 1.15; color: var(--ink); letter-spacing: -.01em; }
.filter-chip.expired .number { color: var(--red); }
.filter-chip .label { font-size: .82rem; }
.filter-chip:hover { background: #f5f7fa; }
.filter-chip.active { background: var(--blue-soft); border-color: #c3d3ee; color: var(--blue-ink); }

/* Tabela poslova */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow); }
.records-header { padding: 18px 20px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line-soft); }
.records-header p { margin: 0; }
.filters { display: flex; align-items: end; gap: 10px; }
.filters > div:first-child { width: 300px; }
.filters select, .filters .combo { min-width: 190px; }
.table-wrap { overflow-x: auto; position: relative; }
table { border-collapse: collapse; width: 100%; min-width: 820px; font-size: .9rem; }
th { position: sticky; top: 0; background: #f7f9fb; color: var(--ink-3); font-size: .78rem; font-weight: 600; text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:first-child td { border-top: 0; }
td:first-child { font-weight: 600; }
td .sub { display: block; font-size: .78rem; color: var(--ink-3); margin-top: 2px; font-weight: 400; }
#jobs-body tr { cursor: pointer; transition: background-color .1s; }
#jobs-body tr:hover { background: #f6f8fb; }
#jobs-body tr.row-expired td:first-child { box-shadow: inset 3px 0 0 var(--red); }
#jobs-body tr.row-due30 td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.th-sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; display: inline-flex; align-items: center; gap: 5px; }
.th-sort::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); opacity: .25; }
th[aria-sort="ascending"] .th-sort, th[aria-sort="descending"] .th-sort { color: var(--ink); }
th[aria-sort="ascending"] .th-sort::after { opacity: 1; transform: rotate(-135deg) translateY(-1px); }
th[aria-sort="descending"] .th-sort::after { opacity: 1; }
.th-sort:hover { color: var(--ink); }
.validity { display: block; width: 92px; height: 4px; background: var(--line-soft); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.validity .fill { display: block; height: 100%; width: 0; background: var(--green); border-radius: 2px; }
.validity.expired .fill { background: var(--red); }
.validity.due30 .fill { background: var(--amber); }
.validity.due90 .fill { background: #c7b44a; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--line-soft); color: var(--ink-2); }
.badge.expired { background: var(--red-soft); color: #a52b22; }
.badge.due30 { background: var(--amber-soft); color: #8c5c00; }
.badge.due90 { background: var(--olive-soft); color: var(--olive); }
.badge.ok { background: var(--green-soft); color: #23664a; }
.badge.permanent { background: var(--perm-soft); color: var(--perm); }
.badge.inactive { background: #f0f2f5; color: var(--ink-3); }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.footnote { font-size: .8rem; color: var(--ink-3); margin: 16px 2px; max-width: 75ch; }

/* Straničenje */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--line-soft); }
.pager-size { display: flex; align-items: center; gap: 8px; }
.pager-size label { margin: 0; white-space: nowrap; font-weight: 500; }
.pager-size select { width: auto; padding: 6px 28px 6px 10px; }
.pager-buttons { display: flex; align-items: center; gap: 6px; }
.page-numbers { display: flex; gap: 4px; }
.page-number { min-width: 34px; height: 34px; border: 1px solid transparent; background: none; border-radius: var(--radius-s); font-size: .88rem; color: var(--ink-2); }
.page-number:hover { background: #f2f5f8; }
.page-number.current { background: var(--ink); color: #fff; font-weight: 600; }
.page-gap { align-self: center; color: var(--ink-3); padding: 0 2px; }
.pager-step { padding: 7px 12px; }

/* Prijava */
.auth-view { min-height: calc(100vh - 160px); display: grid; grid-template-columns: 1fr 400px; align-items: center; gap: 64px; max-width: 1040px; margin: auto; }
.auth-intro h1 { font-size: 2.6rem; line-height: 1.1; letter-spacing: -.025em; max-width: 16ch; }
.auth-intro p { max-width: 46ch; color: var(--ink-2); font-size: 1.05rem; }
.auth-legend { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .85rem; color: var(--ink-2); }
.auth-legend li { display: flex; align-items: center; gap: 7px; }
.auth-legend li::before { content: ""; width: 22px; height: 6px; border-radius: 3px; }
.auth-legend .expired::before { background: var(--red); }
.auth-legend .due30::before { background: var(--amber); }
.auth-legend .ok::before { background: var(--green); }
.auth-legend .permanent::before { background: #9fb2d6; }
.auth-panel { padding: 28px; }
.auth-panel form label:not(:first-child), dialog form label:not(:first-child) { margin-top: 14px; }
.message-panel { max-width: 620px; margin: 60px auto; padding: 32px; }
.message-panel p { color: var(--ink-2); }

/* Dijalozi */
dialog { width: min(560px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-m); padding: 24px; color: var(--ink); background: var(--paper); box-shadow: 0 24px 64px -16px rgb(27 42 65 / .35); }
dialog::backdrop { background: rgb(19 30 47 / .55); }
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: dialog-in .16s ease-out; }
  @keyframes dialog-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; }
.dialog-actions { justify-content: flex-end; margin-top: 20px; }
.wide-dialog { width: min(1000px, calc(100% - 32px)); }
.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; background: #f6f8fb; padding: 16px; border-radius: var(--radius-s); margin-bottom: 22px; }
.details-grid strong { display: block; overflow-wrap: anywhere; font-weight: 600; }
.detail-label { font-size: .78rem; color: var(--ink-3); margin-bottom: 2px; }
.history-title { margin-bottom: 6px; }
.history-item { position: relative; border-left: 2px solid var(--line); margin-left: 6px; padding: 8px 0 12px 18px; overflow-wrap: anywhere; font-size: .9rem; }
.history-item::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink-3); }
.history-item:last-child::before { border-color: var(--blue); background: var(--blue); }
.history-item p { margin: 3px 0; color: var(--ink-2); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; font-weight: 600; color: var(--ink-3); margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--blue); }
.catalog-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.catalog-toolbar input[type="search"] { flex: 1 1 240px; width: auto; }
.catalog-toolbar .button { margin-left: auto; }
.catalog-toolbar label.checkbox { margin: 0; white-space: nowrap; }
.wide-dialog table { min-width: 640px; }
.wide-dialog th { position: static; }
#catalog-status:empty { display: none; }
#type-impact { margin: 16px 0 0; white-space: pre-line; font-size: .88rem; }
#users-dialog { width: min(920px, calc(100% - 32px)); }
#users-dialog fieldset { margin: 1rem 0; padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: var(--radius-s); }
#users-dialog legend { font-weight: 600; padding: 0 6px; }
#users-dialog fieldset button { margin-top: 14px; }
#users-dialog td { overflow-wrap: break-word; }
#users-dialog td:first-child { min-width: 240px; }
#users-dialog td:nth-child(2) { white-space: nowrap; }
#users-dialog td:last-child { display: flex; flex-wrap: wrap; gap: 6px; }
#users-dialog select { min-width: 130px; }
#users-status { margin: 1rem 0; }
#setup-form label:has(#setup-account-confirm) { display: flex; align-items: flex-start; gap: 10px; }
#setup-account-confirm { width: auto; margin: 3px 0 0; flex: none; }
#setup-identity { overflow-wrap: anywhere; }
.form-error { margin-bottom: 14px; }

/* Combobox (pretraživ, grupisan izbor) */
.combo-native { position: absolute !important; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.combo { position: relative; }
.combo-trigger { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 9px 11px; text-align: left; font-size: .92rem; }
.combo-trigger:hover:not(:disabled) { border-color: #b9c5d3; }
.combo.open .combo-trigger { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(31 79 160 / .14); }
.combo-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-placeholder .combo-value { color: #9aa6b5; }
.combo-chevron { width: 7px; height: 7px; border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3); transform: rotate(45deg) translateY(-2px); font-size: 0; flex: none; }
.combo.open .combo-chevron { transform: rotate(-135deg) translate(-1px, -1px); }
.combo-pop { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s); box-shadow: 0 16px 40px -12px rgb(27 42 65 / .35); padding: 6px; }
.combo-search { border: 0; border-bottom: 1px solid var(--line-soft); border-radius: 0; padding: 8px 8px 10px; margin-bottom: 4px; }
.combo-search:focus, .combo-search:focus-visible { box-shadow: none; outline: none; border-color: var(--blue); }
.combo-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.combo-group { font-size: .75rem; font-weight: 600; color: var(--ink-3); padding: 10px 8px 4px; }
.combo-option { padding: 7px 8px 7px 14px; border-radius: 4px; cursor: pointer; font-size: .9rem; }
.combo-option.active { background: var(--blue-soft); color: var(--blue-ink); }
.combo-option[aria-selected="true"] { font-weight: 600; }
.combo-option[aria-selected="true"]::after { content: "✓"; float: right; color: var(--blue); }
.combo-empty { padding: 10px 8px; margin: 0; color: var(--ink-3); font-size: .88rem; }

/* Prilagođavanje ekranima */
@media (max-width: 1080px) {
  .records-header { align-items: stretch; flex-direction: column; }
  .filters { width: 100%; }
  .filters > div, .filters > div:first-child { flex: 1; width: auto; }
  .status-filters { grid-template-columns: repeat(3, 1fr); }
  .auth-view { gap: 32px; grid-template-columns: 1fr 380px; }
}
@media (max-width: 680px) {
  .shell { padding: 20px 16px 48px; }
  .topbar-inner { padding: 10px 16px; }
  .brand span, .user-bar span { display: none; }
  h1 { font-size: 1.6rem; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { width: 100%; }
  .heading-actions .button-primary { flex: 1; }
  .status-board { padding: 14px; }
  .status-filters { grid-template-columns: repeat(2, 1fr); }
  .filter-chip .number { font-size: 1.35rem; }
  .filters { flex-direction: column; align-items: stretch; }
  .records-header { padding: 16px; }
  .auth-view { grid-template-columns: 1fr; gap: 24px; min-height: 0; padding-top: 12px; }
  .auth-intro h1 { font-size: 1.9rem; }
  .auth-panel { padding: 22px; }
  .details-grid { grid-template-columns: 1fr 1fr; }
  .records-panel table { min-width: 0; }
  .records-panel thead { display: none; }
  .records-panel tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 14px 16px; border-top: 1px solid var(--line-soft); }
  .records-panel tbody td { display: block; padding: 0; border: 0; box-shadow: none !important; }
  .records-panel tbody td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: .72rem; color: var(--ink-3); font-weight: 600; margin-bottom: 1px; }
  .records-panel tbody td:nth-child(1), .records-panel tbody td:nth-child(2) { grid-column: span 2; }
  .records-panel tbody td:last-child { grid-column: span 2; text-align: right; }
  #jobs-body tr.row-expired { box-shadow: inset 3px 0 0 var(--red); }
  #jobs-body tr.row-due30 { box-shadow: inset 3px 0 0 var(--amber); }
  .pager { flex-direction: column; align-items: stretch; padding: 12px 16px; }
  .pager-buttons { justify-content: space-between; }
  .page-numbers { display: none; }
  .catalog-toolbar .button { margin-left: 0; width: 100%; }
}
