/* Визуальная система экранов приложения.
   Экран разговора #screen-training намеренно не входит в область действия. */

:root{
  --ui-canvas:#0b0f18;
  --ui-surface:#121927;
  --ui-surface-raised:#182236;
  --ui-surface-soft:#202c43;
  --ui-border:#34435e;
  --ui-border-strong:#51678d;
  --ui-text:#f4f7fc;
  --ui-muted:#b7c1d4;
  --ui-subtle:#8998b2;
  --ui-accent:#9aafff;
  --ui-accent-strong:#7896ff;
  --ui-accent-2:#c1a7ff;
  --ui-success:#65d89b;
  --ui-warning:#f1c66f;
  --ui-danger:#ff8f91;
  --ui-danger-bg:#3a2028;
  --ui-radius-sm:10px;
  --ui-radius-md:14px;
  --ui-radius-lg:20px;
  --ui-shadow:0 18px 50px rgba(0,0,0,.24);
  --ui-shadow-soft:0 10px 28px rgba(0,0,0,.16);
}

.visually-hidden{
  position:absolute !important;
  width:1px !important;
  height:1px !important;
  padding:0 !important;
  margin:-1px !important;
  overflow:hidden !important;
  clip:rect(0,0,0,0) !important;
  white-space:nowrap !important;
  border:0 !important;
}

.skip-link{
  position:fixed;
  top:12px;
  left:12px;
  z-index:10001;
  transform:translateY(-160%);
  padding:10px 14px;
  border-radius:10px;
  background:var(--ui-accent);
  color:#090e1a;
  font-weight:700;
  text-decoration:none;
  transition:transform .15s ease;
}
.skip-link:focus{transform:translateY(0);}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin){
  color:var(--ui-text);
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) h1{
  color:var(--ui-text);
  background:none;
  -webkit-background-clip:initial;
  background-clip:initial;
  -webkit-text-fill-color:initial;
  letter-spacing:-.02em;
}
:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) h1[tabindex="-1"]:focus{outline:none;}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) h2{
  color:var(--ui-text);
  letter-spacing:-.01em;
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) .sub,
:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) .hint{
  color:var(--ui-muted);
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) .card{
  background:linear-gradient(180deg,rgba(24,34,54,.96),rgba(18,25,39,.98));
  border-color:var(--ui-border);
  border-radius:var(--ui-radius-lg);
  box-shadow:var(--ui-shadow-soft);
  padding:22px;
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) label{
  color:var(--ui-muted);
  font-weight:600;
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) :is(input,textarea,select){
  min-height:44px;
  background:#0d1421;
  color:var(--ui-text);
  border-color:var(--ui-border);
  border-radius:12px;
  padding:10px 12px;
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) :is(input,textarea,select):hover{
  border-color:var(--ui-border-strong);
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) :is(input,textarea,select):focus{
  outline:2px solid transparent;
  border-color:var(--ui-accent);
  box-shadow:0 0 0 3px rgba(154,175,255,.2);
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) :is(input,textarea,select)[aria-invalid="true"]{
  border-color:var(--ui-danger);
  box-shadow:0 0 0 3px rgba(255,143,145,.14);
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) summary:focus-visible{
  outline:3px solid var(--ui-accent);
  outline-offset:-3px;
  border-radius:10px;
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) button:focus-visible,
.confirm-overlay button:focus-visible,
.launcher :is(a,button):focus-visible{
  outline:3px solid var(--ui-accent);
  outline-offset:3px;
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) .btn-primary{
  background:linear-gradient(135deg,var(--ui-accent),var(--ui-accent-2));
  color:#090e1a;
  border:1px solid rgba(255,255,255,.22);
  border-radius:13px;
  box-shadow:0 12px 28px rgba(94,118,214,.24);
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) .btn-primary:hover{
  opacity:1;
  filter:brightness(1.04);
  transform:translateY(-1px);
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) .btn-ghost{
  background:var(--ui-surface-soft);
  color:var(--ui-text);
  border-color:var(--ui-border);
  border-radius:11px;
}

:is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) .btn-ghost:hover{
  border-color:var(--ui-accent);
  background:#273550;
}

.btn-danger-soft{
  background:var(--ui-danger-bg) !important;
  color:#ffc7c8 !important;
  border:1px solid #75414b !important;
}
.btn-danger-soft:hover{border-color:var(--ui-danger) !important;}

.page-kicker{
  color:var(--ui-accent);
  font-size:12px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
  margin-bottom:6px;
}

