:root {
  --ink: #142033;
  --muted: #5c6b80;
  --line: #d7e0ea;
  --card: #ffffff;
  --bg: #eef3f8;
  --blue: #0c4a6e;
  --cyan: #0e7490;
  --amber: #b45309;
  --green: #047857;
  --red: #b91c1c;
  --shadow: 0 10px 30px rgba(20, 32, 51, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Calibri, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 100% -10%, #d5eef5 0%, transparent 55%),
    var(--bg);
  min-height: 100vh;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  padding: 22px 28px 8px;
}
.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(145deg, var(--blue), var(--cyan));
  color: white; display: grid; place-items: center; font-weight: 700;
}
h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.nav { display: flex; gap: 8px; }
.nav a, button, .chip, #account {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}
.nav a.active { background: var(--blue); color: white; border-color: var(--blue); }
#account { color: var(--blue); text-decoration: none; padding: 7px 10px; }
.live {
  display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end;
  gap: 8px; color: var(--muted); font-size: 13px;
}
.dot {
  width: 9px; height: 9px; border-radius: 50%; background: #16a34a;
  box-shadow: 0 0 0 0 rgba(22, 163, 74, .6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.wrap { padding: 8px 28px 32px; }
.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}
.filter {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  box-shadow: var(--shadow);
  max-height: 168px;
  overflow: auto;
}
.filter h3 {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  position: sticky; top: 0; background: white;
}
.chip { display: block; width: 100%; text-align: left; margin: 0 0 4px; padding: 5px 8px; border-radius: 8px; font-size: 12px; }
.chip.on { background: #e0f2fe; border-color: #7dd3fc; color: #0c4a6e; font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.kpi {
  background: var(--card);
  border-radius: 16px;
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--cyan);
}
.kpi:nth-child(2) { border-top-color: var(--blue); }
.kpi:nth-child(3) { border-top-color: var(--amber); }
.kpi:nth-child(4) { border-top-color: #7c3aed; }
.kpi:nth-child(5) { border-top-color: var(--green); }
.kpi:nth-child(6) { border-top-color: var(--red); }
.kpi span { display: block; color: var(--muted); font-size: 12px; }
.kpi strong { display: block; margin-top: 6px; font-size: 20px; letter-spacing: -.03em; }
.kpi em { font-style: normal; color: var(--muted); font-size: 12px; }

.grid { display: grid; grid-template-columns: 1.4fr .8fr; gap: 12px; margin-top: 12px; }
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px 16px 8px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 8px; font-size: 15px; }
.card canvas { width: 100% !important; height: 260px !important; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child, td.left, th.left { text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.up { color: var(--green); }
.down { color: var(--red); }
.toolbar { display: flex; gap: 8px; align-items: center; margin: 8px 0 12px; }
input, select, textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; background: white; color: var(--ink);
}
input[type="search"] {
  flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit;
}
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.table-wrap { overflow: auto; background: white; border-radius: 16px; box-shadow: var(--shadow); }
.note { color: var(--muted); font-size: 12px; margin-top: 8px; }

button.primary {
  background: var(--blue); color: white; border-color: var(--blue); font-weight: 600;
}
button:disabled { opacity: .55; cursor: wait; }
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.auth-card {
  width: min(420px, 100%); padding: 30px; border-radius: 20px;
  background: white; box-shadow: var(--shadow);
}
.auth-card .mark { margin-bottom: 18px; }
.auth-card h1 { margin-bottom: 4px; }
.form-stack { display: grid; gap: 14px; margin-top: 22px; }
.form-stack label, .form-grid label {
  display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600;
}
.form-message { color: var(--red); min-height: 18px; margin: 0; font-size: 13px; }
.form-message.success { color: var(--green); }
.notice {
  margin-top: 18px; padding: 12px; border-radius: 10px;
  background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; font-size: 13px;
}
.admin-layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px;
}
.admin-wide { grid-column: 1 / -1; }
.form-grid { display: grid; gap: 12px; }
.form-grid fieldset {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.form-grid legend { color: var(--muted); font-size: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 14px; }
label.check { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 7px; }
label.check input { width: 16px; height: 16px; padding: 0; }
.admin-list { display: grid; gap: 8px; }
.admin-row {
  display: grid; grid-template-columns: minmax(140px, .7fr) minmax(160px, 1fr) 2fr auto auto auto;
  align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line);
}
.admin-row small { display: block; color: var(--muted); margin-top: 3px; }
.admin-row label { color: var(--muted); font-size: 12px; }
.row-actions { display: flex; gap: 6px; }
.company-row { grid-template-columns: 1fr 1fr auto auto; }
.module-badge {
  width: fit-content; padding: 5px 9px; border-radius: 999px;
  background: #e0f2fe; color: var(--blue); font-size: 12px;
}
@media (max-width: 1100px) {
  .filters, .kpis, .grid { grid-template-columns: 1fr 1fr; }
  .top { flex-direction: column; align-items: flex-start; }
  .live { justify-content: flex-start; }
  .admin-row { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .filters, .kpis, .grid, .admin-layout { grid-template-columns: 1fr; }
  .admin-wide { grid-column: auto; }
}
