:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #059669;
  --success-light: #ecfdf5;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --teal: #0d9488;
  --teal-light: #f0fdfa;
  --cyan: #0891b2;
  --cyan-light: #ecfeff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.06);
  --sidebar-w: 270px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.85rem;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
  box-shadow: 2px 0 12px rgba(15, 23, 42, 0.04);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.15rem 0.35rem 1.15rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar__logo {
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 58px;
  height: 48px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 30% 25%, #fff 0%, transparent 55%),
    linear-gradient(160deg, #ecfdf5, #f0fdf4 45%, #e2e8f0);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    0 4px 12px rgba(15, 23, 42, 0.1);
}
.logo-battery {
  display: block;
  width: 52px;
  height: auto;
  max-height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.22));
  transform: translateY(1px);
}
.sidebar__brand-text { min-width: 0; }
.brand-title {
  display: block;
  font-size: 0.98rem;
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--text);
  font-weight: 800;
}
.brand-title__nek {
  color: #15803d;
  letter-spacing: 0.04em;
}
.brand-title__dash {
  color: #94a3b8;
  margin: 0 0.05em;
  font-weight: 700;
}
.brand-title__inn {
  color: #0f172a;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.sidebar__sub {
  display: block;
  margin-top: 0.18rem;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* Roles removed — kept minimal for legacy */
.role-switch { display: none !important; }

.role-switch__label {
  margin: 0 0 0.5rem 0.35rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
}

.role-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.role-btn:hover { color: var(--text); border-color: var(--primary); background: var(--primary-light); }
.role-btn--active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.role-badge {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
}

.role-badge--warehouse { border-color: #93c5fd; color: #1d4ed8; background: #eff6ff; }
.role-badge--sorting_primary { border-color: #5eead4; color: #0f766e; background: #f0fdfa; }
.role-badge--sorting_secondary { border-color: #67e8f9; color: #0e7490; background: #ecfeff; }
.role-badge--crushing { border-color: #fcd34d; color: #b45309; background: #fffbeb; }
.role-badge--supervisor { border-color: #c4b5fd; color: #6d28d9; background: #f5f3ff; }

.sync-status {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  margin-bottom: 0.35rem;
  text-align: center;
}

.sync-box { margin-bottom: 0.85rem; }
.sync-detail {
  margin: 0 0 0.45rem;
  padding: 0 0.2rem;
  font-size: 0.7rem;
  line-height: 1.35;
  color: #b91c1c;
  text-align: left;
}
.sync-detail[hidden] { display: none !important; }

.sync-status--local { background: #f1f5f9; color: #64748b; }
.sync-status--online { background: #ecfdf5; color: #047857; }
.sync-status--error { background: #fef2f2; color: #dc2626; }

[hidden] { display: none !important; }

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.report-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.report-panel__head h2 { margin: 0; }
.report-date { color: var(--muted); margin: 0 0 1rem; }
.report-body h3 { margin: 1.25rem 0 0.5rem; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.report-big { font-size: 2.5rem; font-weight: 800; color: var(--primary); margin: 0.25rem 0; }
.report-big small { font-size: 1rem; color: var(--muted); font-weight: 600; }

.print-only { display: none; }

@media print {
  body.printing * { visibility: hidden; }
  body.printing .print-only,
  body.printing .print-only * { visibility: visible; }
  body.printing .print-only {
    display: block;
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    padding: 2rem;
  }
  .print-sheet h1 { margin: 0 0 1rem; }
  .print-footer { margin-top: 2rem; font-size: 0.85rem; color: #666; }
}

.topbar__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.15s;
}

.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn--active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-btn__icon { font-size: 1.05rem; }
.nav-btn[hidden] { display: none; }

.sidebar__footer {
  padding: 0.75rem 0.35rem 0;
  border-top: 1px solid var(--border);
}

.sidebar__date { font-size: 0.78rem; color: var(--muted); }

/* Main */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 1.5rem 2rem 2.5rem;
  max-width: 1440px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar h1 { margin: 0; font-size: 1.45rem; font-weight: 700; color: var(--text); }
.topbar__sub { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.88rem; }
.topbar__stats { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.stat-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.stat-pill strong { color: var(--primary); }

.view { display: none; }
.view--active { display: block; }

/* Cards & panels */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card h3, .panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.panel__hint {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.panel__head h2 { margin: 0; }

/* ——— Dashboard ——— */
.dash-hero {
  position: relative;
  margin: 0 0 1rem;
  padding: 1rem 1.15rem 1.15rem;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(900px 280px at 8% -20%, rgba(37, 99, 235, 0.12), transparent 55%),
    radial-gradient(700px 240px at 92% 0%, rgba(13, 148, 136, 0.1), transparent 50%),
    linear-gradient(145deg, #ffffff 0%, #f5f8fb 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.dash-hero__eyebrow {
  display: none;
}
.dash-hero__title {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.dash-hero__lead {
  margin: 0.2rem 0 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 36rem;
}
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}
@media (max-width: 1100px) {
  .dash-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .dash-kpis { grid-template-columns: 1fr; }
}
.dash-kpi {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  display: grid;
  gap: 0.25rem;
  border-top: 3px solid var(--primary);
}
.dash-kpi:hover {
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}
.dash-kpi--wh { border-top-color: var(--primary); }
.dash-kpi--primary { border-top-color: var(--teal); }
.dash-kpi--secondary { border-top-color: var(--cyan); }
.dash-kpi--crush { border-top-color: var(--warning); }
.dash-kpi--furnace { border-top-color: var(--danger); }
.dash-kpi__label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.dash-kpi__flow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.dash-kpi__pair {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}
.dash-kpi__sub {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.dash-kpi__value {
  font-size: clamp(1.25rem, 2.2vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}
.dash-kpi__value--sm {
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
}
.dash-kpi__value small {
  margin-left: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}
.dash-kpi__meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.dash-flow-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.35rem 0.25rem;
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  background: linear-gradient(135deg, #f8fafc, #eef6ff 55%, #f0fdf4);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.dash-flow-strip__item {
  flex: 1 1 7.5rem;
  min-width: 6.5rem;
  display: grid;
  gap: 0.1rem;
  padding: 0.35rem 0.45rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}
.dash-flow-strip__item--accent {
  background: rgba(13, 148, 136, 0.1);
  box-shadow: inset 0 0 0 1px rgba(13, 148, 136, 0.2);
}
.dash-flow-strip__lab {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.dash-flow-strip__item strong {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.dash-flow-strip__item em {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--muted);
}
.dash-flow-strip__arrow {
  align-self: center;
  color: #94a3b8;
  font-weight: 700;
  padding: 0 0.1rem;
}

.dash-charts {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: 1rem;
  margin: 0 0 1.25rem;
}
.dash-chart-card--wide {
  /* на узких экранах выработка сверху на всю ширину — см. media */
}
@media (max-width: 1100px) {
  .dash-charts { grid-template-columns: 1fr; }
  .dash-chart-card--wide { order: -1; }
}
.dash-chart-card {
  margin: 0;
  padding: 1rem 1.1rem 1.15rem;
  min-height: 280px;
}
.dash-chart-card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.dash-chart-card__head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.dash-chart-card__hint {
  font-size: 0.75rem;
  color: var(--muted);
}
.dash-chart { min-height: 200px; }
.dash-chart--split {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.75rem;
  align-items: center;
}
@media (max-width: 500px) {
  .dash-chart--split { grid-template-columns: 1fr; }
}
.dash-donut-wrap {
  display: flex;
  justify-content: center;
}
.dash-donut-wrap svg { width: 132px; height: 132px; }

.dash-hbar {
  display: grid;
  gap: 0.65rem;
}
.dash-hbar__row {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  gap: 0.55rem;
  align-items: center;
}
@media (max-width: 500px) {
  .dash-hbar__row { grid-template-columns: 5.5rem 1fr; }
  .dash-hbar__val { grid-column: 2; justify-self: end; font-size: 0.78rem; }
}
.dash-hbar__label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-hbar__track {
  height: 12px;
  border-radius: 999px;
  background: #e8eef5;
  overflow: hidden;
}
.dash-hbar__fill {
  height: 100%;
  border-radius: inherit;
  width: 0;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.dash-hbar__val {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  min-width: 4.5rem;
  text-align: right;
}
.dash-chart__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  color: var(--muted);
  font-size: 0.9rem;
}

.dash-bottom {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.dash-bottom--secondary .panel {
  background: #fafbfc;
  border-style: dashed;
}
.dash-priority {
  margin: 0 0 1rem;
  border: 1px solid #bfdbfe;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.08);
  background: linear-gradient(180deg, #f8fbff 0%, #fff 55%);
}
.dash-priority h2 { font-size: 1.15rem; }
@media (max-width: 900px) {
  .dash-bottom,
  .dash-bottom--secondary { grid-template-columns: 1fr; }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.dashboard-simple {
  display: none;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.dash-card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}

.dash-card__big {
  margin: 0;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}

.dash-card__big small { font-size: 1rem; color: var(--muted); font-weight: 500; }

.dash-card__lead {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--cyan);
  line-height: 1.2;
}

.dash-card__sub {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.dash-card__hint {
  margin: 0.5rem 0 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dash-types {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.dash-types li {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.dash-types li:last-child { border-bottom: none; }
.dash-types__empty { color: var(--muted); font-size: 0.85rem; justify-content: center; }

.dash-card--warehouse { border-left: 4px solid var(--primary); }
.dash-card--primary { border-left: 4px solid var(--teal); }
.dash-card--secondary { border-left: 4px solid var(--cyan); }
.dash-card--crush { border-left: 4px solid var(--warning); }

.card--wide { grid-column: 1 / -1; }

.metric-row { display: flex; gap: 1.5rem; }

.metric__val {
  display: block;
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}

.metric__lbl { font-size: 0.78rem; color: var(--muted); }

/* Flow map */
.flow-map {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  box-shadow: var(--shadow);
}

.flow-section { margin-bottom: 1.25rem; }
.flow-section:last-child { margin-bottom: 0; }

.flow-section__title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.65rem;
  font-weight: 600;
}

.flow-nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.flow-node {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  min-width: 105px;
  text-align: center;
}

.flow-node__icon { font-size: 1.2rem; display: block; margin-bottom: 0.2rem; }
.flow-node__name { font-size: 0.75rem; font-weight: 600; color: var(--text); }
.flow-node__count { font-size: 1rem; font-weight: 700; color: var(--primary); margin-top: 0.2rem; }
.flow-arrow { color: var(--border-strong); font-size: 1.1rem; }

/* Warehouse */
.warehouse-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 960px) {
  .warehouse-layout { grid-template-columns: 1fr; }
}

.receive-form { display: flex; flex-direction: column; gap: 0.65rem; }

.excel-import {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.excel-import h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.excel-import__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.6rem 0;
}

.excel-file-btn { cursor: pointer; }

.excel-preview {
  margin: 0.75rem 0;
  font-size: 0.88rem;
}

.excel-preview__table-wrap {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.excel-preview__errors {
  margin-top: 0.5rem;
  color: #b91c1c;
}

.request-chip__kind {
  display: inline-block;
  margin-right: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.field { display: flex; flex-direction: column; gap: 0.25rem; }
.field__label { font-size: 0.78rem; font-weight: 600; color: var(--muted); }

.zones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.zone-card, .utilization-card {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  min-height: 110px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.zone-card--target, .utilization-card.zone-card--target {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  cursor: pointer;
}

.utilization-card {
  background: var(--success-light);
  border-color: #6ee7b7;
}

.utilization-card__head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
}

.utilization-card__badge {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--success);
  color: #fff;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.zone-card__head, .utilization-card__head, .zone-card__toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  width: 100%;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.25rem;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
}

.zone-card__chev, .intake-card__chev {
  color: var(--muted);
  width: 1rem;
  flex: 0 0 auto;
}

.zone-card__meta {
  margin-left: auto;
  margin-bottom: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.zone-card__meta strong { color: var(--primary); }

.zone-card__items {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.zone-empty {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
}

.input--area {
  min-height: 4.5rem;
  resize: vertical;
  font-family: inherit;
}

.field__hint { color: var(--muted); font-weight: 400; }

.numbers-tools {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.numbers-tools__count {
  font-size: 0.82rem;
  color: var(--muted);
}

.intake-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.intake-card--selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.intake-card__summary {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 0.15rem 0.45rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.intake-card__chev {
  grid-row: 1 / span 2;
  align-self: center;
}

.intake-card__main {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

.intake-card__driver { font-size: 0.95rem; }
.intake-card__weight { font-weight: 700; color: var(--primary); white-space: nowrap; }
.intake-card__sub { grid-column: 2; font-size: 0.78rem; color: var(--muted); }

.intake-card__body {
  padding: 0 0.75rem 0.7rem 1.9rem;
  font-size: 0.86rem;
  border-top: 1px dashed var(--border);
}

.intake-card__body p { margin: 0.35rem 0; }

.intake-card__actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.intake-card__top {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
}

.intake-card__top .intake-card__summary { flex: 1; }

.intake-card__qr-btn {
  align-self: center;
  margin-right: 0.4rem;
  flex: 0 0 auto;
}

.box-scan {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--border);
}

.box-scan h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.qr-label__hint {
  margin: 0.35rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.modal__content--qr { text-align: center; max-width: 28rem; }
.qr-canvas {
  margin: 0.75rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 300px;
  height: 300px;
  background: #fff;
}
.qr-canvas canvas,
.qr-canvas img,
.qr-canvas table {
  display: block;
  width: 300px !important;
  height: 300px !important;
  max-width: 100%;
}
.qr-text {
  text-align: left;
  font-size: 0.78rem;
  background: var(--surface, #f8fafc);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem;
  white-space: pre-wrap;
  max-height: 10rem;
  overflow: auto;
}

@media print {
  .no-print { display: none !important; }
  body * { visibility: hidden !important; }
  #qrModal, #qrModal *, .qr-label, .qr-label * { visibility: visible !important; }
  #qrModal {
    position: fixed !important;
    inset: 0 !important;
    background: #fff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 0 !important;
    padding: 0 !important;
    max-width: none !important;
  }
  .qr-label {
    text-align: center;
    padding: 1rem;
  }
  .qr-canvas { width: 70mm !important; height: 70mm !important; }
}

.request-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.request-chip__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.2;
}

.split-remain {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0.25rem 0 0.75rem;
}

.request-chip:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.request-chip--selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.request-chip--util { border-color: #6ee7b7; }
.request-chip--util:hover { background: var(--success-light); }

.request-chip__num { font-weight: 700; color: var(--text); }
.request-chip__wt { font-size: 0.7rem; color: var(--muted); }

.move-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--primary-light);
  border: 1px solid #93c5fd;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
}

/* Sorting */
.sorting-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.25rem;
}

.section-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--teal-light);
  color: var(--teal);
  border: 1px solid #99f6e4;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.section-badge--blue {
  background: var(--cyan-light);
  color: var(--cyan);
  border-color: #a5f3fc;
}

.panel--primary-sort { border-top: 4px solid var(--teal); }

.primary-stock {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin: 0 0 0.85rem;
  display: grid;
  gap: 0.35rem;
}
.primary-stock__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.95rem;
}
.primary-stock__row strong {
  font-size: 1.25rem;
  color: #047857;
}
.primary-stock__row--muted {
  color: #64748b;
  font-size: 0.88rem;
}
.primary-stock__row--muted strong {
  font-size: 1rem;
  color: #b45309;
}

.primary-accept {
  margin: 0 0 1rem;
  padding: 0.75rem;
  border: 1px dashed #f59e0b;
  border-radius: 10px;
  background: #fffbeb;
}
.primary-accept__title {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
}
.primary-accept__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}
.primary-accept__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #fff;
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  border: 1px solid #fde68a;
}
.primary-accept__info {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}
.primary-accept__info span {
  font-size: 0.85rem;
  color: #64748b;
}

.intake-card--pending {
  border-color: #f59e0b;
  background: #fffbeb;
}
.intake-card__badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: #f59e0b;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: middle;
}
.intake-card__warn {
  color: #b45309;
  font-weight: 600;
}
.panel--secondary-sort { border-top: 4px solid var(--cyan); }

.entry-log {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
}

.entry-log li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
}

.entry-log li:last-child { border-bottom: none; }
.entry-log time { color: var(--muted); font-size: 0.75rem; flex-shrink: 0; }
.entry-log__empty { color: var(--muted); font-style: italic; justify-content: center !important; }

.day-summary {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: var(--teal-light);
  border: 1px solid #99f6e4;
  border-radius: 10px;
}

.day-summary--blue { background: var(--cyan-light); border-color: #a5f3fc; }
.day-summary--compact { margin-top: 0.5rem; background: var(--surface2); border-color: var(--border); }

.day-summary__label {
  font-size: 0.85rem;
  color: var(--muted);
  flex: 1;
}

.day-summary__value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--teal);
  line-height: 1;
}

.day-summary--blue .day-summary__value { color: var(--cyan); }
.day-summary--compact .day-summary__value { color: var(--success); font-size: 1.6rem; }

.day-summary__unit {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

/* Production */
.production-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}

.inline-form, .shift-form {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.period-totals {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface-2, #f8fafc);
  border-radius: var(--radius, 10px);
  border: 1px solid var(--border, #e2e8f0);
}

.period-totals--blue { background: #eff6ff; border-color: #bfdbfe; }
.period-totals--compact { padding: 0.55rem 0.75rem; font-size: 0.9rem; }

.period-totals__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.period-totals__row strong {
  color: var(--text);
  font-size: 1.05rem;
}

.period-totals__row--accent strong { color: var(--primary); font-size: 1.15rem; }

.entry-log__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.entry-log__actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.entry-del-btn {
  border: none;
  background: transparent;
  color: var(--danger, #dc2626);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.entry-del-btn:hover { background: #fee2e2; }

.crusher-outputs-grid {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.secondary-types-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.secondary-type-field {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) 7rem;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.secondary-type-field--active {
  border-color: var(--cyan, #0891b2);
  box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.15);
}

.secondary-type-field .field__label {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0;
}

.secondary-batch-form .btn { width: 100%; }

@media (min-width: 640px) {
  .secondary-types-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.crusher-output-field .field__label { font-size: 0.82rem; }

.crusher-output-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.panel--crusher { border-top: 4px solid var(--warning); }
.panel--furnace { border-top: 4px solid var(--danger); }
.panel--accumulator { border-top: 4px solid #64748b; }
.panel--accumulator-page {
  max-width: 36rem;
}

.route-stocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  margin: 0 0 0.85rem;
}
.route-stocks__item {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  display: grid;
  gap: 0.15rem;
  font-size: 0.82rem;
  color: #0369a1;
}
.route-stocks__item strong {
  font-size: 1.05rem;
  color: #0c4a6e;
}

.crusher-feed {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin: 0 0 1rem;
  display: grid;
  gap: 0.4rem;
}
.crusher-feed__row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.92rem;
}
.crusher-feed__row--buffer { color: #92400e; }
.crusher-zinc-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}
.crusher-zinc-actions .input { max-width: 8rem; }

.accumulator-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.accumulator-list__item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.65rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.flow-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.75rem;
  padding: 0.85rem;
  color: var(--muted);
  font-size: 0.82rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.flow-connector__line { width: 36px; height: 2px; background: var(--border-strong); }

/* Forms */
.input {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
  min-width: 0;
  flex: 1;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input--lg { font-size: 1.15rem; padding: 0.75rem 1rem; text-align: center; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); }
.btn--success { background: var(--success); color: #fff; }
.btn--success:hover { background: #047857; }
.btn--warning { background: var(--warning); color: #fff; }
.btn--warning:hover { background: #b45309; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #b91c1c; }
.btn--ghost { background: var(--surface); color: var(--muted); border: 1px solid var(--border-strong); }
.btn--ghost:hover { color: var(--text); background: var(--surface2); }
.btn--lg { padding: 0.75rem 1.25rem; font-size: 0.95rem; }
.btn--sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; }

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.data-table th, .data-table td {
  padding: 0.5rem 0.45rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th { color: var(--muted); font-weight: 600; font-size: 0.78rem; }
.data-table tbody tr:hover { background: var(--surface2); }

/* Lists */
.activity-list, .journal-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-list li, .journal-list li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.activity-list li:last-child, .journal-list li:last-child { border-bottom: none; }
.activity-list time, .journal-list time { color: var(--muted); font-size: 0.78rem; flex-shrink: 0; }

/* Toast */
.toast {
  margin-top: 0.65rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.84rem;
}

.toast--success { background: var(--success-light); border: 1px solid #6ee7b7; color: var(--success); }
.toast--error { background: var(--danger-light); border: 1px solid #fca5a5; color: var(--danger); }

/* Modal */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
  max-width: 420px;
  width: calc(100% - 2rem);
}

.modal::backdrop { background: rgba(15, 23, 42, 0.4); }
.modal__content { padding: 1.5rem; }
.modal__content h3 { margin: 0 0 1rem; font-size: 1.1rem; }

.modal__details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 1.25rem;
  font-size: 0.88rem;
}

.modal__details div { display: contents; }
.modal__details dt { color: var(--muted); font-weight: 600; }
.modal__details dd { margin: 0; color: var(--text); }

.modal__actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

/* User block */
.user-block {
  padding: 0 0.15rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.user-block__label {
  margin: 0 0 0.35rem 0.35rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.user-block__info {
  padding: 0.5rem 0.6rem;
  background: var(--surface2);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.user-block__info strong { display: block; font-size: 0.9rem; }
.user-block__info span { font-size: 0.75rem; color: var(--muted); }

.btn--block { width: 100%; justify-content: center; }

.apk-download {
  display: block;
  margin-top: 0.55rem;
  padding: 0.45rem 0.6rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent, #2563eb);
  text-decoration: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface2);
}
.apk-download:hover { border-color: var(--accent, #2563eb); background: #eff6ff; }
.apk-download--auth {
  margin: 0.75rem 0 0.5rem;
  text-align: left;
}

/* Period filter */
.period-filter {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.input--sm {
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  min-width: 0;
}

.input--area {
  resize: vertical;
  min-height: 4rem;
  font-family: inherit;
}

.panel__hint {
  margin: -0.25rem 0 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

/* Auth modal */
.modal--auth { max-width: 380px; }

.auth-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.auth-tab {
  flex: 1;
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  cursor: pointer;
  font-size: 0.85rem;
}

.auth-tab--active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.auth-form { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 0.75rem; }

.auth-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

/* Accounting */
.accounting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.account-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.account-card__label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.account-card__val { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.account-card__sub { font-size: 0.82rem; color: var(--muted); }
.account-card--blue { border-color: #93c5fd; background: var(--primary-light); }
.account-card--red { border-color: #fca5a5; background: var(--danger-light); }
.account-card--green { border-color: #6ee7b7; background: var(--success-light); }
.account-card--orange { border-color: #fcd34d; background: var(--warning-light); }

/* Faults */
.faults-layout {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 340px);
  gap: 1rem;
  align-items: start;
}

.panel--downtime-analytics {
  margin-bottom: 1rem;
}

.downtime-summary { margin: 0.5rem 0 1rem; }

.downtime-kpi {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.downtime-kpi__item {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border, #d8dee6);
  border-radius: 8px;
  background: var(--panel, #fff);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.downtime-kpi__lab {
  font-size: 0.78rem;
  color: var(--muted);
}

.downtime-kpi__item strong { font-size: 1.15rem; }
.downtime-kpi__item small { color: var(--muted); font-size: 0.75rem; }

.downtime-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.downtime-list { list-style: none; margin: 0; padding: 0; }
.downtime-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border, #e8edf3);
}
.downtime-row em {
  grid-column: 1 / -1;
  font-style: normal;
  font-size: 0.78rem;
  color: var(--muted);
}

.tools-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1rem;
  align-items: start;
}

.tools-form { display: flex; flex-direction: column; gap: 0.75rem; }
.tools-list { list-style: none; margin: 0; padding: 0; }
.tools-item {
  padding: 0.85rem;
  border: 1px solid var(--border, #d8dee6);
  border-radius: 8px;
  margin-bottom: 0.65rem;
  background: var(--panel, #fff);
}
.tools-item__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.tools-item__qty { margin-left: auto; font-weight: 700; }
.tools-item__note { margin: 0 0 0.35rem; font-size: 0.88rem; color: var(--muted); }
.tools-item__meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.5rem; }
.tools-item__inv { margin: 0 0 0.35rem; font-size: 0.9rem; }
.tools-upd { margin: 0.5rem 0; padding: 0.5rem 0; border-top: 1px solid var(--border, #e5e7eb); }
.tools-upd__title { font-size: 0.78rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--muted); }
.tools-upd__list { list-style: none; margin: 0 0 0.5rem; padding: 0; }
.tools-upd__item { display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; margin-bottom: 0.25rem; }
.tools-upd__link { color: var(--accent, #2563eb); }
.tools-upd__upload { display: inline-flex; cursor: pointer; margin-top: 0.25rem; }

@media (max-width: 900px) {
  .downtime-kpi { grid-template-columns: 1fr 1fr; }
  .downtime-grid, .tools-layout { grid-template-columns: 1fr; }
}

.panel--fault-history { min-width: 0; }

.fault-count {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.9rem;
}

.fault-form { display: flex; flex-direction: column; gap: 0.75rem; }

.fault-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.fault-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius);
  padding: 0.85rem;
}

.fault-item__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.fault-item__downtime {
  font-size: 0.78rem;
  color: var(--danger);
  font-weight: 600;
  white-space: nowrap;
}

.fault-item__desc { margin: 0 0 0.35rem; font-size: 0.9rem; }
.fault-item__cause { margin: 0 0 0.35rem; font-size: 0.85rem; color: var(--muted); }
.fault-item__meta { font-size: 0.78rem; color: var(--muted); }

.period-range {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.period-range__field {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.period-range__label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: lowercase;
}
.period-range__sep { color: var(--muted); font-size: 0.85rem; }
.demo-accounts {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
}

.demo-accounts__title {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1e40af;
}

.demo-accounts__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.demo-account-btn {
  width: 100%;
  text-align: left;
  border: 1px solid #93c5fd;
  background: #fff;
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.demo-account-btn:hover { border-color: #2563eb; background: #dbeafe; }
.demo-account-btn strong { font-size: 0.88rem; }
.demo-account-btn span { font-size: 0.75rem; color: var(--muted); }
.demo-account-btn code {
  font-family: ui-monospace, monospace;
  background: #e2e8f0;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  color: var(--text);
}

.shift-bar, .line-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  padding: 0.55rem 0.7rem;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.shift-bar__status, .line-controls__status {
  flex: 1;
  min-width: 140px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.shift-bar__status--open, .line-controls__status--run { color: #059669; }

.mix-hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted, #64748b);
  line-height: 1.35;
}
.line-controls__status--stop { color: #dc2626; }

.lines-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.line-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  background: var(--surface);
  border-left: 4px solid #94a3b8;
}

.line-card--run { border-left-color: #059669; background: linear-gradient(160deg, #ecfdf5, #fff 55%); }
.line-card--stop { border-left-color: #dc2626; background: linear-gradient(160deg, #fef2f2, #fff 55%); }
.line-card--closed { border-left-color: #64748b; background: #f8fafc; }

.line-card__head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  font-weight: 700;
  margin-bottom: 0.4rem;
  font-size: 0.92rem;
}

.line-card__badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
}

.line-card--run .line-card__badge { background: #a7f3d0; color: #065f46; }
.line-card--stop .line-card__badge { background: #fecaca; color: #991b1b; }

.line-card__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin: 0 0 0.45rem;
}
.line-card__stats--single { grid-template-columns: 1fr; }
.line-card__stat {
  display: grid;
  gap: 0.1rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.95);
}
.line-card__stat span {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.line-card__stat strong {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.line-card__stat small {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}
.line-card__stat--out {
  background: rgba(13, 148, 136, 0.08);
}
.line-card__note {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.line-card__output { margin: 0 0 0.35rem; font-size: 1.25rem; letter-spacing: -0.02em; }
.line-card__output small { font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.line-card__reason, .line-card__fault {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  color: #b91c1c;
}
.line-card__meta { margin: 0; font-size: 0.72rem; color: var(--muted); }

.dash-faults-panel { margin-bottom: 0; }
.fault-list--dash { max-height: 280px; }
.fault-item--compact { padding: 0.65rem; }

.lines-board-panel { margin-bottom: 0; }

.dash-export-panel {
  margin-bottom: 0;
}

.dash-export-panel .panel__toolbar {
  align-items: center;
}

.report-export-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.report-export-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.fault-item__timeline {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border);
}

.fault-item__timeline-title {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}

.fault-history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.fault-history__item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.1rem;
  padding: 0.4rem 0.55rem;
  background: var(--surface-2, #f8fafc);
  border-radius: 8px;
  font-size: 0.78rem;
}

.fault-history__item strong { color: var(--text); }
.fault-history__item time { color: var(--muted); }
.fault-history__item em { color: var(--muted); font-style: normal; }

.fault-history__item--created { border-left: 3px solid #64748b; }
.fault-history__item--in_progress { border-left: 3px solid #d97706; }
.fault-history__item--resolved { border-left: 3px solid #059669; }

.entry-who {
  color: var(--muted);
  font-size: 0.75rem;
}

.role-switch__locked {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.role-btn:disabled {
  opacity: 1;
  cursor: default;
}

.field--inline { margin: 0; }

/* Improvements */
.improvements-layout {
  display: grid;
  grid-template-columns: minmax(280px, 400px) 1fr;
  gap: 1rem;
  align-items: start;
}

.suggestion-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.suggestion-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.suggestion-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.85rem;
}

.suggestion-item__text { margin: 0 0 0.35rem; font-size: 0.92rem; line-height: 1.45; }
.suggestion-item__meta { font-size: 0.78rem; color: var(--muted); }

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.75rem;
  }

  .sidebar__nav {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }

  .nav-btn { flex: 1; min-width: 110px; justify-content: center; font-size: 0.8rem; }
  .main { margin-left: 0; padding: 0.75rem; padding-top: 3.25rem; }
  .sidebar__footer { display: none; }
  .sorting-sections { grid-template-columns: 1fr; }
  .faults-layout, .improvements-layout { grid-template-columns: 1fr; }
  .period-filter { width: 100%; }
  .topbar__right { flex-wrap: wrap; }
  .topbar__stats { display: none; }

  .dash-hero__title { font-size: 1.35rem; }
  .dash-hero__lead { font-size: 0.9rem; margin-bottom: 0.85rem; }
  .dash-kpi {
    padding: 1rem;
    gap: 0.45rem;
  }
  .dash-kpi__value { font-size: 1.55rem; }
  .dash-kpi__value--sm { font-size: 1.25rem; }
  .dash-kpi__sub { font-size: 0.74rem; }
  .dash-kpi__meta { font-size: 0.85rem; line-height: 1.35; }

  .dash-flow-strip {
    flex-direction: column;
    gap: 0.45rem;
  }
  .dash-flow-strip__arrow { display: none; }
  .dash-flow-strip__item {
    flex: none;
    width: 100%;
    padding: 0.65rem 0.75rem;
  }
  .dash-flow-strip__item strong { font-size: 1.25rem; }
  .dash-flow-strip__item em { font-size: 0.8rem; }

  .lines-board {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }
  .line-card { padding: 1rem; }
  .line-card__head { font-size: 1.05rem; }
  .line-card__stats { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .line-card__stat strong { font-size: 1.35rem; }
  .line-card__note { font-size: 0.85rem; }

  .dash-chart-card { min-height: 0; padding: 0.85rem; }
  .dash-chart { min-height: 160px; }
  .dash-hbar__row { grid-template-columns: 5rem 1fr; gap: 0.4rem; }
  .dash-hbar__label { font-size: 0.78rem; }
  .dash-hbar__val { font-size: 0.85rem; }

  .production-grid { grid-template-columns: 1fr; }
  .crusher-outputs-grid { grid-template-columns: 1fr; }
  .input--lg, .btn--lg { min-height: 3rem; font-size: 1.05rem; }
  .secondary-type-field {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
  .secondary-type-field .secondary-type-input,
  .crusher-output-input,
  .furnace-output-input {
    font-size: 1.15rem;
    min-height: 2.75rem;
  }
}

/* v4 additions */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 20;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

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

.quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0.75rem;
}

.quick-btn {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}

.quick-btn:active { transform: scale(0.97); }

.barcode-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.barcode-video {
  width: 100%;
  max-height: 200px;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  background: #000;
}

.panel__toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.panel__toolbar h2 { margin: 0; }

.toolbar-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.compare-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  font-size: 0.8rem;
}

.compare-card__label { color: var(--muted); display: block; margin-bottom: 0.2rem; }
.compare-card__val { font-weight: 700; font-size: 1rem; }
.compare-card__delta { font-size: 0.75rem; }
.compare-card__delta--up { color: var(--success); }
.compare-card__delta--down { color: var(--danger); }

.user-picker {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}

.user-pick-btn {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  cursor: pointer;
  font-size: 0.85rem;
}

.user-pick-btn strong { display: block; }
.user-pick-btn span { color: var(--muted); font-size: 0.75rem; }

.field--check {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem;
}

.field--check input { width: auto; }

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge--open { background: #fef2f2; color: #dc2626; }
.status-badge--in_progress { background: #fffbeb; color: #d97706; }
.status-badge--resolved { background: #ecfdf5; color: #059669; }
.status-badge--new { background: var(--primary-light); color: var(--primary); }
.status-badge--planned { background: #fffbeb; color: #d97706; }
.status-badge--done { background: #ecfdf5; color: #059669; }
.status-badge--rejected { background: #f1f5f9; color: #64748b; }

.fault-actions, .suggestion-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.role-badge--mechanic { background: #fef3c7; color: #b45309; }

.sync-status--queue { background: #fffbeb; color: #b45309; }

@media (max-width: 768px) {
  .mobile-menu-btn { display: block; }

  .sidebar {
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    z-index: 15;
  }

  .main { margin-left: 0; padding: 3.5rem 1rem 1rem; }

  .btn, .quick-btn, .nav-btn, .role-btn { min-height: 44px; }

  .input, .input--sm { min-height: 44px; font-size: 16px; }

  .inline-form { flex-direction: column; }

  .inline-form .input, .inline-form .btn { width: 100%; }
}

.panel--danger-zone {
  border: 2px solid #fecaca;
  background: linear-gradient(135deg, #fef2f2, #fff 60%);
  margin-bottom: 1rem;
}
.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.danger-zone h2 {
  margin: 0 0 0.35rem;
  color: #b91c1c;
}
.danger-zone .btn--danger {
  min-width: 12rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25);
}
.users-admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.users-admin-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.users-admin-list__item--dup {
  border-color: #f59e0b;
  background: #fffbeb;
}
.users-admin-list__info { display: grid; gap: 0.2rem; min-width: 12rem; flex: 1; }
.users-admin-list__info span { font-size: 0.85rem; color: var(--muted); }
.users-admin-list__dup-hint { color: #b45309 !important; font-size: 0.8rem !important; }
.users-admin-list__actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}
.users-admin-list__actions .btn { min-width: 4.5rem; }
.users-admin-list__badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}
.users-admin-list__badge--pending {
  background: #fef3c7;
  color: #92400e;
}
.users-admin-list__badge--ok {
  background: #d1fae5;
  color: #065f46;
}
.users-admin-list__badge--dup {
  background: #ffedd5;
  color: #9a3412;
}

/* Nav flyout */
.nav-flyout { position: relative; margin-top: 0.35rem; }
.nav-btn--home {
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #eff6ff, #ecfeff);
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}
.nav-btn--home.nav-btn--active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.nav-btn--more { width: 100%; justify-content: flex-start; }
.nav-flyout__panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 40;
  display: grid;
  gap: 0.25rem;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}
.nav-flyout__panel[hidden] { display: none !important; }
.nav-flyout__panel .nav-btn { margin: 0; }

.line-card__who {
  margin: 0 0 0.45rem;
  display: grid;
  gap: 0.1rem;
}
.line-card__who strong {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.line-card__who span { font-size: 0.78rem; color: var(--muted); }
.line-card__who--empty {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

.dash-operators {
  display: grid;
  gap: 0.65rem;
  max-height: 420px;
  overflow: auto;
}
.dash-operators__empty { margin: 0; color: var(--muted); font-size: 0.9rem; }
.dash-op-line {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #fff;
}
.dash-op-line header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}
.dash-op-line__now {
  font-style: normal;
  font-weight: 600;
  font-size: 0.75rem;
  color: #065f46;
  background: #d1fae5;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}
.dash-op-line__now--off {
  color: #64748b;
  background: #f1f5f9;
}
.dash-op-line ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.dash-op { display: flex; flex-direction: column; gap: 0.05rem; }
.dash-op strong { font-size: 0.88rem; }
.dash-op span { font-size: 0.75rem; color: var(--muted); }
.dash-op-line__none { margin: 0; font-size: 0.8rem; color: var(--muted); }

.tv-exit-bar {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 0.85rem;
  background: rgba(15, 23, 42, 0.82);
  color: #fff;
  border-radius: 10px;
  backdrop-filter: blur(6px);
  font-size: 0.95rem;
  font-weight: 600;
}
.tv-exit-bar[hidden] { display: none !important; }
.tv-exit-bar .btn { color: #fff; border-color: rgba(255,255,255,0.35); }

/* TV mode — fullscreen dashboard for shop-floor display */
body.tv-mode .mobile-menu-btn,
body.tv-mode .sidebar,
body.tv-mode .topbar__stats,
body.tv-mode .dash-export-panel,
body.tv-mode .dash-faults-panel .btn,
body.tv-mode #userBlock,
body.tv-mode .sync-status {
  display: none !important;
}
body.tv-mode .app { display: block; }
body.tv-mode .main {
  margin-left: 0 !important;
  padding: 1rem 1.25rem 4rem;
  max-width: none;
}
body.tv-mode .topbar {
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
}
body.tv-mode .topbar h1 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  letter-spacing: 0.06em;
}
body.tv-mode .period-filter { transform: scale(1.05); transform-origin: right center; }
body.tv-mode .dash-hero {
  padding: 1.5rem 1.75rem;
}
body.tv-mode .dash-hero__title {
  font-size: clamp(2rem, 4vw, 3rem);
}
body.tv-mode .dash-kpi__value {
  font-size: clamp(1.8rem, 3.2vw, 2.6rem);
}
body.tv-mode .line-card__who strong {
  font-size: clamp(1.15rem, 2vw, 1.55rem);
}
body.tv-mode .line-card__stat strong,
body.tv-mode .line-card__output {
  font-size: clamp(1.35rem, 2.3vw, 1.85rem);
}
body.tv-mode .dash-flow-strip__item strong {
  font-size: clamp(1.2rem, 2vw, 1.6rem);
}
body.tv-mode .dash-bottom {
  grid-template-columns: 1fr 1fr;
}
body.tv-mode .dash-priority {
  margin-bottom: 1.25rem;
}
body.tv-mode .dash-charts {
  font-size: 1.05rem;
}
body.tv-mode .dash-faults-panel { display: none; }
body.tv-mode .dash-bottom--secondary { grid-template-columns: 1fr; max-width: 42rem; }
body.tv-mode .view:not(.view--active) { display: none !important; }


.nav-btn__badge {
  display: inline-block;
  min-width: 1.1rem;
  padding: 0.05rem 0.35rem;
  margin-left: 0.25rem;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  vertical-align: middle;
}
.chat-panel { display: flex; flex-direction: column; min-height: min(70vh, 640px); }
.chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.75rem;
  background: #f8fafc;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  max-height: min(55vh, 520px);
}
.chat-empty { color: var(--muted, #6b7280); text-align: center; padding: 2rem 1rem; }
.chat-msg {
  max-width: 85%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e5e7eb;
  align-self: flex-start;
}
.chat-msg--mine {
  align-self: flex-end;
  background: #eff6ff;
  border-color: #bfdbfe;
}
.chat-msg__meta {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted, #6b7280);
  margin-bottom: 0.25rem;
}
.chat-msg__meta time { margin-left: auto; }
.chat-msg__text { white-space: pre-wrap; word-break: break-word; }
.chat-msg__del {
  border: 0; background: transparent; color: #9ca3af; cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 0.2rem;
}
.chat-msg__del:hover { color: #dc2626; }
.chat-form { display: flex; gap: 0.5rem; }
.chat-form .input { flex: 1; }

.nav-btn__badge--mention { background: #d97706; }
.chat-msg--mention { border-color: #f59e0b; box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }
.chat-mention { color: #1d4ed8; font-weight: 600; }
.chat-mention-wrap { position: relative; }
.chat-mention-list {
  position: absolute;
  left: 0; right: 4.5rem; bottom: 100%;
  z-index: 20;
  margin: 0 0 0.35rem;
  padding: 0.25rem;
  list-style: none;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  max-height: 220px;
  overflow-y: auto;
}
.chat-mention-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem;
  width: 100%; border: 0; background: transparent; text-align: left;
  padding: 0.45rem 0.55rem; border-radius: 6px; cursor: pointer;
}
.chat-mention-item:hover { background: #eff6ff; }
.chat-mention-item span { font-size: 0.8rem; color: #6b7280; }

.nav-btn__badge--pending { background: #d97706; }
/* Light UI by default; dark only in TV mode */
body:not(.tv-mode) {
  background: var(--bg, #f3f4f6);
  color: var(--text, #111827);
}
body.tv-mode {
  background: #0b1220;
  color: #e5e7eb;
}
body.tv-mode .dash-hero {
  background: linear-gradient(145deg, #111827 0%, #0f172a 100%);
  border-color: #1f2937;
}
body.tv-mode .dash-kpi {
  background: rgba(17, 24, 39, 0.92);
  border-color: #374151;
  color: #e5e7eb;
}
.dash-kpi__meta:empty { display: none; }
