:root {
  --bg: #0a090c;
  --bg-2: #0e0c12;
  --surface: #131017;
  --surface-2: #181420;
  --line: #ffffff12;
  --line-2: #ffffff1f;
  --text: #ece8f0;
  --muted: #8f8896;
  --faint: #66606e;
  --accent: #b545f0;
  --accent-2: #6b5bff;
  --accent-soft: #b545f024;
  --green: #4bbd8e;
  --red: #e0697a;
  --amber: #e0a55e;
  --sidebar: 236px;
  --topbar: 64px;
  --bottombar: 66px;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 520px at 8% -10%, #b545f01c, transparent 60%),
    radial-gradient(760px 420px at 100% 0%, #6b5bff18, transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.brand { display: grid; gap: 1px; }
.brand strong { font-size: 15px; letter-spacing: -0.02em; }
.brand span { color: var(--faint); font-size: 11px; letter-spacing: .04em; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); cursor: pointer; color: var(--muted);
  transition: border-color .15s, color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--line-2); color: var(--text); background: var(--surface-2); }
.icon-btn:active { transform: scale(.96); }
.icon-btn.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Login ============ */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  width: min(100%, 400px);
  display: grid; gap: 16px;
  padding: 32px 28px calc(28px + var(--safe-b));
  border: 1px solid var(--line); border-radius: 22px;
  background: linear-gradient(180deg, #18141ff0, #100e14f4);
  box-shadow: 0 30px 80px #00000088, inset 0 1px #ffffff0e;
}
.login-mark {
  display: grid; place-items: center;
  width: 52px; height: 52px; margin-bottom: 2px;
  border-radius: 15px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px #b545f055;
}
.login-mark svg { width: 24px; height: 24px; }
.input { display: grid; gap: 7px; }
.input > span { color: var(--muted); font-size: 12px; }
.input > div {
  display: flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 8px 0 14px;
  border: 1px solid var(--line); border-radius: 13px; background: #0a0810;
  transition: border-color .15s, box-shadow .15s;
}
.input > div:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input > div > svg { color: var(--faint); width: 19px; height: 19px; }
.input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 15px; }
.peek { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--faint); cursor: pointer; }
.peek:hover { color: var(--text); background: #ffffff0a; }
button.primary {
  height: 48px; margin-top: 4px;
  border: 0; border-radius: 13px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #7a3ef0);
  color: #fff; font-size: 15px; font-weight: 620; letter-spacing: -0.01em;
  box-shadow: 0 10px 26px #b545f03d;
}
button.primary:disabled { opacity: .6; cursor: default; }
.feedback { min-height: 16px; margin: 0; color: var(--red); font-size: 12.5px; }

/* ============ App shell ============ */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 14px 18px;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 22px; }
.side-nav { display: grid; gap: 4px; }
.side-nav button, .bottombar button {
  display: flex; align-items: center; gap: 12px;
  width: 100%; height: 44px; padding: 0 12px;
  border: 0; border-radius: 12px; background: transparent;
  color: var(--muted); font-size: 13.5px; text-align: left; cursor: pointer;
  transition: background .15s, color .15s;
}
.side-nav button:hover { background: #ffffff07; color: var(--text); }
.side-nav button.active { background: var(--accent-soft); color: #fff; }
.side-nav button.active svg { color: var(--accent); }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding: 16px 8px 0; border-top: 1px solid var(--line); }
.side-user { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--muted); font-size: 12.5px; }
.side-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--topbar); padding: 12px 26px;
  border-bottom: 1px solid var(--line);
  background: #0a090ce6; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.top-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.title h1 { margin: 0; font-size: 17px; font-weight: 640; letter-spacing: -0.02em; }
