@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500..700&family=Manrope:wght@500;700;800&family=Sora:wght@400;500;600;700;800&display=swap");

/* ═══════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════ */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  /* Background layers */
  --bg: #0a0e1a;
  --bg-elevated: #0f1424;
  --bg-surface: #141a2e;
  --bg-surface-hover: #1a2038;
  --bg-overlay: rgba(10, 14, 26, 0.85);
  --topbar-bg: rgba(10, 14, 26, 0.92);
  --sidebar-backdrop-bg: rgba(0, 0, 0, 0.6);
  --floating-toggle-bg: rgba(15, 20, 36, 0.92);
  --floating-toggle-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);

  /* Text */
  --text-primary: #f0f4ff;
  --text-secondary: #8b9dc3;
  --text-tertiary: #5c6f94;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* Accent */
  --accent: #5b8def;
  --accent-soft: rgba(91, 141, 239, 0.12);
  --accent-hover: #7aa5ff;

  /* Status */
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);

  /* Sizing */
  --sidebar-width: 260px;
  --topbar-height: 56px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Font */
  font-family: "Sora", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  font-weight: 500;
  color: var(--text-primary);
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #eef3f8;
  --bg-elevated: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f2f6fb;
  --bg-overlay: rgba(237, 243, 250, 0.86);
  --topbar-bg: rgba(248, 251, 255, 0.92);
  --sidebar-backdrop-bg: rgba(133, 151, 178, 0.28);
  --floating-toggle-bg: rgba(255, 255, 255, 0.94);
  --floating-toggle-shadow: 0 14px 34px rgba(62, 91, 134, 0.16);

  --text-primary: #172235;
  --text-secondary: #556b87;
  --text-tertiary: #7f92ac;

  --border-subtle: rgba(23, 34, 53, 0.06);
  --border-default: rgba(23, 34, 53, 0.12);
  --border-strong: rgba(23, 34, 53, 0.18);

  --accent: #2f68db;
  --accent-soft: rgba(47, 104, 219, 0.12);
  --accent-hover: #1f57cf;

  --success: #1f9a63;
  --warning: #c48212;
  --danger: #d65454;

  --shadow-sm: 0 1px 3px rgba(59, 83, 122, 0.08), 0 1px 2px rgba(59, 83, 122, 0.06);
  --shadow-md: 0 6px 16px rgba(59, 83, 122, 0.12);
  --shadow-lg: 0 16px 38px rgba(59, 83, 122, 0.16);
}

/* ═══════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:root[data-theme="light"] body {
  background:
    radial-gradient(circle at 12% 14%, rgba(47, 104, 219, 0.11), transparent 24%),
    radial-gradient(circle at 85% 18%, rgba(48, 186, 204, 0.1), transparent 16%),
    linear-gradient(180deg, #f4f8fc 0%, #eef3f8 58%, #e7edf5 100%);
}

::selection {
  background: rgba(91, 141, 239, 0.3);
  color: var(--text-primary);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  border: 0;
  background: none;
  cursor: pointer;
}

/* ═══════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════ */
.app-layout {
  min-height: 100vh;
}

/* ─── SIDEBAR ───────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 40;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  transform: translateX(-100%);
  transition: transform 320ms var(--ease-out);
  overflow: hidden;
}

.sidebar.is-open {
  transform: translateX(0);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 14px 12px;
  overflow-y: auto;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), #3b6fd4);
  color: #fff;
  box-shadow: 0 2px 8px rgba(91, 141, 239, 0.3);
}

.sidebar-brand-text strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-brand-text span {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.sidebar-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: background 150ms ease, color 150ms ease;
}

.sidebar-close svg {
  width: 18px;
  height: 18px;
}

.sidebar-close:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* Venue info */
.sidebar-venue {
  display: grid;
  gap: 2px;
  padding: 10px 11px;
  margin-bottom: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.sidebar-venue-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.sidebar-venue-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-venue-user {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Nav links */
.sidebar-nav {
  display: grid;
  gap: 0;
  align-content: start;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 500;
  transition: background 150ms ease, color 150ms ease;
  border: none;
  text-decoration: none;
}

.sidebar-link:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  transform: none;
}

.sidebar-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link.is-active .nav-icon {
  opacity: 1;
}

.sidebar-link-label {
  white-space: nowrap;
}

/* Footer actions */
.sidebar-footer {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 150ms ease, color 150ms ease;
}

.sidebar-action-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-action-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.sidebar-logout:hover {
  color: var(--danger);
}

/* Backdrop */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: var(--sidebar-backdrop-bg);
  backdrop-filter: blur(4px);
  animation: fadeIn 200ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─── MOBILE TOP BAR ────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-height);
  padding: 0 16px;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  transition: background 150ms ease;
}

