/* ============================================================
   Modern UI (v4)
   Тёмная тема с фирменным неон-лаймом и электрик-блю акцентами.
   Переиспользуемая дизайн-система: токены → база → компоненты → страницы.
   ============================================================ */

/* ---------- 1. Design Tokens ---------- */
:root {
  color-scheme: dark;

  /* палитра (сохранена с прошлой версии — «blue-ink» dark + neon accents) */
  --color-pitch-black: #061018;
  --color-graphite: #0b1620;
  --color-deep-slate: #12202d;
  --color-charcoal-grey: #223446;
  --color-muted-ash: #31495f;
  --color-gunmetal: #42607b;
  --color-porcelain: #f3f7fb;
  --color-light-steel: #d7e3ef;
  --color-storm-cloud: #94a9bf;
  --color-fog-grey: #6f879d;

  /* акценты */
  --color-neon-lime: #d8ff62;
  --color-neon-lime-2: #badc49;
  --color-aether-blue: #79a8ff;
  --color-aether-blue-2: #5e80e6;
  --color-forest-green: #12a86b;
  --color-mint-glow: #5cf2b3;
  --color-warning-red: #ff6b6b;
  --color-amber: #ffd056;
  --color-violet: #b089ff;

  /* поверхности (с лёгким голубым подтоном для «глубины») */
  --surface-0: rgba(6, 12, 20, 0.92);
  --surface-1: rgba(12, 22, 34, 0.82);
  --surface-2: rgba(18, 30, 44, 0.86);
  --surface-3: rgba(24, 38, 54, 0.78);
  --surface-glass: rgba(10, 20, 30, 0.58);
  --border-soft: rgba(135, 164, 192, 0.12);
  --border-strong: rgba(135, 164, 192, 0.22);
  --border-focus: rgba(216, 255, 98, 0.56);

  /* тени */
  --shadow-sm: 0 8px 22px rgba(1, 10, 20, 0.22);
  --shadow-md: 0 16px 34px rgba(1, 10, 20, 0.28);
  --shadow-lg: 0 28px 60px rgba(1, 10, 20, 0.38);
  --shadow-inset-hi: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-subtle-2: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 0 0 1px var(--border-soft);
  --shadow-subtle-3: 0 14px 30px rgba(2, 12, 23, 0.22), 0 0 0 1px var(--border-soft);
  --shadow-subtle-6: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 0 0 1px rgba(255, 255, 255, 0.04), 0 20px 45px rgba(0, 0, 0, 0.25);
  --shadow-xl: 0 30px 70px rgba(1, 10, 20, 0.44);

  /* радиусы */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-2xl: 32px;

  /* типографика */
  --font-inter-variable: "Inter", "SF Pro Display", "Segoe UI Variable",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-berkeley-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace,
    SFMono-Regular, Menlo, Consolas, monospace;

  /* тайминги */
  --ease-out: cubic-bezier(0.2, 0.7, 0.25, 1);
  --t-fast: 0.14s;
  --t-med: 0.22s;
}

/* ---------- 2. Base / Reset ---------- */
* {
  box-sizing: border-box;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: rgba(135, 164, 192, 0.18);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(135, 164, 192, 0.3);
}
*::-webkit-scrollbar-track {
  background: transparent;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(1000px 500px at 0% -10%, rgba(121, 168, 255, 0.14), transparent 70%),
    radial-gradient(800px 400px at 100% 0%, rgba(216, 255, 98, 0.06), transparent 72%),
    linear-gradient(180deg, #06111c 0%, #08161f 60%, #071220 100%);
  background-attachment: fixed;
  color: var(--color-porcelain);
  font: 14px/1.55 var(--font-inter-variable);
  font-feature-settings: "ss01", "cv11", "cv02", "cv04";
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 20%, transparent 80%, rgba(0, 0, 0, 0.12)),
    repeating-linear-gradient(45deg, transparent 0 18px, rgba(135, 164, 192, 0.012) 18px 19px);
  z-index: 0;
}

a {
  color: inherit;
  transition: color var(--t-fast) var(--ease-out);
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

code,
pre,
kbd {
  font-family: var(--font-berkeley-mono);
}

::selection {
  background: rgba(216, 255, 98, 0.28);
  color: var(--color-porcelain);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  letter-spacing: -0.03em;
  line-height: 1.18;
}

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

.hidden {
  display: none !important;
}

.muted {
  color: var(--color-storm-cloud);
}

/* ---------- 3. App Shell ---------- */
.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
}

.nav-overlay {
  display: none;
}

/* ---------- 4. Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: linear-gradient(180deg, rgba(8, 16, 26, 0.92), rgba(6, 14, 22, 0.9));
  border-right: 1px solid var(--border-soft);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(18px);
  z-index: 30;
}

.sidebar-inner {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
}

.sidebar-brand {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 14px;
  border-bottom: 1px dashed var(--border-soft);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.4), transparent 60%),
    linear-gradient(140deg, var(--color-neon-lime), var(--color-neon-lime-2));
  color: #05121c;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow:
    0 12px 24px rgba(216, 255, 98, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.brand-block {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-title {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--color-fog-grey);
  letter-spacing: 0.03em;
}

.sidebar-close {
  display: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: rgba(8, 18, 28, 0.6);
  color: var(--color-light-steel);
  font-size: 14px;
  cursor: pointer;
}

.sidebar-scroll {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.nav-groups {
  display: grid;
  gap: 16px;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-group-label {
  margin: 0 0 4px;
  padding: 0 10px;
  color: var(--color-fog-grey);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: #c7d4e3;
  text-decoration: none;
  font-size: 14px;
  font-weight: 510;
  transition: background-color var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out),
    transform var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out);
}

.nav-item:hover {
  background: rgba(26, 41, 55, 0.75);
  border-color: var(--border-soft);
  color: var(--color-porcelain);
  transform: translateX(2px);
}

.nav-item.active {
  background: linear-gradient(120deg, rgba(216, 255, 98, 0.16), rgba(121, 168, 255, 0.12) 70%);
  border-color: rgba(216, 255, 98, 0.28);
  color: var(--color-porcelain);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 22px rgba(2, 12, 23, 0.22);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--color-neon-lime), var(--color-aether-blue));
}

.sidebar-actions {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

.sidebar-actions .button-link {
  width: 100%;
}

/* ---------- 5. Mobile Topbar & Menu Toggle ---------- */
.mobile-topbar {
  display: none;
}