.title p { margin: 1px 0 0; color: var(--faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.filters { display: flex; align-items: center; gap: 8px; }
.field {
  display: flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 10px 0 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  transition: border-color .15s;
}
.field:focus-within { border-color: var(--accent); }
.field > svg { color: var(--faint); width: 18px; height: 18px; }
.field select, .field input {
  height: 100%; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 13.5px;
}
.field select { padding-right: 4px; max-width: 200px; }
.field input[type="date"] { width: 140px; }

.warning {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 16px 26px 0; padding: 12px 14px;
  border: 1px solid #e0a55e40; border-radius: 13px;
  background: #e0a55e12; color: var(--amber); font-size: 12.5px; line-height: 1.45;
}
.warning svg { margin-top: 1px; width: 18px; height: 18px; }

.content { flex: 1; padding: 22px 26px 30px; }
.view { display: none; }
.view.active { display: block; }
.view.enter { animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ Cards ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 13px; }
.cards + .cards { margin-top: 13px; }
.cards.hero { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.card {
  position: relative; display: grid; gap: 9px; align-content: start;
  min-width: 0; min-height: 118px; padding: 17px 18px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow: inset 0 1px #ffffff09;
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.card-top .label { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.card-ico {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 10px; background: #ffffff08; color: var(--muted);
}
.card-ico svg { width: 18px; height: 18px; }
.card .value { font-size: 25px; font-weight: 660; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; line-height: 1.1; overflow-wrap: anywhere; }
.card .hint { color: var(--faint); font-size: 11.5px; }
.card.key { border-color: #b545f044; background: linear-gradient(150deg, #b545f018, var(--surface) 60%); }
.card.key .card-ico { background: var(--accent-soft); color: var(--accent); }
.card.good .value { color: var(--green); }
.card.good .card-ico { background: #4bbd8e1c; color: var(--green); }
.card.bad .value { color: var(--red); }
.card.bad .card-ico { background: #e0697a1c; color: var(--red); }
.card.warn .value { color: var(--amber); }
.card.warn .card-ico { background: #e0a55e1c; color: var(--amber); }
.hero .card { min-height: 128px; }
.hero .card .value { font-size: 28px; }

.skeleton .card { opacity: .5; }
.skeleton .value { color: transparent; background: #ffffff10; border-radius: 6px; }

/* ============ Panel / table ============ */
.panel { margin-top: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 13.5px; font-weight: 640; }
.panel-head span { color: var(--faint); font-size: 12px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 820px; border-collapse: collapse; }
th {
  position: sticky; top: 0;
  padding: 11px 16px; color: var(--faint); background: #0f0d13;
  font-size: 10.5px; font-weight: 650; letter-spacing: .07em; text-align: left; text-transform: uppercase; white-space: nowrap;
}
td { padding: 13px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.name { color: var(--text); font-weight: 560; }
th:first-child, td:first-child { position: sticky; left: 0; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
th:first-child { background: #0f0d13; z-index: 1; }
tbody tr:hover td { background: #ffffff05; }
tbody tr:hover td:first-child { background: #161320; }
td.pos { color: var(--green); } td.neg { color: var(--red); }
.pill { display: inline-block; margin-left: 8px; padding: 3px 8px; border-radius: 20px; font-size: 10.5px; vertical-align: middle; }
.pill.off { background: #e0697a1f; color: var(--red); }
.pill.part { background: #e0a55e1f; color: var(--amber); }

.foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; padding: 14px 26px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); color: var(--faint); font-size: 11.5px; }

.only-mobile { display: none; }
.scrim { position: fixed; inset: 0; z-index: 20; background: #00000099; backdrop-filter: blur(2px); }

/* ============ Mobile ============ */
@media (max-width: 900px) {
  .only-mobile { display: inline-grid; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(84vw, 300px); height: 100dvh;
    padding-top: calc(22px + var(--safe-t));
    transform: translateX(-104%); transition: transform .22s ease;
    box-shadow: 20px 0 60px #00000080;
  }
  .sidebar.open { transform: none; }
  .topbar { padding: 10px 16px; padding-top: calc(10px + var(--safe-t)); gap: 10px; }
  .filters { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .field { flex: none; }
  .field select { max-width: 170px; }
  .warning { margin: 12px 16px 0; }
  body { overflow-x: hidden; }
  .main, .content { min-width: 0; }
  .content { padding: 16px 16px calc(18px + var(--bottombar) + var(--safe-b)); }
  .cards, .cards.hero { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { min-height: 104px; padding: 14px; }
  .card .value { font-size: 20px; }
  .hero .card .value { font-size: 22px; }
  .card-ico { width: 30px; height: 30px; }
  .foot { padding-bottom: calc(14px + var(--bottombar) + var(--safe-b)); }

  .bottombar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    display: grid; grid-template-columns: repeat(6, 1fr);
    height: calc(var(--bottombar) + var(--safe-b));
    padding: 6px 4px calc(6px + var(--safe-b));
    border-top: 1px solid var(--line);
    background: #0d0b11f2; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  }
  .bottombar button {
    flex-direction: column; justify-content: center; gap: 3px;
    height: auto; padding: 4px 2px; border-radius: 10px;
    color: var(--faint); font-size: 10px;
  }
  .bottombar button svg { width: 21px; height: 21px; }
  .bottombar button.active { color: var(--accent); background: transparent; }
}

@media (max-width: 380px) {
  .cards, .cards.hero { grid-template-columns: 1fr; }
  .bottombar button span { display: none; }
}
