/* ============================================================================
   Lelit Bianca — Nordic Minimalist Instrument System
   Matte white surfaces, stone-gray canvas, crisp hairline geometry, zero bloat.
   ============================================================================ */

:root {
  color-scheme: light;
  --bg-canvas: #F3F3F0;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F8F8F6;
  --bg-muted: #EFEFEA;
  --border-line: #E2E2DC;
  --border-strong: #C9C9C1;

  --ink: #141413;
  --ink-secondary: #52524E;
  --ink-muted: #86867F;
  --ink-faint: #AEAEA6;

  --green: #16794F;
  --green-bg: #EDF7F2;
  --green-border: #C2E2D2;

  --steel: #1F649B;
  --steel-bg: #EFF5FA;
  --steel-border: #C8DCEC;

  --ochre: #9A5B13;
  --ochre-bg: #FCF5EB;
  --ochre-border: #E7CFA8;

  --copper: #B85D19;
  --red: #C43225;
  --red-bg: #FDF1F0;
  --red-border: #ECC5C1;

  --radius-card: 12px;
  --radius-control: 8px;
  --radius-pill: 999px;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg-canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input, select, textarea {
  user-select: auto;
  font-family: inherit;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D2D2CA; border-radius: 999px; }

/* Shell */
.app-shell {
  max-width: 1480px;
  min-height: 0;
  margin: 0 auto;
  padding: 6px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Top Bar */
.top-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-card);
  padding: 6px 10px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border-radius: var(--radius-control);
  background: var(--ink);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
  font-size: 11.5px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.brand-title {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.status-line {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.status-line[data-tone="ok"] { color: var(--green); }
.status-line[data-tone="warn"] { color: var(--ochre); }

/* Segmented Navigation */
.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--bg-muted);
  padding: 2px;
  border-radius: 9px;
}

.nav-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 550;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-tab:hover {
  color: var(--ink);
}

.nav-tab.active {
  background: var(--bg-surface);
  color: var(--ink);
  border-color: var(--border-line);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(20, 20, 19, 0.04);
}

/* Header Actions */
.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background: var(--ink-faint);
  flex-shrink: 0;
}
.dot-green { background: var(--green); }
.dot-ochre { background: var(--ochre); }
.dot-steel { background: var(--steel); }
.dot-ink { background: var(--ink); }
.dot-white { background: #FFFFFF; }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border-line);
  background: var(--bg-surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 550;
  padding: 5px 10px;
  min-height: 32px;
  border-radius: var(--radius-control);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
  text-decoration: none;
}

.btn:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

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

/* Primary Carbon Button */
.btn-primary,
.btn-ble {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
  font-weight: 600;
}
.btn-ble:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
  background: #2A2A28;
  border-color: #2A2A28;
}
.btn-ble.connected {
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green-border);
}

/* Subtle Tinted Buttons */
.btn-green-soft {
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green-border);
  font-weight: 600;
}
.btn-green-soft:hover:not(:disabled) {
  background: #E2F2EA;
  border-color: #ABD7C1;
}

.btn-ochre-soft {
  background: var(--ochre-bg);
  color: var(--ochre);
  border-color: var(--ochre-border);
  font-weight: 600;
}
.btn-ochre-soft:hover:not(:disabled) {
  background: #F8ECDA;
}

.btn-stop {
  background: var(--red);
  color: #FFFFFF;
  border-color: var(--red);
  font-weight: 600;
}
.btn-stop:hover:not(:disabled) {
  background: #AE2B1F;
}

.btn-lg-touch {
  min-height: 38px;
  font-size: 12.5px;
  border-radius: 8px;
}

/* ============================================================================
   STAGE PROGRESSION BAR (CLEAN LOCKED VS UNLOCKED SPINE)
   ============================================================================ */
.stage-rail-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-card);
  padding: 4px 8px;
}

