:root{
  --bg:#f4f6fb;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e6eaf2;

  --blue:#2f3f8f;
  --blue2:#334aa6;

  --ok:#16a34a;
  --warn:#f59e0b;
  --alarm:#ef4444;

  --radius:16px;

  --ring:0 0 0 4px rgba(51,74,166,0.14);
  --shadow-sm:0 6px 18px rgba(15,23,42,0.08);
  --shadow-md:0 12px 34px rgba(15,23,42,0.10);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  color:var(--text);
  background:var(--bg);
}

a{ color:inherit; text-decoration:none; }
code{
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;
  font-size:.95em;
}

/* ========== TOPBAR ========== */
.topbar{
  background:var(--blue);
  position:sticky;
  top:0;
  z-index:10;
  box-shadow:0 10px 28px rgba(0,0,0,.16);
  border-bottom:1px solid rgba(255,255,255,.10);
}

.topbar__inner{
  max-width:1200px;
  margin:0 auto;
  padding:12px 18px;
  min-height:64px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}

.topbar__left{
  display:flex;
  align-items:center;
  gap:14px;
  min-width:0;
}

.brand{
  display:inline-flex;
  align-items:center;
  padding:4px 6px;
  border-radius:12px;
}
.brand:focus-visible{
  outline:none;
  box-shadow:0 0 0 3px rgba(255,255,255,.22), 0 0 0 6px rgba(0,0,0,.10);
}
.brand__logo{ height:38px; width:auto; display:block; }

.nav{
  display:flex;
  align-items:center;
  gap:10px;
  white-space:nowrap;
}

.nav__link{
  color:rgba(255,255,255,.92);
  font-weight:700;
  font-size:14px;
  padding:9px 12px;
  border-radius:12px;
  transition:background 140ms ease, transform 140ms ease, color 140ms ease;
}
.nav__link:hover{ background:rgba(255,255,255,.10); color:#fff; }
.nav__link:active{ transform:translateY(1px); }

.topbar__right{
  display:flex;
  align-items:center;
  gap:12px;
}

/* language dropdown */
.lang{ position:relative; }

.lang__btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:9px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.18);
  background:rgba(255,255,255,.10);
  color:rgba(255,255,255,.92);
  font-weight:800;
  font-size:14px;
  cursor:pointer;
  transition:background 140ms ease, transform 140ms ease, border-color 140ms ease;
}
.lang__btn:hover{ background:rgba(255,255,255,.16); }
.lang__btn:active{ transform:translateY(1px); }
.lang__chev{ opacity:.85; font-size:12px; }

.lang__menu{
  position:absolute;
  top:100%;
  left:0;
  margin-top:8px;
  min-width:180px;
  padding:8px;
  border-radius:14px;
  border:1px solid rgba(15,23,42,.10);
  background:#fff;
  box-shadow:0 14px 36px rgba(15,23,42,.18);
  display:none;
  z-index:50;
}
.lang__menu::before{
  content:"";
  position:absolute;
  top:-10px;
  left:0;
  right:0;
  height:10px;
}
.lang:hover .lang__menu,
.lang:focus-within .lang__menu{ display:block; }

.lang__item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 10px;
  border-radius:12px;
  font-weight:800;
  color:rgba(15,23,42,.86);
}
.lang__item:hover{
  background:rgba(51,74,166,.08);
  color:rgba(15,23,42,1);
}

/* user pill */
.userpill{
  display:none;
  background:rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.18);
  color:rgba(255,255,255,.95);
  padding:8px 10px;
  border-radius:999px;
  align-items:center;
  gap:10px;
  font-size:13px;
  max-width:360px;
}
.userpill__name{
  font-weight:700;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.userpill__role{
  opacity:.85;
  font-weight:800;
  letter-spacing:.06em;
  font-size:11px;
}

/* ========== PAGE ========== */
.page{
  max-width:1200px;
  margin:0 auto;
  padding:18px 18px 40px;
  min-height:calc(100vh - 88px);
}
.container{ max-width:1200px; margin:0 auto; }

.pagehead{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:14px;
  margin-bottom:14px;
}
.h1{ margin:0; font-size:26px; letter-spacing:-.02em; }
.sub{ margin:6px 0 0; color:var(--muted); }

/* ========== CARDS ========== */
.card{
  background:var(--card);
  border:1px solid rgba(230,234,242,.95);
  border-radius:var(--radius);
  box-shadow:var(--shadow-sm);
}
.card:hover{ box-shadow:var(--shadow-md); }

.card__head{
  padding:16px 18px 10px;
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
}
.card__title{ font-weight:900; font-size:15px; }
.card__meta{ color:var(--muted); font-size:13px; font-weight:700; }

.strong{ font-weight:800; }

/* ========== FILTERS BAR (NEW) ========== */
.filtersbar{
  display:grid;
  grid-template-columns:1fr auto;
  gap:14px;
  align-items:stretch;
  margin-bottom:14px;
}

.filters{ padding:0 18px 18px; }

.filters__row{
  display:grid;
  grid-template-columns:1.6fr .7fr auto auto;
  gap:10px;
  align-items:center;
}

/* ========== KPI ROW ========== */
.kpirow{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:10px;
}
.kpirow--compact .kpicard{
  min-width:92px;
  justify-content:center;
  text-align:center;
  padding:12px 12px;
}

.kpicard{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--border);
  background:var(--card);
  box-shadow:var(--shadow-sm);
}
.kpicard__label{
  font-weight:900;
  font-size:11px;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:rgba(15,23,42,.55);
}
.kpicard__value{
  font-weight:900;
  font-size:22px;
  letter-spacing:-.02em;
  color:var(--text);
}
.kpicard--ok{ border-color:rgba(22,163,74,.22); background:rgba(22,163,74,.04); }
.kpicard--warn{ border-color:rgba(245,158,11,.26); background:rgba(245,158,11,.05); }
.kpicard--alarm{ border-color:rgba(239,68,68,.26); background:rgba(239,68,68,.05); }

