/* SNT v2 — Design system */
:root {
  --bg: #f5f5f4;
  --bg-accent: #fafaf9;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --primary: #0f766e;
  --primary-strong: #0d9488;
  --secondary: #d97706;
  --secondary-strong: #b45309;
  --sidebar: #292524;
  --line: #d6d3d1;
  --good: #15803d;
  --warn: #c2410c;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3 {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  font-weight: 600;
  line-height: 1.3;
}

h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; font-weight: 600; }

/* ── Shell layout ── */

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
}

/* ── Sidebar ── */

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 16px 12px;
  background: var(--sidebar);
  color: #fff;
}

.sidebar-brand {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 28px;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  margin-bottom: 20px;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}

.brand-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-copy .eyebrow {
  margin: 0;
  color: #a8a29e;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-copy strong {
  overflow: hidden;
  color: #fff;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-toggle,
.sidebar-icon-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #a8a29e;
  cursor: pointer;
  font-size: 14px;
}

.sidebar-toggle:hover,
.sidebar-icon-button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-toggle svg,
.sidebar-icon-button svg {
  width: 16px;
  height: 16px;
}

.sidebar-nav {
  display: grid;
  gap: 2px;
}

.sidebar-group-label {
  margin: 14px 10px 4px;
  color: #78716c;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
}

.sidebar-nav > .sidebar-group-label:first-child {
  margin-top: 0;
}

.sidebar-menu-group {
  display: grid;
  gap: 2px;
}

.sidebar-group-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  margin-top: 10px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: #78716c;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sidebar-nav > .sidebar-menu-group:first-child .sidebar-group-toggle {
  margin-top: 0;
}

.sidebar-group-toggle .sidebar-group-label {
  margin: 0;
}

.sidebar-group-chevron {
  color: #78716c;
  font-size: 11px;
  line-height: 1;
  transition: transform 160ms ease;
}

.sidebar-menu-group:not(.is-open) .sidebar-group-chevron {
  transform: rotate(-90deg);
}

.sidebar-subnav {
  display: grid;
  grid-template-rows: 0fr;
  margin-left: 10px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  transition: grid-template-rows 180ms ease;
}

.sidebar-menu-group.is-open .sidebar-subnav {
  grid-template-rows: 1fr;
}

.sidebar-subnav-inner {
  display: grid;
  gap: 2px;
  overflow: hidden;
}

.sidebar-subnav .sidebar-link {
  min-height: 36px;
}

.sidebar-link {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  border-left: 3px solid transparent;
  background: transparent;
  color: #a8a29e;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  isolation: isolate;
  transition: background 100ms, color 100ms;
}

.sidebar-link::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.18) 0, transparent 58%);
  content: "";
  opacity: 0;
  transform: scale(0.72);
  pointer-events: none;
}

.sidebar-link:active::before {
  animation: sidebar-ripple 360ms ease-out;
}

@keyframes sidebar-ripple {
  0% {
    opacity: 0.35;
    transform: scale(0.55);
  }
  100% {
    opacity: 0;
    transform: scale(1.18);
  }
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e7e5e4;
}

.sidebar-link.is-active {
  border-left-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-link.is-open {
  background: rgba(20, 184, 166, 0.12);
  color: #fff;
}

.sidebar-link.is-open .nav-icon {
  color: var(--primary-strong);
}

.sidebar-link.is-active .nav-icon {
  color: var(--primary-strong);
}

.view-button-hidden {
  display: none;
}

.layout > .panel[hidden] {
  display: none !important;
}

.nav-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #78716c;
  font-size: 16px;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.5;
}

.menu-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--sidebar);
}

.menu-badge[hidden] {
  display: none;
}

.info-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  cursor: help;
}

.info-tooltip::after {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: min(320px, calc(100vw - 48px));
  padding: 10px 12px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
  content: attr(data-tooltip);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.info-tooltip:hover::after,
.info-tooltip:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.sidebar-user {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 28px;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.sidebar-user-copy strong,
.sidebar-user-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-copy strong {
  color: #e7e5e4;
  font-size: 13px;
}

.sidebar-user-copy span {
  color: #a8a29e;
  font-size: 12px;
}

.mobile-nav,
.mobile-more-menu {
  display: none;
}

/* ── Main area ── */

.app-main {
  min-width: 0;
  padding: 0 24px 36px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 52px;
  margin: 0 -24px 20px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 245, 244, 0.92);
  backdrop-filter: blur(8px);
}

.topbar-heading {
  display: grid;
  gap: 2px;
}

.breadcrumbs {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: end;
}

.topbar-snt-select {
  width: min(280px, 32vw);
}

.topbar-snt-select span {
  font-size: 11px;
}

.topbar-active-snt {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1px 9px;
  align-items: center;
  min-width: 200px;
  max-width: min(340px, 34vw);
  padding: 8px 12px;
  border: 1px solid rgba(15, 118, 110, 0.26);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(240, 253, 250, 0.96), rgba(255, 251, 235, 0.9));
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.1);
}

.topbar-active-snt::before {
  content: "";
  grid-row: 1 / span 2;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.16), rgba(245, 158, 11, 0.14));
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.48);
}

.topbar-active-snt span {
  color: #0f766e;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.topbar-active-snt strong {
  overflow: hidden;
  color: #1c1917;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-dot {
  width: 8px;
  height: 8px;
  margin: 0 4px 15px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.offline-banner {
  margin: 0 auto 16px;
  max-width: 1100px;
  padding: 12px 14px;
  border: 1px solid rgba(194, 65, 12, 0.2);
  border-radius: 6px;
  background: #fff7ed;
  color: var(--warn);
  font-weight: 600;
  line-height: 1.45;
}

.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.is-authenticated .status-banner {
  display: none;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
}
.status-dot.online { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.status-dot.offline { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,0.4); }

/* ── Grid layout ── */

.layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  max-width: 1100px;
  margin: 0 auto;
  gap: 14px;
}

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.panel-head {
  margin-bottom: 14px;
}

.panel-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: baseline;
}

.panel-title-row h2 {
  margin: 0;
}