.stage-rail-bar.preview-mode {
  border-color: var(--ochre-border);
  background: var(--ochre-bg);
}

.stage-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.stage-pill {
  appearance: none;
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
  color: var(--ink-muted);
  border-radius: var(--radius-control);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 550;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.stage-pill:hover {
  border-color: var(--border-strong);
  color: var(--ink);
  background: var(--bg-surface);
}

.stage-pill.unlocked {
  background: var(--bg-surface);
  border-color: var(--green-border);
  color: var(--ink);
}

.stage-pill.next-up {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--ink-secondary);
}

.stage-pill.previewed {
  background: var(--bg-surface);
  border-color: var(--ochre-border);
  color: var(--ochre);
}

.stage-pill .stg-code {
  font-weight: 650;
  font-size: 10.5px;
  color: inherit;
}

.stage-rail-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ============================================================================
   MAIN 12-COLUMN GRID (25% LEFT CONTROLS / 75% RIGHT WIDESCREEN CHART)
   ============================================================================ */
.cockpit-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

.col-left {
  grid-column: span 3 / span 3;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.col-center {
  grid-column: span 9 / span 9;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.col-left .card {
  padding: 7px 10px;
}

.col-left .btn-lg-touch {
  min-height: 31px;
  font-size: 11.5px;
  padding: 3px 8px;
}

@media (max-width: 1100px) {
  .col-left { grid-column: span 4 / span 4; }
  .col-center { grid-column: span 8 / span 8; }
}

@media (max-width: 780px) {
  .col-left, .col-center {
    grid-column: span 12 / span 12;
    display: flex;
    flex-direction: column;
  }
}

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-card);
  padding: 9px 11px;
  position: relative;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.card-title {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  color: var(--ink-muted);
  margin: 0;
}

/* Clean Minimal Status Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 550;
  padding: 1.5px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-line);
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  white-space: nowrap;
}

.badge-live {
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green-border);
}

.badge-preview {
  background: var(--ochre-bg);
  color: var(--ochre);
  border-color: var(--ochre-border);
}

.badge-next {
  background: var(--bg-surface);
  color: var(--ink-secondary);
  border-color: var(--border-strong);
}

.badge-locked {
  background: var(--bg-muted);
  color: var(--ink-muted);
  border-color: var(--border-line);
  cursor: pointer;
}
.badge-locked:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

/* Locked Hardware Slot Treatment */
.lockable-slot {
  position: relative;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.lockable-slot[data-locked="true"] {
  background: #FAF9F7;
  border-style: dashed;
  border-color: #D5D5CD;
}

.lockable-slot[data-locked="true"][data-open-stage-card] {
  cursor: pointer;
}

.lockable-slot[data-locked="true"][data-open-stage-card]:hover {
  border-color: var(--border-strong);
}

.lockable-slot[data-locked="true"] .slot-body {
  opacity: 0.38;
  pointer-events: none;
  filter: grayscale(0.6);
}

.slot-lock-cta {
  display: none;
}

.lockable-slot[data-locked="true"] .slot-lock-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-control);
  background: var(--bg-surface);
  border: 1px solid var(--border-line);
  font-size: 11px;
  color: var(--ink-secondary);
  cursor: pointer;
}
.lockable-slot[data-locked="true"] .slot-lock-cta:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

/* ============================================================================
   WEIGHT READOUT & LEVER CUE
   ============================================================================ */
.weight-readout-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 1px 0 6px;
}

.weight-big {
  font-size: 34px;
  line-height: 1;
  font-weight: 650;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.flow-big {
  font-size: 18px;
  line-height: 1.05;
  font-weight: 600;
  color: var(--steel);
}

@keyframes pulseNordicCue {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 121, 79, 0.0); }
  50% { box-shadow: 0 0 0 6px rgba(22, 121, 79, 0.18); }
}

.drop-lever-cue {
  animation: pulseNordicCue 0.75s infinite;
  border-color: var(--green) !important;
  background: var(--green-bg) !important;
}

