:root {
  --bg: #070c14;
  --sidebar: #080e18;
  --surface: #0d1623;
  --surface-alt: #101b2a;
  --surface-soft: #0a121e;
  --border: rgba(255, 255, 255, .065);
  --border-strong: rgba(255, 255, 255, .11);
  --text: #f7f9fd;
  --muted: #99a5b8;
  --purple: #7c5cff;
  --purple-2: #5b42c9;
  --blue: #3987ff;
  --cyan: #20d3d2;
  --green: #21e78c;
  --amber: #f59e0b;
  --red: #ff5f75;
  --sidebar-w: 224px;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(120deg, rgba(124, 92, 255, .07), transparent 34%),
    linear-gradient(180deg, #070b13 0%, #07101a 100%);
}
button, input, textarea, select { font: inherit; }
button { border: 0; cursor: pointer; color: var(--text); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
input, textarea, select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #09111d;
  color: var(--text);
}
input, select { height: 40px; padding: 0 12px; }
textarea { min-height: 108px; padding: 11px 12px; resize: vertical; }
svg { display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.text-danger { color: var(--red); }

.app {
  min-height: 100vh;
  padding-left: var(--sidebar-w);
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: var(--sidebar-w);
  height: 100vh;
  padding: 28px 16px 20px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(8, 14, 24, .98);
}
.brand {
  display: flex;
  align-items: center;
  padding: 0 2px;
}
.syntra-logo {
  width: 166px;
  height: auto;
  flex: 0 0 auto;
  display: block;
}
.nav {
  display: grid;
  gap: 7px;
  margin-top: 30px;
}
.sidebar .nav-item, .collapse {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 44px;
  padding: 0 15px;
  border-radius: 8px;
  background: transparent;
  color: #c8d0dd;
  font-weight: 700;
  text-align: left;
}
.sidebar .nav-item svg, .collapse svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  color: #c6cfdd;
}
.sidebar .nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(124, 92, 255, .44), rgba(66, 88, 185, .34));
  border: 1px solid rgba(124, 92, 255, .35);
}
.sidebar .nav-item.active svg { color: #fff; }
.badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--purple);
  font-size: 12px;
  font-weight: 850;
}
.agency {
  margin-top: auto;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(13, 22, 35, .42);
}
.avatar, .avatar-button {
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #2e405f, #7c5cff);
  color: #fff;
  font-weight: 850;
}
.avatar { width: 34px; height: 34px; }
.agency-copy { display: grid; gap: 2px; line-height: 1.1; }
.agency-copy span { color: var(--muted); font-size: 12px; }
.collapse {
  margin-top: 20px;
  min-height: 36px;
  color: var(--muted);
  padding-left: 11px;
}
.main {
  min-height: 100vh;
  padding: 30px 32px 24px;
}
.page { display: none; }
.page.active { display: block; }

.topbar, .simple-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}
.topbar h1, .simple-header h1 {
  margin: 0 0 5px;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: 0;
}
.topbar p, .simple-header p {
  margin: 0;
  color: #c0c8d4;
  font-size: 16px;
}
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.segmented {
  height: 40px;
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #08111d;
}
.segmented button {
  width: 58px;
  background: transparent;
  color: #b9c3d0;
  font-weight: 800;
}
.segmented button.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, .62), rgba(99, 70, 190, .45));
  color: #fff;
}
.period-control, .control-button, .icon-button, .pill {
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #08111d;
  color: #edf2f8;
}
.period-control {
  width: 232px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
}
.period-control svg, .control-button svg, .icon-button svg { width: 17px; height: 17px; }
.period-control select {
  height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #edf2f8;
  font-weight: 750;
}
.control-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  font-weight: 850;
}
.icon-button {
  width: 42px;
  display: grid;
  place-items: center;
}
.avatar-button {
  border: 0;
  background: #0d1725;
}

.kpi-grid {
  display: grid;
  gap: 16px;
}
.main-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.secondary-kpis {
  grid-template-columns: 1.12fr 1fr 1.12fr 1.28fr;
  margin-top: 16px;
}
.metric-card, .panel, .auth-card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(13, 22, 35, .96), rgba(8, 16, 27, .96));
}
.metric-card {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
}
.primary-card {
  height: 142px;
  padding: 20px 19px;
}
.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: #eef2f8;
  font-size: 14px;
  font-weight: 750;
}
.metric-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  flex: 0 0 auto;
}
.metric-icon svg { width: 18px; height: 18px; }
.metric-icon.purple { background: rgba(124, 92, 255, .18); color: var(--purple); }
.metric-icon.blue { background: rgba(57, 135, 255, .16); color: var(--blue); }
.metric-icon.cyan { background: rgba(32, 211, 210, .15); color: var(--cyan); }
.metric-icon.green { background: rgba(33, 231, 140, .14); color: var(--green); }
.metric-icon.amber { background: rgba(245, 158, 11, .17); color: var(--amber); }
.metric-card strong {
  display: block;
  margin-top: 18px;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}
