/* =========================================================================
   VaultBrowser Hub — konzola
   Gust operatorski UI. Sve boje idu kroz promenljive da bi tema bila
   jedna tacka izmene; nista nije hardkodovano po komponentama.
   ========================================================================= */

:root {
  --bg:          #0e1014;
  --bg-elev:     #12151c;
  --panel:       #161a22;
  --panel-2:     #1b2029;   /* hover / uneseni red */
  --panel-3:     #202634;   /* aktivno stanje */
  --border:      #262b36;
  --border-soft: #1e2530;

  --text:        #e6e9ef;
  --dim:         #8b93a3;
  --dimmer:      #666e7e;

  --accent:      #3ecfcf;
  --accent-dim:  rgba(62, 207, 207, .13);
  --accent-line: rgba(62, 207, 207, .38);
  --glow:        0 0 0 1px rgba(62, 207, 207, .35), 0 0 14px -2px rgba(62, 207, 207, .45);

  --ok:          #3ecf8e;
  --ok-bg:       rgba(62, 207, 142, .12);
  --warn:        #f5a524;
  --warn-bg:     rgba(245, 165, 36, .12);
  --danger:      #f45b5b;
  --danger-bg:   rgba(244, 91, 91, .12);
  --danger-row:  rgba(244, 91, 91, .07);

  --radius:      8px;
  --radius-sm:   5px;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --sidebar-w: 236px;
  --topbar-h: 62px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;                 /* skroluje .content, ne stranica */
}

/* Sve brojke su tabularne — kolone se ne "igraju" pri osvezavanju. */
.num, .mono, table.grid td, .kpi-value, kbd, .json-preview {
  font-variant-numeric: tabular-nums;
}

.mono { font-family: var(--mono); }

::selection { background: rgba(62, 207, 207, .28); }

/* Skrolbarovi u tonu teme */
* { scrollbar-width: thin; scrollbar-color: #2c3341 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #2c3341; border-radius: 6px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: #3a4354; }

/* =========================================================================
   Raspored
   ========================================================================= */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;                     /* dozvoljava horizontalni scroll u tabelama */
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 40px;
}

/* =========================================================================
   Sidebar
   ========================================================================= */

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.brand-mark {
  width: 24px; height: 24px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(62, 207, 207, .5));
  flex: 0 0 auto;
}
.brand-mark .s2 { stroke-linecap: round; }
.brand-mark .s3 { fill: var(--accent); stroke: none; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 13.5px; letter-spacing: .2px; }
.brand-text span { font-size: 10.5px; color: var(--dim); letter-spacing: .5px; text-transform: uppercase; }

.nav {
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: background .12s, color .12s;
}

.nav-item svg {
  width: 16px; height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}
.nav-item svg .s2 { stroke-width: 2; }

.nav-item:hover { background: var(--panel-2); color: var(--text); }

.nav-item.is-active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(62, 207, 207, .18);
}

/* Akcenat traka levo od aktivne stavke */
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -8px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.nav-item:focus-visible { outline: none; box-shadow: var(--glow); }

.nav-badge {
  margin-left: auto;
  min-width: 19px;
  padding: 1px 6px;
  border-radius: 9px;
  background: var(--warn);
  color: #17130a;
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  padding: 3px 9px 3px 7px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .6px;
  color: var(--warn);
}
.mode-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 7px var(--warn);
}
.mode-pill.is-live { color: var(--ok); }
.mode-pill.is-live .dot { background: var(--ok); box-shadow: 0 0 7px var(--ok); }

.build-line { font-size: 10.5px; color: var(--dimmer); }

/* =========================================================================
   Topbar
   ========================================================================= */

.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #12161d, #101319);
}

.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.topbar-title p { margin: 1px 0 0; font-size: 11.5px; color: var(--dim); }

.topbar-tools { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

/* --- polja --- */

.field { display: flex; flex-direction: column; gap: 3px; position: relative; }
.field-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--dimmer);
  font-weight: 600;
}

input[type="text"], input[type="search"], input[type="number"], input[type="date"], select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  font: inherit;
  font-size: 12.5px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  min-width: 0;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgba(62, 207, 207, .12);
}

input::placeholder { color: var(--dimmer); }

/* Ikonice date/search kontrola su po defaultu tamne na tamnom */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="search"]::-webkit-search-cancel-button { filter: invert(.65); cursor: pointer; }