.hamburger:hover {
  background: var(--bg-surface);
}

.hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: background 150ms ease;
}

.hamburger:hover span {
  background: var(--text-primary);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 0.65rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #3b6fd4);
  color: #fff;
}

.topbar-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── MAIN CONTENT ──────────────────── */
.main-content {
  padding: 20px 16px 32px;
  min-height: calc(100vh - var(--topbar-height));
}

.theme-floating-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
  display: grid;
  gap: 1px;
  min-width: 108px;
  padding: 11px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--floating-toggle-bg);
  color: var(--text-primary);
  box-shadow: var(--floating-toggle-shadow);
  backdrop-filter: blur(12px);
  text-align: left;
}

.theme-floating-toggle-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.theme-floating-toggle strong {
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.theme-floating-toggle:hover {
  border-color: var(--accent);
  background: var(--bg-surface);
}

/* ═══════════════════════════════════════
   PAGES — SHARED
   ═══════════════════════════════════════ */

/* Page headings */
.page-head {
  display: grid;
  gap: 6px;
  margin-bottom: 24px;
}

.page-heading {
  margin: 0;
  font-family: "Manrope", "Sora", sans-serif;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.page-subheading {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 520px;
}

/* Reused .page-title and .page-shell */
.page-title {
  margin: 0;
  font-family: "Manrope", "Sora", sans-serif;
  letter-spacing: -0.04em;
  line-height: 1.02;
}

.page-shell {
  display: grid;
  gap: 24px;
}

.eyebrow {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.muted-copy {
  margin: 0;
  color: var(--text-secondary);
}

/* Stack utilities */
.stack-lg { display: grid; gap: 24px; }
.stack-md { display: grid; gap: 18px; }
.stack-sm { display: grid; gap: 10px; }

/* ═══════════════════════════════════════
   PANEL (generic card)
   ═══════════════════════════════════════ */
.panel {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel h3 {
  margin: 0;
  font-family: "Manrope", "Sora", sans-serif;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.compact-panel {
  padding: 18px;
}

.narrow-panel {
  max-width: 720px;
  width: 100%;
  justify-self: center;
}

/* ═══════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════ */
.button-primary,
.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid transparent;
  transition: all 180ms ease;
  cursor: pointer;
}

.button-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(91, 141, 239, 0.25);
}

.button-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(91, 141, 239, 0.3);
}

.button-secondary {
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.button-secondary:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.button-primary:disabled,
.button-secondary:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  transition: all 150ms ease;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ═══════════════════════════════════════
   DASHBOARD PAGE
   ═══════════════════════════════════════ */
.dashboard-page {
  max-width: 720px;
}

.tool-grid {
  display: grid;
  gap: 12px;
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  text-decoration: none;
  transition: all 200ms var(--ease-out);
}

.tool-card:hover {
  border-color: var(--accent);
  background: var(--bg-surface-hover);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-md);
}

.tool-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
}

.tool-card-icon svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.tool-card-body {
  flex: 1;
  min-width: 0;
}

.tool-card-body strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.tool-card-body p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.tool-card-arrow {
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: color 150ms ease, transform 150ms ease;
}

.tool-card-arrow svg {
  width: 18px;
  height: 18px;
}

.tool-card:hover .tool-card-arrow {
  color: var(--accent);
  transform: translateX(2px);
}

/* ═══════════════════════════════════════
   INVENTORY PAGE
   ═══════════════════════════════════════ */
.inventory-layout {
  display: grid;
  gap: 18px;
}

.inventory-sidebar-panel,
.inventory-main-panel {
  min-width: 0;
}

.inventory-create-form {
  display: grid;
  gap: 12px;
}

.inventory-create-inline {
  align-items: end;
}

.inventory-snapshot-form,
.inventory-consumption-filter {
  display: grid;
  gap: 12px;
}

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

.inventory-mode-actions .button-secondary.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text-primary);
}

