/* Night mode follows Malaysia time (19:00-06:59). Day mode keeps existing styles. */
html[data-theme="dark"] {
  color-scheme: dark;
  --nav: #0b1728;
  --blue: #3486ef;
  --bg: #0d1828;
  --text: #e9f1fc;
  --muted: #acbdd3;
  --line: #344760;
  --good: #79d4ac;
  --danger: #ff858e;
  --night-surface: #17263a;
  --night-raised: #20344c;
  --night-soft: #243b57;
  --night-link: #8fc2ff;
}
html[data-theme="dark"] body,
html[data-theme="dark"] body.client-portal-ui,
html[data-theme="dark"] body.pwa-app-mode.client-portal-ui { background: var(--bg) !important; color: var(--text); }
html[data-theme="dark"] header { background: var(--nav); }
html[data-theme="dark"] footer { color: var(--muted); }
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] label,
html[data-theme="dark"] strong,
html[data-theme="dark"] b { color: inherit; }
html[data-theme="dark"] a:not(.btn):not(.brand):not(.social-platform-icon) { color: var(--night-link); }
html[data-theme="dark"] a:focus-visible,
html[data-theme="dark"] button:focus-visible,
html[data-theme="dark"] input:focus-visible,
html[data-theme="dark"] select:focus-visible,
html[data-theme="dark"] textarea:focus-visible { outline: 2px solid #8fc2ff; outline-offset: 2px; }
html[data-theme="dark"] .card,
html[data-theme="dark"] table,
html[data-theme="dark"] .realthai-studio .panel,
html[data-theme="dark"] .realthai-studio .stat,
html[data-theme="dark"] .realthai-studio dialog,
html[data-theme="dark"] .overview-stat,
html[data-theme="dark"] .overview-card,
html[data-theme="dark"] .partner-video,
html[data-theme="dark"] .partner-empty,
html[data-theme="dark"] .client-planning-compact tr,
html[data-theme="dark"] .client-portal-content-table tr,
html[data-theme="dark"] .planning-board-table tr:not(:first-child),
html[data-theme="dark"] table.mobile-card-table > tbody > tr { background: var(--night-surface) !important; border-color: var(--line) !important; color: var(--text); }
html[data-theme="dark"] .card[style*="background:#f4f8ff"],
html[data-theme="dark"] .realthai-studio .realthai-overview-share { background: var(--night-raised) !important; border-color: var(--line) !important; }
html[data-theme="dark"] th { background: var(--night-raised); color: var(--muted); }
html[data-theme="dark"] th,
html[data-theme="dark"] td,
html[data-theme="dark"] .overview-video,
html[data-theme="dark"] .partner-video details,
html[data-theme="dark"] .partner-share-row,
html[data-theme="dark"] .client-planning-detail + .client-planning-detail { border-color: var(--line) !important; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .simple-editor-tools button,
html[data-theme="dark"] .realthai-studio button:not(.btn):not(.primary),
html[data-theme="dark"] .overview-toolbar a,
html[data-theme="dark"] .overview-month-picker button,
html[data-theme="dark"] .overview-month-picker select,
html[data-theme="dark"] .partner-months a { background: var(--night-raised) !important; border-color: var(--line) !important; color: var(--text) !important; }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #9eafc5; opacity: 1; }
html[data-theme="dark"] input[type="checkbox"],
html[data-theme="dark"] input[type="radio"] { accent-color: #5fa5ff; }
html[data-theme="dark"] .muted,
html[data-theme="dark"] .metric span,
html[data-theme="dark"] .planning-copy-label,
html[data-theme="dark"] .overview-empty,
html[data-theme="dark"] .overview-note,
html[data-theme="dark"] .partner-note { color: var(--muted) !important; }
html[data-theme="dark"] .badge,
html[data-theme="dark"] .planning-meta-chip,
html[data-theme="dark"] .planning-platforms span:not(.planning-platform),
html[data-theme="dark"] .overview-metrics span,
html[data-theme="dark"] .overview-video small,
html[data-theme="dark"] .partner-meta span,
html[data-theme="dark"] .realthai-studio .tag { background: var(--night-soft) !important; color: #bedcff !important; }
html[data-theme="dark"] .btn { background: #266bc7; color: #fff; }
html[data-theme="dark"] .btn.gray { background: #445b78; color: #fff; }
html[data-theme="dark"] .btn.red { background: #a93e4b; color: #fff; }
html[data-theme="dark"] .flash { background: #173e33; color: #a9efd0; }
html[data-theme="dark"] .flash.error { background: #512b38; color: #ffd2d4; }
html[data-theme="dark"] .planning-title,
html[data-theme="dark"] .planning-copy,
html[data-theme="dark"] .realthai-studio .stat strong,
html[data-theme="dark"] .realthai-studio .quota strong { color: var(--text); }
html[data-theme="dark"] .planning-extra,
html[data-theme="dark"] .realthai-studio .table-wrap { border-color: var(--line); }
html[data-theme="dark"] .planning-platforms span.planning-platform,
html[data-theme="dark"] .social-platform-icon { color: #fff !important; }
html[data-theme="dark"] .social-platform-icon.google { background: var(--night-raised); color: #8fc2ff !important; border-color: var(--line); }
html[data-theme="dark"] .realthai-studio { --studio-line: var(--line); --studio-muted: var(--muted); --studio-blue: #5fa5ff; }
html[data-theme="dark"] .realthai-studio-nav button,
html[data-theme="dark"] .realthai-studio .partner-pill a { background: var(--night-raised) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] .realthai-studio-nav button.active,
html[data-theme="dark"] .realthai-studio .months button.selected,
html[data-theme="dark"] .realthai-studio .partner-pills button.selected,
html[data-theme="dark"] .realthai-studio button.primary,
html[data-theme="dark"] .overview-copy { background: #266bc7 !important; color: #fff !important; border-color: #266bc7 !important; }
html[data-theme="dark"] .realthai-studio .hint,
html[data-theme="dark"] .realthai-studio .caption-preview,
html[data-theme="dark"] .realthai-studio .quota span,
html[data-theme="dark"] .overview-caption,
html[data-theme="dark"] .poster,
html[data-theme="dark"] .tnc { background: var(--night-raised) !important; color: var(--text) !important; border-color: var(--line) !important; }
html[data-theme="dark"] .realthai-studio #message:not(:empty) { background: #473924; color: #ffe3ab; border-color: #927244; }
html[data-theme="dark"] .realthai-studio .stat,
html[data-theme="dark"] .realthai-studio .quota span,
html[data-theme="dark"] .realthai-studio-top small,
html[data-theme="dark"] .overview-stat span,
html[data-theme="dark"] .overview-toolbar p,
html[data-theme="dark"] .overview-card p,
html[data-theme="dark"] .partner-section > p { color: var(--muted); }
html[data-theme="dark"] .overview-hero,
html[data-theme="dark"] .partner-hero { background: #102a46; color: #fff; }
html[data-theme="dark"] .overview-hero h1,
html[data-theme="dark"] .partner-hero h1 { color: #fff; }
html[data-theme="dark"] .overview-bar,
html[data-theme="dark"] .bar { background: #314969; }
html[data-theme="dark"] .overview-caption-row summary,
html[data-theme="dark"] .partner-video summary { color: var(--night-link) !important; }
html[data-theme="dark"] .overview-caption-missing { color: var(--muted) !important; }
html[data-theme="dark"] .bottom-nav { background: var(--night-surface) !important; border-color: var(--line) !important; }
html[data-theme="dark"] .bottom-nav a { color: var(--muted) !important; }
html[data-theme="dark"] .bottom-nav a.active { color: var(--night-link) !important; background: var(--night-soft) !important; }
html[data-theme="dark"] .app-bottom-nav { background: rgba(23,38,58,.97) !important; border-color: var(--line) !important; }
html[data-theme="dark"] .app-bottom-nav a { color: var(--muted) !important; }
html[data-theme="dark"] .app-bottom-nav a.active { color: var(--night-link) !important; background: var(--night-soft) !important; }
@media print {
  html[data-theme="dark"] { color-scheme: light; }
  html[data-theme="dark"] body { background: #fff !important; color: #172234 !important; }
  html[data-theme="dark"] .card,
  html[data-theme="dark"] table,
  html[data-theme="dark"] .overview-card,
  html[data-theme="dark"] .overview-stat,
  html[data-theme="dark"] .partner-video { background: #fff !important; color: #172234 !important; border-color: #dce3ec !important; }
  html[data-theme="dark"] th { background: #f8fafc !important; color: #68758a !important; }
}