select {
  appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%238b93a3' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 11px;
  cursor: pointer;
}

.tenant-field select { min-width: 178px; }

.search-field { min-width: 210px; }
.search-field input { padding-left: 28px; padding-right: 26px; width: 100%; }
.search-icon {
  position: absolute;
  left: 8px; bottom: 7px;
  width: 13px; height: 13px;
  fill: none; stroke: var(--dimmer); stroke-width: 1.8; stroke-linecap: round;
  pointer-events: none;
}
.kbd-hint, kbd {
  position: absolute;
  right: 7px; bottom: 7px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dimmer);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  line-height: 14px;
  pointer-events: none;
}
.search-field input:focus ~ .kbd-hint { opacity: 0; }

/* --- dugmad --- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { background: var(--panel-3); border-color: #313a4a; }
.btn:focus-visible { outline: none; box-shadow: var(--glow); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-ghost { background: transparent; color: var(--dim); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }

.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { background: rgba(62, 207, 207, .2); border-color: var(--accent); box-shadow: 0 0 12px -3px rgba(62,207,207,.5); }

.btn-sm { padding: 3px 9px; font-size: 11.5px; }

.btn-ok     { color: var(--ok);     border-color: rgba(62,207,142,.35);  background: var(--ok-bg); }
.btn-ok:hover { background: rgba(62,207,142,.2); border-color: var(--ok); }
.btn-danger { color: var(--danger); border-color: rgba(244,91,91,.35);   background: var(--danger-bg); }
.btn-danger:hover { background: rgba(244,91,91,.2); border-color: var(--danger); }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 20px;
  line-height: 1;
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.link-btn {
  border: 0; background: transparent; padding: 0;
  color: var(--accent); font: inherit; font-size: 11.5px; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* =========================================================================
   Traka greške
   ========================================================================= */

.error-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 22px -4px;
  padding: 10px 12px;
  border: 1px solid rgba(244, 91, 91, .4);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-bg);
}
.error-banner[hidden] { display: none; }
.error-banner svg {
  width: 19px; height: 19px; flex: 0 0 auto;
  fill: none; stroke: var(--danger); stroke-width: 1.6; stroke-linejoin: round;
}
.error-banner svg .s2 { stroke-linecap: round; }
.error-banner svg .s3 { fill: var(--danger); stroke: none; }
.error-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.error-body strong { font-size: 12.5px; color: #ffb4b4; }
.error-body span { font-size: 11.5px; color: var(--dim); font-family: var(--mono); word-break: break-word; }

/* =========================================================================
   Paneli
   ========================================================================= */

.view { display: none; }
.view.is-active { display: block; animation: fade .18s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(255,255,255,.018), transparent);
}
.panel-head h2 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .3px;
  display: flex; align-items: center; gap: 7px;
}
.panel-note { margin-left: auto; font-size: 11px; color: var(--dim); }
.panel-body { padding: 14px; }
.panel-foot {
  padding: 9px 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--dim);
}

.panel-pending {
  border-color: rgba(245, 165, 36, .38);
  box-shadow: 0 0 0 1px rgba(245,165,36,.07), 0 6px 22px -12px rgba(245,165,36,.5);
}
.panel-pending .panel-head { background: rgba(245, 165, 36, .07); }

.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 0 rgba(245,165,36,.6);
  animation: pulse 2s infinite;
  flex: 0 0 auto;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245,165,36,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(245,165,36,0); }
  100% { box-shadow: 0 0 0 0 rgba(245,165,36,0); }
}

/* =========================================================================
   KPI plocice
   ========================================================================= */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px 14px;
  overflow: hidden;
}
/* tanka linija u boji statusa na vrhu plocice */
.kpi::after {
  content: "";
  position: absolute; inset: 0 0 auto 0;
  height: 2px;
  background: var(--accent);
  opacity: .55;
}
.kpi[data-tone="ok"]::after     { background: var(--ok); }
.kpi[data-tone="warn"]::after   { background: var(--warn); }
.kpi[data-tone="danger"]::after { background: var(--danger); }

