:root {
  color-scheme: dark;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7f8;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --surface: #ffffff;
  --surface-2: #e9f0f2;
  --border: rgba(20, 64, 77, 0.14);
  --border-strong: rgba(20, 113, 137, 0.32);
  --line: rgba(20, 64, 77, 0.16);
  --text: #102630;
  --muted: #5c7079;
  --accent: #087e9b;
  --accent-strong: #05677f;
  --warm: #9a5d22;
  --accent-warm: #9a5d22;
  --shadow: 0 24px 70px rgba(26, 62, 73, 0.12);
}

.theme-toggle {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
  backdrop-filter: blur(14px);
  transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s ease;
}

.theme-toggle:hover { transform: translateY(-1px) rotate(6deg); }
.theme-toggle:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent); outline-offset: 3px; }
.theme-toggle svg { width: 20px; height: 20px; stroke: currentColor; transition: transform .25s ease, opacity .2s ease; }
.theme-toggle .theme-sun { display: none; }
:root[data-theme="light"] .theme-toggle .theme-sun { display: block; }
:root[data-theme="light"] .theme-toggle .theme-moon { display: none; }

.topbar, .portal-header, .admin-header { padding-right: 76px; }

:root[data-theme="light"] body {
  background: linear-gradient(180deg, #f8fbfc 0%, #edf3f4 55%, #f7f4ef 100%);
}
:root[data-theme="light"] body::before {
  background-image: linear-gradient(rgba(16, 38, 48, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(16, 38, 48, .035) 1px, transparent 1px);
}
:root[data-theme="light"] .auth-view {
  background: linear-gradient(90deg, rgba(248,251,252,.98) 0%, rgba(248,251,252,.82) 55%, rgba(248,251,252,.26) 100%), radial-gradient(circle at 78% 42%, rgba(8,126,155,.14), transparent 27%), repeating-linear-gradient(115deg, transparent 0 42px, rgba(8,126,155,.04) 43px 44px);
}
:root[data-theme="light"] .project-rail { background: #eef4f5; }
:root[data-theme="light"] .progress-orbit::after { background: var(--bg); }
:root[data-theme="light"] input,
:root[data-theme="light"] textarea,
:root[data-theme="light"] select { color: var(--text); background: #fff; }
:root[data-theme="light"] label { color: #304b56; }
:root[data-theme="light"] dialog { box-shadow: 0 40px 100px rgba(25, 55, 66, .2); }
:root[data-theme="light"] dialog::backdrop { background: rgba(28, 45, 51, .35); }
:root[data-theme="light"] .admin-auth {
  background: radial-gradient(circle at 78% 45%, rgba(8,126,155,.13), transparent 25%), repeating-linear-gradient(115deg, transparent 0 44px, rgba(8,126,155,.04) 45px 46px);
}

@media (max-width: 650px) {
  .theme-toggle { top: 12px; right: 12px; width: 42px; height: 42px; }
  .topbar, .portal-header, .admin-header { padding-right: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle, .theme-toggle svg { transition: none; }
}