.mobile-only {
  display: none;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: rgba(10, 20, 30, 0.8);
  color: var(--color-porcelain);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}

.menu-toggle:hover {
  background: rgba(18, 32, 46, 0.92);
  border-color: var(--border-strong);
}

.menu-toggle-icon {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 12px;
}
.menu-toggle-icon::before,
.menu-toggle-icon::after,
.menu-toggle-icon span {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.menu-toggle-icon::before { top: 0; }
.menu-toggle-icon::after { bottom: 0; }
.menu-toggle-icon { background: none; }
.menu-toggle-icon {
  box-shadow: inset 0 5px 0 currentColor;
}

.menu-toggle-label {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.mobile-topbar-title {
  display: grid;
  justify-items: center;
  line-height: 1.25;
  min-width: 0;
}
.mobile-topbar-title strong {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 48vw;
}
.mobile-topbar-title span {
  color: var(--color-storm-cloud);
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* ---------- 6. Page Area ---------- */
.page-shell {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page-main {
  padding: 34px 34px 48px;
}

.page-main-inner {
  max-width: 1480px;
  margin: 0 auto;
}

.page-titlebar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.page-titlebar h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3.4vw, 2.9rem);
  font-weight: 680;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.page-body {
  display: grid;
  gap: 20px;
}

.page-body > * + * {
  margin-top: 0;
}

.stack {
  display: grid;
  gap: 18px;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.layout-main,
.layout-side,
.field-grid,
.check-grid,
.action-grid,
.status-grid {
  display: grid;
  gap: 12px;
}

.field-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.check-grid,
.action-grid,
.status-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.page-body > .eyebrow:first-child {
  margin-top: -4px;
}

/* ---------- 7. Panels / Cards ---------- */
.panel {
  position: relative;
  padding: 20px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(18, 30, 44, 0.88), rgba(10, 20, 30, 0.86));
  box-shadow: var(--shadow-sm), var(--shadow-inset-hi);
  transition: transform var(--t-med) var(--ease-out),
    box-shadow var(--t-med) var(--ease-out),
    border-color var(--t-med) var(--ease-out);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 620;
  letter-spacing: -0.03em;
}

.panel h3 {
  font-size: 17px;
  font-weight: 600;
}

.panel p,
.panel li {
  line-height: 1.6;
}

.panel-copy {
  margin-bottom: 14px;
  display: grid;
  gap: 4px;
}

.panel-copy p:last-child {
  margin-bottom: 0;
}

.panel-copy > .muted,
.quick-link-card > p {
  display: none;
}

.subtle-panel {
  background: linear-gradient(180deg, rgba(14, 25, 37, 0.84), rgba(8, 17, 27, 0.84));
}

.danger-panel {
  background: linear-gradient(180deg, rgba(66, 20, 26, 0.55), rgba(22, 14, 18, 0.94));
  border-color: rgba(255, 107, 107, 0.28);
}

.danger-panel h2 {
  color: #ffd4d4;
}

.compact-panel {
  padding: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--color-aether-blue);
  font-size: 11px;
  font-weight: 680;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.field-hint,
.panel-note {
  margin: 6px 0 0;
  color: var(--color-fog-grey);
  font-size: 12px;
}

.option-card {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(9, 19, 29, 0.7);
  transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}

.option-card:hover {
  border-color: var(--border-strong);
  background: rgba(12, 24, 36, 0.82);
}

.option-card-label {
  display: block;
  color: var(--color-porcelain);
  font-weight: 600;
}

.option-card-note {
  display: block;
  margin-top: 4px;
  color: var(--color-fog-grey);
  font-size: 12px;
}

.compact-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.compact-list li {
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(7, 16, 24, 0.6);
}

.compact-list strong,
.status-card strong {
  display: block;
  color: var(--color-porcelain);
}

.status-card {
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(9, 19, 29, 0.7);
}

.status-card p {
  margin: 6px 0 0;
}

/* ---------- 8. Metrics ---------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.metric {
  position: relative;
  overflow: hidden;
  padding: 18px 18px 18px;
  min-height: 128px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(20, 32, 46, 0.95), rgba(10, 20, 30, 0.92));
  box-shadow: var(--shadow-sm), var(--shadow-inset-hi);
  transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}

.metric::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-neon-lime), var(--color-aether-blue) 58%, transparent 90%);
  opacity: 0.8;
}

.metric:hover,
.panel:hover,
.quick-link-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), var(--shadow-inset-hi);
  border-color: var(--border-strong);
}

.metric-label {
  display: block;
  color: var(--color-storm-cloud);
  font-size: 12px;
  font-weight: 550;
  letter-spacing: 0.02em;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--color-porcelain);
  font-variant-numeric: tabular-nums;
}

.metric-note {
  display: block;
  margin-top: 12px;
  color: var(--color-storm-cloud);
  font-size: 12px;
  line-height: 1.5;
}

.period-metric strong {
  font-size: clamp(1.05rem, 2.2vw, 1.5rem);
  line-height: 1.3;
}

/* ---------- 9. Quick link / operation cards ---------- */
.quick-link-card,
.operations-grid .quick-link-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  min-height: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(20, 32, 46, 0.92), rgba(9, 19, 29, 0.9));
  text-decoration: none;
  color: var(--color-porcelain);
  transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}

.quick-link-card strong {
  font-size: 17px;
  font-weight: 620;
  letter-spacing: -0.02em;
}

.quick-link-card:hover {
  border-color: rgba(216, 255, 98, 0.28);
}

/* ---------- 10. Tables ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-xl);
}

.table-wrap table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(16, 27, 40, 0.94), rgba(10, 20, 30, 0.92));
  box-shadow: var(--shadow-sm);
}

.table-wrap th,
.table-wrap td {
  padding: 13px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(135, 164, 192, 0.1);
}

.table-wrap th {
  color: var(--color-light-steel);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(20, 32, 46, 0.96);
  position: sticky;
  top: 0;
}

.table-wrap tr:last-child td {
  border-bottom: 0;
}

.table-wrap tbody tr {
  transition: background var(--t-fast) var(--ease-out);
}

.table-wrap tbody tr:hover td {
  background: rgba(121, 168, 255, 0.04);
}

.cell-text {
  display: inline-block;
  max-width: 100%;
  word-break: break-word;
}

.cell-details {
  max-width: 100%;
}

.cell-details summary {
  padding: 0;
  color: var(--color-light-steel);
}

.cell-details .cell-expand {
  padding-top: 8px;
  color: var(--color-porcelain);
  word-break: break-word;
}

.table-scope.is-compact .table-wrap th,
.table-scope.is-compact .table-wrap td {
  padding-top: 8px;
  padding-bottom: 8px;
}

/* ---------- 11. Forms / Inputs ---------- */
form.search,
.settings-grid {
  display: grid;
  gap: 12px;
}

form.search {
  grid-template-columns: minmax(0, 1.7fr) auto;
  align-items: stretch;
}

form[data-live-search] {
  grid-template-columns: 1fr;
}

.settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  color: var(--color-light-steel);
  font-size: 12px;
  font-weight: 550;
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(8, 18, 28, 0.76);
  color: var(--color-porcelain);
  box-shadow: var(--shadow-inset-hi);
  transition: border-color var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out),
    background-color var(--t-fast) var(--ease-out);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-fog-grey);
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--border-strong);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(216, 255, 98, 0.1), var(--shadow-inset-hi);
}

