* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--canvas); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.error { color: var(--critical); background: rgba(239, 107, 117, .08); border: 1px solid rgba(239, 107, 117, .25); padding: 10px 12px; border-radius: 12px; font-size: 14px; margin: 0 0 16px; }
.pill { background: var(--raised); color: var(--live); padding: 6px 12px; border-radius: 999px; font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Вход */
body.auth { display: grid; place-items: center; min-height: 100vh; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px; width: 360px;
  box-shadow: 0 0 0 1px rgba(103, 136, 243, .08), 0 0 40px -12px rgba(103, 136, 243, .35); }
.auth-card .brand { margin: 0 0 20px; font-size: 18px; letter-spacing: .14em; font-weight: 700; }
.auth-card label { display: block; margin-bottom: 16px; color: var(--muted); font-size: 14px; }
.auth-card input { width: 100%; margin-top: 8px; height: 44px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--raised); color: var(--text); padding: 0 14px; font-size: 15px; }
button.primary { width: 100%; height: 44px; border: 0; border-radius: 14px; background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer; font-family: var(--font); }

/* Оболочка */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--border); padding: 24px 16px; display: flex; flex-direction: column; gap: 6px; }
.sidebar .brand { font-size: 16px; letter-spacing: .14em; font-weight: 700; padding: 6px 10px; margin-bottom: 14px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: block; padding: 12px 14px; border-radius: 12px; color: var(--muted); font-size: 14.5px; font-weight: 500; }
.nav-item:hover { background: rgba(255, 255, 255, .03); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px rgba(103, 136, 243, .28); }
.nav-item.disabled { opacity: .4; pointer-events: none; }
.sidebar .logout { margin-top: auto; }
.sidebar .logout button { width: 100%; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); cursor: pointer; font-family: var(--font); font-size: 14px; }
.sidebar .logout button:hover { color: var(--text); border-color: var(--border-strong); }
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 80px; display: flex; align-items: center; justify-content: space-between; padding: 0 34px; border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 23px; margin: 0; font-weight: 700; }
.content { padding: 32px 34px; display: grid; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 24px; }
.panel h2 { margin: 0 0 8px; font-size: 16px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 767px) { .shell { grid-template-columns: 1fr; } .sidebar { display: none; } }

.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.form-row input { height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--raised); color: var(--text); padding: 0 12px; font-size: 14px; font-family: var(--font); }
.form-row input[type=number] { width: 90px; }
button.compact { width: auto; padding: 0 18px; height: 42px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.data td { padding: 12px 10px; border-bottom: 1px solid var(--border); }
table.data tr:last-child td { border-bottom: 0; }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 8px; }
.btn-sm { height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; font-family: var(--font); }
.btn-sm:hover { color: var(--text); border-color: var(--border-strong); }
.btn-sm.danger:hover { color: var(--critical); border-color: var(--critical); }
.token-box { background: var(--raised); border: 1px solid rgba(103,136,243,.3); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.token-box .url { font-family: var(--mono); font-size: 13px; color: var(--accent); word-break: break-all; }
.tag-sm { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--raised); color: var(--muted); }
.tag-sm.on { color: var(--live); }
.tag-sm.off { color: var(--faint); }
.tag-sm.exp { color: var(--warning); }
.form-row select { height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--raised); color: var(--text); padding: 0 12px; font-size: 14px; font-family: var(--font); }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
body.viewer { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.viewer-card { text-align: center; max-width: 640px; width: 100%; }
.viewer-card h1 { font-size: 26px; margin: 0 0 4px; }
.viewer-stage { margin-top: 24px; aspect-ratio: 16 / 9; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; display: grid; place-items: center; padding: 24px;
  box-shadow: 0 0 0 1px rgba(103,136,243,.06), 0 0 40px -14px rgba(103,136,243,.4); }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.meters { display: grid; gap: 14px; }
.meter-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-size: 13.5px; }
.meter-row .num { color: var(--text); font-weight: 600; }
.track { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.fill { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .3s ease; }
.fill.warn { background: var(--warning); }
@media (prefers-reduced-motion: reduce) { .fill { transition: none; } }