.kpi-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--dim);
  font-weight: 600;
  display: block;
}
.kpi-value {
  font-size: 27px;
  font-weight: 650;
  letter-spacing: -.5px;
  line-height: 1.15;
  margin-top: 5px;
  font-family: var(--mono);
}
.kpi[data-tone="ok"]     .kpi-value { color: var(--ok); }
.kpi[data-tone="warn"]   .kpi-value { color: var(--warn); }
.kpi[data-tone="danger"] .kpi-value { color: var(--danger); text-shadow: 0 0 18px rgba(244,91,91,.4); }
.kpi[data-tone="accent"] .kpi-value { color: var(--accent); }

.kpi-sub { font-size: 11px; color: var(--dimmer); margin-top: 3px; }
.kpi-sub .up { color: var(--ok); }
.kpi-sub .down { color: var(--danger); }

/* =========================================================================
   Podela na dve kolone
   ========================================================================= */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.split > .panel { margin-bottom: 0; }

/* =========================================================================
   Grafikon
   ========================================================================= */

.chart-body { padding: 8px 6px 6px; }
.chart-host { width: 100%; }
.chart-host svg { display: block; width: 100%; height: auto; }

.chart-grid-line { stroke: var(--border); stroke-width: 1; }
.chart-bar { fill: var(--accent); opacity: .65; transition: opacity .12s; rx: 2; }
.chart-bar:hover { opacity: 1; filter: drop-shadow(0 0 6px rgba(62,207,207,.7)); }
.chart-label { fill: var(--dimmer); font-size: 9.5px; font-family: var(--mono); }
.chart-axis-label { fill: var(--dimmer); font-size: 9.5px; font-family: var(--mono); }

/* =========================================================================
   Lista dogadjaja
   ========================================================================= */

.event-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }

.event-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: start;
  padding: 8px 2px;
  border-bottom: 1px dashed var(--border-soft);
}
.event-item:last-child { border-bottom: 0; }

.event-dot {
  width: 7px; height: 7px; border-radius: 50%;
  margin-top: 5px;
  background: var(--dim);
  flex: 0 0 auto;
}
.event-item[data-sev="danger"] .event-dot { background: var(--danger); box-shadow: 0 0 7px var(--danger); }
.event-item[data-sev="warn"]   .event-dot { background: var(--warn); }
.event-item[data-sev="ok"]     .event-dot { background: var(--ok); }

.event-main { min-width: 0; }
.event-name {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .1px;
}
.event-item[data-sev="danger"] .event-name { color: var(--danger); }
.event-item[data-sev="warn"]   .event-name { color: var(--warn); }
.event-meta {
  font-size: 11px;
  color: var(--dim);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-time { font-size: 10.5px; color: var(--dimmer); font-family: var(--mono); white-space: nowrap; }

/* =========================================================================
   Tabele
   ========================================================================= */

/* Kljucno za responsive: tabela skroluje UNUTAR svog kontejnera,
   layout se ne lomi i stranica nikad ne dobija horizontalni scroll. */
.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

table.grid {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
table.grid-audit { min-width: 940px; }

table.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #131720;
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--dim);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.grid thead th.num { text-align: right; }

table.grid tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  color: var(--text);
}
table.grid tbody td.num { text-align: right; font-family: var(--mono); }
table.grid tbody tr:last-child td { border-bottom: 0; }

table.grid tbody tr.is-clickable { cursor: pointer; }
table.grid tbody tr.is-clickable:hover td { background: var(--panel-2); }
table.grid tbody tr.is-selected td { background: var(--accent-dim); box-shadow: inset 3px 0 0 -1px var(--accent); }

.cell-strong { font-weight: 600; }
.cell-dim { color: var(--dim); }
.cell-mono { font-family: var(--mono); font-size: 11.5px; }
.cell-nowrap { white-space: nowrap; }
.cell-trunc { max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Red sa DPoP prekrsajem — vizuelno se izdvaja iz cele tabele. */
tr.row-danger td {
  background: var(--danger-row);
  box-shadow: inset 2px 0 0 var(--danger);
}
tr.row-danger:hover td { background: rgba(244, 91, 91, .13); }
tr.row-revoked td { opacity: .5; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* =========================================================================
   Znacke
   ========================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1.5px 7px;
  border-radius: 11px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .25px;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 16px;
}
.badge::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}
.badge.no-dot::before { display: none; }