.panel-head p {
  max-width: none;
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.panel-auth {
  grid-column: 4 / span 6;
  max-width: 480px;
  justify-self: center;
}

.panel-workspace {
  position: static;
  grid-column: span 12;
  background: var(--panel);
}

.panel-search,
.panel-reading {
  grid-column: span 7;
}

.panel-subscriber-manage,
.panel-cost {
  grid-column: span 5;
}

.panel-receipts {
  grid-column: span 10;
}

.panel-journal,
.panel-import,
.panel-members,
.panel-invites,
.panel-snt-settings,
.panel-snt-requisites,
.panel-snt-licensing,
.panel-reports,
.panel-payments,
.panel-instructions,
.panel-bot,
.panel-android,
.panel-settings,
.panel-security,
.panel-media,
.panel-ocr-overview,
.panel-sheet-wizard {
  grid-column: span 12;
}

.sheet-wizard-layout {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr) minmax(160px, 220px);
  gap: 16px;
  align-items: start;
}

.sheet-wizard-main {
  min-width: 0;
}

.sheet-limit-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  color: var(--muted);
}

.sheet-limit-card h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 16px;
}

.sheet-limit-card p {
  margin: 0 0 10px;
  font-size: 13px;
}

.sheet-limit-card ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.45;
}

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

.instruction-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-accent);
}

.instruction-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.instruction-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.sheet-limit-card.is-current {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.16);
  color: var(--text);
}

.sheet-import-warning {
  margin-top: 16px;
  color: var(--danger);
  font-weight: 700;
  text-align: center;
}

@media (max-width: 980px) {
  .sheet-wizard-layout {
    grid-template-columns: 1fr;
  }
}

.panel-security {
  grid-column: span 6;
}

.panel-tariffs {
  grid-column: span 12;
}

.panel-snt-requisites {
  order: 10;
}

.panel-tariffs {
  order: 11;
}

.admin-settings-panel.is-tab-hidden {
  display: none;
}

/* ── Typography helpers ── */

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field span,
.summary-label,
.meta-line,
.reading-updated,
.subscriber-meta,
.subscriber-meter {
  color: var(--muted);
}

.muted-text {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.text-center {
  text-align: center;
}

/* ── Form elements ── */

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-accent);
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus,
.button:focus,
.subscriber-card:focus {
  outline: 2px solid rgba(15, 118, 110, 0.3);
  outline-offset: 1px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.field {
  display: grid;
  gap: 6px;
  width: 100%;
}

.field-inline {
  min-width: min(320px, 100%);
}

.field-grow {
  flex: 1 1 280px;
}

.field span {
  font-size: 13px;
  font-weight: 600;
}

.field-checkbox {
  align-content: end;
}

.field-checkbox input {
  width: 18px;
  min-height: 18px;
  padding: 0;
}

.bot-development-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid #b91c1c;
  border-radius: 8px;
  background: #dc2626;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.bot-toggle-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.bot-toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.bot-toggle-card strong,
.bot-toggle-card small {
  display: block;
}

.bot-toggle-card small {
  margin-top: 2px;
  color: var(--muted);
}

.bot-toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.bot-toggle-track {
  position: relative;
  flex: 0 0 58px;
  width: 58px;
  height: 32px;
  border-radius: 999px;
  background: var(--danger);
  transition: background 0.16s ease;
}

.bot-toggle-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  transition: transform 0.16s ease;
}

.bot-toggle-input:checked + .bot-toggle-track {
  background: var(--good);
}

.bot-toggle-input:checked + .bot-toggle-track .bot-toggle-thumb {
  transform: translateX(26px);
}

.bot-toggle-input:disabled + .bot-toggle-track {
  opacity: 0.55;
  cursor: not-allowed;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.register-email-code-group {
  gap: 8px;
  align-self: stretch;
}

.register-email-code-group .button {
  justify-self: start;
}

/* ── Buttons ── */

.button {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 100ms;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

.button.primary:hover {
  background: var(--primary-strong);
}

.button.secondary {
  background: var(--secondary);
  color: #fff;
}

.button.secondary:hover {
  background: var(--secondary-strong);
}

.button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.button.ghost:hover {
  background: var(--bg);
}

.button.ghost.is-active {
  background: rgba(15, 118, 110, 0.06);
  border-color: rgba(15, 118, 110, 0.3);
  color: var(--primary);
}

.button.danger {
  border: 1px solid rgba(220, 38, 38, 0.2);
  background: #fef2f2;
  color: var(--danger);
}

.button.danger:hover {
  background: #fee2e2;
}

.danger-zone {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid rgba(220, 38, 38, 0.22);
  border-radius: 8px;
  background: #fff7f7;
}

.danger-zone[hidden] {
  display: none;
}

a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

/* ── Cards & status ── */

.status-card,
.summary-box,
.subscriber-card,
.reading-item,
.media-preview-card,
.ocr-overview-card,
.analytics-card,
.report-card,
.form-disclosure,
.excel-preview-table {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.status-card {
  min-height: 44px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 6px;
  border-left: 4px solid var(--line);
  line-height: 1.45;
  white-space: pre-wrap;
}

.status-card.success {
  color: var(--good);
  border-left-color: var(--good);
  background: #f0fdf4;
}

.status-card.warning {
  color: var(--warn);
  border-left-color: var(--warn);
  background: #fff7ed;
}

.status-card.error {
  color: var(--danger);
  border-left-color: var(--danger);
  background: #fef2f2;
}

.status-card.muted {
  color: var(--muted);
  border-left-color: var(--line);
  background: var(--bg-accent);
}

.workspace-status-note {
  margin-top: 0;
  margin-bottom: 12px;
}

/* ── Workspace dashboard ── */

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

.workspace-hint .status-card {
  margin-top: 0;
  min-height: 0;
}

.workspace-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.workspace-trial-welcome {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
  padding: 16px;
  border: 1px solid rgba(31, 97, 141, 0.22);
  border-radius: var(--radius);
  background: #f8fafc;
}

.workspace-trial-welcome[hidden] {
  display: none;
}

.workspace-trial-welcome h3 {
  margin: 0;
  font-size: 18px;
}

.workspace-trial-welcome p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.summary-box {
  padding: 14px;
}

.workspace-setup-progress {
  display: grid;
  gap: 12px;
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: var(--radius);
  background: #f0fdfa;
}

.workspace-setup-progress[hidden] {
  display: none;
}

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

.workspace-setup-head h3,
.workspace-setup-head p {
  margin: 0;
}

.workspace-setup-head p {
  color: var(--muted);
}

.workspace-setup-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  min-height: 36px;
}

.workspace-setup-link {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.workspace-setup-link:hover,
.workspace-setup-link:focus-visible {
  text-decoration: underline;
}

.workspace-setup-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.setup-step {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.setup-step:hover {
  border-color: rgba(15, 118, 110, 0.42);
}

.setup-step strong,
.setup-step small {
  display: block;
}

.setup-step small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.setup-step-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  color: #92400e;
  background: #fef3c7;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.setup-step-badge.is-done {
  color: #166534;
  background: #dcfce7;
}

.summary-label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 500;
}

.current-user-role-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #0f766e;
  background: #ccfbf1;
}

.current-user-role-badge[data-role="super-admin"] {
  color: #7c2d12;
  background: #ffedd5;
}

.workspace-license-type-card {
  border-color: rgba(31, 97, 141, 0.32);
  background: #eff6ff;
}

#workspace-license-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  color: #1d4ed8;
  background: #dbeafe;
}