textarea {
  min-height: 132px;
  resize: vertical;
  line-height: 1.5;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--color-neon-lime);
  box-shadow: none;
}

input[type="file"] {
  padding: 10px 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  color: var(--color-light-steel);
}

.check.option-card {
  margin: 0;
}

/* ---------- 12. Buttons ---------- */
button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 11px 16px;
  border: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--color-neon-lime) 0%, var(--color-neon-lime-2) 100%);
  color: #05121c;
  font-weight: 640;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(2, 12, 23, 0.2), var(--shadow-inset-hi);
  transition: transform var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out),
    filter var(--t-fast) var(--ease-out),
    background var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out);
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: 0 16px 28px rgba(1, 10, 20, 0.26), var(--shadow-inset-hi);
}

button:active,
.button-link:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

button:focus-visible,
.button-link:focus-visible,
.nav-item:focus-visible,
.menu-toggle:focus-visible,
a:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 1px rgba(216, 255, 98, 0.55),
    0 0 0 4px rgba(216, 255, 98, 0.18),
    0 16px 28px rgba(1, 10, 20, 0.18);
}

.button-link.secondary,
button.secondary,
.toolbar button {
  background: rgba(15, 27, 40, 0.9);
  color: var(--color-light-steel);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-inset-hi);
}

.button-link.secondary:hover,
button.secondary:hover,
.toolbar button:hover {
  background: rgba(20, 34, 49, 0.96);
  border-color: var(--border-strong);
}

.button-link.danger,
button.danger {
  background: linear-gradient(180deg, rgba(255, 107, 107, 0.22), rgba(220, 63, 63, 0.2));
  color: #ffd4d4;
  border: 1px solid rgba(255, 107, 107, 0.32);
}

.button-link.danger:hover,
button.danger:hover {
  background: linear-gradient(180deg, rgba(255, 107, 107, 0.3), rgba(220, 63, 63, 0.26));
  border-color: rgba(255, 107, 107, 0.48);
}

.history-back-button {
  position: relative;
  width: 46px;
  min-width: 46px;
  min-height: 46px;
  padding: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(15, 27, 40, 0.86);
  color: var(--color-porcelain);
  box-shadow: var(--shadow-inset-hi);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}

.history-back-button:hover,
.history-back-button:focus-visible {
  background: rgba(20, 34, 49, 0.94);
  border-color: rgba(216, 255, 98, 0.28);
}

.history-back-chevron {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateX(2px) rotate(45deg);
}

/* groups of buttons */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions .button-link,
.actions button,
.actions form {
  flex: 1 1 220px;
}

.actions form {
  margin: 0;
}

.actions form button {
  width: 100%;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scope-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* sticky action bar at the bottom of forms */
.sticky-actions {
  position: sticky;
  bottom: 14px;
  z-index: 5;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  background: rgba(7, 16, 24, 0.82);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
}

.sticky-actions .button-link,
.sticky-actions button,
.sticky-actions form {
  margin: 0;
}

.form-actions {
  margin-top: 18px;
}

.mobile-action-bar {
  box-shadow: 0 18px 40px rgba(1, 10, 20, 0.28);
}

.segmented-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: rgba(7, 16, 24, 0.4);
}

.segmented-actions .button-link {
  flex: 1 1 150px;
}

.segmented-actions .button-link[aria-current="page"] {
  background: linear-gradient(180deg, var(--color-neon-lime), var(--color-neon-lime-2));
  color: #05121c;
}

/* ---------- 13. Notices / Errors ---------- */
.notice,
.error {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  box-shadow: 0 14px 28px rgba(1, 10, 20, 0.14);
  font-size: 14px;
}

.notice {
  background: linear-gradient(180deg, rgba(18, 168, 107, 0.22), rgba(9, 33, 24, 0.58));
  color: #bdf5d4;
  border-color: rgba(18, 168, 107, 0.38);
}

.notice::before {
  content: "✅ ";
}

.error {
  background: linear-gradient(180deg, rgba(255, 107, 107, 0.2), rgba(42, 16, 18, 0.7));
  color: #ffc5c5;
  border-color: rgba(255, 107, 107, 0.38);
}

.error::before {
  content: "⚠️ ";
}

.notice:empty,
.error:empty {
  display: none;
}

/* ---------- 14. Status pills ---------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-pill.ok,
.status-pill.success {
  background: rgba(18, 168, 107, 0.18);
  color: #a6edc2;
  border-color: rgba(18, 168, 107, 0.38);
}

.status-pill.warn,
.status-pill.warning {
  background: rgba(228, 242, 34, 0.14);
  color: #ecf38f;
  border-color: rgba(228, 242, 34, 0.32);
}

.status-pill.bad,
.status-pill.danger {
  background: rgba(255, 107, 107, 0.14);
  color: #ffb1b1;
  border-color: rgba(255, 107, 107, 0.4);
}

.status-pill.neutral,
.status-pill.info {
  background: rgba(121, 168, 255, 0.14);
  color: #c7d8f5;
  border-color: rgba(121, 168, 255, 0.34);
}

.status-pill.muted {
  background: rgba(135, 164, 192, 0.1);
  color: var(--color-storm-cloud);
  border-color: var(--border-soft);
}

.meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-pills span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(7, 16, 24, 0.5);
  color: var(--color-light-steel);
  font-size: 13px;
}

/* ---------- 15. Logs / Pre ---------- */
pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(7, 16, 24, 0.7);
  box-shadow: var(--shadow-inset-hi);
  font-size: 12.5px;
  line-height: 1.6;
  color: #d7e3ef;
}

