/* Оформление кабинета account.kopsov.pro — язык «Прибор» экосистемы Kopsov PRO, как в кабинете Академии.
   tokens.css и fonts.css — копии из KPT Academy web (web/src); правила ниже до блока «Кабинет KPC» — её же
   (web/src/styles.css): колонка разделов, полоса системы, панели, кнопки, пилюли, поля, вход. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg-ground); color: var(--text-primary);
  font-family: var(--font-text); font-size: var(--size-body); line-height: var(--line-body);
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: var(--tracking-heading); text-wrap: balance; margin: 0; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.label {
  font-size: var(--size-label); font-weight: 500; letter-spacing: var(--tracking-label);
  text-transform: uppercase; color: var(--text-muted);
}
::selection { background: var(--accent-soft); }
:focus-visible { outline: var(--focus-w) solid var(--accent); outline-offset: 2px; }

/* ── Кнопки: янтарь — только для главного действия, остальное тихое ── */
@property --ring-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes ring-spin { to { --ring-angle: 360deg; } }
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 38px; padding: 0 var(--space-4); font: inherit; font-size: var(--size-value); font-weight: 500;
  color: var(--text-on-accent); border: 0; border-radius: var(--radius-control); cursor: pointer; white-space: nowrap;
  background: linear-gradient(180deg, var(--accent-light), var(--accent) 55%, var(--accent-dark));
  box-shadow: var(--shadow-button); transition: filter var(--motion-duration) var(--motion-easing), transform 120ms;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn::after {
  content: ""; position: absolute; inset: calc(-1 * var(--border-w)); border-radius: inherit;
  padding: var(--border-w); pointer-events: none; opacity: 0;
  transition: opacity var(--motion-duration) var(--motion-easing);
  background: conic-gradient(from var(--ring-angle),
    var(--ring-dim) 0%, var(--accent) 27%, var(--ring-spark) 30%, var(--accent) 33%,
    var(--ring-dim) 40%, var(--ring-dim) 50%,
    var(--accent) 77%, var(--ring-spark) 80%, var(--accent) 83%, var(--ring-dim) 90%);
  -webkit-mask: linear-gradient(black 0 0) content-box, linear-gradient(black 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(black 0 0) content-box, linear-gradient(black 0 0);
  mask-composite: exclude;
  animation: ring-spin var(--ring-duration) linear infinite;
}
.btn:hover::after { opacity: 1; }
.btn[disabled] { opacity: 0.45; cursor: default; box-shadow: none; filter: none; }
.btn[disabled]::after { content: none; }
.btn.quiet {
  background: var(--quiet-fill); color: var(--text-primary); border: var(--border-w) solid var(--border-default); box-shadow: none;
  transition: border-color var(--motion-duration), background var(--motion-duration), color var(--motion-duration);
}
.btn.quiet:hover { border-color: var(--accent-line); background: var(--bg-raised); color: var(--accent-light); filter: none; }
.btn.danger { background: var(--loss-soft); color: var(--loss); border: var(--border-w) solid var(--loss-line); box-shadow: none; }
.btn.danger:hover { background: rgba(237, 80, 85, 0.2); filter: none; }
.btn.sm { min-height: var(--control-h); padding: 0 var(--space-3); font-size: var(--size-small); }
.btn.icon { width: var(--control-h); min-height: var(--control-h); padding: 0; }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Поля ── */
.field { display: flex; flex-direction: column; gap: var(--space-1-5); }
.field > span { font-size: var(--size-caption); color: var(--text-secondary); }
input, select, textarea {
  width: 100%; padding: 9px 12px; font: inherit; font-size: var(--size-value); color: var(--text-primary);
  background: var(--bg-ground); border: var(--border-w) solid var(--border-default); border-radius: var(--radius-control);
  transition: border-color var(--motion-duration);
}
textarea { resize: vertical; min-height: 96px; line-height: var(--line-note); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
input[type="file"] { padding: 8px; }

/* ── Пилюли состояния: точка и слово вместе ── */
.pill {
  display: inline-flex; align-items: center; gap: var(--space-1-5); padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: var(--size-caption); font-weight: 500; white-space: nowrap; background: var(--neutral-soft); color: var(--text-primary);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--neutral); }
.pill.ok { background: var(--profit-soft); } .pill.ok::before { background: var(--profit); }
.pill.err { background: var(--loss-soft); } .pill.err::before { background: var(--loss); }
.pill.warn { background: var(--warning-soft); } .pill.warn::before { background: var(--warning); }
.pill.sys { background: var(--system-soft); } .pill.sys::before { background: var(--system); animation: blink 1.4s ease-in-out infinite; }
.pill.lock { background: transparent; border: var(--border-w) solid var(--border-default); color: var(--text-secondary); }
.pill.lock::before { content: none; }
@keyframes blink { 50% { opacity: 0.3; } }

/* ── Каркас: колонка разделов слева, полоса системы сверху ── */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; z-index: 30; overflow-y: auto; scrollbar-width: none;
  display: flex; flex-direction: column; gap: var(--space-1-5);
  padding: var(--space-4) var(--space-3) var(--space-3-5);
  background: var(--bg-ground); border-right: var(--border-w) solid var(--border-subtle);
}
.brand { display: flex; align-items: center; gap: var(--space-3); margin: 0 0 var(--space-4); padding: var(--space-1) var(--space-2); }
.brand img { width: var(--brand-mark); height: var(--brand-mark); flex: none; }
.brand-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-name b { font-family: var(--font-display); font-size: var(--size-body); font-weight: 600; letter-spacing: var(--tracking-heading); white-space: nowrap; }
.brand-name small { font-family: var(--font-mono); font-size: var(--size-axis); font-weight: 500; letter-spacing: var(--tracking-code); color: var(--text-muted); white-space: nowrap; }
.nav-group { margin: var(--space-3) var(--space-3) var(--space-1); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  position: relative; height: var(--nav-item-h); padding: 0 var(--space-3); display: flex; align-items: center; gap: var(--space-3);
  color: var(--text-secondary); border-radius: var(--radius-control); font-size: var(--size-small); font-weight: 500;
  transition: color var(--motion-duration), background var(--motion-duration);
}
.nav a:hover { color: var(--text-primary); background: var(--quiet-fill); }
.nav a.on { color: var(--text-primary); background: var(--rail-fill); box-shadow: inset 0 0 0 var(--border-w) var(--border-subtle); }
.nav a.on::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: var(--candle-w);
  border-radius: var(--radius-pill); background: var(--candle); box-shadow: var(--candle-glow);
  animation: candle-in var(--motion-spring) var(--ease-spring) both;
}
@keyframes candle-in { from { transform: scaleY(0.2); opacity: 0; } }
.nav svg, .tabbar svg {
  width: var(--nav-icon); height: var(--nav-icon); flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--motion-spring) var(--ease-spring);
}
.nav a:hover svg { transform: translateX(1px) scale(1.06); }
.rail-foot { margin-top: auto; padding-top: var(--space-3); }
.who {
  display: flex; align-items: center; gap: var(--space-2-5); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-2-5);
  border: var(--border-w) solid var(--border-subtle); border-radius: var(--radius-card);
}
.avatar {
  width: var(--control-h); height: var(--control-h); flex: none; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: var(--size-label); font-weight: 600;
  background: var(--bg-raised); border: var(--border-w) solid var(--border-default);
}
.who-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.who-text b, .who-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text b { font-size: var(--size-small); font-weight: 500; }
.who-text small { font-size: var(--size-label); color: var(--text-muted); }
.who button { background: transparent; border: 0; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 6px; display: grid; }
.who button:hover { color: var(--accent-light); background: var(--quiet-fill); }
.who button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.field-area { position: relative; min-width: 0; background: var(--bg-base); isolation: isolate; }
.field-area::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 320px; z-index: -1; pointer-events: none;
  background: radial-gradient(80% 100% at 50% 0%, rgba(143, 194, 255, 0.05), transparent 70%);
}
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--space-4);
  min-height: 60px; padding: var(--space-3) var(--space-8);
  background: rgba(11, 13, 16, 0.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: var(--border-w) solid var(--border-subtle);
}
.topbar::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 1px; width: 30%;
  background: linear-gradient(90deg, transparent, var(--system), transparent); opacity: 0;
}
.topbar.pulse::after { animation: run-light 900ms ease-out; }
@keyframes run-light { 0% { transform: translateX(-30%); opacity: 1; } 100% { transform: translateX(330%); opacity: 0; } }
.topbar h1 { font-size: var(--size-heading); }
.topbar .sub { font-size: var(--size-caption); color: var(--text-muted); }
.topbar .spacer { flex: 1; }
.page { max-width: var(--content-max); margin: 0 auto; padding: var(--space-8) var(--space-8) 80px; }
.page.wide { max-width: 1440px; }
.enter > * { animation: rise var(--motion-spring) var(--ease-spring) both; }
.enter > *:nth-child(2) { animation-delay: 50ms; } .enter > *:nth-child(3) { animation-delay: 100ms; }
.enter > *:nth-child(4) { animation-delay: 150ms; } .enter > *:nth-child(n+5) { animation-delay: 200ms; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* Телефон: шапка со знаком и нижняя полоса разделов. */
.mob-head, .tabbar { display: none; }

/* ── Панели и карточки ── */
.panel {
  position: relative; background: var(--panel-sheen), var(--bg-surface);
  border: var(--border-w) solid var(--border-card); border-radius: var(--radius-panel); box-shadow: var(--panel-depth);
}
.panel.pad { padding: var(--space-6); }
.section { margin-top: var(--space-10); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.section-head h2 { font-size: var(--size-title); }
.greeting h1 { font-size: var(--size-big); font-weight: 500; }
.greeting p { margin-top: var(--space-2); color: var(--text-secondary); }

.bar { display: flex; align-items: center; gap: var(--space-3); }
.bar-track { flex: 1; height: 6px; border-radius: var(--radius-pill); background: var(--bg-raised); overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2BB673, var(--profit));
  transform-origin: left; animation: grow 900ms var(--ease-spring) both; box-shadow: 0 0 10px rgba(61, 214, 140, 0.35);
}
.bar-fill.sys { background: var(--system); box-shadow: 0 0 10px rgba(143, 194, 255, 0.35); }
@keyframes grow { from { transform: scaleX(0); } }
.bar-num { font-family: var(--font-mono); font-size: var(--size-caption); color: var(--text-secondary); min-width: 38px; text-align: right; }

.empty { padding: var(--space-10) var(--space-6); text-align: center; color: var(--text-secondary); }
.empty h3 { color: var(--text-primary); font-size: var(--size-heading); margin-bottom: var(--space-2); }

/* Скелет загрузки */
.skel { background: linear-gradient(90deg, var(--bg-surface) 0%, var(--bg-raised) 50%, var(--bg-surface) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: var(--radius-card); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Вход ── */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg-base); }
.auth-stage { position: relative; display: flex; flex-direction: column; justify-content: center; padding: 64px; overflow: hidden; background: var(--bg-ground); border-right: var(--border-w) solid var(--border-subtle); }
.auth-stage::before { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 50% at 30% 40%, rgba(255, 122, 24, 0.10), transparent 70%), radial-gradient(50% 50% at 80% 90%, rgba(143, 194, 255, 0.07), transparent 70%); }
.auth-stage > * { position: relative; }
.auth-stage img { width: 120px; height: 120px; margin-bottom: var(--space-8); filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.6)); }
.auth-stage h1 { font-size: 44px; font-weight: 500; line-height: 1.08; letter-spacing: -0.03em; }
.auth-stage h1 em { font-style: normal; color: var(--accent); }
.auth-stage p { margin-top: var(--space-4); color: var(--text-secondary); max-width: 46ch; }
.auth-stage .tags { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-6); }
.auth-form-wrap { display: grid; place-items: center; padding: var(--space-8); }
.auth-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: var(--space-4); }
.auth-form h2 { font-size: var(--size-title); }
.auth-form .switch { font-size: var(--size-small); color: var(--text-secondary); text-align: center; }
.auth-form .switch a { color: var(--accent-light); }
.auth-place { margin-top: var(--space-2); font-size: var(--size-small); color: var(--text-secondary); }
.auth-other { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); margin-top: var(--space-2); padding-top: var(--space-5); border-top: var(--border-w) solid var(--border-subtle); font-size: var(--size-small); color: var(--text-secondary); }
.error { color: var(--loss); font-size: var(--size-small); background: var(--loss-soft); border: var(--border-w) solid var(--loss-line); padding: 8px 12px; border-radius: var(--radius-control); }
.notice { color: var(--text-primary); font-size: var(--size-small); background: var(--warning-tile-fill); border: var(--border-w) solid var(--warning-tile-line); padding: 10px 14px; border-radius: var(--radius-control); }