#workspace-license-type[data-license-type="trial"] {
  color: #92400e;
  background: #fef3c7;
}

#workspace-license-type[data-license-type="paid"] {
  color: #166534;
  background: #dcfce7;
}

#workspace-license-type[data-license-type="free"] {
  color: #374151;
  background: #e5e7eb;
}

#workspace-license-type[data-license-type="super"] {
  color: #5b21b6;
  background: #ede9fe;
}

.workspace-dashboard {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-accent);
}

.workspace-license-activation {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid rgba(217, 119, 6, 0.28);
  border-radius: var(--radius);
  background: #fffbeb;
}

.panel-snt-licensing {
  display: grid;
  gap: 14px;
}

.panel-snt-licensing .panel-head,
.panel-snt-licensing .status-card,
.panel-snt-licensing .reading-list {
  margin-top: 0;
}

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

.license-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
  padding: 16px 18px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-left: 5px solid var(--primary);
  border-radius: 8px;
  background: #f0fdfa;
}

.license-overview[data-tone="warning"] {
  border-color: rgba(217, 119, 6, 0.32);
  border-left-color: var(--accent);
  background: #fff7ed;
}

.license-overview[data-tone="error"] {
  border-color: rgba(185, 28, 28, 0.28);
  border-left-color: #b91c1c;
  background: #fef2f2;
}

.license-overview-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.license-overview strong {
  display: block;
  color: #111827;
  font-size: 22px;
  line-height: 1.2;
}

.license-overview p {
  margin: 6px 0 0;
  color: #0f766e;
  font-size: 14px;
  font-weight: 600;
}

.license-status-pill {
  display: inline-grid;
  place-items: center;
  min-width: 84px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.license-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.license-kpi-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.license-kpi-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.license-kpi-card strong {
  display: block;
  overflow: hidden;
  color: var(--primary);
  font-size: 18px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.license-tabs {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--line);
}

.license-tab {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #fffaf0;
  color: #a16207;
  font-weight: 800;
  cursor: pointer;
}

.license-tab.active {
  background: var(--primary);
  color: #fff;
}

.license-tab-panel {
  display: none;
}

.license-tab-panel.active {
  display: block;
}

.license-technical-details {
  margin-top: 14px;
}

.license-technical-details summary {
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.license-technical-details .license-status-grid {
  margin-top: 10px;
}

.license-status-grid .status-card,
.license-admin-status-grid .status-card {
  min-width: 0;
}

.license-admin-status-grid #snt-license-key-output {
  grid-column: 1 / -1;
}

.license-admin-panel {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.license-events-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

.workspace-tabs {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  border-bottom: 2px solid var(--line);
  margin-bottom: 10px;
}

.workspace-tab {
  position: relative;
  z-index: 1;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
  margin-bottom: -2px;
  background: #fffbeb;
  font: inherit;
  font-weight: 600;
  color: #92400e;
  cursor: pointer;
  transform: translateY(3px);
  opacity: 0.78;
  transition: color 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.2s, opacity 0.2s;
}

.workspace-tab:hover {
  color: var(--text);
  border-color: var(--secondary);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.12);
  opacity: 0.9;
}

.workspace-tab.active {
  z-index: 2;
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  border-bottom-color: var(--primary);
  transform: translateY(0);
  opacity: 1;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.18);
}

.workspace-tab-content {
  display: none;
}

.workspace-tab-content.active {
  display: block;
}

.dashboard-top-trend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  min-height: 20px;
}

.dashboard-top-trend svg {
  width: 48px;
  height: 20px;
}

.dashboard-top-trend .trend-up {
  color: var(--danger);
}

.dashboard-top-trend .trend-down {
  color: var(--good);
}

.dashboard-top-trend .trend-flat {
  color: var(--muted);
}