.log-output {
  max-height: 560px;
  min-height: 280px;
}

.log-output.is-expanded {
  max-height: none;
}

.log-output.is-compact {
  font-size: 12px;
  line-height: 1.35;
}

.diagnostic-panel {
  gap: 18px;
}

.diagnostic-panel .log-output {
  background: rgba(7, 16, 24, 0.76);
}

/* ---------- 16. Details ---------- */
details {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(8, 18, 28, 0.56);
}

summary {
  cursor: pointer;
  padding: 11px 14px;
  color: var(--color-light-steel);
  font-weight: 550;
}

details[open] summary {
  border-bottom: 1px solid var(--border-soft);
}

details pre {
  border: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: none;
}

/* ---------- 17. Preview helpers ---------- */
.preview-stack {
  display: grid;
  gap: 12px;
}

.preview-box {
  margin-top: 12px;
}

.preview-box img,
.preview-box video,
.template-example {
  display: block;
  max-width: min(460px, 100%);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--color-pitch-black);
}

.template-example {
  max-width: 160px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(121, 168, 255, 0.12);
  border: 1px solid rgba(121, 168, 255, 0.24);
  color: #c7d8f5;
  font-size: 12px;
}

/* ---------- 18. User cards / lists ---------- */
.user-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 16px;
}

.user-list-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(20, 32, 46, 0.96), rgba(9, 19, 29, 0.92));
  box-shadow: var(--shadow-sm), var(--shadow-inset-hi);
  transition: transform var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
}

.user-list-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.user-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.user-card-id {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(121, 168, 255, 0.12);
  border: 1px solid rgba(121, 168, 255, 0.26);
  color: #c7d8f5;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.user-list-card h3 {
  margin: 6px 0 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.user-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.user-card-meta span,
.user-hero-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(7, 16, 24, 0.5);
  color: var(--color-light-steel);
  font-size: 13px;
}

.user-mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.user-mini-stat {
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(7, 16, 24, 0.6);
  text-align: left;
}

.user-mini-stat span {
  display: block;
  color: var(--color-storm-cloud);
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.user-mini-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.user-hero {
  display: grid;
  gap: 20px;
  padding: 26px;
  border-radius: var(--radius-2xl);
  background:
    radial-gradient(circle at 85% -10%, rgba(121, 168, 255, 0.18), transparent 40%),
    radial-gradient(circle at -5% 110%, rgba(216, 255, 98, 0.1), transparent 45%),
    linear-gradient(180deg, rgba(19, 32, 45, 0.96), rgba(9, 18, 28, 0.94));
}

.user-hero-main {
  display: grid;
  gap: 10px;
}

.user-hero-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.user-hero h2 {
  font-size: clamp(1.9rem, 3vw, 2.6rem);
  letter-spacing: -0.04em;
}

.user-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.user-hero-actions {
  align-items: stretch;
}

.user-profile-panel {
  gap: 20px;
}

.user-profile-details,
.user-profile-actions {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.inline-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.inline-action-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: rgba(7, 16, 24, 0.54);
}

.user-summary-list li {
  min-height: 84px;
}

.user-inline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.user-inline-head strong {
  font-size: 22px;
  letter-spacing: -0.03em;
}

/* ---------- 19. Detail cards ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.detail-card {
  min-height: 100px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: rgba(7, 16, 24, 0.54);
}

.detail-label {
  display: block;
  color: var(--color-storm-cloud);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-card strong {
  display: block;
  margin-top: 10px;
  color: var(--color-porcelain);
  font-size: 16px;
  line-height: 1.45;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

/* ---------- 20. Entity cards (templates, broadcasts, channels) ---------- */
.entity-toolbar {
  margin-bottom: 16px;
}

.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.entity-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(20, 32, 46, 0.96), rgba(9, 19, 29, 0.92));
  box-shadow: var(--shadow-sm), var(--shadow-inset-hi);
  transition: transform var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}

.entity-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.entity-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.entity-card h3 {
  margin: 6px 0 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.entity-card-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.template-card {
  gap: 14px;
}

.template-overview-panel {
  gap: 16px;
}

.template-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.template-overview-copy {
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: rgba(7, 16, 24, 0.5);
}

.template-overview-copy p {
  margin: 10px 0 0;
}

.template-prompt-preview pre {
  min-height: 0;
  margin: 10px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.template-gallery {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.template-gallery .template-example {
  width: 100%;
  max-width: none;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.card-title-link {
  color: var(--color-porcelain);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease-out);
}

.card-title-link:hover {
  color: var(--color-neon-lime);
}

/* ---------- 21. Generation cards ---------- */
.generation-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.generation-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(20, 32, 46, 0.96), rgba(9, 19, 29, 0.92));
  box-shadow: var(--shadow-sm), var(--shadow-inset-hi);
}

.generation-card-error {
  border-color: rgba(255, 107, 107, 0.48);
  background:
    linear-gradient(180deg, rgba(66, 20, 26, 0.35), rgba(9, 19, 29, 0.92));
  box-shadow: inset 0 0 0 1px rgba(255, 107, 107, 0.18), var(--shadow-sm);
}

.generation-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.generation-card h3 {
  margin: 6px 0 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.generation-content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.generation-actions {
  align-items: stretch;
}

.generation-detail {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(7, 16, 24, 0.5);
}

.generation-detail summary {
  cursor: pointer;
  padding: 12px 14px;
  color: var(--color-light-steel);
}

.generation-detail-text {
  margin: 0;
  padding: 0 14px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--color-porcelain);
}

/* ---------- 22. Tokens grid ---------- */
.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.token-form {
  margin: 0;
}

.token-unit-panel {
  margin-bottom: 16px;
}

.token-card,
.compact-token-card {
  gap: 14px;
  padding: 18px;
}

.token-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.token-mode-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(7, 16, 24, 0.5);
}