.page-description{
  color:var(--ui-muted);
  font-size:14px;
  line-height:1.55;
  margin-top:5px;
}

.app-topbar{
  position:sticky;
  top:0;
  z-index:30;
  margin:-24px -16px 24px;
  padding:18px 16px;
  background:rgba(11,15,24,.9);
  border-bottom:1px solid rgba(52,67,94,.72);
  backdrop-filter:blur(14px);
}

.app-topbar-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  flex-wrap:wrap;
}

.user-chip{
  display:inline-flex;
  align-items:center;
  min-height:36px;
  padding:7px 11px;
  border:1px solid var(--ui-border);
  border-radius:999px;
  background:var(--ui-surface);
  color:var(--ui-muted);
}

/* Вход и первый запуск */
#screen-login.active{
  display:grid;
  min-height:100vh;
  max-width:none;
  place-items:center;
  padding:32px 16px;
  background:
    radial-gradient(circle at 16% 12%,rgba(120,150,255,.16),transparent 35%),
    radial-gradient(circle at 84% 88%,rgba(193,167,255,.12),transparent 34%);
}

.login-shell{width:min(460px,100%);}
.login-brand{text-align:left; margin-bottom:20px;}
.brand-lockup{display:flex; align-items:center; gap:13px;}
.brand-mark{
  display:grid;
  place-items:center;
  width:48px;
  height:48px;
  border-radius:15px;
  background:linear-gradient(135deg,var(--ui-accent),var(--ui-accent-2));
  color:#090e1a;
  font-size:24px;
  font-weight:900;
  letter-spacing:-.04em;
  box-shadow:0 12px 32px rgba(95,119,214,.28);
}
.app-brand-title{display:flex; align-items:center; gap:8px;}
.app-brand-title span{font-size:22px;}
.login-brand h1{font-size:29px; line-height:1.12; margin:0;}
.login-brand .page-description{margin-left:61px;}
.login-card{margin:0 !important; max-width:none !important;}
.login-card h2{font-size:20px; margin:0 0 16px !important;}
.field-group{margin-top:13px;}
.field-group label{margin:0 0 6px;}
.password-field{position:relative;}
.password-field input{padding-right:92px;}
.password-toggle{
  position:absolute;
  right:7px;
  top:7px;
  min-height:30px;
  padding:4px 9px;
  background:transparent;
  color:var(--ui-accent);
  border:0;
  font-size:12px;
  font-weight:700;
}
.form-error{
  min-height:20px;
  color:#ffb7b9 !important;
  margin-top:8px;
}
.login-help{
  margin-top:14px;
  padding-top:14px;
  border-top:1px solid var(--ui-border);
  color:var(--ui-subtle);
  font-size:12px;
  line-height:1.5;
}

/* Главный экран */
#screen-setup{max-width:1080px;}
#screen-setup .scenario-grid{
  grid-template-columns:repeat(auto-fit,minmax(300px,1fr));
  gap:14px;
}
#screen-setup .scenario{
  display:grid;
  grid-template-columns:48px minmax(0,1fr) auto;
  grid-template-rows:auto auto auto;
  gap:4px 12px;
  align-items:start;
  min-height:150px;
  padding:18px;
  border:1px solid var(--ui-border);
  background:linear-gradient(145deg,var(--ui-surface),#111928);
  border-radius:18px;
  box-shadow:var(--ui-shadow-soft);
}
#screen-setup .scenario:hover{
  transform:translateY(-2px);
  border-color:var(--ui-accent);
}
#screen-setup .scenario.selected{
  border-color:var(--ui-accent);
  background:linear-gradient(145deg,#1d2a43,#202a44);
  box-shadow:0 0 0 3px rgba(154,175,255,.15),var(--ui-shadow-soft);
}
#screen-setup .scenario .emoji{
  grid-column:1;
  grid-row:1 / span 3;
  display:grid;
  place-items:center;
  width:48px;
  height:48px;
  border-radius:14px;
  background:#263550;
  font-size:24px;
}
#screen-setup .scenario h3{
  grid-column:2;
  grid-row:1;
  margin:1px 0 0;
  font-size:17px;
  line-height:1.3;
}
#screen-setup .scenario p{
  grid-column:2 / 4;
  grid-row:2;
  font-size:13px;
  line-height:1.55;
  color:var(--ui-muted);
}
#screen-setup .scenario .scenario-chip{
  grid-column:3;
  grid-row:1;
  margin:0;
  justify-self:end;
  background:#273550;
  border-color:var(--ui-border);
  color:var(--ui-muted);
}
#screen-setup .case-panel{
  margin-top:16px;
  border-color:rgba(154,175,255,.4);
}
#screen-setup .case-preview{
  background:#101827;
  border-color:var(--ui-border);
  border-radius:14px;
  padding:15px;
}
.case-preview-heading{display:flex; align-items:center; gap:10px; margin-bottom:6px;}
.case-preview-heading h3{margin:0;}
.case-preview-icon{
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  flex:0 0 38px;
  border-radius:11px;
  background:#263550;
  font-size:20px;
}
.progress-details-row{display:flex; justify-content:flex-end; margin:2px 0 8px;}
.progress-details-row .btn-ghost{min-height:38px;}
.microphone-help{margin:12px auto 20px; max-width:680px;}
.microphone-help summary{text-align:center; color:var(--ui-muted);}
.microphone-help p{text-align:center; margin-top:7px;}
.section-heading-row{
  display:flex;
  align-items:end;
  justify-content:space-between;
  gap:16px;
  margin:28px 0 13px;
}
.section-heading-row h2{margin:0;}
.section-heading-row p{margin:0; color:var(--ui-muted); font-size:13px;}

