/* ===================== design tokens ===================== */
:root {
  --bg: #0a0d13;
  --bg-soft: #0e1219;
  --surface: #12161f;
  --surface-2: #171c27;
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .14);
  --text: #e9edf4;
  --text-soft: #b6bfcd;
  --muted: #7e8899;
  --accent: #e40000;
  --accent-2: #ff5a3c;
  --teal: #2dd4bf;
  --blue: #60a5fa;
  --violet: #a78bfa;
  --amber: #fbbf24;
  --rose: #fb7185;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 480px at 88% -12%, rgba(228, 0, 0, .075), transparent 60%),
    radial-gradient(900px 420px at -12% -4%, rgba(96, 165, 250, .055), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

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

/* ===================== nav ===================== */
nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; gap: .25rem; align-items: center;
  padding: .65rem 1.6rem;
  background: rgba(10, 13, 19, .72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
nav .brand {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 800; font-size: 1rem; letter-spacing: -.02em;
  color: var(--text); text-decoration: none; margin-right: 1.3rem;
}
nav .brand .dot {
  width: 24px; height: 24px; border-radius: 8px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 16px rgba(228, 0, 0, .4);
}
nav a:not(.brand) {
  color: var(--muted); text-decoration: none;
  font-weight: 500; font-size: .9rem;
  padding: .42rem .85rem; border-radius: 9px;
  transition: background .15s, color .15s;
}
nav a:not(.brand):hover { color: var(--text); background: rgba(255, 255, 255, .05); }
nav a.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(228, 0, 0, .26), rgba(228, 0, 0, .08));
  box-shadow: inset 0 0 0 1px rgba(228, 0, 0, .42);
}

/* ===================== layout ===================== */
main { max-width: 1220px; margin: 0 auto; padding: 1.4rem 1.6rem 3rem; }
.page-head { margin: .4rem 0 1.5rem; animation: rise .4s ease both; }
.page-head h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.035em; margin: 0; }
.page-head p { color: var(--muted); margin: .4rem 0 0; font-size: .92rem; }
h2 { font-size: 1.02rem; font-weight: 700; letter-spacing: -.01em; margin: 1.9rem 0 .5rem; }
.muted { color: var(--muted); font-size: .85rem; }

/* ===================== kpi cards ===================== */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: .9rem; margin-bottom: 1.3rem;
}
.kpi {
  position: relative; overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .95rem 1.05rem;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  animation: rise .5s ease both;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.kpi:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.kpi::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 2px; opacity: .65;
  background: linear-gradient(90deg, var(--tint, var(--accent)), transparent 80%);
}
.kpi .chip {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px; font-size: 14px;
  margin-bottom: .55rem;
  background: color-mix(in srgb, var(--tint, var(--accent)) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--tint, var(--accent)) 30%, transparent);
}
.kpi .lbl {
  display: block; color: var(--muted);
  font-size: .7rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; margin-bottom: .2rem;
}
.kpi strong {
  font-size: 1.22rem; font-weight: 700; letter-spacing: -.015em;
  font-variant-numeric: tabular-nums;
}

/* ===================== cards & charts ===================== */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 1rem; }
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.05rem 1.1rem;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  animation: rise .5s ease both;
  transition: border-color .2s;
}
.card:hover { border-color: var(--border-strong); }
.card.wide { grid-column: 1 / -1; }
.card h3 {
  font-size: .74rem; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; margin: 0 0 .85rem;
}
.chart { position: relative; height: 235px; }
.grid .card:nth-child(2) { animation-delay: .05s; }
.grid .card:nth-child(3) { animation-delay: .1s; }
.grid .card:nth-child(4) { animation-delay: .15s; }
.grid .card:nth-child(5) { animation-delay: .2s; }
.grid .card:nth-child(6) { animation-delay: .25s; }
.grid .card:nth-child(7) { animation-delay: .3s; }

/* ===================== tables ===================== */
table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: .88rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  margin: .2rem 0 1.4rem;
}
th, td { text-align: left; padding: .55rem .8rem; }
th {
  color: var(--muted); font-weight: 600; font-size: .7rem;
  text-transform: uppercase; letter-spacing: .06em;
  background: rgba(255, 255, 255, .035);
  border-bottom: 1px solid var(--border);
}
td { border-bottom: 1px solid rgba(255, 255, 255, .045); font-variant-numeric: tabular-nums; }
tbody tr:hover td, table tr:hover td { background: rgba(255, 255, 255, .03); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }
tr.total td {
  font-weight: 700; background: rgba(255, 255, 255, .045);
  border-top: 1px solid var(--border-strong);
}