.token-mode-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.token-mode-head strong {
  font-size: 14px;
}

.compact-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.compact-detail-card {
  padding: 12px;
  min-height: 0;
}

.token-save-button {
  justify-self: start;
  min-width: 136px;
}

.compact-field,
.compact-toggle {
  margin: 0;
}

.compact-toggle {
  align-items: center;
}

/* ---------- 23. Settings ---------- */
.settings-stack {
  gap: 14px;
}

.settings-boolean-grid,
.settings-secret-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* ---------- 24. Empty states ---------- */
.empty-state {
  min-height: 220px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 4px;
}

.empty-state h2 {
  margin-bottom: 6px;
}

/* ---------- 25. Pagination ---------- */
.pagination-bar {
  padding: 14px 16px;
}

.pagination-bar .actions {
  align-items: center;
  justify-content: space-between;
}

.pagination-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(7, 16, 24, 0.52);
  color: var(--color-light-steel);
  font-variant-numeric: tabular-nums;
}

/* ---------- 26. Process hero ---------- */
.process-hero {
  padding: 24px;
  border-radius: var(--radius-2xl);
  background:
    radial-gradient(circle at 90% 0%, rgba(121, 168, 255, 0.18), transparent 40%),
    radial-gradient(circle at 0% 100%, rgba(216, 255, 98, 0.09), transparent 45%),
    linear-gradient(180deg, rgba(19, 32, 45, 0.96), rgba(9, 18, 28, 0.92));
}

.process-hero-copy {
  margin-bottom: 18px;
}

.operations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.operations-grid .actions {
  margin-top: auto;
}

.process-detail-layout .detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stat-text {
  font-size: 16px !important;
  line-height: 1.5;
  letter-spacing: -0.01em !important;
}

.report-block {
  font-size: 15px;
  line-height: 1.75;
}

.report-block br + br {
  display: block;
  content: "";
  margin-top: 8px;
}

.html-preview,
.current_caption,
.current_text {
  padding: 14px;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(7, 16, 24, 0.4);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.text-settings-stack,
.text-settings-items {
  display: grid;
  gap: 16px;
}

.text-settings-section > summary,
.text-setting-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.text-settings-section > summary strong,
.text-setting-card > summary strong {
  display: block;
}

.text-setting-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: rgba(8, 17, 26, 0.52);
  box-shadow: var(--shadow-sm);
}

.text-setting-card > summary {
  padding: 18px 20px;
}

.text-setting-editor-shell {
  padding: 0 20px 20px;
}

.text-setting-summary-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
  min-width: 0;
}

.text-setting-summary-meta .muted {
  max-width: 520px;
  text-align: right;
}

.text-setting-key {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.text-setting-layout {
  align-items: start;
}

.text-setting-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.text-setting-preview-head h2 {
  margin: 0;
}

.text-setting-default-source {
  overflow: auto;
  margin: 12px 0 0;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(6, 14, 22, 0.82);
  border: 1px solid var(--border-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

.text-setting-service-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(7, 16, 24, 0.4);
}

.text-setting-reset-actions {
  margin-top: 12px;
}

.text-setting-runtime-note {
  margin-top: 12px;
}

.text-setting-runtime-note code {
  white-space: pre-wrap;
  word-break: break-word;
}

.text-settings-search-form {
  align-items: end;
}

.text-settings-search-field {
  min-width: 0;
}

.text-settings-search-actions {
  justify-content: flex-start;
}

.text-settings-total {
  margin: 16px 0 0;
}

.text-setting-telegram-preview {
  position: sticky;
  top: 16px;
}

/* ---------- 27. Telegram post preview ---------- */
.telegram-post-preview {
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(20, 32, 46, 0.92), rgba(9, 19, 29, 0.92));
}

.telegram-post-shell {
  display: grid;
  gap: 10px;
}

.telegram-post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.telegram-post-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(160deg, rgba(216, 255, 98, 0.28), rgba(121, 168, 255, 0.42));
  border: 1px solid rgba(216, 255, 98, 0.22);
}

.telegram-post-title {
  font-size: 14px;
  font-weight: 600;
}

.telegram-post-subtitle {
  color: var(--color-fog-grey);
  font-size: 12px;
}

.telegram-post-bubble {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 18px 18px 18px 6px;
  background: rgba(11, 22, 33, 0.95);
  box-shadow: var(--shadow-sm);
}

.telegram-post-media {
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: rgba(8, 18, 28, 0.64);
}

.telegram-post-media img,
.telegram-post-media video {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
}

.telegram-post-caption,
.telegram-post-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.telegram-post-caption blockquote,
.telegram-post-text blockquote {
  margin: 0;
  padding-left: 12px;
  border-left: 3px solid rgba(121, 168, 255, 0.55);
  color: var(--color-light-steel);
}

.telegram-post-file {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
}

.telegram-post-file strong {
  font-size: 14px;
}

.premium-emoji-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  margin: 0 2px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(216, 255, 98, 0.28);
  background: rgba(216, 255, 98, 0.12);
  color: #ecf38f;
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
  white-space: normal;
  flex-wrap: wrap;
}

.premium-emoji-chip::before {
  content: '✨';
  font-size: 12px;
}

.premium-emoji-chip code {
  font-size: 10px;
  color: #f6f8c1;
}

.premium-emoji-chip-fallback {
  font-size: 16px;
  line-height: 1;
}

.telegram-post-empty {
  color: var(--color-fog-grey);
}

/* ---------- 28. API check result ---------- */
.api-check-result {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(7, 16, 24, 0.5);
}

/* ---------- 29. Live feed on dashboard (dark theme) ---------- */
.live-panel {
  margin-top: 1rem;
  padding: 20px;
  border: 1px solid rgba(216, 255, 98, 0.24);
  background:
    linear-gradient(180deg, rgba(216, 255, 98, 0.06), transparent 60%),
    linear-gradient(180deg, rgba(20, 32, 46, 0.94), rgba(9, 19, 29, 0.92));
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.live-panel .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-neon-lime);
}