:is(#screen-setup,#screen-dynamics,#screen-report) .metrics{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(170px,1fr));
  gap:12px;
}
:is(#screen-setup,#screen-dynamics,#screen-report) .metrics .m{
  min-width:0;
  padding:14px 15px;
  background:#101827;
  border-color:var(--ui-border);
  border-radius:14px;
}
:is(#screen-setup,#screen-dynamics,#screen-report) .metrics .m b{
  color:var(--ui-text);
  font-size:23px;
}

.history-toolbar{
  display:grid;
  grid-template-columns:repeat(2,minmax(180px,1fr));
  gap:12px;
  margin-top:14px;
}
.history-toolbar label{margin-top:0;}
.hist-chart{
  align-items:stretch;
  gap:8px;
  height:142px;
  padding:12px 4px 4px;
  overflow-x:auto;
  border-bottom:1px solid var(--ui-border);
  scrollbar-width:thin;
  scrollbar-color:var(--ui-border-strong) transparent;
}
.hist-chart::-webkit-scrollbar{height:6px;}
.hist-chart::-webkit-scrollbar-track{background:transparent;}
.hist-chart::-webkit-scrollbar-thumb{background:var(--ui-border-strong); border-radius:999px;}
.hist-chart-item{
  flex:1 0 46px;
  max-width:58px;
  min-width:46px;
  display:grid;
  grid-template-rows:20px 1fr 20px;
  align-items:end;
  gap:4px;
}
.hist-chart-score{
  color:var(--ui-muted);
  font-size:11px;
  font-weight:700;
  text-align:center;
}
.hist-bar-button{
  position:relative;
  width:100%;
  height:100%;
  padding:0;
  border:0;
  border-radius:7px 7px 2px 2px;
  background:transparent;
}
.hist-bar-button::before{
  content:'';
  position:absolute;
  inset:auto 6px 0;
  height:var(--bar-height);
  min-height:5px;
  border-radius:7px 7px 2px 2px;
  background:var(--bar-color);
  opacity:.9;
}
.hist-bar-button:hover::before{filter:brightness(1.12);}
.hist-chart-date{
  color:var(--ui-subtle);
  font-size:10px;
  text-align:center;
  white-space:nowrap;
}
.hist-list{line-height:1.45;}
.history-entry{
  margin-bottom:9px;
  padding:0;
  border:1px solid var(--ui-border);
  border-radius:13px;
  background:#101827;
  overflow:hidden;
}
.history-entry>summary{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto auto;
  align-items:center;
  gap:10px;
  min-height:52px;
  padding:12px 14px;
  list-style:none;
  color:var(--ui-text);
}
.history-entry>summary::-webkit-details-marker{display:none;}
.history-entry>summary::after{
  content:'Показать';
  color:var(--ui-accent);
  font-size:12px;
  font-weight:700;
}
.history-entry[open]>summary::after{content:'Скрыть';}
.history-entry>summary:hover{background:#162238;}
.history-entry-body{padding:0 14px 16px;}
.history-entry-title{overflow:hidden; text-overflow:ellipsis;}
.history-entry-score{font-weight:800;}

/* Динамика */
#screen-dynamics{max-width:1220px;}
#screen-dynamics .dynamics-filters{
  grid-template-columns:minmax(190px,1fr) minmax(230px,1.35fr) minmax(145px,.75fr) minmax(145px,.75fr);
}
.dynamics-legend{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin:0 0 13px;
}
.score-band{
  display:inline-flex;
  align-items:center;
  gap:7px;
  min-height:30px;
  padding:5px 9px;
  border:1px solid var(--ui-border);
  border-radius:999px;
  color:var(--ui-muted);
  font-size:12px;
}
.score-band::before{
  content:'';
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--band-color);
}
#screen-dynamics .dynamics-chart{
  border-color:var(--ui-border);
  border-radius:16px;
  background:linear-gradient(180deg,rgba(120,150,255,.1),rgba(13,20,33,.5));
  scrollbar-width:thin;
  scrollbar-color:var(--ui-border-strong) transparent;
}
#screen-dynamics .dynamics-chart::-webkit-scrollbar{height:6px;}
#screen-dynamics .dynamics-chart::-webkit-scrollbar-track{background:transparent;}
#screen-dynamics .dynamics-chart::-webkit-scrollbar-thumb{background:var(--ui-border-strong); border-radius:999px;}
.dynamics-session{
  background:#101827;
  border-color:var(--ui-border);
  border-radius:13px;
  padding:0;
  overflow:hidden;
}
.dynamics-session summary{
  min-height:56px;
  padding:12px 14px;
}
.dynamics-session summary::after{
  content:'Показать';
  color:var(--ui-accent);
  font-size:12px;
  font-weight:700;
}
.dynamics-session[open] summary::after{content:'Скрыть';}
.dynamics-session-body{padding:14px;}
#screen-dynamics .score-point{cursor:default;}