.badge-ok      { color: var(--ok);     background: var(--ok-bg);     border-color: rgba(62,207,142,.28); }
.badge-warn    { color: var(--warn);   background: var(--warn-bg);   border-color: rgba(245,165,36,.28); }
.badge-danger  { color: var(--danger); background: var(--danger-bg); border-color: rgba(244,91,91,.28); }
.badge-neutral { color: var(--dim);    background: rgba(139,147,163,.1); border-color: rgba(139,147,163,.2); }
.badge-accent  { color: var(--accent); background: var(--accent-dim); border-color: rgba(62,207,207,.28); }

/* IdP znacke — prepoznatljive na prvi pogled */
.badge-entra    { color: #6aa8ff; background: rgba(106,168,255,.12); border-color: rgba(106,168,255,.3); }
.badge-keycloak { color: #c58cff; background: rgba(197,140,255,.12); border-color: rgba(197,140,255,.3); }

.badge-role-platform_admin { color: var(--accent); background: var(--accent-dim); border-color: rgba(62,207,207,.3); }
.badge-role-admin { color: #6aa8ff; background: rgba(106,168,255,.12); border-color: rgba(106,168,255,.28); }
.badge-role-user  { color: var(--dim); background: rgba(139,147,163,.1); border-color: rgba(139,147,163,.2); }

.chip-list { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
}
.chip.is-verified { color: var(--ok); border-color: rgba(62,207,142,.28); background: var(--ok-bg); }
.chip .chip-x {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  font-size: 13px; line-height: 1; padding: 0 0 0 2px; opacity: .6;
}
.chip .chip-x:hover { opacity: 1; color: var(--danger); }

/* Ikonica upozorenja uz tooltip */
.help {
  display: inline-grid;
  place-items: center;
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 9px;
  font-weight: 700;
  cursor: help;
  opacity: .8;
  flex: 0 0 auto;
}

/* =========================================================================
   Skeleton (stanje ucitavanja)
   ========================================================================= */

.skel {
  display: block;
  height: 9px;
  border-radius: 4px;
  background: linear-gradient(90deg, #1c212b 25%, #232a36 37%, #1c212b 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
tr.skel-row td { padding: 9px 12px; }

.empty-state {
  padding: 34px 20px;
  text-align: center;
  color: var(--dim);
}
.empty-state strong { display: block; color: var(--text); font-size: 13px; margin-bottom: 3px; font-weight: 600; }
.empty-state span { font-size: 11.5px; }

@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; }
  .pulse-dot { animation: none; }
  .view.is-active { animation: none; }
}

/* =========================================================================
   Paginacija
   ========================================================================= */

.pager { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.pager-info { font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; }

/* =========================================================================
   Filteri
   ========================================================================= */

.filters {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255,255,255,.012);
}
.filters .field select { min-width: 200px; }

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--dim);
  cursor: pointer;
  padding-bottom: 6px;
}
.check-inline input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.check-inline:hover { color: var(--text); }

/* =========================================================================
   Politika
   ========================================================================= */

.ceiling-note {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--accent-line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(62,207,207,.09), rgba(62,207,207,.02) 55%, transparent),
    var(--panel);
}
.ceiling-note svg {
  width: 22px; height: 22px; flex: 0 0 auto; margin-top: 1px;
  fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(62,207,207,.45));
}
.ceiling-note svg .s2 { stroke-linecap: round; }
.ceiling-note svg .s3 { fill: var(--accent); stroke: none; }
.ceiling-note strong { color: var(--accent); font-size: 13px; display: block; margin-bottom: 5px; }
.ceiling-note u { text-decoration-color: var(--accent-line); text-underline-offset: 2px; }
.ceiling-note p { margin: 0 0 6px; font-size: 12px; color: #c3cad6; line-height: 1.55; max-width: 105ch; }
.ceiling-note p:last-child { margin-bottom: 0; }
.ceiling-note .mono { color: var(--accent); font-size: 11.5px; }
.ceiling-note em { color: var(--text); font-style: normal; font-weight: 600; }

.policy-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .85fr);
  gap: 16px;
  align-items: start;
}
.policy-layout > .panel { margin-bottom: 0; }

.policy-form { display: flex; flex-direction: column; gap: 0; padding: 0; }

.form-section { padding: 13px 15px; border-bottom: 1px solid var(--border-soft); }
.form-section:last-child { border-bottom: 0; }