.live-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-mint-glow);
  box-shadow: 0 0 0 0 rgba(92, 242, 179, 0.55);
  animation: live-pulse 1.6s infinite;
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(92, 242, 179, 0.55);
    transform: scale(1);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(92, 242, 179, 0);
    transform: scale(1.08);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(92, 242, 179, 0);
    transform: scale(1);
  }
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.live-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(11, 22, 33, 0.88);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-med) var(--ease-out),
    box-shadow var(--t-med) var(--ease-out),
    border-color var(--t-med) var(--ease-out),
    opacity var(--t-med) var(--ease-out);
}

.live-card-fresh {
  animation: live-card-in 0.38s var(--ease-out) both;
}

.live-card-leaving {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.live-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.live-card[data-kind="error"] {
  border-left: 3px solid #ff6b6b;
}
.live-card[data-kind="edit"] {
  border-left: 3px solid var(--color-aether-blue);
}
.live-card[data-kind="generation"] {
  border-left: 3px solid var(--color-mint-glow);
}
.live-card[data-kind="template"] {
  border-left: 3px solid var(--color-violet);
}
.live-card[data-kind="chatgpt"] {
  border-left: 3px solid var(--color-amber);
}

.live-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.live-time {
  font-size: 0.78rem;
  color: var(--color-fog-grey);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.live-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.live-model {
  font-weight: 620;
  font-size: 0.95rem;
  color: var(--color-porcelain);
  word-break: break-all;
  letter-spacing: -0.01em;
}

.live-user-row {
  font-size: 0.9rem;
  color: var(--color-light-steel);
}

.live-user {
  color: var(--color-aether-blue);
  text-decoration: none;
  font-weight: 550;
}

.live-user:hover {
  text-decoration: underline;
}

.live-card-foot {
  display: flex;
  gap: 0.35rem;
  margin-top: auto;
  flex-wrap: wrap;
}

.live-tag {
  display: inline-block;
  font-size: 0.78rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(121, 168, 255, 0.14);
  color: #c7d8f5;
  border: 1px solid rgba(121, 168, 255, 0.24);
}

.live-feed-footer {
  margin-top: 0.85rem;
  font-size: 0.8rem;
  color: var(--color-fog-grey);
}

@keyframes live-card-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- 30. Mobile form intro (hide on desktop) ---------- */
.mobile-form-intro {
  display: none;
}

/* ---------- 31. Form busy state ---------- */
form.is-submitting {
  pointer-events: none;
}

form[aria-busy="true"] .mobile-action-bar,
form[aria-busy="true"] .sticky-actions {
  border-color: rgba(121, 168, 255, 0.28);
  box-shadow: 0 20px 44px rgba(1, 10, 20, 0.32);
}

form[aria-busy="true"] button[type="submit"] {
  opacity: 0.88;
}

form[aria-busy="true"] button[type="submit"]::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 32. Responsive — Tablet (≤920px) ---------- */
@media (max-width: 920px) {
  body {
    font-size: 13.5px;
  }

  body[data-nav-state="open"] {
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 14, 0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-med) var(--ease-out);
    z-index: 25;
  }

  body[data-nav-state="open"] .nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(82vw, 320px);
    max-width: 320px;
    padding: 18px 14px 20px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    transform: translateX(-100%);
    transition: transform var(--t-med) var(--ease-out);
    box-shadow: var(--shadow-xl);
  }

  body[data-nav-state="open"] .sidebar {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-actions {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 20;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(6, 14, 22, 0.86);
    border-bottom: 1px solid var(--border-soft);
    backdrop-filter: blur(16px);
  }

  .mobile-only {
    display: inline-flex;
  }

  .page-main {
    padding: 16px 14px 28px;
  }

  .page-titlebar {
    display: none;
  }

  .page-body {
    gap: 16px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .metric {
    min-height: 0;
    padding: 14px;
  }

  .metric strong {
    font-size: 22px;
  }

  .settings-grid,
  .layout-two,
  .field-grid,
  .check-grid,
  .action-grid,
  .status-grid,
  .quick-links-grid,
  .operations-grid,
  .entity-grid,
  .generation-list,
  .user-list,
  .template-overview-grid,
  .template-gallery,
  .compact-detail-grid,
  .generation-content-grid,
  .token-mode-grid,
  .inline-action-grid,
  .user-mini-stats,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .mobile-form-intro {
    display: block;
  }

  form.search {
    grid-template-columns: 1fr;
  }

  .actions,
  .toolbar,
  .scope-actions {
    flex-direction: column;
  }

  .actions .button-link,
  .actions button,
  .actions form,
  .scope-actions form,
  .toolbar button,
  button {
    width: 100%;
    flex-basis: 100%;
  }

  .actions,
  .toolbar,
  .scope-actions {
    width: 100%;
  }

  .segmented-actions {
    padding: 8px;
  }

  .user-card-heading,
  .entity-card-head,
  .entity-card-fields,
  .generation-card-head {
    display: grid;
  }

  .user-card-meta,
  .user-hero-meta,
  .user-hero-actions,
  .meta-pills,
  .generation-actions {
    flex-direction: column;
  }

  .user-card-meta span,
  .user-hero-meta span,
  .meta-pills span,
  .pagination-status {
    width: 100%;
  }

  .pagination-bar .actions {
    flex-direction: column;
  }

  .empty-state {
    min-height: 180px;
  }

  .diagnostic-panel .log-output {
    min-height: 220px;
  }

  .sticky-actions {
    bottom: 10px;
    padding: 10px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    border-radius: 18px;
  }

  .template-example {
    max-width: 100%;
  }

  /* Table → card layout on mobile */
  .table-wrap {
    overflow: visible;
  }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap th,
  .table-wrap td {
    display: block;
  }

  .table-wrap table {
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody {
    display: grid;
    gap: 12px;
  }

  .table-wrap tr {
    padding: 14px;
    background: linear-gradient(180deg, rgba(16, 27, 40, 0.96), rgba(10, 20, 30, 0.92));
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
  }

  .table-wrap td {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-soft);
    display: grid;
    grid-template-columns: minmax(96px, 112px) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
  }

  .table-wrap td::before {
    content: attr(data-label);
    color: var(--color-storm-cloud);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .table-wrap td:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .table-wrap td:first-child {
    padding-top: 0;
  }

  .check {
    align-items: flex-start;
  }

  .option-card {
    padding: 12px;
  }
}

/* ---------- 33. Small phones (≤480px) ---------- */
@media (max-width: 480px) {
  .page-main {
    padding: 14px 12px 24px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric strong {
    font-size: 24px;
  }

  .table-wrap td {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .mobile-topbar-title strong {
    font-size: 13px;
    max-width: 42vw;
  }
}

/* ---------- 34. Large screens (≥1280px) ---------- */
@media (min-width: 1280px) {
  body {
    font-size: 15px;
  }

  .page-main {
    padding: 40px 44px 52px;
  }

  .panel,
  .metric {
    padding: 22px;
  }

  .panel h2 {
    font-size: 22px;
  }

  .entity-grid,
  .user-list,
  .generation-list {
    gap: 18px;
  }
}

/* ---------- 35. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ============================================================
   Sales dashboard (v5)
   ============================================================ */
.sales-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
  padding: 24px;
  border-radius: var(--radius-2xl);
  background:
    radial-gradient(circle at 90% -10%, rgba(216, 255, 98, 0.16), transparent 40%),
    radial-gradient(circle at 0% 120%, rgba(121, 168, 255, 0.14), transparent 45%),
    linear-gradient(180deg, rgba(19, 32, 45, 0.96), rgba(9, 18, 28, 0.92));
}

.sales-hero-copy {
  display: grid;
  gap: 6px;
}

.sales-hero-copy h2 {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.sales-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.kpi-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(20, 32, 46, 0.94), rgba(9, 19, 29, 0.92));
  box-shadow: var(--shadow-sm), var(--shadow-inset-hi);
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-neon-lime), var(--color-aether-blue) 55%, transparent 92%);
  opacity: 0.7;
}

.kpi-icon {
  font-size: 18px;
  line-height: 1;
}

.kpi-label {
  color: var(--color-storm-cloud);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kpi-value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-porcelain);
  font-variant-numeric: tabular-nums;
}

