:root {
  --bg: #070b15;
  --surface: #0e1422;
  --surface-strong: #121b2d;
  --ink: #eef6ff;
  --muted: #7d879b;
  --line: #1a2438;
  --primary: #20d6a0;
  --primary-strong: #16b987;
  --accent: #26b9f2;
  --green: #20d6a0;
  --amber: #f0a43a;
  --red: #ef5b67;
  --purple: #9b6cff;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 107, 135, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(214, 85, 63, 0.12), transparent 30%),
    var(--bg);
}

.login-panel {
  width: min(960px, 100%);
  min-height: 560px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  overflow: hidden;
}

.login-visual {
  position: relative;
  padding: 44px;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(17, 78, 99, 0.88), rgba(23, 107, 135, 0.74)),
    url("data:image/svg+xml,%3Csvg width='900' height='700' viewBox='0 0 900 700' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='900' height='700' fill='%23176B87'/%3E%3Cpath d='M108 488C205 338 319 285 450 330C589 378 674 309 790 144' stroke='%23E7F3F6' stroke-width='18' stroke-opacity='.28'/%3E%3Cpath d='M111 235H292V559H111V235Z' fill='%23ffffff' fill-opacity='.14'/%3E%3Cpath d='M347 151H528V559H347V151Z' fill='%23ffffff' fill-opacity='.18'/%3E%3Cpath d='M583 286H764V559H583V286Z' fill='%23ffffff' fill-opacity='.12'/%3E%3Ccircle cx='679' cy='178' r='48' fill='%23D6553F' fill-opacity='.55'/%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.36);
  font-weight: 800;
}

.login-visual h1 {
  margin: 140px 0 14px;
  max-width: 460px;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: 0;
}

.login-visual p {
  margin: 0;
  max-width: 430px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.7;
}

.login-form {
  padding: 52px 44px;
  align-self: center;
}

.login-form h2,
.panel-title h1,
.section-title h2,
.modal-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-form h2 {
  font-size: 28px;
}

.login-form p {
  margin: 10px 0 28px;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

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

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 14px;
  font-weight: 750;
  color: #fff;
  background: var(--primary);
}

.btn:hover {
  background: var(--primary-strong);
}

.btn.secondary {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.btn.secondary:hover {
  background: var(--surface-strong);
}

.btn.danger {
  background: var(--red);
}

.btn.ghost {
  color: var(--primary);
  background: transparent;
  border-color: transparent;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.error {
  min-height: 24px;
  color: var(--red);
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: #101820;
  color: #fff;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 18px;
}

.sidebar-header strong {
  display: block;
}

.sidebar-header span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav button {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  text-align: left;
}

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

.nav-code {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 11px;
  font-weight: 800;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 249, 0.92);
  backdrop-filter: blur(14px);
}

.panel-title h1 {
  font-size: 24px;
}

.panel-title p,
.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e3edf2;
  color: var(--primary);
  font-weight: 800;
}

.content {
  padding: 26px;
}

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

.metric-card,
.chart-panel,
.table-panel,
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.04);
}

