:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-gradient: linear-gradient(135deg, #f7faff 0%, #eef3ff 45%, #f8fbff 100%);
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --surface-2: #eaf0ff;
  --text: #182033;
  --heading: #0d1730;
  --muted: #64708a;
  --border: #dce3f1;
  --primary: #2457d6;
  --primary-dark: #163da0;
  --primary-soft: #eaf0ff;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --ok: #0f7a3d;
  --ok-bg: #e9f8ee;
  --warn: #9a6200;
  --warn-bg: #fff6df;
  --neutral-bg: #eef3ff;
  --neutral: #2457d6;
  --topbar: #0f1f46;
  --topbar-text: #ffffff;
  --topbar-muted: #c8d5ff;
  --shadow: 0 18px 45px rgba(17, 31, 66, 0.08);
  --focus: 0 0 0 4px rgba(36, 87, 214, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1020;
  --bg-gradient: linear-gradient(135deg, #080d1c 0%, #101b35 55%, #07101e 100%);
  --surface: #121a2e;
  --surface-soft: #17213a;
  --surface-2: #1e2d52;
  --text: #e9eefc;
  --heading: #ffffff;
  --muted: #aab6d3;
  --border: #2b395d;
  --primary: #7aa2ff;
  --primary-dark: #5484f7;
  --primary-soft: #1c2e5f;
  --danger: #ff9b90;
  --danger-bg: #3b1717;
  --ok: #82e6a7;
  --ok-bg: #173424;
  --warn: #ffd37a;
  --warn-bg: #372810;
  --neutral-bg: #1c2e5f;
  --neutral: #b9ccff;
  --topbar: #070b16;
  --topbar-text: #ffffff;
  --topbar-muted: #b9c8ee;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  --focus: 0 0 0 4px rgba(122, 162, 255, 0.22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-gradient);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, auto);
  gap: 24px;
  align-items: center;
  padding: 24px clamp(16px, 4vw, 48px);
  background: var(--topbar);
  color: var(--topbar-text);
}

.brand-block { min-width: 0; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(28px, 4vw, 44px); line-height: 1.05; letter-spacing: -0.03em; }
h2 { margin-bottom: 0; font-size: clamp(24px, 3vw, 34px); line-height: 1.15; color: var(--heading); letter-spacing: -0.02em; }
h3 { margin-bottom: 16px; font-size: 18px; line-height: 1.25; color: var(--heading); }
.subtitle { color: var(--topbar-muted); margin: 0; max-width: 720px; }
.eyebrow { color: var(--primary); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; margin-bottom: 6px; }
.topbar .eyebrow { color: #9db4ff; }
.section-copy { color: var(--muted); margin: 8px 0 0; max-width: 760px; }

.top-panel { display: grid; gap: 10px; justify-items: end; }
.session-card {
  width: 100%;
  max-width: 540px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 10px 12px;
  text-align: right;
}
.session-label { display: block; color: var(--topbar-muted); font-size: 12px; font-weight: 700; }
.session-card strong { display: block; margin-top: 2px; font-size: 15px; }
.role-buttons, .top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.app-shell { max-width: 1440px; margin: 0 auto; padding: 22px clamp(14px, 3vw, 36px) 50px; }
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  margin-bottom: 14px;
  scrollbar-width: thin;
}
.tab {
  flex: 0 0 auto;
  min-height: 42px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 750;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
}
.tab:hover { transform: translateY(-1px); color: var(--heading); }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.panel { display: none; }
.panel.active { display: block; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 14px 0 18px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.card {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: clamp(16px, 2vw, 20px);
  box-shadow: var(--shadow);
}
.card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title-row h3 { margin-bottom: 0; }
.metric { min-height: 120px; }
.metric .label { color: var(--muted); font-weight: 750; margin-bottom: 0; }
.metric .value { font-size: clamp(24px, 3vw, 38px); font-weight: 900; margin: 8px 0; color: var(--heading); letter-spacing: -0.03em; }
.metric .hint { color: var(--muted); font-size: 13px; margin: 0; }

.btn {
  min-height: 42px;
  border: 0;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible, .tab:focus-visible, input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--focus); border-color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: var(--primary-soft); color: var(--neutral); }
.btn.ghost { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.18); }
.btn.ghost.active { background: #ffffff; color: #0f1f46; }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.import-label { position: relative; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.stack { display: grid; gap: 10px; }
label { display: grid; gap: 6px; color: var(--muted); font-weight: 800; font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  background: var(--surface-soft);
  color: var(--text);
  min-height: 42px;
}
textarea { resize: vertical; min-height: 160px; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }
.note { color: var(--muted); font-size: 14px; line-height: 1.55; }
.list { display: grid; gap: 10px; }
.list.compact { margin-top: 14px; max-height: 320px; overflow: auto; }
.row-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}
.row-item strong { display: block; margin-bottom: 4px; color: var(--heading); }
.row-item span { color: var(--muted); font-size: 13px; }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 900; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral); }
.summary-box { border: 1px dashed var(--border); border-radius: 16px; padding: 14px; background: var(--surface-soft); color: var(--muted); line-height: 1.6; }
.summary-box strong { color: var(--heading); }
.summary-box + .summary-box { margin-top: 10px; }
.image-preview { min-height: 96px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border); border-radius: 16px; background: var(--surface-soft); color: var(--muted); overflow: hidden; text-align: center; }
.image-preview img { max-width: 100%; max-height: 220px; border-radius: 12px; display: block; }
.table-wrap { overflow: auto; border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { text-align: left; border-bottom: 1px solid var(--border); padding: 11px 10px; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-soft); position: sticky; top: 0; }
.footer { text-align: center; color: var(--muted); padding: 24px; }
.empty { color: var(--muted); padding: 16px; border: 1px dashed var(--border); border-radius: 14px; background: var(--surface-soft); }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--topbar);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
  z-index: 9999;
  font-weight: 800;
  max-width: min(360px, calc(100vw - 32px));
}

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

@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr; align-items: flex-start; }
  .top-panel { justify-items: stretch; width: 100%; }
  .session-card { max-width: none; text-align: left; }
  .role-buttons, .top-actions { justify-content: flex-start; }
  .grid.two, .cards { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .section-head { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  body { font-size: 14px; }
  .topbar { padding: 20px 14px; }
  .app-shell { padding-inline: 12px; }
  .btn, .tab { width: auto; min-height: 44px; }
  .top-actions .btn, .top-actions label, .role-buttons .btn { flex: 1 1 140px; }
  .card { border-radius: 18px; }
  table { min-width: 760px; }
}

@media print {
  .topbar, .tabs, .btn, .footer { display: none !important; }
  body { background: white; }
  .panel { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}