/* Брифинг */
#screen-brief{max-width:860px;}
.brief-card{
  display:grid;
  grid-template-columns:56px minmax(0,1fr);
  gap:18px;
  align-items:start;
}
.brief-icon{
  display:grid;
  place-items:center;
  width:56px;
  height:56px;
  border-radius:17px;
  background:#263550;
  font-size:27px;
}
.brief-title{font-size:21px; font-weight:750;}
.brief-subtitle{color:var(--ui-muted); font-size:13px; margin-top:3px;}
.brief-content{grid-column:1 / -1; display:grid; grid-template-columns:1.2fr .8fr; gap:12px;}
.brief-section{
  padding:15px;
  border:1px solid var(--ui-border);
  border-radius:14px;
  background:#101827;
}
.brief-section h2{margin:0 0 7px !important; font-size:14px !important; color:var(--ui-muted);}
.brief-section p{line-height:1.55;}
.brief-facts{display:grid; gap:8px; margin:0; padding:0; list-style:none;}
.brief-facts li{position:relative; padding-left:16px; line-height:1.5;}
.brief-facts li::before{content:''; position:absolute; left:0; top:.62em; width:6px; height:6px; border-radius:50%; background:var(--ui-accent);}

/* Разбор */
#screen-report{max-width:1040px;}
#screen-report>h1{font-size:28px;}
.report-score-card{padding:26px !important;}
.score-ring .ring-caption{
  fill:var(--ui-muted);
  font-size:10px;
  font-weight:700;
  text-anchor:middle;
}
.report-score-card .score-label{
  max-width:680px;
  margin:0 auto 24px;
  line-height:1.55;
  color:var(--ui-text);
  font-size:15px;
}
#screen-report .crit{
  display:grid;
  grid-template-columns:minmax(180px,260px) minmax(120px,1fr) 48px;
}
#screen-report .crit .name{flex:none;}
.report-actions{
  position:sticky;
  bottom:12px;
  z-index:20;
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:8px;
  padding:10px;
  border:1px solid var(--ui-border);
  border-radius:16px;
  background:rgba(13,20,33,.9);
  box-shadow:var(--ui-shadow);
  backdrop-filter:blur(14px);
}
.report-actions>div{min-width:0 !important; flex:auto !important;}
.report-actions :is(.btn-primary,.btn-ghost){width:100%; height:100%; margin:0; padding:11px 12px; font-size:13px;}
#screen-report .dyn-row .name{min-width:0; overflow-wrap:anywhere;}