.inventory-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.inventory-section-head strong {
  display: block;
  color: var(--text-primary);
  font-size: 0.96rem;
  font-weight: 700;
}

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

.inventory-warehouse-list,
.inventory-item-list,
.inventory-snapshot-list {
  display: grid;
  gap: 12px;
}

.inventory-warehouse-card,
.inventory-snapshot-card,
.inventory-item-card,
.inventory-lot-chip,
.inventory-selected-product {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
}

.inventory-warehouse-card {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  color: var(--text-secondary);
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.inventory-warehouse-card strong,
.inventory-snapshot-card strong,
.inventory-item-card strong,
.inventory-selected-product strong,
.inventory-lot-chip strong {
  color: var(--text-primary);
}

.inventory-warehouse-card span,
.inventory-snapshot-card span,
.inventory-item-card span,
.inventory-warehouse-meta span,
.inventory-selected-product span,
.inventory-product-option span,
.inventory-lot-chip span {
  color: var(--text-secondary);
}

.inventory-warehouse-card small,
.inventory-snapshot-card small,
.inventory-warehouse-meta small,
.inventory-product-option small,
.inventory-lot-chip small {
  color: var(--text-tertiary);
}

.inventory-warehouse-card:hover,
.inventory-warehouse-card.is-active {
  border-color: var(--accent);
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.inventory-snapshot-card {
  display: grid;
  gap: 3px;
  padding: 14px 16px;
}

.inventory-snapshot-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(91, 141, 239, 0.25);
}

.inventory-warehouse-meta {
  display: grid;
  gap: 2px;
  justify-items: end;
  text-align: right;
}

.inventory-history-actions {
  display: flex;
  justify-content: flex-start;
}

.inventory-session-button {
  width: 100%;
  text-align: left;
}

.inventory-operation-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inventory-operation-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.inventory-operation-button:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.inventory-operation-button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text-primary);
}

.inventory-stock-form {
  display: grid;
  gap: 12px;
}

.inventory-stock-grid {
  display: grid;
  gap: 12px;
}

.inventory-product-search {
  position: relative;
}

.inventory-product-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 6;
  display: grid;
  gap: 8px;
  max-height: 320px;
  padding: 10px;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
}

.inventory-product-empty {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.84rem;
}

.inventory-product-option {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease;
}

.inventory-product-option:hover {
  border-color: var(--accent);
  background: var(--bg-surface-hover);
}

.inventory-stock-submit {
  display: flex;
  align-items: end;
}

.inventory-stock-submit .button-primary {
  width: 100%;
}

.inventory-selected-product {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
}

.inventory-item-card {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.inventory-item-identity {
  min-width: 0;
}

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

.inventory-item-head > div {
  display: grid;
  gap: 2px;
}

.inventory-item-total {
  justify-items: end;
  text-align: right;
}

.inventory-lot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inventory-lot-chip {
  display: grid;
  gap: 2px;
  min-width: min(240px, 100%);
  padding: 10px 12px;
}

.inventory-history-layout {
  display: grid;
  gap: 14px;
}

.inventory-history-column {
  display: grid;
  gap: 12px;
  min-width: 0;
}

/* ═══════════════════════════════════════
   ASSISTANT / CHAT PAGE
   ═══════════════════════════════════════ */
.assistant-page {
  display: flex;
  flex-direction: column;
  max-width: 800px;
  margin: 0 auto;
}

.assistant-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.chat-container {
  display: flex;
  flex-direction: column;
}

.chat-container.has-thread {
  min-height: min(72vh, 780px);
}

/* Empty state */
.chat-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 16px 24px;
  text-align: center;
}

