html {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0B0D;
  --surface: #141416;
  --surface-subtle: #1A1A1E;
  --text: #FFFFFF;
  --text-soft: #D6D6D6;
  --muted: #A0A0A8;
  --muted-soft: #7C7C85;
  --border: #2B2B30;
  --border-soft: #222228;
  --accent: #D62029;
  --accent-hover: #E4002B;
  --accent-soft: #35161A;
  --accent-softer: #241114;
  --success: #4ADE80;
  --success-soft: #12331F;
  --danger: #FB7185;
  --danger-soft: #3A171D;
  --warning: #FBBF24;
  --warning-soft: #3A2A10;
  --blue: #60A5FA;
  --blue-soft: #152A45;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.34);
  --shadow-md: 0 18px 40px rgba(0, 0, 0, 0.38);
}

.theme-ready body,
.theme-ready .sidebar,
.theme-ready .topbar,
.theme-ready .card,
.theme-ready input,
.theme-ready select,
.theme-ready textarea,
.theme-ready button {
  transition:
    color 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.topbar-actions .topbar-icon[data-theme-toggle] {
  cursor: pointer;
  font-size: 0;
}

.topbar-actions .topbar-icon[data-theme-toggle]::before {
  content: "☼";
  font-size: 17px;
  line-height: 1;
}

html[data-theme="dark"] .topbar-actions .topbar-icon[data-theme-toggle]::before {
  content: "☾";
}

html[data-theme="dark"] body,
html[data-theme="dark"] .shell,
html[data-theme="dark"] .main {
  background: var(--bg);
  color: var(--text);
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .brand,
html[data-theme="dark"] .sidebar-bottom {
  border-color: var(--border);
  background: var(--surface);
}

html[data-theme="dark"] .topbar {
  border-color: var(--border);
  background: rgba(11, 11, 13, 0.92);
}

html[data-theme="dark"] .workspace-chip,
html[data-theme="dark"] .card,
html[data-theme="dark"] .filter-shell,
html[data-theme="dark"] .posts-toolbar,
html[data-theme="dark"] .posts-table-panel,
html[data-theme="dark"] .active-ads-card {
  border-color: var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

html[data-theme="dark"] .card:hover {
  border-color: #3A3A42;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .login-page {
  background:
    radial-gradient(circle at 18% 16%, rgba(214, 32, 41, 0.2), transparent 34%),
    radial-gradient(circle at 82% 84%, rgba(84, 84, 84, 0.12), transparent 30%),
    var(--bg);
}

html[data-theme="dark"] .login-card {
  border-color: var(--border);
  background: rgba(20, 20, 22, 0.96);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.48);
}

html[data-theme="dark"] .empty-template {
  background:
    radial-gradient(circle at 20% 18%, rgba(214, 32, 41, 0.18), transparent 30%),
    linear-gradient(135deg, var(--surface), var(--accent-softer) 48%, var(--surface));
}

html[data-theme="dark"] .empty-template h3,
html[data-theme="dark"] .page-heading h2,
html[data-theme="dark"] .brand-lockup strong,
html[data-theme="dark"] .kpi-card:not(:nth-child(2)) strong {
  color: var(--text);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .select-button,
html[data-theme="dark"] .time-range-trigger__button,
html[data-theme="dark"] .account-filter-select,
html[data-theme="dark"] .posts-choice-trigger,
html[data-theme="dark"] .posts-clear-button,
html[data-theme="dark"] .posts-update-button,
html[data-theme="dark"] .posts-form-cancel,
html[data-theme="dark"] .posts-drawer-close,
html[data-theme="dark"] .posts-page-button,
html[data-theme="dark"] .posts-page-arrow {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: var(--muted-soft);
}

html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.72;
}

html[data-theme="dark"] .search-box {
  border-color: var(--border);
  background: var(--surface-subtle);
}

html[data-theme="dark"] .search-box:focus-within {
  border-color: rgba(214, 32, 41, 0.72);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(214, 32, 41, 0.16);
}

html[data-theme="dark"] .select-menu,
html[data-theme="dark"] .posts-choice-menu,
html[data-theme="dark"] .time-range-picker,
html[data-theme="dark"] .posts-drawer-panel {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
}

html[data-theme="dark"] .select-option:hover,
html[data-theme="dark"] .posts-choice-option:hover,
html[data-theme="dark"] .time-range-picker__preset:hover,
html[data-theme="dark"] .time-range-picker__day:hover,
html[data-theme="dark"] .posts-clear-button:hover,
html[data-theme="dark"] .posts-update-button:hover,
html[data-theme="dark"] .posts-form-cancel:hover {
  border-color: var(--border);
  background: var(--surface-subtle);
  color: var(--text);
}

html[data-theme="dark"] .select-option.is-selected,
html[data-theme="dark"] .posts-choice-option.is-selected,
html[data-theme="dark"] .time-range-picker__preset.is-active {
  background: var(--accent-soft);
  color: var(--text);
}

html[data-theme="dark"] .time-range-picker__sidebar {
  border-color: var(--border);
  background: #101012;
}

html[data-theme="dark"] .time-range-picker__toolbar,
html[data-theme="dark"] .time-range-picker__footer {
  border-color: var(--border);
}

html[data-theme="dark"] .time-range-picker__label,
html[data-theme="dark"] .time-range-picker__timezone,
html[data-theme="dark"] .time-range-picker__weekday,
html[data-theme="dark"] .time-range-picker__input-separator {
  color: var(--muted);
}

html[data-theme="dark"] .time-range-picker__preset,
html[data-theme="dark"] .time-range-picker__month-header,
html[data-theme="dark"] .time-range-picker__day {
  color: var(--text);
}

html[data-theme="dark"] .time-range-picker__day.is-outside-month {
  color: var(--muted-soft);
}

html[data-theme="dark"] .time-range-picker__nav-btn,
html[data-theme="dark"] .time-range-picker__date-input-button,
html[data-theme="dark"] .time-range-picker__btn--ghost {
  border-color: var(--border);
  background: var(--surface-subtle);
  color: var(--text);
}

html[data-theme="dark"] .time-range-picker__day.is-selected,
html[data-theme="dark"] .time-range-picker__btn--primary {
  border-color: var(--brand-primary);
  background: var(--brand-primary);
  color: #FFFFFF;
}

html[data-theme="dark"] .time-range-picker__day.is-in-range {
  background: var(--accent-soft);
  color: #FFD8DA;
}

html[data-theme="dark"] .line-chart,
html[data-theme="dark"] .product-bars,
html[data-theme="dark"] .donut-chart-box {
  background-color: var(--bg);
}

html[data-theme="dark"] .bar-track {
  background: #222228;
}

html[data-theme="dark"] .donut::after {
  background: var(--bg);
}

html[data-theme="dark"] .line-point {
  border-color: var(--surface);
}

html[data-theme="dark"] .posts-summary-item--total,
html[data-theme="dark"] .posts-summary-item--stopped,
html[data-theme="dark"] .posts-status--stopped_ads,
html[data-theme="dark"] .active-ads-pill {
  background: #25252B;
  color: var(--text-soft);
}

html[data-theme="dark"] .posts-summary-item--running,
html[data-theme="dark"] .posts-status--running_ads {
  background: var(--success-soft);
  color: var(--success);
}

html[data-theme="dark"] .posts-status--not_found_in_ads {
  background: var(--warning-soft);
  color: var(--warning);
}

html[data-theme="dark"] .posts-action-cell,
html[data-theme="dark"] .posts-table th:last-child {
  box-shadow: -8px 0 12px -12px rgba(0, 0, 0, 0.8);
}

html[data-theme="dark"] .posts-drawer-backdrop {
  background: rgba(0, 0, 0, 0.68);
}

html[data-theme="dark"] .posts-drawer-panel {
  box-shadow: -18px 0 45px rgba(0, 0, 0, 0.52);
}

html[data-theme="dark"] .posts-summary-item:focus-visible,
html[data-theme="dark"] .posts-summary-item.is-active {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px currentColor;
}

html[data-theme="dark"] ::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

html[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--bg);
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  border: 3px solid var(--bg);
  border-radius: 999px;
  background: #3A3A42;
}

@media (prefers-reduced-motion: reduce) {
  .theme-ready body,
  .theme-ready .sidebar,
  .theme-ready .topbar,
  .theme-ready .card,
  .theme-ready input,
  .theme-ready select,
  .theme-ready textarea,
  .theme-ready button {
    transition: none;
  }
}