/* Админка */
#screen-admin{max-width:1440px;}
.admin-heading{font-size:23px; font-weight:800; letter-spacing:-.02em;}
.ad-nav{
  position:sticky;
  top:76px;
  z-index:25;
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:7px;
  padding:7px;
  margin-bottom:18px;
  border:1px solid var(--ui-border);
  border-radius:15px;
  background:rgba(13,20,33,.92);
  backdrop-filter:blur(14px);
}
.ad-nav button{
  min-height:44px;
  border-radius:10px;
  background:transparent;
  border-color:transparent;
  color:var(--ui-muted);
}
.ad-nav button.active{
  background:var(--ui-accent);
  color:#090e1a;
  border-color:var(--ui-accent);
}
.ad-page[hidden]{display:none !important;}
.admin-page-card{padding:24px !important;}
.admin-page-title{display:flex; align-items:flex-start; justify-content:space-between; gap:18px; margin-bottom:16px;}
.admin-page-title h2{margin:0 !important; font-size:22px;}
.admin-page-title p{margin:5px 0 0; max-width:820px;}

.scenario-admin-list{display:grid; gap:10px;}
.scenario-admin-item{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:16px;
  padding:14px 15px;
  border:1px solid var(--ui-border);
  border-radius:14px;
  background:#101827;
}
.scenario-admin-title{display:flex; align-items:center; gap:10px; font-weight:800;}
.scenario-admin-icon{
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  border-radius:11px;
  background:#263550;
  font-size:19px;
}
.scenario-admin-meta{margin-top:5px; color:var(--ui-muted); font-size:12px;}
.scenario-admin-actions{display:flex; gap:7px; flex-wrap:wrap; justify-content:flex-end;}