.workspace-users {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.workspace-dashboard-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.workspace-dashboard-head h3 {
  margin: 0;
  font-size: 14px;
}

.workspace-dashboard-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.workspace-dashboard-period {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.compact-field {
  min-width: 116px;
}

.compact-field span {
  margin-bottom: 4px;
}

.dashboard-top-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-top-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  min-height: 100px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  background: #fff;
}

.dashboard-top-card strong {
  color: var(--text);
  font-size: 14px;
}

.dashboard-top-card span:last-child {
  color: var(--text);
  font-weight: 600;
}

.dashboard-top-card.top-1 { border-left-color: var(--secondary); }
.dashboard-top-card.top-2 { border-left-color: #78716c; }
.dashboard-top-card.top-3 { border-left-color: var(--primary); }
.dashboard-top-card.top-snt { border-left-color: var(--text); }

.workspace-user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.workspace-user-card {
  display: grid;
  gap: 4px;
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  background: var(--bg-accent);
}

.workspace-user-card strong {
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.workspace-user-card span {
  color: var(--text);
  font-weight: 600;
}

.workspace-user-card small {
  color: var(--muted);
}

/* ── Subscriber & reading ── */

.subscriber-card {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 14px;
  text-align: left;
  border-radius: var(--radius);
  cursor: pointer;
}

.subscriber-card.is-selected,
.reading-item.is-selected {
  border-color: rgba(15, 118, 110, 0.4);
  background: rgba(15, 118, 110, 0.04);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.15);
}

.subscriber-plot {
  font-size: 1.1rem;
  font-weight: 700;
}

.subscriber-form,
.invite-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.subscriber-form .row,
.invite-form .row {
  grid-column: 1 / -1;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.reading-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.reading-item {
  padding: 12px 14px;
  border-radius: var(--radius);
}

.reading-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.reading-values {
  font-weight: 600;
}

.reading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

.reading-list .reading-item:nth-child(even) {
  background: var(--bg-accent);
}

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

.reading-form .row {
  grid-column: 1 / -1;
}

.meta-line {
  min-height: 20px;
}

/* ── Forms: rows, stacks ── */

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

.row {
  display: flex;
  gap: 12px;
  align-items: end;
}

.row-wrap {
  flex-wrap: wrap;
}

.journal-form,
.tariff-form,
.member-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.journal-form .row,
.tariff-form .row,
.member-form .row {
  grid-column: 1 / -1;
}

/* ── Disclosure / accordion ── */

.form-disclosure {
  overflow: hidden;
}

.form-disclosure summary {
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  list-style: none;
}

.form-disclosure summary::-webkit-details-marker {
  display: none;
}

.form-disclosure summary::after {
  content: "+";
  float: right;
  color: var(--muted);
}

.form-disclosure[open] summary::after {
  content: "−";
}

.form-disclosure-body {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
}

.form-disclosure-compact {
  margin-top: 12px;
}

.form-disclosure-compact summary {
  padding: 10px 14px;
  font-size: 13px;
}

/* ── Journal table ── */

.journal-table-container {
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.journal-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  font-size: 13px;
}

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

.journal-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--sidebar);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.journal-table tr.is-missing-reading td {
  color: var(--muted);
  background: var(--bg-accent);
}

.journal-edit-cell {
  width: 48px;
}

.journal-edit-button {
  min-width: 32px;
  width: 32px;
  height: 32px;
  font-size: 16px;
}

.journal-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 250px;
}

.journal-table-actions .button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.modal-card.manual-readings-modal-card {
  width: min(1180px, calc(100vw - 48px));
  overflow-x: hidden;
}

.modal-card.excel-import-modal-card {
  width: min(860px, calc(100vw - 48px));
  overflow-x: hidden;
}

.excel-import-modal-body .excel-import-block {
  margin-top: 0;
}

.manual-readings-modal-card .modal-head,
.manual-readings-modal-card .modal-body,
.manual-readings-modal-card .modal-footer {
  min-width: 0;
  overflow-x: hidden;
}

.manual-readings-toolbar {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(220px, 280px) minmax(120px, 150px) auto;
  gap: 12px;
  align-items: end;
}

.manual-readings-add-button {
  min-width: 132px;
}

.manual-readings-add-count-field {
  min-width: 0;
}

.manual-readings-table-wrap {
  max-width: 100%;
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.manual-readings-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
}

.manual-readings-table th,
.manual-readings-table td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.manual-readings-table th {
  background: var(--bg-accent);
  color: var(--text);
  font-weight: 600;
}

.manual-readings-table input,
.manual-readings-table select {
  min-width: 120px;
}

.manual-readings-table th:last-child,
.manual-readings-table td:last-child {
  width: 48px;
  text-align: right;
}

.manual-readings-value-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 8px;
}

.manual-readings-value-group label {
  display: grid;
  gap: 4px;
}

.manual-readings-value-group span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.manual-readings-row-actions {
  white-space: nowrap;
}

.manual-readings-row-remove {
  color: var(--muted);
}

.manual-readings-row-message td {
  padding-top: 0;
  color: var(--muted);
  font-size: 12px;
}

.manual-readings-row-message.is-error td {
  color: var(--danger);
}

.manual-readings-row-message.is-success td {
  color: var(--success);
}

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

.onboarding-choice-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.onboarding-choice-card h3,
.onboarding-choice-card p {
  margin: 0;
}

.onboarding-choice-card p {
  color: var(--muted);
}

.onboarding-format-toggle {
  justify-self: start;
}

.onboarding-format-example {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.onboarding-format-example[hidden] {
  display: none;
}

.onboarding-format-example div {
  display: grid;
  gap: 4px;
}

.onboarding-format-example code {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--bg-accent);
  color: var(--text);
  white-space: normal;
}

.onboarding-format-example p {
  margin: 0;
  color: var(--muted);
}

/* ── Receipts ── */

.receipt-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.receipt-form .row,
.receipt-form .field-full {
  grid-column: 1 / -1;
}

.receipt-selector select {
  min-height: 220px;
}

.receipt-results {
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.receipt-results:empty {
  display: none;
}

.receipt-results-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 13px;
}

.receipt-results-table th,
.receipt-results-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.receipt-results-table th {
  background: var(--sidebar);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.receipt-print-section {
  margin-top: 16px;
}

.receipt-compact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.receipt-card-compact,
.receipt-large {
  border: 1px solid #111827;
  background: #fff;
  color: #111827;
  font-family: Arial, sans-serif;
}

.receipt-card-compact {
  display: flex;
  min-height: 260px;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  font-size: 12px;
  line-height: 1.25;
}

.receipt-compact-header {
  font-size: 15px;
  font-weight: 700;
}

.receipt-compact-period {
  margin-top: 6px;
  color: #374151;
}

.receipt-compact-amount {
  margin-top: 10px;
  font-size: 14px;
}

.receipt-compact-qr {
  margin-top: 10px;
  text-align: center;
}

.receipt-compact-qr img {
  width: 112px;
  height: 112px;
}

.receipt-compact-caption {
  margin-top: 4px;
  color: #4b5563;
  font-size: 10px;
}

.receipt-large {
  max-width: 760px;
  padding: 20px;
  font-size: 13px;
}

.receipt-large-header,
.receipt-large-total,
.receipt-large-qr {
  text-align: center;
}

.receipt-large-title {
  margin: 0;
}

.receipt-large-subtitle {
  margin: 6px 0 14px;
}

.receipt-large-table {
  width: 100%;
  border-collapse: collapse;
}

.receipt-large-table td {
  padding: 7px;
  border-bottom: 1px solid #d1d5db;
}

.receipt-large-payer {
  margin: 16px 0;
  padding: 12px;
  background: #f9fafb;
}

.receipt-large-total {
  margin: 16px 0;
  font-size: 22px;
}

.receipt-large-qr img {
  width: 150px;
  height: 150px;
}

.receipt-large-qr p,
.receipt-large-footer {
  color: #4b5563;
  font-size: 11px;
}

.receipt-large-footer {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid #111827;
}

/* ── Import ── */

.import-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.import-grid > div {
  min-width: 0;
}

.panel-import .panel-head p {
  max-width: none;
}

.import-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.excel-import-block {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.excel-import-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.excel-import-steps span {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  background: #f8fafc;
}

.excel-import-steps span.is-active {
  color: var(--accent);
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.08);
}

.excel-import-steps span.is-done {
  color: #166534;
  border-color: rgba(22, 101, 52, 0.25);
  background: rgba(22, 101, 52, 0.08);
}

.excel-import-step-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.excel-import-advanced {
  display: grid;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.excel-import-advanced summary {
  cursor: pointer;
  font-weight: 700;
}

.excel-import-advanced > .muted-text {
  margin: 2px 0 0;
}

.excel-import-advanced[open] > .muted-text {
  margin-bottom: 4px;
}

.excel-import-advanced .excel-import-step-panel + .excel-import-step-panel {
  margin-top: 10px;
}

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

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

.excel-preview-table {
  margin-top: 12px;
  overflow: auto;
}

.excel-preview-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
}

.excel-preview-table th,
.excel-preview-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid rgba(0, 0, 0, 0.04);
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
}