.chat-empty strong {
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.05em;
  background: linear-gradient(180deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Thread */
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 200px;
  max-height: 58vh;
  overflow-y: auto;
  padding: 4px 0 120px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.chat-msg {
  max-width: 100%;
  width: fit-content;
  white-space: pre-wrap;
  line-height: 1.65;
}

.chat-msg p {
  margin: 0;
  white-space: pre-wrap;
  color: inherit;
}

.chat-msg-assistant {
  display: flex;
  gap: 12px;
  align-self: stretch;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.chat-msg-assistant p {
  color: var(--text-secondary);
}

.chat-msg-avatar {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding-top: 2px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.chat-msg-avatar svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.chat-msg-user {
  align-self: flex-end;
  max-width: min(100%, 32rem);
  padding: 12px 16px;
  border-radius: var(--radius-lg) var(--radius-lg) 6px var(--radius-lg);
  background: var(--accent);
  color: #fff;
}

.chat-msg-pending {
  opacity: 0.7;
}

/* Composer */
.chat-composer {
  display: grid;
  gap: 6px;
  width: 100%;
  margin: 0 auto;
}

.chat-composer.is-sticky {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: auto;
  padding: 20px 0 max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 40%);
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: var(--shadow-md);
  transition: border-color 200ms ease;
}

.chat-input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.1), var(--shadow-md);
}

.chat-input {
  width: 100%;
  min-height: 24px;
  max-height: 220px;
  padding: 8px 4px;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.92rem;
  line-height: 1.5;
}

.chat-input::placeholder {
  color: var(--text-tertiary);
}

.chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  transition: background 150ms ease, opacity 150ms ease;
}

.chat-send svg {
  width: 18px;
  height: 18px;
}

.chat-send:hover:not(:disabled) {
  background: var(--accent-hover);
}

.chat-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.chat-status {
  min-height: 1.2rem;
  margin: 0;
  color: var(--text-tertiary);
  font-size: 0.8rem;
  padding-left: 4px;
}

/* ═══════════════════════════════════════
   FORM FIELDS
   ═══════════════════════════════════════ */
.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field input,
.field select,
.field textarea,
.prompt-textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-primary);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field textarea,
.prompt-textarea {
  padding: 12px 14px;
  resize: vertical;
}

.field textarea.prompt-textarea {
  min-height: 144px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.prompt-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.1);
}

.field-helper {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

/* ═══════════════════════════════════════
   AUTH / LOGIN
   ═══════════════════════════════════════ */
.portal-frame {
  position: relative;
  min-height: 100vh;
  padding: 20px 16px;
}

.portal-background {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(91, 141, 239, 0.1), transparent 30%),
    radial-gradient(circle at 88% 20%, rgba(52, 211, 153, 0.06), transparent 25%);
  pointer-events: none;
}

:root[data-theme="light"] .portal-background {
  background:
    radial-gradient(circle at 12% 18%, rgba(47, 104, 219, 0.1), transparent 30%),
    radial-gradient(circle at 88% 20%, rgba(32, 155, 101, 0.06), transparent 25%);
}

.auth-root {
  padding-bottom: 28px;
}

.workspace-shell,
.auth-stage,
.public-page-shell {
  position: relative;
  z-index: 1;
  width: min(1280px, 100%);
  margin: 0 auto;
}

.auth-stage {
  display: grid;
  gap: 20px;
  align-items: stretch;
}

.auth-side,
.auth-card {
  position: relative;
}

.auth-side {
  display: grid;
  gap: 24px;
  padding: 12px 4px;
}

.auth-brand {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
}

.auth-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  border-radius: 12px;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--accent), #3b6fd4);
  color: #fff;
  box-shadow: 0 2px 8px rgba(91, 141, 239, 0.3);
}

.auth-brand strong {
  display: block;
  font-size: 1rem;
}