.form-section > h3 {
  margin: 0 0 3px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 7px;
}
.form-hint { font-size: 11px; color: var(--dim); margin: 0 0 10px; line-height: 1.5; }
.form-hint .mono { color: #a9b2c1; font-size: 10.5px; }

.form-row { display: flex; align-items: center; gap: 12px; padding: 5px 0; }
.form-row label.form-label { font-size: 12.5px; flex: 1; min-width: 0; }
.form-row .form-sub { display: block; font-size: 10.5px; color: var(--dimmer); }

/* --- editor liste --- */
.list-editor { display: flex; flex-direction: column; gap: 7px; }
.list-add { display: flex; gap: 6px; }
.list-add input { flex: 1; }

/* --- prekidac --- */
.switch {
  position: relative;
  width: 34px; height: 19px;
  flex: 0 0 auto;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
  padding: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--dim);
  transition: transform .15s, background .15s;
}
.switch[aria-checked="true"] {
  background: var(--accent-dim);
  border-color: var(--accent-line);
  box-shadow: 0 0 10px -3px rgba(62,207,207,.6);
}
.switch[aria-checked="true"]::after { transform: translateX(15px); background: var(--accent); }
.switch:focus-visible { outline: none; box-shadow: var(--glow); }
.switch:disabled { opacity: .4; cursor: not-allowed; }

/* --- checkbox mreza --- */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.check-item:hover { border-color: #313a4a; background: var(--panel-2); }
.check-item input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; flex: 0 0 auto; }
.check-item.is-locked { opacity: .55; cursor: not-allowed; background: rgba(244,91,91,.05); border-color: rgba(244,91,91,.22); }
.check-item.is-locked input { cursor: not-allowed; }
.check-item .lock-note { margin-left: auto; font-size: 9.5px; color: var(--danger); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.check-item code { font-family: var(--mono); font-size: 11px; }
/* U check-item-u su labela i opis jedan ispod drugog, ne jedan pored drugog. */
.check-item .form-sub { display: block; font-size: 10.5px; color: var(--dimmer); }

/* Vrednost koju ce profil odseci */
.clamp-warn {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--warn);
}
.clamp-warn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }

.version-chip {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(62,207,207,.28);
  border-radius: 11px;
  padding: 1px 9px;
}

.policy-actions .save-state { margin-left: auto; font-size: 11.5px; }
.save-state.is-dirty { color: var(--warn); }
.save-state.is-saved { color: var(--ok); }