.excel-preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-accent);
  color: var(--text);
  font-weight: 600;
}

.excel-preview-table tr:last-child td {
  border-bottom: none;
}

.panel-subhead {
  margin-top: 20px;
}

/* ── Media preview ── */

.media-preview-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1.1fr);
  gap: 12px;
  margin-top: 12px;
}

.media-preview-card {
  min-height: 200px;
  padding: 12px;
}

.media-preview-card img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--bg);
}

/* ── OCR overview ── */

.ocr-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.ocr-overview-card {
  min-height: 100px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.ocr-overview-card.warning {
  border-left: 3px solid var(--warn);
  background: #fff7ed;
}

.ocr-overview-card.error {
  border-left: 3px solid var(--danger);
  background: #fef2f2;
}

.ocr-overview-card.success {
  border-left: 3px solid var(--good);
  background: #f0fdf4;
}

.ocr-overview-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ocr-overview-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.ocr-overview-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

/* ── Sheet Wizard ── */

.sheet-wizard-steps {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.sheet-wizard-step-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.sheet-wizard-step-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sheet-wizard-step-btn.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.sheet-wizard-step-btn .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-alt, #e5e5e5);
  font-size: 12px;
  font-weight: 700;
}

.sheet-wizard-step-btn.is-active .step-num {
  background: var(--accent);
  color: #fff;
}

.sheet-wizard-step {
  display: none;
}

.sheet-wizard-step.is-active {
  display: block;
}

.sheet-upload-queue-item.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.sheet-tpl-info {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.sheet-tpl-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.sheet-tpl-col {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 10px;
  background: var(--surface-alt, #f5f5f5);
  border-radius: 6px;
  font-size: 13px;
}

.sheet-tpl-col strong {
  min-width: 18px;
  text-align: center;
}

.sheet-tpl-col em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.sheet-preview-table,
.sheet-apply-result-table {
  display: grid;
  gap: 0;
  overflow-x: auto;
  margin: 12px 0;
}

.sheet-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) 90px 90px 60px minmax(120px, 2fr) 50px;
  gap: 4px;
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}

.sheet-apply-result-table .sheet-row {
  grid-template-columns: minmax(80px, 1fr) 120px minmax(120px, 2fr);
}

.sheet-row-header {
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-alt, #fafafa);
  border-bottom: 2px solid var(--border);
}

.sheet-row-skipped {
  opacity: 0.45;
}

.sheet-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.sheet-cell-conf {
  text-align: center;
}

.sheet-cell-raw {
  color: var(--muted);
  font-size: 12px;
}

.sheet-input {
  width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  background: var(--bg);
}

.sheet-skip {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.sheet-apply-dryrun-field {
  display: flex;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
}

.sheet-apply-dryrun-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.hint-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 4px 0 12px;
}

/* ── Analytics & reports ── */

.analytics-card,
.report-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.analytics-row-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-weight: 600;
}

.analytics-bar-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.analytics-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-strong));
}

.analytics-bar-fill-payment {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

.analytics-section-title {
  margin: 16px 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.analytics-lists-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}

.analytics-list-col {
  min-width: 0;
}

.analytics-scroll-list {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
}

.analytics-scroll-list .analytics-card {
  padding: 8px 10px;
  gap: 4px;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.analytics-scroll-list .analytics-card:last-child {
  border-bottom: none;
}

.analytics-scroll-list .analytics-row-head {
  font-size: 13px;
}

.analytics-scroll-list .analytics-bar-track {
  height: 5px;
}

.analytics-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.analytics-kpi-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-accent);
}

.analytics-kpi-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.analytics-kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 2px;
}

.analytics-chart-container {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-accent);
  overflow-x: auto;
}

.analytics-svg-chart {
  display: block;
}

.analytics-chart-bar {
  fill: var(--primary);
  transition: fill 0.15s;
}

.analytics-chart-bar:hover {
  fill: var(--primary-strong);
}

.analytics-chart-value {
  font-size: 10px;
  fill: var(--text);
  text-anchor: middle;
  font-weight: 600;
}

.analytics-chart-label {
  font-size: 10px;
  fill: var(--muted);
  text-anchor: middle;
}

.report-card pre,
.analytics-card pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
}

/* ── View switching ── */

.view-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  justify-content: flex-end;
}

.view-button {
  min-height: 38px;
  padding: 0 14px;
}