/* ===================== flash ===================== */
.flash {
  display: flex; gap: .55rem; align-items: center;
  padding: .78rem 1rem; border-radius: 12px;
  margin-bottom: 1.1rem; font-size: .92rem;
  border: 1px solid; animation: rise .35s ease both;
}
.flash.ok    { background: rgba(45, 212, 191, .06); border-color: rgba(45, 212, 191, .32); color: #86efac; }
.flash.warn  { background: rgba(251, 191, 36, .06); border-color: rgba(251, 191, 36, .35); color: #fcd34d; }
.flash.error { background: rgba(228, 0, 0, .07); border-color: rgba(228, 0, 0, .45); color: #fca5a5; }

/* ===================== forms & buttons ===================== */
input, select {
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: .52rem .75rem; font: inherit; font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: rgba(228, 0, 0, .55);
  box-shadow: 0 0 0 3px rgba(228, 0, 0, .18);
}
button, .btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: 0; border-radius: 10px;
  padding: .55rem 1.15rem; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; display: inline-block;
  box-shadow: 0 6px 18px rgba(228, 0, 0, .28);
  transition: transform .15s, box-shadow .15s;
}
button:hover, .btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(228, 0, 0, .35); }
.btn.ghost {
  background: rgba(255, 255, 255, .06); box-shadow: none;
  border: 1px solid var(--border); color: var(--text-soft);
}
.btn.ghost:hover { transform: none; background: rgba(255, 255, 255, .09); }
button.danger {
  background: rgba(255, 77, 61, .08); box-shadow: none;
  border: 1px solid rgba(255, 77, 61, .35); color: #ff8d80;
  padding: .25rem .7rem; font-weight: 500;
}
button.danger:hover { transform: none; background: rgba(255, 77, 61, .14); }

.filters {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  margin: 0 0 1.2rem; animation: rise .4s ease both;
}

/* ===================== explore filter bar ===================== */
.filterbar {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1.2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .18);
  animation: rise .4s ease both;
}
.filterbar label {
  color: var(--muted); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em; font-weight: 600;
  display: flex; flex-direction: column; gap: .35rem;
}
.frow { display: flex; flex-wrap: wrap; gap: .8rem 1.1rem; align-items: flex-end; }
.frow + .frow { margin-top: .9rem; }
.chks { display: flex; gap: .4rem .9rem; flex-wrap: wrap; align-items: center; }
label.chk {
  flex-direction: row; align-items: center; gap: .35rem;
  text-transform: none; letter-spacing: 0; font-size: .85rem;
  font-weight: 500; color: var(--text);
}
.range { display: flex; gap: .4rem; align-items: center; }
input.mini { width: 4.6rem; }

.grid2 {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem; margin-bottom: 1.1rem;
}
.grid2 table { margin-bottom: 0; }

.minibar {
  height: 4px; border-radius: 99px; background: rgba(255, 255, 255, .07);
  margin-top: .35rem; width: 100%; max-width: 190px; overflow: hidden;
}
.minibar i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* ===================== upload dropzone ===================== */
.dropzone { border-style: dashed; border-color: var(--border-strong); }
.dropzone p { color: var(--muted); margin: .3rem 0 1rem; font-size: .92rem; }