.metric-card small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}
.metric-card small.up { color: var(--green); }
.metric-card small.down { color: var(--red); }
.sparkline {
  position: absolute;
  right: 13px;
  bottom: 13px;
  width: 132px;
  height: 48px;
  opacity: .95;
}
.compact-card {
  height: 74px;
  display: grid;
  grid-template-columns: auto minmax(116px, 1fr) minmax(76px, auto) 78px;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}
.compact-card b {
  display: block;
  margin-bottom: 5px;
  color: #eef3fa;
  font-size: 14px;
}
.compact-card strong {
  margin: 0;
  font-size: 19px;
}
.compact-card small {
  margin: 0;
  text-align: right;
  white-space: nowrap;
  font-size: 12px;
}
.mini-spark {
  width: 78px;
  height: 34px;
}

.dashboard-grid {
  display: grid;
  gap: 16px;
}
.chart-row {
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  margin-top: 18px;
}
.bottom-row {
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  margin-top: 12px;
}
.panel {
  border-radius: 10px;
  padding: 20px 22px 16px;
}
.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.panel-title h2, .panel-title h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}
.panel-title select {
  width: 64px;
  height: 36px;
}
.legend {
  display: flex;
  gap: 24px;
  margin-top: 13px;
  color: #e6ecf5;
  font-size: 13px;
  font-weight: 700;
}
.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 7px;
  border-radius: 999px;
  vertical-align: -1px;
}
.dot.purple { background: var(--purple); }
.dot.blue { background: var(--blue); }
.dot.cyan { background: var(--cyan); }
.dot.amber { background: var(--amber); }
.dot.green { background: var(--green); }
.chart-box {
  position: relative;
  height: 204px;
}
.chart-box svg, .donut svg { width: 100%; height: 100%; }
.chart-line {
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: draw .85s ease forwards;
}
.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 168px;
  padding: 10px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: rgba(7, 12, 20, .96);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .32);
  color: #eaf0f8;
  font-size: 12px;
  line-height: 1.55;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -112%);
  transition: opacity .12s ease;
}
.chart-tooltip.visible { opacity: 1; }
.breakdown-layout {
  display: grid;
  grid-template-columns: 204px minmax(180px, .8fr) minmax(190px, .9fr);
  align-items: center;
  gap: 24px;
}
.donut {
  position: relative;
  width: 204px;
  height: 204px;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  pointer-events: none;
}
.donut-center strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}
.donut-center span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}
.breakdown-list {
  display: grid;
  gap: 14px;
}
.break-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
}
.break-item b { display: block; margin-bottom: 4px; }
.break-item span:last-child { color: var(--muted); font-size: 13px; }
.insight {
  min-height: 158px;
  padding-left: 24px;
  border-left: 1px solid var(--border);
}
.insight-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 28px;
  color: #eff4fb;
  font-weight: 750;
}
.insight p {
  margin: 0 0 8px;
  color: #cfd6e1;
}
.insight strong {
  color: var(--purple);
  font-size: 34px;
  line-height: 1;
}
.insight small {
  display: block;
  margin-top: 12px;
  font-weight: 850;
}
.insight small.up { color: var(--green); }
.insight small.down { color: var(--red); }