.view-button.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.chip {
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

body[data-view="desk"] [data-screen="ocr"],
body[data-view="desk"] [data-screen="lab"],
body[data-view="desk"] [data-screen="admin"] {
  display: none;
}

body[data-view="admin"] [data-screen="desk"],
body[data-view="admin"] [data-screen="ocr"],
body[data-view="admin"] [data-screen="lab"] {
  display: none;
}

body[data-view="ocr"] [data-screen="desk"],
body[data-view="ocr"] [data-screen="lab"],
body[data-view="ocr"] [data-screen="admin"] {
  display: none;
}

body[data-view="lab"] [data-screen="desk"],
body[data-view="lab"] [data-screen="ocr"],
body[data-view="lab"] [data-screen="admin"] {
  display: none;
}

/* ── Modal ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.modal-overlay.is-front {
  z-index: 70;
}

.modal-overlay.is-top {
  z-index: 90;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: min(480px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
}

.register-modal-card {
  width: min(560px, 100%);
}

.onboarding-modal-card {
  width: min(520px, 100%);
}

.modal-head,
.modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
}

.modal-body {
  padding: 0 16px 16px;
}

.onboarding-body {
  display: grid;
  gap: 12px;
}

.onboarding-progress {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.onboarding-dots {
  display: flex;
  gap: 5px;
}

.onboarding-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--line);
}

.onboarding-dot.is-active {
  width: 18px;
  background: var(--primary);
}

.onboarding-dot.is-done {
  background: var(--success);
}

.onboarding-footer {
  border-top: 1px solid var(--line);
}

.onboarding-inline-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

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

.onboarding-inline-grid .field {
  min-width: 0;
}

.onboarding-inline-grid .field.is-wide {
  grid-column: 1 / -1;
}

.excel-import-block:not(.has-file) [data-import-step="sheet"],
.excel-import-block:not(.has-file) [data-import-step="advanced"],
.excel-import-block:not(.has-file) [data-import-step="structure"],
.excel-import-block:not(.has-file) [data-import-step="month"],
.excel-import-block:not(.has-file) [data-import-step="preview"],
.excel-import-block:not(.has-file) .excel-mapping-grid,
.excel-import-block:not(.has-file) .excel-preview-table {
  display: none;
}

.excel-import-block.has-file:not(.has-sheet) [data-import-step="advanced"],
.excel-import-block.has-file:not(.has-sheet) [data-import-step="structure"],
.excel-import-block.has-file:not(.has-sheet) [data-import-step="month"],
.excel-import-block.has-file:not(.has-sheet) [data-import-step="preview"],
.excel-import-block.has-file:not(.has-sheet) .excel-mapping-grid,
.excel-import-block.has-file:not(.has-sheet) .excel-preview-table {
  display: none;
}

.modal-footer-inline {
  margin: 12px -16px -16px;
}

.excel-preview-modal-card {
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-color: rgba(15, 118, 110, 0.22);
  background: #f8fafc;
}

.excel-preview-modal-card.is-wide {
  width: min(1760px, calc(100vw - 24px));
}

.excel-preview-modal-body {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding-top: 4px;
  background: #f8fafc;
}

.excel-preview-modal-card .modal-head {
  align-items: flex-start;
  border-bottom: 1px solid rgba(15, 118, 110, 0.18);
  background: #ffffff;
}

.excel-preview-modal-card .modal-head h2 {
  margin: 0;
  color: #0f172a;
  font-size: 20px;
}

.excel-preview-modal-card .modal-head .muted-text,
.excel-preview-modal-card .modal-footer .muted-text {
  color: #475569;
}

.excel-preview-modal-card .modal-footer {
  border-top: 1px solid rgba(15, 118, 110, 0.18);
  background: #ffffff;
}

.excel-preview-modal-body .excel-preview-table {
  max-height: 320px;
  margin-top: 0;
  border-color: #cbd5e1;
  background: #ffffff;
}

.excel-preview-modal-body .excel-preview-table table {
  min-width: 760px;
}

.excel-preview-modal-body .excel-preview-table th {
  background: #e0f2fe;
  color: #0f172a;
  border-bottom-color: #94a3b8;
}

.excel-preview-modal-body .excel-preview-table th,
.excel-preview-modal-body .excel-preview-table td {
  padding: 8px 10px;
  color: #1e293b;
  background: #ffffff;
}

.excel-preview-modal-body .excel-preview-table th:first-child,
.excel-preview-modal-body .excel-preview-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 52px;
  border-right: 1px solid #cbd5e1;
}

.excel-preview-modal-body .excel-preview-table th:last-child,
.excel-preview-modal-body .excel-preview-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 92px;
  border-left: 1px solid #cbd5e1;
}

.excel-preview-modal-body .excel-preview-table th:first-child,
.excel-preview-modal-body .excel-preview-table th:last-child {
  z-index: 3;
}

.excel-preview-modal-body .excel-preview-table tr:nth-child(even) td {
  background: #f8fafc;
}

.excel-preview-modal-body input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: #0f766e;
}

.excel-preview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.44fr);
  gap: 12px;
  align-items: start;
}

.excel-preview-panel {
  min-width: 0;
}

.excel-preview-panel h3 {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 15px;
}

.excel-preview-panel-mapping,
.excel-preview-panel-mapping h3 {
  text-align: right;
}

.excel-preview-mapping-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  background: #f0fdfa;
}

.excel-preview-mapping-summary-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.excel-preview-mapping-chip {
  display: inline-flex;
  align-items: center;
  text-align: right;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  color: #115e59;
  background: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.excel-preview-mapping-chip.is-empty {
  color: #64748b;
  background: #f8fafc;
}

.excel-preview-modal-mapping {
  margin: 0 0 4px;
  gap: 10px;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.excel-preview-modal-mapping .field {
  min-width: 0;
}

.excel-preview-modal-mapping .field span {
  color: #0f172a;
  font-weight: 700;
  text-align: right;
}

.excel-preview-modal-mapping select {
  min-height: 36px;
  padding: 6px 28px 6px 10px;
  border-color: #94a3b8;
  background: #ffffff;
  color: #0f172a;
  text-align: right;
  text-align-last: right;
}

.excel-preview-rules {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(37, 99, 235, 0.24);
  border-left: 4px solid #2563eb;
  border-radius: 6px;
  color: #1e3a8a;
  background: #eff6ff;
  line-height: 1.5;
}

.excel-preview-rules summary {
  cursor: pointer;
  font-weight: 700;
}

.excel-preview-rules p {
  margin: 8px 0 0;
}

@media (max-width: 980px) {
  .excel-preview-layout {
    grid-template-columns: 1fr;
  }

  .excel-preview-modal-body .excel-preview-table {
    max-height: 260px;
  }
}

/* ── Toast ── */

.toast-stack {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 28px));
}

.toast {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
  animation: toast-slide-in 150ms ease-out;
  white-space: pre-wrap;
}

