:root {
  color-scheme: light dark;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-muted: #eef3fa;
  --text: #14213d;
  --muted: #66728a;
  --line: #dbe3ef;
  --brand: #2357e8;
  --brand-strong: #173ca4;
  --accent: #7855d6;
  --safe: #11845b;
  --warn: #a85f00;
  --danger: #b33243;
  --shadow: 0 18px 45px rgb(24 42 78 / 10%);
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1422;
    --surface: #151f31;
    --surface-muted: #1b2940;
    --text: #f2f6ff;
    --muted: #aab7ce;
    --line: #2d3d58;
    --brand: #7897ff;
    --brand-strong: #a8bcff;
    --accent: #b39bff;
    --safe: #59c99c;
    --warn: #f0b35b;
    --danger: #ff8997;
    --shadow: 0 18px 45px rgb(0 0 0 / 25%);
  }
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-muted: #eef3fa;
  --text: #14213d;
  --muted: #66728a;
  --line: #dbe3ef;
  --brand: #2357e8;
  --brand-strong: #173ca4;
  --accent: #7855d6;
  --safe: #11845b;
  --warn: #a85f00;
  --danger: #b33243;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1422;
  --surface: #151f31;
  --surface-muted: #1b2940;
  --text: #f2f6ff;
  --muted: #aab7ce;
  --line: #2d3d58;
  --brand: #7897ff;
  --brand-strong: #a8bcff;
  --accent: #b39bff;
  --safe: #59c99c;
  --warn: #f0b35b;
  --danger: #ff8997;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 20;
  left: 1rem;
  top: -5rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 2px solid var(--brand);
  border-radius: 10px;
}

.skip-link:focus { top: 1rem; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 1.5rem 1.25rem;
  background: #111a2b;
  color: #f7f9ff;
}

.brand { display: flex; gap: .8rem; align-items: center; text-decoration: none; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, #4b75f2, #7659d4);
  font-weight: 900;
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: .18rem; color: #aebbd4; font-size: .69rem; letter-spacing: .14em; }
.sidebar nav { display: grid; gap: .35rem; }
.nav-item {
  display: flex;
  gap: .75rem;
  align-items: center;
  padding: .75rem;
  border-radius: 11px;
  color: #bdc8dc;
  text-decoration: none;
}
.nav-item span { display: grid; width: 24px; height: 24px; place-items: center; }
.nav-item:hover, .nav-item.active { background: #25334d; color: #ffffff; }
.secure-note { margin: auto 0 0; color: #9daac1; font-size: .78rem; line-height: 1.55; }
.secure-note span { color: #53d79c; }

.workspace { min-width: 0; display: flex; min-height: 100vh; flex-direction: column; }
.topbar {
  min-height: 72px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 93%, transparent);
}
.surface-pill { color: var(--safe); font-weight: 750; font-size: .85rem; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.locale-link { color: var(--brand-strong); font-weight: 750; }
.theme-switcher { display: flex; padding: .2rem; border: 1px solid var(--line); border-radius: 11px; }
.theme-option { padding: .42rem .6rem; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .8rem; }
.theme-option.selected { background: var(--surface-muted); color: var(--text); font-weight: 750; }

.content { width: min(1180px, 100%); margin: 0 auto; padding: clamp(2rem, 5vw, 4.5rem); }
.hero { max-width: 760px; margin-bottom: 2rem; }
.eyebrow { margin: 0 0 .65rem; color: var(--brand); font-weight: 850; text-transform: uppercase; letter-spacing: .12em; font-size: .76rem; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 4rem); line-height: 1.02; letter-spacing: -.045em; }
.hero > p:last-child { margin-top: 1rem; color: var(--muted); font-size: 1.05rem; line-height: 1.7; }

.access-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
  margin: 2rem 0;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-left: 5px solid var(--warn);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.access-card.state-ready { border-left-color: var(--safe); }
.access-card.state-forbidden { border-left-color: var(--danger); }
.access-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: var(--surface-muted); font-weight: 900; }
.access-card strong { font-size: 1rem; }
.access-card p { margin: .35rem 0 0; color: var(--muted); line-height: 1.55; }

.projection-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 2.5rem 0 1rem; }
.projection-toolbar h2 { margin: 0; font-size: 1.15rem; }
.projection-toolbar button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .65rem .85rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}
.projection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.projection-card {
  min-height: 220px;
  padding: 1.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.projection-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: var(--surface-muted); color: var(--brand); font-weight: 900; }
