:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #162033;
  --muted: #657187;
  --line: #e5e9f2;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --teal: #0f9f8f;
  --amber: #d97706;
  --rose: #e11d48;
  --green: #16a34a;
  --shadow: 0 18px 45px rgba(25, 35, 64, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0) 260px),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #111827;
  color: #e5e7eb;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #0f9f8f);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.3);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand small {
  margin-top: 3px;
  color: #9ca3af;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
  margin-top: 34px;
}

.nav-item {
  padding: 12px 14px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 14px;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.main {
  width: 100%;
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.35;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel,
.login-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.metric-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.metric-card::after {
  position: absolute;
  right: -24px;
  bottom: -34px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.12);
  content: "";
}

.metric-card.accent::after {
  background: rgba(15, 159, 143, 0.14);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin: 8px 0 6px;
  font-size: 30px;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
}

.panel {
  padding: 20px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
}

.dot.pv,
.bar.pv {
  background: var(--primary);
}

.dot.uv,
.bar.uv {
  background: var(--teal);
}

.dot.cps,
.bar.cps {
  background: var(--amber);
}

.chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  min-height: 190px;
}

.chart-day {
  display: grid;
  grid-template-rows: 138px auto auto;
  gap: 8px;
  align-items: end;
  min-width: 0;
  text-align: center;
}

.bars {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 5px;
  height: 138px;
  padding: 8px;
  border-radius: 8px;
  background: #f8fafc;
}

.bar {
  width: 12px;
  min-height: 8px;
  border-radius: 8px 8px 3px 3px;
}

.chart-day strong {
  font-size: 13px;
}

.chart-day small {
  color: var(--muted);
  font-size: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  gap: 18px;
}

.content-grid.wide-left {
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.7fr);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td small {
  display: block;
  max-width: 420px;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.5;
}

code,
pre {
  border-radius: 6px;
  background: #eef2ff;
  color: #1e3a8a;
  font-family: Consolas, "SFMono-Regular", monospace;
}

code {
  padding: 3px 6px;
  white-space: nowrap;
}

pre {
  overflow: auto;
  padding: 12px;
  line-height: 1.55;
}

.url-cell {
  max-width: 360px;
  overflow: hidden;
  color: var(--primary-dark);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 48px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.on {
  background: #dcfce7;
  color: #166534;
}

.badge.off {
  background: #fee2e2;
  color: #991b1b;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions form {
  margin: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 12px 22px rgba(37, 99, 235, 0.2);
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.ghost {
  border-color: var(--line);
  background: #fff;
}

.button.danger {
  background: #fff1f2;
  color: var(--rose);
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.button.block {
  width: 100%;
}

.form {
  display: grid;
  gap: 15px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 12px;
}

.ad-grid {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.color-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 8px;
}

.color-picker {
  min-width: 52px;
  padding: 4px;
}

.form-actions {
  margin-top: 18px;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 220px auto;
  gap: 12px;
  align-items: center;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.account-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.account-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.account-head strong,
.account-head small {
  display: block;
}

.account-head small,
.account-meta {
  color: var(--muted);
  font-size: 13px;
}

.usage-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.usage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--primary));
}

.account-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 96px;
  padding: 12px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(37, 99, 235, 0.65);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.check-row span {
  margin: 0;
}

.help-panel {
  color: var(--muted);
  line-height: 1.7;
}

.help-panel h2 {
  color: var(--text);
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-list.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.activity {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.activity.inline {
  grid-template-columns: 160px minmax(0, 1fr) auto;
  align-items: center;
}

.activity span,
.activity small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  padding: 18px 0;
  color: var(--muted);
  text-align: center;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.flash.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.flash.error {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #9f1239;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.16), rgba(15, 159, 143, 0.14)),
    #f8fafc;
}

.login-card {
  width: min(430px, 100%);
  padding: 30px;
}

.login-brand {
  margin-bottom: 26px;
}

.login-card h1 {
  margin-bottom: 10px;
}

.login-card p {
  color: var(--muted);
  line-height: 1.7;
}

.compact-form {
  margin-top: 22px;
}

@media (max-width: 1180px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .content-grid,
  .content-grid.wide-left {
    grid-template-columns: 1fr;
  }

  .activity-list.compact {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 18px;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .chart {
    gap: 6px;
  }

  .bars {
    padding: 6px 4px;
  }

  .bar {
    width: 8px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .ad-grid,
  .filter-bar,
  .account-grid,
  .account-meta {
    grid-template-columns: 1fr;
  }

  .activity.inline {
    grid-template-columns: 1fr;
  }
}