.toast.success {
  border-left: 3px solid var(--good);
  color: var(--good);
}

.toast.warning {
  border-left: 3px solid var(--warn);
  color: var(--warn);
}

.toast.error {
  border-left: 3px solid var(--danger);
  color: var(--danger);
}

/* ── Skeleton ── */

.skeleton {
  min-height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, #e7e5e4, #fafaf9, #e7e5e4);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.2s ease-in-out infinite;
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes skeleton-pulse {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ── Anonymous / auth state ── */

body.is-auth-pending .app-shell {
  visibility: hidden;
}

body.is-anonymous .sidebar,
body.is-anonymous .topbar,
body.is-anonymous .panel-instructions,
body.is-anonymous .panel-workspace,
body.is-anonymous [data-screen="desk"],
body.is-anonymous [data-screen="admin"],
body.is-anonymous [data-screen="ocr"],
body.is-anonymous [data-screen="lab"] {
  display: none;
}

body.is-anonymous .app-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 0;
  background-color: #111827;
  background-image: url("Cyber_SNT.jpg");
  background-image: image-set(
    url("Cyber_SNT.webp") type("image/webp"),
    url("Cyber_SNT.jpg") type("image/jpeg")
  );
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

@media (max-width: 760px) {
  body.is-anonymous .app-shell {
    background-image: url("Cyber_SNT_mobile.webp");
  }
}

.auth-bg-loader {
  display: none;
}

body.is-anonymous:not(.auth-bg-loaded) .auth-bg-loader {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 45;
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  transform: translateX(-50%);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.86);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
}

.auth-bg-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: auth-bg-spin 0.8s linear infinite;
}

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

body.is-anonymous .app-main {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: none;
  padding: 32px;
  width: 100%;
}

body.is-anonymous .layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  grid-template-areas:
    "hero auth"
    "hero status";
  align-items: center;
  column-gap: 56px;
  row-gap: 12px;
  width: 100%;
  max-width: min(1480px, calc(100vw - 96px));
  background: transparent;
  padding: 0;
}

body.is-anonymous .status-banner {
  grid-area: status;
  justify-self: center;
  width: min(100%, 400px);
  margin-bottom: 0;
  border: none;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  padding: 14px 18px;
}

body.is-anonymous .auth-hero {
  grid-area: hero;
  display: block;
  justify-self: end;
  width: min(100%, 900px);
  text-align: center;
}

body.is-anonymous .auth-hero h1 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(28px, 3.4vw, 48px);
  line-height: 1.12;
  font-weight: 800;
  text-wrap: balance;
  text-shadow:
    0 2px 8px rgba(0, 0, 0, 0.72),
    0 12px 34px rgba(0, 0, 0, 0.55);
}

body.is-anonymous .panel-auth {
  grid-area: auth;
  display: block;
  width: min(100%, 400px);
  max-width: 400px;
  border: none;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  padding: 32px;
}

body.is-authenticated .panel-auth {
  display: none;
}

body.is-authenticated .auth-hero {
  display: none;
}

.auth-links {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 14px;
  font-size: 13px;
}

.auth-links a {
  color: var(--primary);
  text-decoration: none;
}

.auth-links a:hover {
  text-decoration: underline;
}

.auth-links-sep {
  color: var(--muted);
}