.chart-card {
  padding: 20px;
}

.chart-card .section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.chart-card .section-head .eyebrow {
  margin: 0;
}

.chart-card .section-head h2 {
  margin: 0;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 320px;
  margin-top: 8px;
}

.chart-container-compact {
  height: 280px;
}

.sales-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.sales-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 8px;
}

.sales-table th,
.sales-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-soft);
}

.sales-table th {
  color: var(--color-light-steel);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(20, 32, 46, 0.6);
}

.sales-table tr:last-child td {
  border-bottom: 0;
}

.sales-table td {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 920px) {
  .sales-hero {
    grid-template-columns: 1fr;
    padding: 20px;
  }
  .sales-hero-actions {
    justify-content: stretch;
  }
  .sales-hero-actions .button-link {
    flex: 1 1 auto;
  }
  .sales-charts-row {
    grid-template-columns: 1fr;
  }
  .chart-container {
    height: 260px;
  }
  .chart-container-compact {
    height: 240px;
  }
  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sales-table thead {
    display: none;
  }
  .sales-table,
  .sales-table tbody,
  .sales-table tr,
  .sales-table td {
    display: block;
  }
  .sales-table tr {
    padding: 12px 14px;
    margin-bottom: 10px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: rgba(10, 20, 30, 0.6);
  }
  .sales-table td {
    padding: 6px 0;
    display: grid;
    grid-template-columns: minmax(110px, 140px) 1fr;
    gap: 12px;
    border-bottom: 1px dashed var(--border-soft);
  }
  .sales-table td::before {
    content: attr(data-label);
    color: var(--color-storm-cloud);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .sales-table tr td:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 480px) {
  .kpi-strip {
    grid-template-columns: 1fr;
  }
  .kpi-value {
    font-size: 20px;
  }
}


/* ============================================================
   v5 Density & Typography pass
   Tuning layer applied AFTER the base design system.
   Purpose: crisper typography, denser cards, tighter grid,
   more readable content. Variables stay the same; only sizes
   and spacing are tuned here.
   ============================================================ */

:root {
  /* Explicit spacing scale — use via var(--space-N) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  /* v5 typography scale */
  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-md: 14.5px;
  --fs-lg: 16px;
  --fs-h3: 17px;
  --fs-h2: 18px;
  --fs-h1: 24px;
  --fs-metric: 24px;
}

/* Base — larger default font with tighter tracking */
body {
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "ss01", "cv11", "cv02", "cv04", "tnum";
}

/* Headings — tighter, more modern scale */
.page-titlebar h1 {
  font-size: clamp(1.45rem, 2.5vw, 1.75rem);
  font-weight: 650;
  letter-spacing: -0.035em;
}

.panel h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-h2);
  font-weight: 620;
  letter-spacing: -0.025em;
}

.panel h3 {
  font-size: var(--fs-h3);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0 0 var(--space-2);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.11em;
}

/* Section heads — one-row header with eyebrow + h2 + optional actions */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.section-head .eyebrow {
  margin: 0;
}

.section-head h2 {
  margin: 0;
}

/* Density — panels */
.panel {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
}

.panel .panel-copy {
  margin-bottom: var(--space-3);
}

.panel .panel-copy h2 {
  margin-bottom: var(--space-1);
}

.panel .panel-copy p {
  margin: 0;
  color: var(--color-storm-cloud);
  font-size: 13.5px;
}

/* Metric cards — denser, tabular-nums */
.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-3);
}

.metric {
  padding: var(--space-4);
  min-height: 112px;
  border-radius: var(--radius-lg);
}

.metric-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-storm-cloud);
}

.metric strong {
  margin-top: var(--space-2);
  font-size: var(--fs-metric);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
}

.metric-note {
  margin-top: var(--space-2);
  font-size: 11.5px;
  line-height: 1.45;
}

.period-metric strong {
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.35;
}

/* Entity-like cards — uniform compact padding */
.entity-card,
.user-list-card,
.generation-card,
.token-card,
.compact-token-card {
  padding: var(--space-4);
  gap: var(--space-3);
  border-radius: var(--radius-lg);
}

.entity-card h3,
.user-list-card h3,
.generation-card h3 {
  margin: var(--space-1) 0 0;
  font-size: 18px;
  letter-spacing: -0.03em;
}

/* Detail cards — a bit smaller */
.detail-card {
  min-height: 88px;
  padding: var(--space-3);
  border-radius: var(--radius-md);
}

.detail-card strong {
  margin-top: var(--space-2);
  font-size: 15px;
  line-height: 1.4;
}

.detail-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

