:root{
  --bg:#0b1220;
  --panel:#111b2e;
  --panel2:#0f182a;
  --text:#e9f0ff;
  --muted:rgba(233,240,255,.72);
  --border:rgba(255,255,255,.10);
  --shadow:0 14px 38px rgba(0,0,0,.35);
  --btn:#e11d48;
  --btn2:#b91c1c;
  --btnText:#fff;
  --chip:rgba(255,255,255,.10);
  --tableRow:rgba(255,255,255,.04);
}

html[data-theme="light"]{
  --bg:#f6f7fb;
  --panel:#ffffff;
  --panel2:#fbfbff;
  --text:#0f172a;
  --muted:rgba(15,23,42,.70);
  --border:rgba(15,23,42,.12);
  --shadow:0 14px 38px rgba(15,23,42,.10);
  --btn:#dc2626;
  --btn2:#b91c1c;
  --btnText:#fff;
  --chip:rgba(15,23,42,.06);
  --tableRow:rgba(15,23,42,.04);
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family:system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:radial-gradient(1200px 650px at 30% 10%, rgba(255,255,255,.08), transparent 55%),
             radial-gradient(900px 550px at 90% 0%, rgba(225,29,72,.12), transparent 55%),
             var(--bg);
  color:var(--text);
}

a{color:inherit; text-decoration:none}
.container{max-width:1180px; margin:0 auto; padding:18px}
.muted{color:var(--muted)}
.hidden{display:none !important}

/* Layout with sticky footer */
.page{
  min-height:100vh;
  display:flex;
  flex-direction:column;
}
main{flex:1}

/* Topbar */
.topbar{
  position:sticky;
  top:0;
  z-index:20;
  backdrop-filter: blur(10px);
  background:linear-gradient(180deg, rgba(0,0,0,.35), rgba(0,0,0,.08));
  border-bottom:1px solid var(--border);
}
.topbar__inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 18px;
  max-width:1180px;
  margin:0 auto;
}
.brand__title{
  font-weight:800;
  letter-spacing:.6px;
  font-size:14px;
  text-transform:uppercase;
}
.brand__subtitle{
  font-size:12px;
  color:var(--muted);
  margin-top:2px;
}

.nav{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:flex-end;
}
.nav a{
  padding:8px 12px;
  border:1px solid var(--border);
  border-radius:12px;
  background:rgba(255,255,255,.04);
}
.nav a.active{
  border-color:rgba(225,29,72,.45);
  box-shadow:0 0 0 3px rgba(225,29,72,.12);
}

.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  background:var(--chip);
  border:1px solid var(--border);
  border-radius:999px;
  padding:8px 12px;
  font-size:12px;
}

.btn{
  border:0;
  cursor:pointer;
  border-radius:14px;
  padding:10px 14px;
  font-weight:800;
  color:var(--btnText);
  background:linear-gradient(180deg, var(--btn), var(--btn2));
  box-shadow:0 10px 18px rgba(0,0,0,.22);
}
.btn:active{transform:translateY(1px)}
.btn--ghost{
  background:transparent;
  border:1px solid var(--border);
  color:var(--text);
  box-shadow:none;
}
.btn--small{padding:8px 10px; border-radius:12px; font-size:12px}

.panel{
  background:linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.03));
  border:1px solid var(--border);
  box-shadow:var(--shadow);
  border-radius:18px;
  padding:16px;
  margin-top:14px;
}
.panel__title{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  font-weight:900;
  letter-spacing:.2px;
}

/* Alerts */
.alert{
  margin-top:12px;
  border-radius:14px;
  padding:12px 14px;
  border:1px solid var(--border);
}
.alert--ok{ background:rgba(34,197,94,.12); }
.alert--warn{ background:rgba(245,158,11,.14); }
.alert--bad{ background:rgba(239,68,68,.14); }

/* Forms */
.uploader{
  margin-top:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.uploader__help{font-size:12px; color:var(--muted)}

.filters{
  display:grid;
  grid-template-columns:repeat(6, minmax(0, 1fr));
  gap:10px;
  margin-top:12px;
}
.field label{
  font-size:12px;
  color:var(--muted);
  display:block;
  margin-bottom:6px;
}
.field input, .field select{
  width:100%;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  color:var(--text);
  outline:none;
}
.field .hint{margin-top:6px; font-size:11px; color:var(--muted)}
.field--actions{
  display:flex;
  gap:8px;
  align-items:flex-end;
  justify-content:flex-end;
}
@media (max-width:1100px){
  .filters{grid-template-columns:repeat(2, minmax(0, 1fr))}
  .field--actions{grid-column:1/-1; justify-content:flex-start; flex-wrap:wrap}
}

/* KPI cards */
.kpi-grid{
  margin-top:12px;
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:10px;
}
.kpi{
  border-radius:16px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  padding:12px;
}
.kpi__label{font-size:12px; color:var(--muted)}
.kpi__value{font-size:22px; font-weight:900; margin-top:4px}
.kpi__sub{font-size:12px; color:var(--muted); margin-top:4px}
@media (max-width:1100px){
  .kpi-grid{grid-template-columns:repeat(2, minmax(0, 1fr))}
}

/* Tables with top+bottom scrollbars */
.table-tools{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  margin-top:12px;
}
.search{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  color:var(--text);
  min-width:260px;
}

.scrollbar-top{
  height:14px;
  overflow-x:auto;
  overflow-y:hidden;
  border:1px solid var(--border);
  border-radius:12px;
  background:rgba(255,255,255,.03);
}
.scrollbar-top .scrollbar-inner{
  height:1px;
}

.table-wrap{
  margin-top:10px;
  overflow-x:auto;
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(255,255,255,.02);
}
table{
  width:max-content;
  min-width:100%;
  border-collapse:collapse;
}
th, td{
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  border-right:1px solid var(--border);
  white-space:nowrap;
  font-size:12px;
}
th{
  position:sticky;
  top:0;
  background:rgba(0,0,0,.18);
  backdrop-filter: blur(8px);
  font-weight:900;
}
tr:nth-child(even) td{background:var(--tableRow)}

/* Footer */
.footer{
  margin-top:auto;               /* IMPORTANT: pushes footer to bottom */
  border-top:1px solid var(--border);
  padding:14px 10px;
  text-align:center;
  color:var(--muted);
  font-size:12px;
}
.footer .line{display:block; margin:2px 0}


/* Modal for data entry */
.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.55);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  z-index:100;
}
.modal__card{
  width:min(980px, 100%);
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:var(--shadow);
  padding:14px;
}
.modal__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}
.modal__grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:10px;
}
@media (max-width:900px){
  .modal__grid{grid-template-columns:repeat(1, minmax(0, 1fr))}
}