.scenario-editor-shell{
  display:grid;
  grid-template-columns:190px minmax(0,1fr) 230px;
  gap:16px;
  align-items:start;
}
.scenario-editor-nav,
.scenario-editor-actions{
  position:sticky;
  top:145px;
  display:grid;
  gap:8px;
  padding:14px;
  border:1px solid var(--ui-border);
  border-radius:16px;
  background:#101827;
}
.scenario-editor-nav a{
  padding:10px 11px;
  border-radius:10px;
  color:var(--ui-muted);
  text-decoration:none;
  font-size:13px;
}
.scenario-editor-nav a:hover,
.scenario-editor-nav a:focus-visible{background:#20304a; color:var(--ui-text);}
.scenario-editor-workspace{min-width:0;}
.editor-section{
  margin:0 0 14px !important;
  padding:17px !important;
  border:1px solid var(--ui-border) !important;
  border-radius:16px !important;
  background:#101827;
}
.editor-section>summary{font-weight:800 !important; color:var(--ui-text) !important;}
.editor-section-title{font-size:18px; font-weight:800; margin-bottom:5px;}
.scenario-editor-actions .btn-ghost{width:100%;}
.scenario-editor-actions .save-editor{
  background:var(--ui-accent);
  color:#090e1a;
  border-color:var(--ui-accent);
  font-weight:800;
}
.dirty-status{
  min-height:34px;
  padding:8px 10px;
  border-radius:10px;
  background:#182238;
  color:var(--ui-muted);
  font-size:12px;
  font-weight:700;
}
.dirty-status.is-dirty{background:#3a2d17; color:var(--ui-warning);}
.case-editor{
  margin:10px 0 !important;
  padding:0 !important;
  border:1px solid var(--ui-border) !important;
  border-radius:14px !important;
  background:#121b2c !important;
  overflow:hidden;
}
.case-editor>summary{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  min-height:52px;
  padding:10px 12px !important;
  list-style:none;
  background:#18243a;
}
.case-editor>summary::-webkit-details-marker{display:none;}
.case-editor>summary::before{
  content:'Раскрыть';
  color:var(--ui-accent);
  font-size:11px;
  font-weight:700;
}
.case-editor[open]>summary::before{content:'Свернуть';}
.case-editor-actions{
  display:flex;
  justify-content:flex-end;
  gap:7px;
  padding:10px 14px 0;
}
.case-editor-actions .btn-ghost{min-height:36px; padding:6px 10px;}
.case-editor>summary~*{margin-left:14px; margin-right:14px;}
.case-editor>details:last-child{margin-bottom:14px !important;}
.case-main-fields{
  display:grid;
  grid-template-columns:110px minmax(0,1fr);
  gap:12px;
  align-items:end;
}
.case-emoji-field select{font-size:22px; text-align:center;}

.admin-create-panel,
.admin-operations,
.danger-zone{
  margin:12px 0;
  border:1px solid var(--ui-border);
  border-radius:14px;
  background:#101827;
  overflow:hidden;
}
.admin-create-panel>summary,
.admin-operations>summary,
.danger-zone>summary{
  padding:13px 15px;
  color:var(--ui-text);
  font-weight:800;
  list-style:none;
}
.admin-create-panel>summary::-webkit-details-marker,
.admin-operations>summary::-webkit-details-marker,
.danger-zone>summary::-webkit-details-marker{display:none;}
.admin-create-panel[open]>summary,
.admin-operations[open]>summary{border-bottom:1px solid var(--ui-border);}
.admin-panel-body{padding:4px 15px 16px;}
.danger-zone{border-color:#633943; background:#24161c;}
.danger-zone>summary{color:#ffc0c2;}
.danger-zone[open]>summary{border-bottom:1px solid #633943;}
.danger-actions{display:flex; gap:8px; flex-wrap:wrap; padding:14px;}

.user-table-wrap{border:1px solid var(--ui-border); border-radius:14px; overflow:auto;}
table.user-table{min-width:1080px; background:#101827;}
table.user-table th{padding:11px 10px; background:#18243a; color:var(--ui-muted);}
table.user-table td{padding:9px 10px;}
table.user-table tbody tr:hover{background:#142036;}
.user-actions .btn-ghost:last-child{background:var(--ui-danger-bg); color:#ffc0c2; border-color:#633943;}
.user-tree-group th{
  padding:14px 12px 8px !important;
  background:#0d1421 !important;
  color:var(--ui-accent) !important;
  font-size:12px !important;
  letter-spacing:.06em;
  text-transform:uppercase;
}
.user-tree-row .user-id{
  display:flex;
  align-items:center;
  gap:6px;
  padding-left:calc(var(--tree-depth) * 18px);
}
.tree-branch{width:10px; height:10px; border-left:1px solid var(--ui-border-strong); border-bottom:1px solid var(--ui-border-strong);}
.user-tree-row[style*="--tree-depth:0"] .tree-branch{border:0; width:0;}

.history-command-bar{
  display:grid;
  grid-template-columns:minmax(220px,1fr) auto;
  gap:12px;
  align-items:end;
}
.history-command-actions{display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end;}
.history-export-bar{display:flex; gap:8px; flex-wrap:wrap; margin:10px 0 14px;}
.history-entry-actions,.session-actions{display:flex; gap:8px; flex-wrap:wrap; margin-top:12px;}

/* Выбор команды и многосерийная динамика */
.dyn-user-filter{grid-column:span 2;}
.dyn-user-picker{
  min-height:44px;
  max-height:245px;
  overflow:auto;
  padding:10px;
  border:1px solid var(--ui-border);
  border-radius:12px;
  background:#0d1421;
}
.dyn-user-actions{display:flex; gap:7px; margin-bottom:8px;}
.dyn-user-actions .btn-ghost{min-height:34px; padding:5px 9px;}
.dyn-user-node{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  min-height:34px;
  padding:4px 5px 4px calc(5px + var(--tree-depth) * 18px);
  border-radius:8px;
}
.dyn-user-node:hover{background:#18243a;}
.dyn-user-node label{display:flex; align-items:center; gap:7px; margin:0; color:var(--ui-text); cursor:pointer;}
.dyn-user-node input{min-height:auto; width:auto;}
.dyn-user-node small{color:var(--ui-subtle);}
.dyn-group-button{
  min-height:28px;
  padding:3px 8px;
  border:1px solid var(--ui-border);
  border-radius:8px;
  background:#202c43;
  color:var(--ui-muted);
  font-size:11px;
}
.dynamics-chart-heading{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px;}
.segmented-control{display:flex; gap:4px; padding:4px; border:1px solid var(--ui-border); border-radius:12px; background:#0d1421;}
.segmented-control button{
  min-height:34px;
  padding:6px 10px;
  border-radius:8px;
  background:transparent;
  color:var(--ui-muted);
  font-size:12px;
}
.segmented-control button.active{background:var(--ui-accent); color:#090e1a; font-weight:800;}
#dynCriterionControl{max-width:420px; margin-bottom:10px;}
.dyn-series-legend{display:flex; gap:7px; flex-wrap:wrap; margin:9px 0;}
.dyn-series-legend button{
  position:relative;
  min-height:30px;
  padding:5px 9px 5px 22px;
  border:1px solid var(--ui-border);
  border-radius:999px;
  background:#101827;
  color:var(--ui-text);
  font-size:11px;
}
.dyn-series-legend button::before{
  content:'';
  position:absolute;
  left:8px;
  top:50%;
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--series-color);
  transform:translateY(-50%);
}
.dyn-series-legend button.is-hidden{opacity:.42; text-decoration:line-through;}

.settings-layout{
  display:grid;
  grid-template-columns:210px minmax(0,1fr);
  gap:16px;
  align-items:start;
}
.settings-nav{
  position:sticky;
  top:145px;
  display:grid;
  gap:6px;
  padding:12px;
  border:1px solid var(--ui-border);
  border-radius:15px;
  background:#101827;
}
.settings-nav a{
  padding:10px;
  border-radius:9px;
  color:var(--ui-muted);
  text-decoration:none;
  font-size:13px;
}
.settings-nav a:hover,.settings-nav a:focus-visible{background:#20304a; color:var(--ui-text);}
.settings-content .card{scroll-margin-top:150px;}

/* Модальные окна и уведомления */
.confirm-overlay{background:rgba(4,7,12,.78); backdrop-filter:blur(8px);}
.confirm-card,.tool-modal-card{
  color:var(--ui-text);
  background:var(--ui-surface);
  border-color:var(--ui-border);
  border-radius:18px;
  scrollbar-width:thin;
  scrollbar-color:var(--ui-border-strong) transparent;
}
.tool-modal-card::-webkit-scrollbar{width:7px; height:7px;}
.tool-modal-card::-webkit-scrollbar-track{background:transparent;}
.tool-modal-card::-webkit-scrollbar-thumb{background:var(--ui-border-strong); border-radius:999px;}
.confirm-card p{color:var(--ui-muted);}
.confirm-card .btn-danger{background:var(--ui-danger); color:#260609;}
.toast{color:var(--ui-text); background:var(--ui-surface); border-color:var(--ui-border);}

/* Единый тёмный загрузчик */
.launcher{
  color:var(--ui-text);
  background:
    radial-gradient(circle at 20% 15%,rgba(120,150,255,.18),transparent 38%),
    radial-gradient(circle at 82% 82%,rgba(193,167,255,.14),transparent 36%),
    var(--ui-canvas);
}
.launcher .card{
  width:min(600px,100%);
  padding:36px;
  text-align:left;
  background:linear-gradient(180deg,#182236,#111827);
  border:1px solid var(--ui-border);
  border-radius:24px;
  box-shadow:var(--ui-shadow);
}
.launcher .logo{
  display:grid;
  place-items:center;
  width:52px;
  height:52px;
  margin:0 0 18px;
  border-radius:16px;
  background:linear-gradient(135deg,var(--ui-accent),var(--ui-accent-2));
  color:#090e1a;
  font-size:0;
  font-weight:900;
}
.launcher .logo::after{content:'🎙️'; font-size:25px;}
.launcher h1{color:var(--ui-text); font-size:25px;}
.launcher .sub,.launcher .stage,.launcher .meta,.launcher .note,.launcher .link{color:var(--ui-muted);}
.launcher .spinner{
  width:48px;
  height:48px;
  margin:24px 0 18px;
  border-color:#263550;
  border-top-color:var(--ui-accent);
}
.launcher .status{font-size:17px;}
.launcher .bar{height:10px; background:#263550;}
.launcher .fill{background:linear-gradient(90deg,var(--ui-accent-strong),var(--ui-accent-2));}
.launcher .btn{
  min-height:44px;
  padding:12px 18px;
  background:var(--ui-accent);
  color:#090e1a;
  font-weight:800;
}
.launcher .link{color:var(--ui-accent);}
.launcher .error .spinner{display:none;}
.launcher .error .progress-wrap{display:none;}
.launcher .error .status{color:#ffc0c2;}
.launcher .error .stage{margin-top:10px;}

@media(max-width:1180px){
  .scenario-editor-shell{grid-template-columns:170px minmax(0,1fr);}
  .scenario-editor-actions{
    position:static;
    grid-column:1 / -1;
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
  .scenario-editor-actions .dirty-status{grid-column:1 / -1;}
}

@media(max-width:900px){
  .app-topbar{position:static; margin:-16px -10px 18px; padding:14px 10px;}
  #screen-dynamics .dynamics-filters{grid-template-columns:repeat(2,minmax(0,1fr));}
  .ad-nav{top:0; grid-template-columns:repeat(2,minmax(0,1fr));}
  .scenario-editor-shell,
  .settings-layout{grid-template-columns:1fr;}
  .scenario-editor-nav,.settings-nav{position:static; display:flex; overflow-x:auto;}
  .scenario-editor-nav a,.settings-nav a{white-space:nowrap;}
  .scenario-editor-actions{grid-template-columns:repeat(2,minmax(0,1fr));}
  .history-command-bar{grid-template-columns:1fr;}
  .history-command-actions{justify-content:flex-start;}
  .report-actions{position:static; grid-template-columns:repeat(2,minmax(0,1fr));}
  .dyn-user-filter{grid-column:1 / -1;}

  .user-table-wrap{overflow:visible; border:0;}
  table.user-table{display:block; min-width:0; background:transparent;}
  table.user-table thead{display:none;}
  table.user-table tbody{display:grid; gap:12px;}
  table.user-table tr{
    display:grid;
    gap:0;
    padding:10px 14px;
    border:1px solid var(--ui-border);
    border-radius:14px;
    background:#101827;
  }
  table.user-table td{
    display:grid;
    grid-template-columns:minmax(116px,.65fr) minmax(0,1.35fr);
    align-items:center;
    gap:10px;
    padding:8px 0;
    border-bottom:1px solid rgba(52,67,94,.55);
    white-space:normal;
  }
  table.user-table td:last-child{border-bottom:0;}
  table.user-table td::before{
    content:attr(data-label);
    color:var(--ui-subtle);
    font-size:11px;
    font-weight:800;
    letter-spacing:.04em;
    text-transform:uppercase;
  }
  table.user-table :is(input,select){min-width:0;}
  .user-limit{min-width:0;}
  .user-actions{min-width:0;}
}

@media(max-width:720px){
  #screen-login.active{padding:20px 12px;}
  .login-brand h1{font-size:25px;}
  .login-brand .page-description{margin-left:0; margin-top:10px;}
  .brand-lockup{align-items:flex-start;}
  #screen-setup .section-heading-row{display:block;}
  #screen-setup .section-heading-row p{margin-top:8px;}
  :is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) .card{padding:16px;}
  .app-topbar-actions{width:100%; display:grid; grid-template-columns:1fr 1fr;}
  .app-topbar-actions .user-chip{grid-column:1 / -1;}
  #screen-setup .scenario-grid{grid-template-columns:1fr;}
  #screen-dynamics .dynamics-filters{grid-template-columns:1fr;}
  #screen-setup .scenario{min-height:135px; padding:15px;}
  .history-toolbar{grid-template-columns:1fr;}
  .dyn-user-filter{grid-column:auto;}
  .dynamics-chart-heading{align-items:flex-start; flex-direction:column;}
  .segmented-control{width:100%;}
  .segmented-control button{flex:1;}
  .case-main-fields{grid-template-columns:88px minmax(0,1fr);}
  .brief-content{grid-template-columns:1fr;}
  .report-actions{grid-template-columns:1fr;}
  #screen-report .crit{grid-template-columns:1fr 1fr 40px;}
  #screen-report .crit .name{grid-column:1 / -1;}
  #screen-report .dyn-row{flex-wrap:wrap;}
  #screen-report .dyn-row .name{flex:1 0 100%; width:auto;}
  .ad-nav{position:static;}
  .scenario-editor-nav,.settings-nav{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    overflow:visible;
  }
  .scenario-editor-nav a,.settings-nav a{white-space:normal;}
  .admin-page-title{display:block;}
  .scenario-admin-item{grid-template-columns:1fr;}
  .scenario-admin-actions{justify-content:flex-start;}
  .scenario-admin-actions .btn-ghost{flex:1 1 120px;}
  .scenario-editor-actions{grid-template-columns:1fr;}
  .history-command-actions,.history-export-bar,.danger-actions{display:grid; grid-template-columns:1fr;}
  .history-command-actions .btn-ghost,.history-export-bar .btn-ghost,.danger-actions .btn-ghost{width:100%;}
  .dynamics-session summary::after,.history-entry>summary::after{grid-column:1 / -1;}
  .history-entry>summary{grid-template-columns:1fr auto;}
  .history-entry>summary::after{grid-column:1 / -1;}
  .launcher{padding:14px;}
  .launcher .card{padding:24px 20px;}
}

@media(prefers-reduced-motion:reduce){
  :is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin),
  :is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) *,
  :is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin)::before,
  :is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin)::after,
  :is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) *::before,
  :is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) *::after,
  .confirm-overlay,.confirm-overlay *,.launcher,.launcher *{
    animation-duration:.01ms !important;
    animation-iteration-count:1 !important;
    scroll-behavior:auto !important;
    transition-duration:.01ms !important;
  }
}

@media(forced-colors:active){
  :is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) :is(.card,.scenario,.btn-ghost,input,textarea,select),
  .ad-nav,.history-entry,.dynamics-session{border:1px solid CanvasText;}
  :is(#screen-login,#screen-setup,#screen-dynamics,#screen-brief,#screen-report,#screen-admin) .btn-primary,
  .launcher .btn{forced-color-adjust:auto;}
}