/* Option cards */
.option-card {
  padding: var(--space-3);
  border-radius: var(--radius-md);
}

/* Compact lists */
.compact-list li {
  padding: var(--space-3);
  border-radius: var(--radius-md);
}

/* Meta pills — slightly smaller */
.meta-pills span,
.user-card-meta span,
.user-hero-meta span {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}

/* Status pills — denser */
.status-pill {
  min-height: 26px;
  padding: 0 10px;
  font-size: 10.5px;
  letter-spacing: 0.05em;
}

/* Buttons — tune proportions */
button,
.button-link {
  min-height: 42px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-weight: 620;
  font-size: 14px;
  letter-spacing: -0.005em;
}

button.secondary,
.button-link.secondary,
.toolbar button {
  font-weight: 580;
}

.menu-toggle {
  padding: 9px 14px 9px 12px;
}

/* Inputs — slightly tighter */
input,
textarea,
select {
  min-height: 44px;
  padding: 11px 14px;
  font-size: 14.5px;
  border-radius: var(--radius-md);
}

textarea {
  min-height: 120px;
  line-height: 1.5;
}

/* Table density tweak */
.table-wrap th,
.table-wrap td {
  padding: 11px 13px;
  font-size: 14px;
}

.table-wrap th {
  font-size: 11.5px;
}

/* Sticky actions — a touch tighter */
.sticky-actions {
  padding: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-radius: var(--radius-lg);
}

/* Segmented period buttons on /sales */
.segmented-actions {
  padding: 8px;
  gap: 8px;
}

.segmented-actions .button-link {
  min-height: 38px;
  padding: 8px 14px;
  font-size: 13px;
  flex: 1 1 140px;
}

/* Page padding */
.page-main {
  padding: 28px 28px 40px;
}

@media (max-width: 1200px) {
  body { font-size: 14.5px; }
  .page-main { padding: 24px 22px 36px; }
}

@media (max-width: 920px) {
  body { font-size: 14px; line-height: 1.5; }
  .panel { padding: var(--space-4); }
  .entity-card,
  .user-list-card,
  .generation-card { padding: var(--space-3); }
  .metric { padding: var(--space-3); min-height: 0; }
  .metric strong { font-size: 20px; }
  .page-main { padding: 14px 12px 28px; }
  .segmented-actions .button-link { flex: 1 1 120px; font-size: 12.5px; }
}

@media (max-width: 480px) {
  body { font-size: 13.5px; }
  .panel h2 { font-size: 17px; }
  .metric strong { font-size: 19px; }
}

/* Dense list — row-based alternative to card grids (for /users master view) */
.dense-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dense-list-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(10, 20, 30, 0.55);
  text-decoration: none;
  color: var(--color-porcelain);
  transition: background var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    transform var(--t-fast) var(--ease-out);
}

.dense-list-item:hover {
  background: rgba(16, 28, 42, 0.74);
  border-color: var(--border-strong);
  transform: translateX(2px);
}

.dense-list-item strong {
  font-size: 14.5px;
  font-weight: 600;
}

.dense-list-item .muted {
  font-size: 12px;
}

/* Report block — moderate width so long lines stay readable */
.report-block {
  max-width: 820px;
  font-size: 14.5px;
  line-height: 1.75;
}

/* Nav items — tighter vertical rhythm */
.nav-item {
  padding: 9px 12px;
  font-size: 14px;
}

.nav-group {
  gap: 2px;
}

.nav-group-label {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  padding: 0 12px;
  margin-bottom: 2px;
}

/* Sidebar brand — smaller mark on tight screens */
.brand-mark {
  width: 38px;
  height: 38px;
  font-size: 13px;
  border-radius: 12px;
}

.brand-title {
  font-size: 16px;
}

.brand-subtitle {
  font-size: 11px;
}


/* ============================================================
   Dashboard (v5 redesign)
   ============================================================ */
.dash-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  padding: 22px 24px;
  border-radius: var(--radius-2xl);
  background:
    radial-gradient(circle at 92% -10%, rgba(216, 255, 98, 0.14), transparent 40%),
    radial-gradient(circle at -5% 110%, rgba(121, 168, 255, 0.12), transparent 45%),
    linear-gradient(180deg, rgba(19, 32, 45, 0.96), rgba(9, 18, 28, 0.92));
}

.dash-hero-main {
  display: grid;
  gap: 4px;
}

.dash-hero-main h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.035em;
}

.dash-hero-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 920px) {
  .dash-hero {
    padding: 18px;
    gap: 14px;
  }
  .dash-hero-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .dash-hero-kpis {
    grid-template-columns: 1fr;
  }
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: rgba(10, 20, 30, 0.55);
}

.status-strip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: rgba(14, 26, 40, 0.75);
  font-size: 13px;
}

.status-strip-item .muted {
  font-size: 12.5px;
}

.status-strip-item code {
  color: var(--color-light-steel);
  background: rgba(121, 168, 255, 0.1);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 12px;
}

/* Master/side layout on dashboard */
.dash-main {
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.95fr);
}

.dash-main .layout-side {
  display: grid;
  gap: 16px;
}

@media (max-width: 1100px) {
  .dash-main {
    grid-template-columns: 1fr;
  }
}

/* Dense-list — items with ›-arrow */
.dense-list-item span:last-child {
  color: var(--color-fog-grey);
  font-size: 18px;
  line-height: 1;
}



/* ============================================================
   Audit fix F9-H2 — utility classes replacing inline style= attrs.
   These exist so the admin CSP can drop 'unsafe-inline' from
   style-src. Keep them thin-purposed and named after the place they
   were extracted from.
   ============================================================ */

/* Login page layout (was 5 inline styles in _login_page). */
.solo {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card-wrap {
  width: min(100%, 460px);
  display: grid;
  gap: 16px;
}

.ttl {
  margin: 0 0 12px;
  font-size: 32px;
  line-height: 1.15;
}

.frm {
  display: grid;
  gap: 14px;
}

.fld {
  margin-bottom: 0;
}

/* Dashboard free-daily checkbox row (was 2 inline styles in _dashboards). */
.compact-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-label {
  cursor: pointer;
  font-weight: normal;
}

/* Miscellaneous (1 inline each in _pages_dashboard and _users). */
.muted-tight {
  margin: 0 0 12px;
}

.subtext {
  opacity: 0.65;
}