.table-wrap { overflow: auto; }
.data-table {
  width: 100%;
  min-width: 580px;
  border-collapse: collapse;
}
.data-table th {
  padding: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
}
.data-table td {
  padding: 11px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.model-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.model-avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #31415b, #7c5cff);
  font-size: 12px;
  font-weight: 850;
}
.ghost-link {
  width: auto;
  min-height: 28px;
  min-height: 28px;
  margin-top: 12px;
  border-radius: 0;
  background: transparent;
  padding: 0;
  color: #9b65ff;
  font-weight: 800;
}
.activity-list { display: grid; }
.activity-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 13px;
  min-height: 49px;
  border-top: 1px solid var(--border);
}
.activity-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--purple);
  background: rgba(124, 92, 255, .16);
}
.activity-icon svg { width: 17px; height: 17px; }
.activity-row b { font-size: 14px; }
.activity-row span { color: var(--muted); font-size: 13px; }
.activity-amount { font-weight: 850; }
.empty-panel, .empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 8, 14, .82);
  backdrop-filter: blur(10px);
}
.auth-card {
  width: min(440px, 100%);
  padding: 28px;
  border-radius: 14px;
}
.brand-modal { margin-bottom: 26px; padding: 0; }
.brand-modal .syntra-logo { width: 208px; }
.auth-card h1 { margin: 0 0 8px; font-size: 26px; }
.auth-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.45; }
.auth-status, .settings-status { min-height: 20px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.auth-status.error, .settings-status.error { color: var(--red); }
.auth-status.ok, .settings-status.ok { color: var(--green); }
.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: #dce4ee;
  font-size: 13px;
  font-weight: 750;
}
.primary, .soft-button {
  min-height: 40px;
  padding: 0 15px;
  border-radius: 10px;
  font-weight: 850;
}
.primary {
  background: linear-gradient(135deg, var(--purple), #4d66dc);
}
.soft-button {
  border: 1px solid var(--border);
  background: #0a1320;
}
.danger { color: #ffd1d7; background: rgba(255, 95, 117, .15); }

.settings-grid, .report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .9fr);
  gap: 16px;
}
.filter-panel {
  margin-top: 16px;
}
.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 14px;
  align-items: end;
}
.filter-grid select[multiple] {
  min-height: 92px;
  padding: 8px;
}
.checkbox-field {
  align-self: center;
}
.checkbox-field span {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-field input {
  width: auto;
  height: auto;
}
.traffic-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.traffic-kpi {
  min-height: 96px;
}
.traffic-kpi span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 16px;
}
.traffic-kpi strong {
  font-size: 26px;
}
.traffic-grid {
  align-items: start;
}
.ads-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.token-settings, .add-account, .report-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}
.accounts-panel, .template-panel, .reports-panel { grid-column: span 1; }
.account-row, .sale-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-top: 1px solid var(--border);
}
.account-main {
  display: flex;
  gap: 10px;
}
.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: #6c7481;
}
.status-dot.connected { background: var(--green); box-shadow: 0 0 0 4px rgba(33, 231, 140, .1); }
.status-dot.waiting_login { background: var(--amber); }
.status-dot.error { background: var(--red); }
.account-actions, .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
}
.variables {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.variable {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #101b2a;
  color: #dfe6ef;
  font-size: 12px;
}
.phone {
  max-width: 350px;
  min-height: 310px;
  margin: 0 auto;
  padding: 12px;
  border: 7px solid #2b3038;
  border-radius: 34px;
  background: #05070a;
}
.notch {
  width: 116px;
  height: 22px;
  margin: -12px auto 18px;
  border-radius: 0 0 16px 16px;
  background: #000;
}
.phone > span {
  display: block;
  margin-bottom: 10px;
  color: #a9b2c1;
  font-size: 12px;
}
.notification {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid #4a5260;
  border-radius: 16px;
  background: #2a2f38;
}
.notification small { color: #c6ceda; }
.notification p { margin: 0; color: #e2e7ef; font-size: 14px; line-height: 1.42; white-space: pre-wrap; }
.report-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0a1320;
}
.report-card h3 { margin: 0 0 14px; }
.full { grid-column: 1 / -1; }
.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.report-editor { margin-top: 16px; }
.mapping-labels, .mapping-row {
  display: grid;
  grid-template-columns: 1.4fr .55fr .65fr .55fr auto;
  gap: 8px;
  align-items: center;
}
.mapping-labels {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}
.mapping-row { margin-bottom: 8px; }
.preview-box {
  min-height: 140px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #070c14;
  color: #dfe7f0;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

@keyframes draw { to { stroke-dashoffset: 0; } }

@media (max-width: 1280px) {
  .main-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .secondary-kpis, .chart-row, .bottom-row, .breakdown-layout, .settings-grid, .report-grid, .filter-grid, .traffic-kpis { grid-template-columns: 1fr; }
  .insight { border-left: 0; border-top: 1px solid var(--border); padding: 18px 0 0; }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .app { padding-left: 0; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 18px;
  }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 20px; }
  .topbar, .simple-header { flex-direction: column; }
  .main-kpis { grid-template-columns: 1fr 1fr; }
  .controls { width: 100%; }
  .period-control { flex: 1 1 230px; }
  .compact-card { grid-template-columns: auto 1fr auto; }
  .compact-card svg.mini-spark { display: none; }
}

@media (max-width: 560px) {
  .main-kpis, .secondary-kpis, .nav, .token-settings, .add-account, .report-toolbar, .two-cols, .ads-form { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .period-control, .segmented, .control-button { width: 100%; }
  .activity-row { grid-template-columns: auto 1fr; }
  .activity-amount, .activity-time { justify-self: start; }
  .mapping-labels { display: none; }
  .mapping-row { grid-template-columns: 1fr 72px; }
  .mapping-extra { display: none; }
}