/* ── Таблицы и раскладка ── */
.table { width: 100%; border-collapse: collapse; font-size: var(--size-small); }
.table th { text-align: left; font-weight: 500; font-size: var(--size-label); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-muted); padding: 12px var(--space-4); border-bottom: var(--border-w) solid var(--border-subtle); }
.table td { padding: 12px var(--space-4); border-bottom: var(--border-w) solid var(--border-subtle); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--bg-raised); }
.table-wrap { overflow-x: auto; }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row .spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.form-grid .full { grid-column: 1 / -1; }

/* ── Кабинет KPC: свои мелочи поверх правил Академии, только на её токенах ── */
.stack > .panel { margin: 0; }
.panel > h2 { font-size: var(--size-sheet-title); line-height: var(--line-sheet-title); margin-bottom: var(--space-4); }
.panel > h2 .muted { font-weight: 500; }
.panel p + p, .panel p + .usage, .usage + .usage { margin-top: var(--space-3); }
.panel > .btn { margin-top: var(--space-4); }
.hint { margin-top: var(--space-4); color: var(--text-muted); font-size: var(--size-small); line-height: var(--line-note); }
.hint b { color: var(--text-primary); font-weight: 600; }
.rows { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-2-5) var(--space-6); margin: 0; font-size: var(--size-value); align-items: center; }
.rows dt { color: var(--text-muted); font-size: var(--size-small); }
.rows dd { margin: 0; display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); min-width: 0; overflow-wrap: anywhere; }
.panel.pad .table th:first-child, .panel.pad .table td:first-child { padding-left: 0; }
.panel.pad .table th:last-child, .panel.pad .table td:last-child { padding-right: 0; }
.table td .btn + .btn { margin-left: var(--space-1); }
.table td .pill + .pill { margin-left: var(--space-1); }
.usage .bar { margin-top: var(--space-2); max-width: 520px; }
.form { display: flex; flex-direction: column; gap: var(--space-4); max-width: 380px; }
.form.inline { flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--space-2); max-width: none; }
.form.inline input, .form.inline select { width: auto; flex: 1 1 160px; min-height: 38px; }
.form.inline .btn.sm { min-height: 38px; }
.msg { font-size: var(--size-small); }
.msg:empty { display: none; }
.msg.err { color: var(--loss); background: var(--loss-soft); border: var(--border-w) solid var(--loss-line); padding: 8px 12px; border-radius: var(--radius-control); }
.msg.ok { color: var(--text-primary); background: var(--profit-soft); border: var(--border-w) solid var(--profit-line); padding: 8px 12px; border-radius: var(--radius-control); overflow-wrap: anywhere; }
.ver { padding: var(--space-4) 0; border-top: var(--border-w) solid var(--border-subtle); }
.ver:first-of-type { padding-top: 0; border-top: 0; }
.ver h3 { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); font-family: var(--font-mono); font-size: var(--size-value); font-weight: 600; letter-spacing: 0; }
.ver pre { margin: var(--space-2) 0 0; white-space: pre-wrap; font: inherit; font-size: var(--size-small); line-height: var(--line-note); color: var(--text-secondary); }
.mob-title { display: none; }
.who-text small { font-family: var(--font-mono); }