.auth-heading {
  margin: 0;
  font-family: "Manrope", "Sora", sans-serif;
  font-size: clamp(2.1rem, 6vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.02;
  max-width: 12ch;
}

.auth-copy {
  display: grid;
  gap: 14px;
}

.auth-card {
  padding: 24px;
}

.auth-form,
.documents-composer-form,
.documents-preview-meta,
.note-composer,
.form-grid {
  display: grid;
  gap: 14px;
}

.auth-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.auth-error,
.error-copy,
.inline-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.94rem;
}

.auth-note-card {
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.auth-note-card span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.auth-note-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.3rem;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.auth-note-card small {
  display: block;
  margin-top: 6px;
  color: var(--text-secondary);
}

.auth-inline-grid {
  display: grid;
  gap: 12px;
}

.auth-support-grid {
  display: grid;
  gap: 16px;
}

.checkbox-field {
  display: grid;
  gap: 12px;
  align-content: start;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

/* ═══════════════════════════════════════
   STATUS ELEMENTS
   ═══════════════════════════════════════ */
.success-banner,
.inline-error-banner {
  padding: 14px 16px;
  border-radius: var(--radius-md);
}

.success-banner {
  border: 1px solid rgba(52, 211, 153, 0.2);
  background: rgba(52, 211, 153, 0.06);
  color: #d4ffe0;
}

.inline-error-banner {
  border: 1px solid rgba(248, 113, 113, 0.2);
  background: rgba(248, 113, 113, 0.06);
  color: #ffd6db;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  font-size: 0.76rem;
  font-weight: 700;
}

.status-pill.active { color: var(--success); }
.status-pill.in-development { color: var(--warning); }
.status-pill.inactive { color: var(--text-tertiary); }

.status-banner {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.88rem;
}

.status-banner.is-success {
  background: rgba(52, 211, 153, 0.08);
  border-color: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.status-banner.is-error {
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.callout {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  background: var(--accent-soft);
}

.callout strong {
  color: var(--accent);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 700;
}

.status-chip.is-invoice { border-color: rgba(96, 165, 250, 0.2); color: #d6e7ff; }
.status-chip.is-delivery_note { border-color: rgba(244, 114, 182, 0.2); color: #ffd8ec; }
.status-chip.is-unknown { border-color: rgba(251, 191, 36, 0.2); color: #ffeab0; }
.status-chip.is-imported { border-color: rgba(52, 211, 153, 0.2); color: #d7ffe8; }
.status-chip.is-unsupported { border-color: rgba(251, 191, 36, 0.2); color: #ffeab0; }
.status-chip.is-error { border-color: rgba(248, 113, 113, 0.2); color: #ffd9d9; }

/* ═══════════════════════════════════════
   DOCUMENTS PAGE
   ═══════════════════════════════════════ */
.documents-shell {
  display: grid;
  gap: 24px;
}

.documents-intro {
  display: grid;
  gap: 18px;
}

.documents-status-grid,
.documents-workspace {
  display: grid;
  gap: 16px;
  align-items: start;
}

.documents-connection-card,
.documents-checklist {
  display: grid;
  gap: 18px;
}

.documents-account-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-direction: column;
}

.documents-account-chip {
  display: grid;
  gap: 3px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.documents-account-chip span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.documents-account-chip strong { font-size: 0.95rem; }
.documents-account-chip small { color: var(--text-secondary); }

.documents-account-actions { display: grid; gap: 12px; }

.documents-composer-head,
.documents-preview-head,
.documents-account-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.documents-submit-row .button-primary,
.preview-actions .button-primary,
.login-panel .button-primary {
  width: 100%;
}

.workflow-steps,
.documents-kind-switch {
  display: grid;
  gap: 12px;
}

.workflow-step {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
}

.workflow-step span {
  color: var(--text-tertiary);
}

.workflow-step strong { font-size: 0.92rem; }

.documents-kind-switch { width: 100%; }

.kind-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  width: 100%;
  transition: all 180ms ease;
  cursor: pointer;
}

.kind-toggle:hover { background: var(--bg-surface-hover); }

.kind-toggle.is-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.kind-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.documents-prompt-field .prompt-textarea { min-height: 180px; }

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

.preview-doc,
.preview-table-shell {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
}

.preview-doc {
  padding: 18px;
  white-space: pre-wrap;
}

.preview-table-shell { overflow: auto; }

.preview-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

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

.preview-table th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.preview-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: sticky;
  bottom: -2px;
  gap: 16px;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
}

.documents-created-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.documents-created-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.empty-state-panel {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
}

/* ═══════════════════════════════════════
   FISCAL DOCUMENTS
   ═══════════════════════════════════════ */
.fiscal-documents-actions,
.fiscal-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.fiscal-mailbox-form { display: grid; gap: 14px; }
.fiscal-mailbox-inline { display: flex; flex-wrap: wrap; gap: 12px; }

.fiscal-upload-button { position: relative; overflow: hidden; }

.fiscal-documents-workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.fiscal-document-list,
.fiscal-detail-grid,
.fiscal-next-steps-list {
  display: grid;
  gap: 12px;
}

.fiscal-document-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.fiscal-document-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-hover);
}

.fiscal-document-item.is-active {
  border-color: var(--accent);
  background: var(--bg-surface-hover);
}

.fiscal-document-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.fiscal-document-item p { color: var(--text-secondary); margin: 0; }

.fiscal-text-preview pre {
  max-height: 520px;
  overflow: auto;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
  font-size: 0.84rem;
}

.empty-state {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════
   ADMIN PAGE
   ═══════════════════════════════════════ */
.admin-shell { display: grid; gap: 24px; }

.admin-main-grid,
.admin-secondary-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.admin-tenant-list { display: grid; gap: 8px; }

.admin-tenant-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.admin-tenant-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.admin-tenant-select {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 14px;
  text-align: left;
  color: inherit;
}

.admin-tenant-select strong { font-size: 0.95rem; }
.admin-tenant-select span,
.admin-tenant-select small { color: var(--text-secondary); }

.admin-selected-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

/* ═══════════════════════════════════════
   MODULE CARDS (architecture etc.)
   ═══════════════════════════════════════ */
.module-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  align-items: start;
}

.module-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.module-card.is-enabled {
  border-color: rgba(91, 141, 239, 0.15);
}

.module-card.is-muted { opacity: 0.85; }

.module-card h3 {
  margin: 0;
  font-family: "Manrope", "Sora", sans-serif;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}

.module-summary { margin: 0; color: var(--text-secondary); }

.module-card-topline,
.module-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.module-card-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
}

.module-availability {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.module-availability.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.module-card-notes,
.summary-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--text-secondary);
}

.module-card-footer,
.module-meta-row {
  display: grid;
  gap: 12px;
}

.module-meta-row {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}

.module-meta-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.module-meta-row strong { font-size: 0.9rem; }

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

/* ═══════════════════════════════════════
   STAT / GLANCE / HIGHLIGHT CARDS
   ═══════════════════════════════════════ */
.stats-grid,
.glance-grid,
.section-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.stat-card,
.glance-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.stat-card span,
.glance-card span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.stat-card strong,
.glance-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.4rem;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.stat-card small,
.glance-card small {
  display: block;
  margin-top: 6px;
  color: var(--text-secondary);
}

.highlight-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

/* Tenant chip and status pills for landing/assistant */
.tenant-chip,
.topbar-status-pill,
.assistant-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
}

.tenant-chip {
  display: grid;
  gap: 2px;
  min-width: 210px;
  padding: 12px 14px;
}

.tenant-chip span,
.assistant-status span {
  color: var(--text-tertiary);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.tenant-chip strong,
.assistant-status strong { font-size: 0.92rem; }
.tenant-chip small { font-size: 0.82rem; color: var(--text-secondary); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: rgba(97, 116, 138, 0.6);
}

.status-dot.is-online {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.12);
}

/* ═══════════════════════════════════════
   QUICK ACTIONS / MODULE SHORTCUTS
   ═══════════════════════════════════════ */
.quick-action-grid,
.module-shortcuts,
.assistant-suggestion-list {
  display: grid;
  gap: 10px;
}

.quick-action-card,
.module-shortcut-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease;
}

.quick-action-card:hover,
.module-shortcut-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-hover);
}