.auth-contact {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.auth-contact a {
  color: var(--primary);
  text-decoration: none;
}

.auth-contact a:hover {
  text-decoration: underline;
}

/* ── Sidebar collapsed ── */

body.sidebar-collapsed .app-shell {
  grid-template-columns: 56px minmax(0, 1fr);
}

body.sidebar-collapsed .sidebar {
  padding-inline: 8px;
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-group-label,
body.sidebar-collapsed .sidebar-group-toggle,
body.sidebar-collapsed .sidebar-user-copy,
body.sidebar-collapsed .sidebar-icon-button {
  display: none;
}

body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .sidebar-user {
  grid-template-columns: 36px;
  justify-content: center;
}

body.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  right: -12px;
  top: 20px;
  background: var(--sidebar);
}

body.sidebar-collapsed .sidebar-link {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 0;
  border-left: 0;
}

body.sidebar-collapsed .sidebar-subnav {
  grid-template-rows: 1fr;
  margin: 0;
  padding: 0;
  border-left: 0;
}

body.sidebar-collapsed .sidebar-subnav-inner {
  overflow: visible;
}

body.sidebar-collapsed .sidebar-link::after {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  z-index: 40;
  width: max-content;
  max-width: 220px;
  padding: 6px 8px;
  border-radius: 5px;
  background: #1c1917;
  color: #fff;
  content: attr(aria-label);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(-4px);
  transition: opacity 120ms ease, transform 120ms ease;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

body.sidebar-collapsed .sidebar-link:hover::after,
body.sidebar-collapsed .sidebar-link:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

body.sidebar-collapsed .menu-badge {
  position: absolute;
  right: 2px;
  top: 2px;
}

/* ── Responsive: tablet ── */

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .brand-copy,
  .nav-label,
  .sidebar-group-label,
  .sidebar-group-toggle,
  .sidebar-user-copy {
    display: none;
  }

  .sidebar-subnav {
    grid-template-rows: 1fr;
    margin: 0;
    padding: 0;
    border-left: 0;
  }

  .sidebar-subnav-inner {
    overflow: visible;
  }

  .sidebar-brand,
  .sidebar-user {
    grid-template-columns: 36px;
    justify-content: center;
  }

  .sidebar-toggle,
  .sidebar-icon-button {
    display: none;
  }

  .sidebar-link {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 0;
    border-left: 0;
  }

  .panel-auth,
  .panel-search,
  .panel-reading,
  .panel-subscriber-manage,
  .panel-cost,
  .panel-receipts,
  .panel-security,
  .panel-invites {
    grid-column: span 12;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .topbar-snt-select {
    width: min(100%, 420px);
  }

  .topbar-active-snt {
    width: min(100%, 420px);
    max-width: none;
  }

  .workspace-hint,
  .workspace-setup-head,
  .workspace-setup-list,
  .workspace-dashboard-head,
  .workspace-dashboard-period,
  .dashboard-top-grid,
  .receipt-form,
  .ocr-lab-overview,
  .ocr-lab-workspace,
  .ocr-lab-batch-form {
    grid-template-columns: 1fr;
  }

  .workspace-dashboard-head,
  .workspace-dashboard-period {
    display: grid;
  }

  .ocr-lab-review-head,
  .ocr-lab-review-row {
    grid-template-columns: 1.4fr repeat(4, minmax(70px, 1fr)) 1.3fr;
  }

  .panel-workspace,
  .ocr-lab-preview-panel {
    position: static;
  }

  .workspace-summary {
    grid-template-columns: 1fr;
  }

  .media-preview-grid {
    grid-template-columns: 1fr;
  }

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

  .excel-import-config,
  .excel-mapping-grid {
    grid-template-columns: 1fr;
  }

  .ocr-overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  body.is-anonymous .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "hero"
      "auth"
      "status";
    max-width: 760px;
  }
}

/* ── Responsive: mobile ── */

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .app-main {
    padding: 0 12px 96px;
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
    gap: 2px;
    padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
    border-top: 1px solid rgba(15, 118, 110, 0.18);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -12px 28px rgba(15, 23, 42, 0.14);
  }

  .mobile-nav-item,
  .mobile-more-item {
    display: grid;
    gap: 3px;
    justify-items: center;
    align-items: center;
    min-width: 0;
    min-height: 52px;
    padding: 5px 4px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #78716c;
    font: inherit;
    cursor: pointer;
  }

  .mobile-nav-item.is-active,
  .mobile-more-item.is-active {
    background: #e6fffb;
    color: var(--primary);
  }

  .mobile-nav-label {
    max-width: 100%;
    overflow: hidden;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-more-menu {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(74px + env(safe-area-inset-bottom));
    z-index: 44;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    max-height: min(60vh, 420px);
    overflow: auto;
    padding: 10px;
    border: 1px solid rgba(15, 118, 110, 0.18);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.22);
  }

  .mobile-more-menu[hidden] {
    display: none;
  }

  body.is-auth-pending .mobile-nav,
  body.is-auth-pending .mobile-more-menu,
  body.is-anonymous .mobile-nav,
  body.is-anonymous .mobile-more-menu {
    display: none;
  }

  .topbar {
    margin-inline: -12px;
    padding-inline: 12px;
  }

  .layout {
    gap: 10px;
  }

  .panel {
    padding: 14px;
  }

  .button {
    width: 100%;
    min-height: 44px;
    white-space: normal;
  }

  .icon-button {
    width: 40px;
    min-width: 40px;
  }

  .register-email-code-group .button {
    justify-self: stretch;
  }

  .modal-overlay {
    align-items: start;
    padding: 10px;
  }

  .modal-card,
  .register-modal-card {
    width: 100%;
    max-height: calc(100dvh - 20px);
    border-radius: 8px;
  }

  .modal-card.manual-readings-modal-card {
    width: 100%;
    max-height: calc(100dvh - 20px);
  }

  .modal-card.excel-import-modal-card {
    width: 100%;
    max-height: calc(100dvh - 20px);
  }

  .manual-readings-toolbar {
    grid-template-columns: 1fr;
  }

  .manual-readings-toolbar .row {
    align-items: stretch;
  }

  .onboarding-choice-grid {
    grid-template-columns: 1fr;
  }

  .modal-head,
  .modal-footer {
    padding: 12px;
  }

  .modal-body {
    padding: 0 12px 12px;
  }

  body.is-anonymous .app-main {
    min-height: 100dvh;
    padding: 16px 10px;
  }

  body.is-anonymous .layout {
    max-width: 100%;
    gap: 16px;
  }

  body.is-anonymous .panel-auth {
    padding: 18px;
  }

  body.is-anonymous .auth-hero h1 {
    font-size: 28px;
  }

  .reading-form,
  .subscriber-form,
  .journal-form,
  .receipt-form,
  .tariff-form,
  .member-form,
  .invite-form {
    grid-template-columns: 1fr;
  }

  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .import-grid,
  .workspace-hint,
  .workspace-summary,
  .license-overview,
  .license-kpi-grid,
  .license-status-grid,
  .license-admin-status-grid,
  .license-events-head {
    grid-template-columns: 1fr;
  }

  .reading-actions {
    justify-content: stretch;
  }

  .view-switcher {
    justify-content: stretch;
  }

  .ocr-overview-grid {
    grid-template-columns: 1fr;
  }

  .ocr-lab-fields {
    grid-template-columns: 1fr;
  }

  .ocr-lab-card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .ocr-lab-review-head,
  .ocr-lab-review-row {
    grid-template-columns: 1fr;
  }

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

  .analytics-lists-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  body {
    font-size: 13px;
  }

  h2 {
    font-size: 17px;
  }

  .auth-links {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-links-sep {
    display: none;
  }

  .modal-head {
    align-items: start;
  }

  .modal-head h2 {
    padding-top: 6px;
  }

  .status-card {
    font-size: 13px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  body,
  .app-main,
  .layout,
  .panel-receipts {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }

  .sidebar,
  .topbar,
  .offline-banner,
  .panel-receipts .panel-head,
  .receipt-form,
  #receipt-status,
  #receipt-summary,
  #receipt-results {
    display: none !important;
  }

  .layout > .panel:not(.panel-receipts) {
    display: none !important;
  }

  .panel-receipts {
    display: block !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  .receipt-print-section {
    margin: 0 !important;
  }

  .receipt-print-page {
    width: 100%;
    page-break-after: always;
  }

  .receipt-print-page:last-child {
    page-break-after: auto;
  }

  .receipt-compact-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 4mm !important;
  }

  .receipt-print-section.print-profile-large .receipt-compact-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 5mm !important;
  }

  .receipt-card-compact {
    height: 89mm;
    min-height: 89mm;
    max-height: 89mm;
    padding: 3.2mm !important;
    font-size: 9.5pt !important;
    page-break-inside: avoid;
  }

  .receipt-print-section.print-profile-large .receipt-card-compact {
    height: 132mm;
    min-height: 132mm;
    max-height: 132mm;
    padding: 4.2mm !important;
    font-size: 11pt !important;
  }

  .receipt-compact-qr img {
    width: 27mm !important;
    height: 27mm !important;
  }

  .receipt-print-section.print-profile-large .receipt-compact-qr img {
    width: 36mm !important;
    height: 36mm !important;
  }
}