.scale-meta-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-control);
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
  font-size: 10.5px;
  color: var(--ink-muted);
}

/* Hardware Stage Rows (Left Column) */
.hw-stage-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 5px;
}

.hw-stage-row {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
  font-size: 11.5px;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.hw-stage-row[data-open-stage] {
  cursor: pointer;
}

.hw-stage-row[data-open-stage]:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
}

.hw-stage-sub {
  display: block;
  font-size: 10px;
  color: var(--ink-muted);
  margin-top: 1px;
}

/* KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

@media (max-width: 1180px) {
  .kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.kpi-tile {
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
  border-radius: 8px;
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 46px;
}

.kpi-tile[data-locked="true"] {
  background: #FAF9F7;
  border-style: dashed;
  border-color: #D7D7CF;
  cursor: pointer;
}
.kpi-tile[data-locked="true"]:hover {
  border-color: var(--border-strong);
}

.kpi-label {
  font-size: 9.5px;
  font-weight: 550;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  white-space: nowrap;
}

.kpi-val {
  font-size: 14.5px;
  font-weight: 650;
  margin-top: 2px;
  letter-spacing: -0.015em;
  color: var(--ink);
}

/* ============================================================================
   1.43" ROUND OLED HARDWARE OBJECT (MACHINED ALUMINUM RING)
   ============================================================================ */
.amoled-bezel {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  padding: 4px;
  background: linear-gradient(145deg, #ECECE7, #CFCFC7);
  border: 1px solid #C2C2BA;
  box-shadow: 0 2px 6px rgba(20, 20, 19, 0.08);
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}

.amoled-bezel.large {
  width: 184px;
  height: 184px;
  padding: 9px;
}

.amoled-screen {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #121211;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  text-align: center;
}

/* Inputs & Form Controls */
.field-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

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

.field-label {
  display: block;
  font-size: 10px;
  font-weight: 550;
  color: var(--ink-muted);
  margin-bottom: 1.5px;
}

.inp {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-control);
  color: var(--ink);
  font-size: 12px;
  font-weight: 550;
  padding: 3px 7px;
  min-height: 28px;
  outline: none;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.inp:focus {
  background: var(--bg-surface);
  border-color: var(--ink);
}

input[type="range"] {
  accent-color: var(--ink);
  cursor: pointer;
}

/* Ratio Segmented Pills */
.ratio-pills {
  display: flex;
  gap: 2px;
  background: var(--bg-muted);
  padding: 2px;
  border-radius: 7px;
}

.ratio-pill {
  flex: 1;
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 0;
  border-radius: 5px;
  cursor: pointer;
}
.ratio-pill.active {
  background: var(--bg-surface);
  border-color: var(--border-line);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(20, 20, 19, 0.04);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 20, 19, 0.28);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open {
  display: flex;
}

.modal-panel {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-line);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 18px 42px rgba(20, 20, 19, 0.12);
}

/* Tables & Stage Cards */
.stage-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 1050px) {
  .stage-cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .stage-cards-grid { grid-template-columns: 1fr; }
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.matrix-table th, .matrix-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-line);
  text-align: left;
}
.matrix-table th {
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-subtle);
}

/* Secondary Views & Utility Layouts */
.machine-grid,
.lab-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
}

.machine-panel {
  grid-column: span 6 / span 6;
}

.lab-col-bench {
  grid-column: span 5 / span 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lab-col-journal {
  grid-column: span 7 / span 7;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 980px) {
  .machine-panel,
  .lab-col-bench,
  .lab-col-journal {
    grid-column: span 12 / span 12;
  }
}

.stages-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sim-bench-bar {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.learned-coast-box {
  padding: 8px 10px;
  border-radius: var(--radius-control);
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cue-banner {
  padding: 8px 10px;
  border-radius: var(--radius-control);
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.hidden {
  display: none !important;
}