.quick-action-label,
.module-shortcut-card strong {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.88rem;
}

.quick-action-meta,
.module-shortcut-card span {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.assistant-suggestion {
  text-align: left;
  min-height: 40px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════
   ACCOUNT / NOTES
   ═══════════════════════════════════════ */
.notes-list,
.summary-actions,
.history-actions,
.supplier-actions {
  display: grid;
  gap: 12px;
}

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

/* ═══════════════════════════════════════
   PUBLIC PAGES (legal, privacy, terms)
   ═══════════════════════════════════════ */
.public-page-shell {
  padding: 32px 0 52px;
}

.public-legal-card {
  display: grid;
  gap: 24px;
  max-width: 860px;
  margin: 0 auto;
  padding: 24px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.public-legal-card p { margin: 0; color: var(--text-secondary); }

.public-legal-head,
.public-legal-section {
  display: grid;
  gap: 10px;
}

.public-legal-head h1 {
  margin: 0;
  font-family: "Manrope", "Sora", sans-serif;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.02;
}

.public-legal-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  color: var(--text-secondary);
}

.public-legal-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

/* ═══════════════════════════════════════
   NOT FOUND / LOGIN
   ═══════════════════════════════════════ */
.not-found,
.login-panel {
  margin-top: 20px;
}

/* ═══════════════════════════════════════
   HEADER — used in older layout, kept for compat
   ═══════════════════════════════════════ */
.workspace-header {
  display: none;
}

.workspace-title {
  margin: 0;
  font-family: "Manrope", "Sora", sans-serif;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.workspace-kicker {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.workspace-context { display: grid; gap: 6px; }

.workspace-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.workspace-summary { margin: 0; color: var(--text-secondary); }

/* ═══════════════════════════════════════
   MISC / UTILITIES
   ═══════════════════════════════════════ */
.section-copy {
  display: grid;
  gap: 10px;
}

.page-intro,
.command-intro {
  display: grid;
  gap: 18px;
}

.command-shell {
  display: grid;
  gap: 16px;
}

.command-shell .compact-panel {
  gap: 20px;
  margin-top: 0;
  padding: 18px;
}

.command-shell .compact-panel .section-copy { gap: 14px; }

.conversation-panel,
.documents-preview-panel {
  display: grid;
}

.tools-shell { display: grid; gap: 24px; }

/* Header action — compat for old header buttons */
.header-action { display: none; }

/* Admin / Account layout */
.admin-layout {
  display: grid;
  gap: 16px;
}

/* Mock form (used in AccountPage, LoginPage) */
.mock-form {
  display: grid;
  gap: 18px;
}

.timeclock-action-row {
  display: grid;
  gap: 14px;
  align-items: stretch;
}

.timeclock-main-button {
  min-height: 64px;
  font-size: 1rem;
}

.timeclock-main-button.stop {
  background: #b91c1c;
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.22);
}

.timeclock-main-button.stop:hover {
  background: #991b1b;
  box-shadow: 0 4px 16px rgba(153, 27, 27, 0.28);
}

.timeclock-live-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
}

.timeclock-live-card strong {
  font-size: 1.5rem;
  letter-spacing: -0.04em;
}

.timeclock-live-card span {
  color: var(--text-secondary);
}

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

.timeclock-entry-list {
  display: grid;
  gap: 12px;
}

.timeclock-entry-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
}

.timeclock-entry-main,
.timeclock-entry-meta {
  display: grid;
  gap: 4px;
}

.timeclock-entry-main span,
.timeclock-entry-meta span {
  color: var(--text-secondary);
}

/* Fiscal documents page */
.fiscal-documents-shell { display: grid; gap: 24px; }
.fiscal-documents-hero { display: grid; gap: 12px; }
.fiscal-documents-stats { display: grid; gap: 12px; }
.fiscal-document-detail { display: grid; gap: 16px; }
.fiscal-inbox-card { display: grid; gap: 16px; }
.fiscal-mailbox-card { display: grid; gap: 16px; }

/* Documents toolbar */
.documents-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.documents-toolbar-copy { display: grid; gap: 6px; }
.documents-toolbar-side { display: flex; gap: 10px; }

/* Mobile nav — disabled in new layout */
.mobile-nav { display: none; }
.more-sheet-backdrop { display: none; }

/* ═══════════════════════════════════════
   RESPONSIVE — TABLET (≥720px)
   ═══════════════════════════════════════ */
@media (min-width: 720px) {
  .main-content {
    padding: 24px 28px 40px;
  }

  .auth-stage,
  .documents-status-grid,
  .documents-workspace,
  .admin-secondary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workflow-steps,
  .glance-grid,
  .auth-support-grid,
  .section-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeclock-action-row { grid-template-columns: minmax(260px, 340px) 1fr; }

  .assistant-suggestion-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .documents-preview-meta,
  .auth-inline-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .documents-kind-switch {
    width: auto;
    grid-template-columns: repeat(2, minmax(0, max-content));
  }

  .documents-account-actions {
    grid-template-columns: repeat(2, minmax(0, max-content));
  }

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

  .fiscal-documents-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .fiscal-documents-workspace {
    grid-template-columns: minmax(260px, 0.82fr) minmax(0, 1.18fr);
  }

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

  .inventory-layout {
    grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr);
    align-items: start;
  }

  .inventory-snapshot-form,
  .inventory-consumption-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }

  .inventory-create-inline {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .inventory-stock-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(160px, 0.5fr) minmax(220px, 0.6fr);
    align-items: end;
  }

  .inventory-history-layout {
    grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.28fr);
    align-items: start;
  }
}