/* ===================== misc ===================== */
.pager { display: flex; gap: .8rem; margin-top: .8rem; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #232b3a; border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ===================== polish pass ===================== */
html { scroll-behavior: smooth; }
::selection { background: rgba(228, 0, 0, .45); color: #fff; }
:focus-visible { outline: 2px solid rgba(228, 0, 0, .65); outline-offset: 2px; border-radius: 6px; }

/* active filter chips */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0 0 1.1rem; animation: rise .35s ease both; }
.chipx {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .32rem .75rem; border-radius: 99px; font-size: .8rem;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--border);
  color: var(--text-soft); text-decoration: none; transition: all .15s;
}
.chipx:hover {
  border-color: rgba(228, 0, 0, .55); color: #fff;
  background: rgba(228, 0, 0, .13); transform: translateY(-1px);
}
.chipx span { color: var(--muted); font-weight: 700; }
.chipx:hover span { color: #ffb3ad; }

/* numbered pagination */
.pbtn {
  min-width: 34px; padding: .35rem .6rem; text-align: center; border-radius: 8px;
  border: 1px solid var(--border); background: rgba(255, 255, 255, .05);
  color: var(--text-soft); text-decoration: none; font-size: .85rem;
  font-variant-numeric: tabular-nums; transition: all .15s;
}
a.pbtn:hover { color: #fff; border-color: var(--border-strong); transform: translateY(-1px); }
.pbtn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 0; color: #fff; font-weight: 700;
  box-shadow: 0 4px 14px rgba(228, 0, 0, .3);
}
.pgap { color: var(--muted); padding: 0 .25rem; }

/* empty states */
.empty { text-align: center; padding: 2.4rem 1rem; }
.empty p { margin: .4rem 0 1.1rem; }
.empty-ico { font-size: 2.1rem; }
.card.empty .empty-ico { margin-bottom: .2rem; }

/* status pill + current-row highlight */
.pill {
  display: inline-block; font-size: .6rem; font-weight: 800; letter-spacing: .07em;
  text-transform: uppercase; color: #fff; margin-left: .4rem; vertical-align: middle;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: .14rem .52rem; border-radius: 99px;
}
tr.current td { background: rgba(228, 0, 0, .055); }
tr.current:hover td { background: rgba(228, 0, 0, .08); }

/* dropzone drag feedback */
.dropzone { text-align: center; padding: 1.6rem 1.2rem; transition: all .18s; }
.dropzone .filters { justify-content: center; margin: .9rem 0 .3rem; }
.dropzone.drag {
  border-color: rgba(228, 0, 0, .6) !important;
  background: rgba(228, 0, 0, .06) !important;
  box-shadow: 0 0 0 4px rgba(228, 0, 0, .12);
  transform: scale(1.008);
}

/* footer */
.site-foot {
  text-align: center; color: var(--muted); font-size: .78rem;
  padding: 1.5rem 1rem 1.2rem; border-top: 1px solid var(--border);
  margin-top: 2.4rem;
}

/* ===================== login page ===================== */
nav .logout-link { margin-left: auto; font-size: .84rem; color: var(--muted); }
nav .logout-link:hover {
  color: #ff8d80; background: rgba(228, 0, 0, .08);
  box-shadow: inset 0 0 0 1px rgba(228, 0, 0, .3);
}

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.login-card {
  width: min(400px, 100%);
  border: 1px solid var(--border); border-radius: 18px;
  padding: 2.1rem 2rem 1.5rem;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  animation: rise .5s ease both;
  display: flex; flex-direction: column; gap: .85rem;
}
.login-card .flash { margin: 0; }
.login-brand {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em;
}
.login-brand .dot {
  width: 30px; height: 30px; border-radius: 10px;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 16px rgba(228, 0, 0, .4);
}
.login-sub { color: var(--muted); margin: 0 0 .3rem; font-size: .92rem; }
.login-card label {
  color: var(--muted); font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  display: flex; flex-direction: column; gap: .4rem;
}
.pw { position: relative; display: flex; }
.pw input { flex: 1; padding-right: 2.9rem; }
.pw button {
  position: absolute; right: .45rem; top: 50%; transform: translateY(-50%);
  background: none; border: 0; padding: .2rem; cursor: pointer;
  font-size: 1rem; opacity: .55; box-shadow: none;
}
.pw button:hover { opacity: 1; }
.login-btn { width: 100%; padding: .72rem; font-size: 1rem; margin-top: .3rem; }
.login-foot { text-align: center; color: var(--muted); font-size: .74rem; margin: .7rem 0 0; }
.tscroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
}
.tscroll table { margin-bottom: .8rem; min-width: 620px; }

@media (max-width: 700px) {
  main { padding: 1rem .9rem 2.4rem; }
  nav { padding: .55rem .9rem; flex-wrap: wrap; gap: .15rem; }
  nav .brand { margin-right: .6rem; }
  nav a:not(.brand) { padding: .38rem .7rem; font-size: .86rem; }
  .page-head h1 { font-size: 1.3rem; }
  .grid, .grid2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: .7rem; }
  .kpi strong { font-size: 1.08rem; }
  .chart { height: 215px; }
  .filters input[type="text"] { flex: 1 1 160px; }
  .frow { gap: .7rem .9rem; }
}