/* ========== BUTTONS / INPUTS ========== */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 14px;
  border-radius:14px;
  border:1px solid transparent;
  cursor:pointer;
  font-weight:800;
  font-size:14px;
  user-select:none;
  transition:transform 140ms ease, filter 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.btn:active{ transform:translateY(1px); }

.btn--primary{
  background:var(--blue2);
  color:#fff;
  border-color:rgba(255,255,255,.12);
}
.btn--primary:hover{ filter:brightness(1.06); }

.btn--ghost{
  background:rgba(51,74,166,.08);
  color:rgba(15,23,42,.86);
  border-color:rgba(51,74,166,.18);
}
.btn--ghost:hover{
  background:rgba(51,74,166,.12);
  border-color:rgba(51,74,166,.24);
}

.btn:focus-visible{ outline:none; box-shadow:var(--ring); }

.input,.select{
  width:100%;
  padding:11px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background:#fff;
  font-size:14px;
  outline:none;
  transition:box-shadow 140ms ease, border-color 140ms ease;
}
.input:focus,.select:focus{
  border-color:rgba(51,74,166,.55);
  box-shadow:var(--ring);
}
.select{ appearance:none; }

/* ========== TABLE ========== */
.tablewrap{
  padding:0 0 12px;
  overflow:auto;
  border-radius:var(--radius);
}
.table{
  width:100%;
  border-collapse:collapse;
  min-width:780px;
}
.table thead th{
  text-align:left;
  font-size:12px;
  letter-spacing:.06em;
  text-transform:uppercase;
  color:var(--muted);
  padding:12px 18px;
  border-bottom:1px solid var(--border);
  background:transparent;
}
.table tbody td{
  padding:14px 18px;
  border-bottom:1px solid rgba(230,234,242,.7);
  vertical-align:middle;
  font-size:14px;
}
.table tbody tr:hover{ background:rgba(51,74,166,.035); }
.rowlink{ cursor:pointer; }

/* chips */
.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:5px 9px;
  border-radius:999px;
  font-weight:800;
  font-size:11px;
  border:1px solid var(--border);
}
.chip::before{
  content:"";
  width:7px;
  height:7px;
  border-radius:50%;
  background:currentColor;
  display:inline-block;
}
.chip--ok{ color:var(--ok); background:rgba(22,163,74,.08); border-color:rgba(22,163,74,.22); }
.chip--warn{ color:var(--warn); background:rgba(245,158,11,.10); border-color:rgba(245,158,11,.26); }
.chip--alarm{ color:var(--alarm); background:rgba(239,68,68,.10); border-color:rgba(239,68,68,.26); }

/* empty state */
.empty{ padding:18px 18px 22px; color:var(--muted); }
.empty__title{ font-weight:900; color:rgba(15,23,42,.86); }
.empty__text{ margin-top:6px; }

/* flash */
.flashwrap{ max-width:1200px; margin:0 auto 14px; }
.flash{
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--border);
  background:#fff;
  box-shadow:var(--shadow-sm);
  font-weight:700;
}
.flash--error{
  border-color:rgba(239,68,68,.30);
  background:rgba(239,68,68,.08);
}

/* footer */
.footer{
  border-top:1px solid var(--border);
  background:#fff;
}
.footer__inner{
  max-width:1200px;
  margin:0 auto;
  padding:18px 18px;
  display:flex;
  justify-content:space-between;
  gap:12px;
  color:var(--muted);
  font-size:13px;
}
.footer__muted{ opacity:.85; }

/* responsive */
@media (max-width:1000px){
  .filtersbar{ grid-template-columns:1fr; }
  .filters__row{ grid-template-columns:1fr; }
  .nav{ display:none; }
  .userpill{ display:inline-flex; }
}
@media (max-width:560px){
  .kpirow{ grid-template-columns:1fr; }
}