/* ── Пороги, как в Академии: 1100 — колонка значками, 900 — один столбец, 720 — телефон ── */
@media (max-width: 1100px) {
  .app { grid-template-columns: var(--rail-w-compact) minmax(0, 1fr); }
  .brand-name, .nav a span, .nav-group, .who-text { display: none; }
  .nav a { justify-content: center; padding: 0; }
  .brand { justify-content: center; padding: var(--space-1) 0; }
  .who { justify-content: center; flex-direction: column; padding: var(--space-2); }
}
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .app { display: block; }
  .rail { display: none; }
  .mob-head { display: flex; align-items: center; gap: var(--space-3); position: sticky; top: 0; z-index: 25; padding: 10px 16px; background: var(--mob-bar-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: var(--border-w) solid var(--border-subtle); }
  .mob-head img { width: 28px; height: 28px; }
  .mob-head b { font-family: var(--font-display); font-size: var(--size-value); font-weight: 600; flex: 1; }
  .mob-head button { background: transparent; border: 0; color: var(--text-muted); padding: 6px; display: grid; }
  .mob-head button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .topbar { display: none; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--mob-bar-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: var(--border-w) solid var(--border-subtle); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: var(--size-axis); color: var(--text-muted); border-radius: 10px; }
  .tabbar a.on { color: var(--accent-light); background: var(--tab-on-fill); }
  .page { padding: var(--space-5) 16px 96px; }
  .auth { grid-template-columns: 1fr; }
  .auth-stage { padding: 32px 20px 28px; border-right: 0; border-bottom: var(--border-w) solid var(--border-subtle); }
  .auth-stage img { width: 64px; height: 64px; margin-bottom: var(--space-4); }
  .auth-stage h1 { font-size: 28px; }
  .auth-stage .tags, .auth-stage p { display: none; }
  .auth-form-wrap { padding: 24px 16px; place-items: start center; }
  /* KPC: разделов больше, чем у Академии, — полоса едет вбок, а не сжимает подписи */
  .tabbar { gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .tabbar::-webkit-scrollbar { display: none; }
  .tabbar a { flex: 1 0 68px; }
  .tabbar span { white-space: nowrap; }
  .mob-title { display: block; font-size: var(--size-mob-title); line-height: var(--line-mob-title); margin-bottom: var(--space-4); }
  .panel.pad { padding: var(--space-5) var(--space-4); border-radius: var(--mob-card-radius); }
  .rows { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
  .rows dd + dt { margin-top: var(--space-2); }
  .form { max-width: none; }
  .field-area { min-height: 100vh; }
  .table th, .table td { white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
}