/* --- JSON pregled --- */
.policy-preview-panel { position: sticky; top: 0; }
.json-preview {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
  color: #c3cad6;
  background: #0b0d11;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-height: 620px;
  overflow: auto;
  white-space: pre;
  tab-size: 2;
}
.json-key { color: #7fd6ff; }
.json-str { color: var(--ok); }
.json-num { color: var(--warn); }
.json-bool { color: #c58cff; }
.json-null { color: var(--dimmer); }
.json-punc { color: var(--dimmer); }

/* =========================================================================
   Drawer (detalji)
   ========================================================================= */

.scrim {
  position: fixed; inset: 0;
  background: rgba(6, 8, 11, .6);
  backdrop-filter: blur(1.5px);
  z-index: 40;
  animation: fade .15s ease;
}
.scrim[hidden] { display: none; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 92vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -22px 0 46px -20px rgba(0,0,0,.85);
  z-index: 41;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .2s cubic-bezier(.32,.72,.35,1);
  visibility: hidden;
}
.drawer.is-open { transform: none; visibility: visible; }

.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.drawer-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.drawer-head p { margin: 2px 0 0; font-size: 11.5px; color: var(--dim); font-family: var(--mono); }

.drawer-body { flex: 1; overflow-y: auto; padding: 0; }

.drawer-section { padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
.drawer-section:last-child { border-bottom: 0; }
.drawer-section > h3 {
  margin: 0 0 10px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--accent);
}

.kv { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 7px 12px; font-size: 12.5px; }
.kv dt { color: var(--dim); font-size: 11.5px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.form-grid { display: flex; flex-direction: column; gap: 11px; }
.form-grid .field-label { margin-bottom: 2px; }
.form-grid input, .form-grid select { width: 100%; }
.field-help { font-size: 10.5px; color: var(--dimmer); margin-top: 3px; line-height: 1.45; }

.drawer-actions { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg-elev); flex: 0 0 auto; }

/* =========================================================================
   Toast
   ========================================================================= */

.toast-host {
  position: fixed;
  bottom: 18px; right: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--panel-2);
  box-shadow: 0 12px 30px -12px rgba(0,0,0,.8);
  font-size: 12.5px;
  animation: toast-in .2s ease;
  pointer-events: auto;
  max-width: 380px;
}
.toast.is-ok     { border-left-color: var(--ok); }
.toast.is-warn   { border-left-color: var(--warn); }
.toast.is-danger { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* =========================================================================
   Responsive — do ~1100px
   ========================================================================= */

@media (max-width: 1280px) {
  .policy-layout { grid-template-columns: minmax(0, 1fr); }
  .policy-preview-panel { position: static; }
  .json-preview { max-height: 380px; }
}

@media (max-width: 1180px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  :root { --sidebar-w: 62px; }

  /* Sidebar se skuplja na ikone — navigacija ostaje, tekst odlazi. */
  .brand-text, .nav-item span:not(.nav-badge), .build-line { display: none; }
  .brand { justify-content: center; padding: 0; }
  .nav-item { justify-content: center; padding: 9px 0; }
  .nav-item.is-active::before { left: -8px; }
  .nav-badge {
    position: absolute;
    top: 3px; right: 6px;
    margin: 0;
    min-width: 15px;
    padding: 0 4px;
    font-size: 9.5px;
  }
  .sidebar-foot { align-items: center; padding: 10px 6px; }
  .mode-pill { padding: 3px 7px; }
  .mode-pill span:not(.dot) { display: none; }

  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-title p { display: none; }
  .content { padding: 14px; }
  .error-banner { margin: 12px 14px -2px; }
  .search-field { min-width: 150px; }
  .tenant-field select { min-width: 140px; }
  .refresh-label { display: none; }
}

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .filters .field select { min-width: 150px; }
}

/* =========================================================================
   Sirine kolona po tabeli
   Namerno u CSS-u, a ne kao style="" na <th>: strogi CSP (style-src 'self')
   blokira i style ATRIBUT, pa bi tabele ostale bez sirina kolona.
   ========================================================================= */

#tenantsTable thead th:nth-child(1) { width: 24%; }
#tenantsTable thead th:nth-child(2) { width: 14%; }
#tenantsTable thead th:nth-child(3) { width: 26%; }
#tenantsTable thead th:nth-child(4) { width: 12%; }
#tenantsTable thead th:nth-child(5) { width: 10%; }
#tenantsTable thead th:nth-child(6) { width: 14%; }

#usersTable thead th:nth-child(1) { width: 26%; }
#usersTable thead th:nth-child(2) { width: 20%; }
#usersTable thead th:nth-child(3) { width: 14%; }
#usersTable thead th:nth-child(4) { width: 16%; }
#usersTable thead th:nth-child(5) { width: 12%; }
#usersTable thead th:nth-child(6) { width: 12%; }

#pendingTable thead th:nth-child(1) { width: 18%; }
#pendingTable thead th:nth-child(2) { width: 22%; }
#pendingTable thead th:nth-child(3) { width: 16%; }
#pendingTable thead th:nth-child(4) { width: 12%; }
#pendingTable thead th:nth-child(5) { width: 16%; }
#pendingTable thead th:nth-child(6) { width: 16%; }

#devicesTable thead th:nth-child(1) { width: 15%; }
#devicesTable thead th:nth-child(2) { width: 19%; }
#devicesTable thead th:nth-child(3) { width: 13%; }
#devicesTable thead th:nth-child(4) { width: 9%; }
#devicesTable thead th:nth-child(5) { width: 13%; }
#devicesTable thead th:nth-child(6) { width: 11%; }
#devicesTable thead th:nth-child(7) { width: 11%; }
#devicesTable thead th:nth-child(8) { width: 9%; }

#auditTable thead th:nth-child(1) { width: 14%; }
#auditTable thead th:nth-child(2) { width: 14%; }
#auditTable thead th:nth-child(3) { width: 18%; }
#auditTable thead th:nth-child(4) { width: 19%; }
#auditTable thead th:nth-child(5) { width: 11%; }
#auditTable thead th:nth-child(6) { width: 24%; }