.metric-card {
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(23px, 3vw, 34px);
  line-height: 1.05;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.dashboard-lower {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
  margin-top: 14px;
}

.chart-panel,
.table-panel,
.settings-panel {
  padding: 18px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-title h2 {
  font-size: 18px;
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 82px 1fr 90px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.bar-fill {
  height: 100%;
  width: var(--value);
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.toolbar input,
.toolbar select {
  min-height: 40px;
  width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  background: #fff;
}

.toolbar select {
  width: min(260px, 100%);
}

.revenue-summary {
  display: grid;
  grid-template-columns: minmax(180px, 0.6fr) minmax(180px, 0.6fr) minmax(280px, 1.4fr);
  gap: 14px;
  margin-bottom: 14px;
}

.compact-chart {
  padding: 16px;
}

.compact-chart .section-title {
  margin-bottom: 12px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

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

th {
  background: #f9fafb;
  color: #475467;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #edf2f7;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.status.active,
.status.ready,
.status.verified,
.status.confirmed,
.status.enabled,
.status.live {
  background: #e8f6ef;
  color: var(--green);
}

.status.review,
.status.pending,
.status.estimated,
.status.tracking,
.status.limited,
.status.unknown {
  background: #fff3df;
  color: var(--amber);
}

.status.locked,
.status.disabled,
.status.failed,
.status.die {
  background: #fdecea;
  color: var(--red);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.mini-btn {
  min-height: 32px;
  border: 1px solid #1b2941;
  border-radius: 6px;
  padding: 5px 8px;
  background: #0c1322;
  color: #d9e4f2;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.mini-btn:hover {
  border-color: rgba(32, 214, 160, 0.42);
  color: #eafff8;
}

#googleAuthBtn,
#googleRealCheckBtn,
#googleDisconnectBtn {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 24, 32, 0.42);
}

.modal {
  width: min(760px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-body {
  padding: 20px;
}

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

.notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid #b8d7e3;
  border-radius: 8px;
  background: #eef8fb;
  color: #174f63;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #101820;
  color: #fff;
  box-shadow: var(--shadow);
}

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

.mobile-menu {
  display: none;
}

body {
  background:
    linear-gradient(180deg, #070b15 0%, #080d18 42%, #060914 100%);
}

.login-page {
  background:
    linear-gradient(135deg, rgba(32, 214, 160, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(38, 185, 242, 0.11), transparent 30%),
    var(--bg);
}

.login-panel,
.login-form,
.modal,
.table-wrap {
  background: var(--surface);
  color: var(--ink);
}

.login-panel {
  border-color: var(--line);
}

.field label {
  color: #b8c2d6;
}

.field input,
.field select,
.field textarea,
.toolbar input,
.toolbar select {
  background: #0a101c;
  border-color: #202b41;
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(32, 214, 160, 0.12);
}

.btn {
  border-color: rgba(32, 214, 160, 0.36);
  background: linear-gradient(135deg, #13b981, #1287a8);
  box-shadow: 0 10px 30px rgba(18, 185, 129, 0.14);
}

.btn:hover {
  background: linear-gradient(135deg, #19ca91, #1499bd);
}

.btn.secondary {
  color: #d9e4f2;
  background: #0c1322;
  border-color: #1b2941;
  box-shadow: none;
}

.btn.secondary:hover {
  background: #121b2e;
}

.icon-btn {
  background: #0b111f;
  border-color: #1b263a;
  color: #c9d4e4;
}

.app-shell {
  grid-template-columns: 228px 1fr;
  background: var(--bg);
}

.sidebar {
  padding: 18px 12px;
  background: #070b14;
  border-right: 1px solid #141c2c;
}

.sidebar-header {
  gap: 10px;
  padding: 0 4px 24px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  color: #bdfbee;
  background:
    linear-gradient(135deg, rgba(32, 214, 160, 0.22), rgba(38, 185, 242, 0.18)),
    #0b1321;
  border: 1px solid #1d3444;
  box-shadow: inset 0 0 18px rgba(32, 214, 160, 0.13);
  font-size: 12px;
}

.sidebar-header strong {
  color: #f4f8ff;
  font-size: 15px;
}

.sidebar-header span {
  color: var(--primary);
  font-weight: 700;
}

.nav {
  gap: 8px;
}

.nav button {
  min-height: 42px;
  grid-template-columns: 28px 1fr;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #aeb8ca;
  font-weight: 700;
}

.nav button:hover,
.nav button.active {
  border-color: rgba(32, 214, 160, 0.42);
  background: linear-gradient(90deg, rgba(32, 214, 160, 0.18), rgba(32, 214, 160, 0.04));
  color: #eafff8;
  box-shadow: inset 3px 0 0 var(--primary);
}

.nav-code {
  width: 22px;
  height: 22px;
  background: transparent;
  color: currentColor;
  font-size: 15px;
}

.topbar {
  min-height: 76px;
  padding: 15px 28px;
  background: rgba(7, 11, 20, 0.92);
  border-bottom: 1px solid #151d2d;
}

.panel-title h1 {
  color: #f5f8ff;
  font-size: 25px;
}

.panel-title p,
.section-title p {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-chip {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #1b263b;
  border-radius: 8px;
  padding: 8px 14px;
  background: #10172a;
  color: #e5ecf8;
  font-weight: 800;
}

.analytics-range-select {
  min-width: 148px;
  cursor: pointer;
}

.analytics-owner-select {
  min-width: 190px;
  max-width: 260px;
  cursor: pointer;
}

.topbar-actions > button.date-chip {
  display: none;
}

.user-chip {
  min-height: 40px;
  border: 1px solid rgba(32, 214, 160, 0.26);
  border-radius: 8px;
  padding: 6px 11px 6px 7px;
  background: rgba(32, 214, 160, 0.1);
  color: #edf7ff;
}

.avatar {
  width: 28px;
  height: 28px;
  background: #18d597;
  color: #062216;
  font-size: 13px;
}

.content {
  padding: 28px;
}

.metric-card,
.chart-panel,
.table-panel,
.settings-panel {
  background:
    linear-gradient(180deg, rgba(20, 28, 47, 0.96), rgba(11, 16, 28, 0.98));
  border-color: #172238;
  box-shadow: var(--shadow);
}

.metric-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.analytics-card {
  position: relative;
  min-height: 132px;
  padding: 18px;
  overflow: hidden;
}

.analytics-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(130deg, rgba(255, 255, 255, 0.055), transparent 38%);
}

.metric-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border-radius: 8px;
  font-weight: 900;
}

.metric-icon.green {
  color: #24e2ad;
  background: rgba(32, 214, 160, 0.12);
  border: 1px solid rgba(32, 214, 160, 0.26);
}

.metric-icon.blue {
  color: #29c6fb;
  background: rgba(38, 185, 242, 0.12);
  border: 1px solid rgba(38, 185, 242, 0.26);
}

.metric-icon.amber {
  color: #ffb956;
  background: rgba(240, 164, 58, 0.13);
  border: 1px solid rgba(240, 164, 58, 0.28);
}

.metric-icon.purple {
  color: #b18bff;
  background: rgba(155, 108, 255, 0.13);
  border: 1px solid rgba(155, 108, 255, 0.28);
}

.metric-card span {
  color: #78849a;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.metric-card strong {
  color: #f4f8ff;
  font-size: clamp(23px, 2.8vw, 31px);
}

.metric-card small {
  color: #78849a;
}

.trend-panel {
  margin-top: 18px;
  padding: 22px;
}

.trend-chart {
  min-height: 280px;
  position: relative;
}

.trend-chart svg {
  width: 100%;
  height: 286px;
  display: block;
}

.chart-grid-line {
  stroke: rgba(125, 135, 155, 0.12);
  stroke-width: 1;
}

.chart-area.views-area {
  fill: url(#viewsFill);
}

.chart-area.revenue-area {
  fill: url(#revenueFill);
}

.chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 10px currentColor);
}

.views-line {
  color: rgba(32, 214, 160, 0.48);
  stroke: #20d6a0;
}

.revenue-line {
  color: rgba(38, 185, 242, 0.44);
  stroke: #26b9f2;
}

.chart-label {
  fill: #6f7b91;
  font-size: 12px;
  text-anchor: middle;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  color: #8c98ac;
  font-size: 12px;
  font-weight: 800;
}

.legend-item::before {
  content: "";
  width: 18px;
  height: 2px;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 999px;
}

.legend-item.views::before {
  background: #20d6a0;
}

.legend-item.revenue::before {
  background: #26b9f2;
}

.top-channel-panel {
  margin-top: 18px;
}

.section-title h2 {
  color: #f4f8ff;
}

.table-wrap {
  background: #0b111f;
  border-color: #182238;
}

table {
  color: #dce6f6;
}

th {
  background: #0d1423;
  color: #7e899d;
}

td {
  border-bottom-color: #172238;
}

td small {
  display: block;
  margin-top: 4px;
  color: #768298;
}

tr:hover td {
  background: rgba(32, 214, 160, 0.035);
}

.status {
  background: #121b2d;
  color: #aeb9ca;
}

.status.active,
.status.ready,
.status.verified,
.status.confirmed,
.status.enabled,
.status.live {
  background: rgba(32, 214, 160, 0.13);
  color: #36e6b4;
}

.status.review,
.status.pending,
.status.estimated,
.status.tracking,
.status.limited,
.status.unknown {
  background: rgba(240, 164, 58, 0.13);
  color: #ffc16d;
}

.status.locked,
.status.disabled,
.status.failed,
.status.die {
  background: rgba(239, 91, 103, 0.13);
  color: #ff7b86;
}

.modal-backdrop {
  background: rgba(2, 5, 12, 0.72);
}

.modal-header,
.modal-footer {
  border-color: #1a2438;
}

.notice {
  border-color: rgba(38, 185, 242, 0.25);
  background: rgba(38, 185, 242, 0.09);
  color: #aee8ff;
}

.toast {
  background: #111a2c;
  border: 1px solid #26344e;
}

.empty {
  color: #7f8ca3;
}

@media (max-width: 1080px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-lower,
  .settings-grid,
  .revenue-summary {
    grid-template-columns: 1fr;
  }
}

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

  .login-visual {
    display: none;
  }

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

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

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

  .content {
    padding: 16px;
  }
}

@media (max-width: 560px) {
  .dashboard-grid,
  .field-row {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}