/* ═══════════════════════════════════════
   RESPONSIVE — DESKTOP (≥1040px)
   ═══════════════════════════════════════ */
@media (min-width: 1040px) {
  /* Sidebar always visible */
  .sidebar {
    transform: translateX(0);
  }

  .sidebar-close {
    display: none;
  }

  .sidebar-backdrop {
    display: none !important;
  }

  /* Hide mobile top bar */
  .topbar {
    display: none;
  }

  /* Main content offset by sidebar */
  .main-content {
    margin-left: var(--sidebar-width);
    padding: 32px 40px 48px;
    min-height: 100vh;
  }

  .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .admin-main-grid {
    grid-template-columns: minmax(280px, 0.84fr) minmax(0, 1.16fr);
  }
}

/* ═══════════════════════════════════════
   RESPONSIVE — SMALL MOBILE (≤719px)
   ═══════════════════════════════════════ */
@media (max-width: 719px) {
  .panel { padding: 16px; }

  .chat-empty {
    padding: 32px 12px 16px;
  }

  .chat-empty strong {
    font-size: clamp(2rem, 11vw, 3rem);
  }

  .chat-thread {
    padding-bottom: 100px;
  }

  .chat-input-row {
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--radius-lg);
  }

  .chat-send {
    width: 36px;
    height: 36px;
  }

  .panel-heading,
  .documents-composer-head,
  .documents-preview-head,
  .documents-account-bar,
  .public-legal-actions,
  .admin-selected-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .workspace-meta { display: grid; }

  .tenant-chip,
  .topbar-status-pill,
  .assistant-status {
    width: 100%;
  }

  .fiscal-documents-workspace { grid-template-columns: 1fr; }
  .fiscal-document-item-head { flex-direction: column; }
  .fiscal-filter-row,
  .fiscal-documents-actions,
  .fiscal-mailbox-inline { display: grid; }
  .inventory-mode-actions,
  .inventory-section-head,
  .inventory-operation-switch { display: grid; }
  .inventory-inline-filter { min-width: 0; }
  .inventory-item-head { flex-direction: column; }
  .inventory-item-total,
  .inventory-warehouse-meta { justify-items: start; text-align: left; }
}