.projection-card h3 { margin: 1.1rem 0 .6rem; }
.projection-card p { min-height: 4.7rem; margin: 0; color: var(--muted); line-height: 1.55; }
.empty-state { display: inline-block; margin-top: 1rem; color: var(--warn); font-size: .82rem; font-weight: 750; }
footer { display: flex; justify-content: space-between; gap: 1rem; margin-top: auto; padding: 1rem clamp(1rem, 4vw, 3rem); border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; gap: 1rem; }
  .sidebar nav { display: flex; overflow-x: auto; }
  .nav-item { white-space: nowrap; }
  .secure-note { display: none; }
  .projection-grid { grid-template-columns: 1fr; }
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1.5rem;
  padding: 2rem 1rem;
}
.auth-brand { display: flex; align-items: center; gap: 0.75rem; }
.auth-brand strong, .auth-brand small { display: block; line-height: 1.1; }
.auth-brand small { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.08em; }
.auth-card {
  width: min(100%, 26rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
}
.auth-card h1 { margin: 0.25rem 0 0.5rem; font-size: 1.5rem; }
.auth-card > p { color: var(--muted); }
.auth-form { display: grid; gap: 1rem; margin-top: 1.25rem; }
.field { display: grid; gap: 0.35rem; font-size: 0.9rem; }
.field input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--text);
  font: inherit;
}
.field input:focus { outline: 2px solid var(--brand); outline-offset: 2px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.button-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.button-ghost { background: transparent; }
.button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.result { padding: 0.75rem 0.9rem; border-radius: 12px; font-size: 0.9rem; margin-top: 0.75rem; }
.result.success { background: color-mix(in srgb, var(--safe) 14%, var(--surface)); color: var(--safe); }
.result.failure { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.auth-security, .auth-links { color: var(--muted); font-size: 0.8rem; margin-top: 1.25rem; }
.logout-form { display: inline-flex; margin: 0; }

.page-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; padding: 0.5rem 0 1.25rem; flex-wrap: wrap; }
.page-hero h1 { margin: 0.25rem 0 0.5rem; font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.1; }
.page-hero p { margin: 0; color: var(--muted); }
.form-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: 1.5rem; margin: 0 0 1.25rem; min-width: 0; }
fieldset.form-card { padding: 1rem 1.25rem 1.25rem; }
legend { padding: 0 0.4rem; font-weight: 700; color: var(--text); }
.card-heading { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.card-heading h2 { margin: 0; font-size: 1.2rem; }
.card-heading p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.step-number { display: grid; place-items: center; flex: 0 0 44px; height: 44px; border-radius: 14px; color: var(--brand-strong); background: var(--surface-muted); font-size: 0.9rem; font-weight: 900; }
.summary-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.summary-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.9rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.summary-list small { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }
.chip-list { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.75rem 0 0; padding: 0; }
.chip-list form { margin: 0; }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.75rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-muted); font-size: 0.85rem; }
.button-secondary { color: var(--brand-strong); border-color: var(--line); background: var(--surface); white-space: nowrap; }
.empty-preview { padding: 1.25rem; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.submit-help { margin: 0; color: var(--muted); font-size: 0.8rem; }
.form-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-fields h3 { margin: 0.5rem 0 0; }
.field-wide { grid-column: 1 / -1; }
.field select { width: 100%; padding: 0.7rem 0.9rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-muted); color: var(--text); font: inherit; }
.field select:focus { outline: 2px solid var(--brand); outline-offset: 2px; }

@media (max-width: 560px) {
  .topbar, .topbar-actions, footer { align-items: flex-start; flex-direction: column; }
  .theme-switcher { max-width: 100%; overflow-x: auto; }
  .content { padding: 1.5rem 1rem 2.5rem; }
  .access-card { grid-template-columns: 1fr; }
  .form-fields { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
