/* SuperMega.TV panel — design tokens and components */

:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --sidebar: #FFFFFF;
  --border: #E5E8EF;
  --border-strong: #D5DAE4;
  --text: #0E1420;
  --text-soft: #3B4354;
  --muted: #5F6877;
  --accent: #0A84FF;
  --accent-text: #0A6BDB;
  --accent-soft: #E9F2FF;
  --good: #15803D;
  --good-soft: #E6F6EC;
  --warn: #B45309;
  --warn-soft: #FEF3E2;
  --danger: #DC2626;
  --danger-soft: #FDECEC;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Inter', 'Inter var', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #080B10;
  --surface: #141B24;
  --surface-2: #101720;
  --sidebar: #0F141B;
  --border: #1E2733;
  --border-strong: #2A3543;
  --text: #F5F7FA;
  --text-soft: #C9D1DE;
  --muted: #9AA4B6;
  --accent: #2E9BFF;
  --accent-text: #6CB6FF;
  --accent-soft: #10263D;
  --good: #34D07A;
  --good-soft: #10281B;
  --warn: #F0A93A;
  --warn-soft: #2A2010;
  --danger: #F87171;
  --danger-soft: #2C1618;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; letter-spacing: -.015em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 12px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* ------------------------------------------------------------------ shell */

.shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
  min-height: 64px;
}

.brand-name { font-size: 15.5px; font-weight: 700; letter-spacing: -.02em; }
.brand-name span { color: var(--accent); }
.brand-sub { display: block; font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: .01em; }

.nav { padding: 8px 12px 20px; flex: 1; }
.nav-group { padding: 14px 0 2px; }
.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px 6px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: background .12s ease, color .12s ease;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav a.active::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}
.nav .icon { width: 17px; height: 17px; flex: none; }
.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 999px;
  padding: 1px 7px;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px;
}

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 6;
}
.topbar-title { font-size: 14.5px; font-weight: 600; }
.topbar-crumb { font-size: 12.5px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
}
.avatar:hover { text-decoration: none; filter: brightness(1.05); }

.content { padding: 26px 28px 56px; max-width: 1440px; width: 100%; }

/* --------------------------------------------------------------- headings */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.greeting { font-size: 30px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; }
.greeting span { color: var(--accent); }
.greeting-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-pad-0 { padding: 0; }
.card-pad-0 .card-head { padding: 20px 20px 0; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); align-items: start; }

/* -------------------------------------------------------------------- kpi */

.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 29px; font-weight: 700; letter-spacing: -.03em; margin-top: 8px; line-height: 1.1; }
.kpi-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}
.kpi-icon.good { background: var(--good-soft); color: var(--good); }
.kpi-icon.warn { background: var(--warn-soft); color: var(--warn); }
.kpi-icon.danger { background: var(--danger-soft); color: var(--danger); }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ----------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ----------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; min-width: 860px; }
.table th.col-customer, .table td.col-customer { min-width: 210px; }
.table th.col-status, .table td.col-status { padding-left: 22px; }
.table .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.table td.pkg { white-space: nowrap; }
.table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .name { font-weight: 600; }
.table .sub { font-size: 12px; color: var(--muted); }
.table .right { text-align: right; }

.empty { padding: 28px 14px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* ------------------------------------------------------------------ forms */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .req { color: var(--danger); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); }

.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 20px; flex-wrap: wrap; }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg label { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: var(--accent-text); }
.seg label:has(input:checked) { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow); }

/* ------------------------------------------------------------------ alerts */

.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; border: 1px solid; }
.flash.good { background: var(--good-soft); border-color: transparent; color: var(--good); }
.flash.error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.flash.info { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }

.callout { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; color: var(--text-soft); }

/* ------------------------------------------------------------------ charts */

.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%;
  max-width: 46px;
  background: var(--accent);
  border-radius: 6px 6px 4px 4px;
  min-height: 4px;
  opacity: .9;
  transition: opacity .12s ease;
}
.bar-col:hover .bar { opacity: 1; }
.bar-value { font-size: 11.5px; font-weight: 650; color: var(--text-soft); }
.bar-label { font-size: 11px; color: var(--muted); text-transform: capitalize; }

/* ------------------------------------------------------------- list rows */

.rows { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.row:last-child { border-bottom: none; }
.row:hover { text-decoration: none; }
.row-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); flex: none;
}
.row-icon.warn { background: var(--warn-soft); color: var(--warn); }
.row-icon.danger { background: var(--danger-soft); color: var(--danger); }
.row-main { min-width: 0; flex: 1; }
.row-title { font-size: 13.5px; font-weight: 600; }
.row-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-value { font-size: 13px; font-weight: 650; white-space: nowrap; }

/* ------------------------------------------------------------------ login */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% 10%, var(--accent-soft), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand-name { font-size: 22px; }
.auth-brand p { color: var(--muted); font-size: 13px; margin-top: 6px; }
.auth-card .card { padding: 26px; }
.auth-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 18px; }

/* --------------------------------------------------------------- toolbar */

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .search { position: relative; flex: 1 1 300px; min-width: 280px; max-width: 420px; }
.toolbar .search input { padding-left: 36px; }
.toolbar .search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.toolbar select { width: auto; min-width: 132px; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.pagination .pages { display: flex; gap: 6px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-decoration: none;
  color: inherit;
  transition: border-color .12s ease, background .12s ease;
}
.tile:hover { border-color: var(--border-strong); background: var(--surface); text-decoration: none; }
.tile .icon-box {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
}
.tile-title { font-size: 13px; font-weight: 650; }
.tile-sub { font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------------- utilities */

.stack { display: flex; flex-direction: column; gap: 16px; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title { font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }
.hr { height: 1px; background: var(--border); margin: 18px 0; }
.pill-list { display: flex; gap: 6px; flex-wrap: wrap; }
.mobile-only { display: none; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; font-weight: 550; }
.copy { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px 8px; font-size: 12.5px; }

/* --------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 264px;
    transform: translateX(-100%);
    transition: transform .18s ease;
    z-index: 30;
    box-shadow: 0 0 40px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: none; }
  .mobile-only { display: grid; }
  .content { padding: 20px 16px 40px; }
  .topbar { padding: 0 16px; }
  .grid-3, .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .greeting { font-size: 24px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 10px; }
}
