/* =========================================================
   Ontwerptemperatuur Design System
   ========================================================= */

:root {
  /* Core palette — Scandinavian: warm beige, charcoal ink, terracotta */
  /* The --slate-* tokens keep their names (used throughout JSX) but now map
     to a warm neutral scale, so every component picks up the new palette
     without code changes. */
  --slate-900: #1a1511;
  --slate-800: #2a2520;
  --slate-700: #3a332b;   /* primary ink */
  --slate-600: #574d40;
  --slate-500: #7a6e5c;
  --slate-400: #9a8d78;
  --slate-300: #c4b89f;
  --slate-200: #e4d9c3;
  --slate-100: #ede3cd;
  --slate-50:  #f4ede0;

  --bg:        #f4ede0;
  --surface:   #ffffff;
  --ink:       #2a2520;
  --ink-soft:  #3a332b;
  --ink-mute:  #7a6e5c;
  --ink-dim:   #9a8d78;
  --border:    #e4d9c3;
  --border-strong: #c4b89f;

  --accent:       #c78b5e;   /* terracotta */
  --accent-hover: #b0744a;
  --accent-soft:  #f5e6d8;
  --accent-tint:  #ebd2be;

  /* Density scale (1 = default, <1 compact, >1 cozy) */
  --density: 1;
  --pad-card:   calc(20px * var(--density));
  --pad-btn-y:  calc(8px  * var(--density));
  --pad-btn-x:  calc(14px * var(--density));
  --gap-stack:  calc(16px * var(--density));

  /* Radius scale for sharp/soft tweak */
  --radius-scale: 1;

  /* Status — muted, harmonious with the warm palette */
  --success:       #7a9667;
  --success-soft:  #e3ecd9;
  --warning:       #d4a34a;
  --warning-soft:  #f5ead0;
  --error:         #c25a3e;
  --error-soft:    #f5dfd5;
  --info:          #7a8ea0;
  --info-soft:     #e3e8ed;

  /* Typography — Work Sans body, Fraunces display, DM Mono numeric */
  --font: "Work Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", "Work Sans", ui-serif, Georgia, serif;
  --font-mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Radii — Scandi cards are generously rounded */
  --r-input: calc(10px * var(--radius-scale));
  --r-btn:   calc(999px * var(--radius-scale));
  --r-card:  calc(18px * var(--radius-scale));
  --r-pill:  999px;

  /* Shadows — warm, subtle; mostly just a hairline */
  --sh-xs: 0 1px 0 rgba(42, 37, 32, 0.04);
  --sh-sm: 0 1px 0 #e4d9c3;
  --sh-md: 0 2px 8px -2px rgba(42, 37, 32, 0.06), 0 1px 0 #e4d9c3;
  --sh-lg: 0 10px 28px -12px rgba(42, 37, 32, 0.16), 0 2px 0 #e4d9c3;
  --sh-accent: 0 6px 18px -8px rgba(199, 139, 94, 0.45);

  /* Motion */
  --e-out: cubic-bezier(0.22, 1, 0.36, 1);
  --e-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
}

#root {
  min-height: 100vh;
}

/* Typography utilities */
.t-h1 { font-family: var(--font-display); font-size: 32px; font-weight: 400; letter-spacing: -0.02em; color: var(--ink); line-height: 1.1; }
.t-h2 { font-family: var(--font-display); font-size: 22px; font-weight: 400; letter-spacing: -0.01em; color: var(--ink); line-height: 1.25; }
.t-h3 { font-size: 15px; font-weight: 600; color: var(--ink); letter-spacing: -0.005em; }
.t-body { font-size: 14px; color: var(--ink-soft); }
.t-label { font-size: 11px; font-weight: 500; color: var(--ink-mute); letter-spacing: 0.08em; text-transform: uppercase; }
.t-caption { font-size: 12px; color: var(--ink-mute); }
.t-mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.t-serif { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; }
.t-serif-italic { font-family: var(--font-display); font-weight: 300; font-style: italic; letter-spacing: -0.005em; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--r-btn);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms var(--e-out), color 140ms var(--e-out),
              border-color 140ms var(--e-out), box-shadow 140ms var(--e-out),
              transform 140ms var(--e-out);
  user-select: none;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.5; cursor: not-allowed; pointer-events: none;
}

.btn--primary {
  background: var(--slate-800);
  color: var(--slate-50);
  box-shadow: none;
}
.btn--primary:hover { background: var(--slate-900); color: #fff; }

.btn--slate {
  background: var(--slate-800);
  color: var(--slate-50);
}
.btn--slate:hover { background: var(--slate-900); color: #fff; }

.btn--accent {
  background: var(--accent);
  color: #fff;
}
.btn--accent:hover { background: var(--accent-hover); box-shadow: var(--sh-accent); }

.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--border);
}
.btn--ghost:hover { background: var(--slate-50); border-color: var(--border-strong); color: var(--ink); }

.btn--subtle {
  background: var(--slate-50);
  color: var(--ink-soft);
}
.btn--subtle:hover { background: var(--slate-100); color: var(--ink); }

.btn--link {
  height: auto;
  padding: 0;
  color: var(--slate-700);
  background: transparent;
}
.btn--link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.btn--lg { height: 44px; padding: 0 22px; font-size: 15px; }
.btn--sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn--icon { width: 36px; padding: 0; }

/* Inputs */
.input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 140ms var(--e-out), box-shadow 140ms var(--e-out);
}
.input::placeholder { color: var(--ink-dim); }
.input:hover { border-color: var(--border-strong); }
.input:focus {
  outline: none;
  border-color: var(--slate-500);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px; font-weight: 500; color: var(--ink-soft);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--r-card);
  box-shadow: var(--sh-sm);
}
.card--flat { box-shadow: none; }
.card--hover { transition: transform 160ms var(--e-out), box-shadow 160ms var(--e-out), border-color 160ms var(--e-out); }
.card--hover:hover { transform: translateY(-1px); box-shadow: var(--sh-md); border-color: var(--border); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.badge--neutral { background: var(--slate-100); color: var(--slate-700); }
.badge--info    { background: var(--surface-alt); color: var(--ink-soft); border: 1px solid var(--border); }
.badge--success { background: var(--success-soft); color: #3c6b4a; }
.badge--warning { background: var(--warning-soft); color: #8a6a1a; }
.badge--error   { background: var(--error-soft); color: #a8432a; }
.badge--accent  { background: var(--accent-soft); color: #8a5836; }
.badge--outline {
  background: white; color: var(--ink-soft);
  border: 1px solid var(--border);
}
.badge--dot::before {
  content: "";
  width: 6px; height: 6px; border-radius: 999px;
  background: currentColor;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle__track {
  position: absolute; inset: 0;
  background: var(--slate-200);
  border-radius: 999px;
  transition: background 160ms var(--e-out);
}
.toggle__thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 180ms var(--e-out);
}
.toggle input:checked ~ .toggle__track { background: var(--slate-800); }
.toggle input:checked ~ .toggle__thumb { transform: translateX(14px); }
.toggle.toggle--accent input:checked ~ .toggle__track { background: var(--accent); }

/* Progress/spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--slate-200);
  border-top-color: var(--slate-700);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}
.spinner--lg { width: 28px; height: 28px; border-width: 3px; }

/* Skill-level spinner (component-driven, sized by inline styles) */
.ot-spinner {
  border-style: solid;
  border-radius: 999px;
  display: inline-block; vertical-align: middle;
  animation: spin 0.8s linear infinite;
}

/* Skeleton shimmer */
@keyframes skel-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skel {
  background: linear-gradient(
    90deg,
    var(--slate-100) 0%,
    var(--slate-200) 40%,
    var(--slate-100) 80%
  );
  background-size: 200% 100%;
  animation: skel-shimmer 1.6s ease-in-out infinite;
}

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
  padding: 36px 24px; gap: 6px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--ink-soft);
}
.empty-state[data-compact="true"] { padding: 20px 16px; }
.empty-state__icon {
  width: 44px; height: 44px; border-radius: 999px;
  background: var(--slate-50); color: var(--ink-mute);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 6px;
}
.empty-state[data-compact="true"] .empty-state__icon {
  width: 32px; height: 32px;
}
.empty-state__title {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.01em;
}
.empty-state[data-compact="true"] .empty-state__title { font-size: 14px; }
.empty-state__message {
  font-size: 13px; line-height: 1.55;
  max-width: 360px; color: var(--ink-soft);
}

/* Wizard shell */
.app-shell { display: flex; min-height: 100vh; }

/* Secondary unit sidebar (multi-EPB projects) */
.unit-sidebar {
  width: 220px; min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.unit-sidebar__header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.unit-sidebar__list {
  flex: 1; overflow-y: auto;
  padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.unit-sidebar__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.unit-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px;
  background: transparent; border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer; text-align: left; width: 100%;
  font-family: inherit; transition: background 120ms, border-color 120ms;
}
.unit-card:hover { background: var(--slate-50); }
.unit-card[data-active="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.unit-card__num {
  width: 26px; height: 26px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  color: var(--ink-soft);
  flex-shrink: 0;
}
.unit-card[data-active="true"] .unit-card__num {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.unit-card__body { flex: 1; min-width: 0; }
.unit-card__title {
  font-size: 13px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.unit-card__bar {
  height: 3px; background: var(--border); border-radius: 2px; margin-top: 6px;
  overflow: hidden;
}
.unit-card__fill {
  height: 100%; background: var(--accent);
  transition: width 200ms ease;
}
@media (max-width: 1100px) {
  .unit-sidebar { width: 180px; min-width: 180px; }
}

.topbar {
  height: 60px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky; top: 0;
  z-index: 20;
}

.wizard-sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.wizard-sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.wiz-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-btn);
  cursor: pointer;
  color: var(--ink-soft);
  transition: background 140ms var(--e-out), color 140ms var(--e-out);
  user-select: none;
  position: relative;
}
.wiz-step:hover { background: var(--slate-100); color: var(--ink); }
.wiz-step[data-state="active"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  box-shadow: var(--sh-sm);
}
.wiz-step[data-state="active"]::before {
  content: none;
}
.wiz-step[data-state="locked"] { opacity: 0.5; cursor: not-allowed; }
.wiz-step[data-state="done"] .wiz-step__num {
  background: var(--slate-700); color: white; border-color: var(--slate-700);
}
.wiz-step__num {
  width: 26px; height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500;
  background: var(--bg);
  color: var(--ink-mute);
  flex-shrink: 0;
  font-family: var(--font-display);
  transition: all 140ms var(--e-out);
}
.wiz-step[data-state="active"] .wiz-step__num {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.wiz-step[data-state="done"] .wiz-step__num {
  background: var(--slate-800); color: var(--slate-50); border-color: var(--slate-800);
}
.wiz-step__label { font-size: 13px; }

/* Page layout inside wizard */
.wiz-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.wiz-main__header {
  padding: 36px 48px 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.wiz-main__header h1 {
  margin: 0 0 6px 0;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.wiz-main__header p  { margin: 0; color: var(--ink-mute); font-size: 14px; max-width: 560px; line-height: 1.55; }

.wiz-main__body {
  flex: 1;
  padding: 0 48px 24px;
  min-height: 0;
}
.wiz-main__footer {
  position: sticky;
  bottom: 0;
  background: rgba(244, 237, 224, 0.9);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 14px 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* Drop zone */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 220px;
  padding: 32px;
  background: white;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-card);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms var(--e-out), background 160ms var(--e-out), transform 160ms var(--e-out);
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone[data-state="uploading"] { border-style: solid; border-color: var(--slate-500); background: var(--slate-50); cursor: wait; }
.dropzone[data-state="done"] { border-style: solid; border-color: var(--border-strong); background: var(--surface); }
.dropzone[data-state="done"] .done-title { color: var(--ink); }
.dropzone__icon {
  width: 48px; height: 48px;
  background: var(--slate-100);
  color: var(--slate-700);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: all 160ms var(--e-out);
}
.dropzone[data-state="done"] .dropzone__icon { background: var(--accent-soft); color: var(--accent); }

/* Toast */
.toast-layer {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: white;
  border: 1px solid var(--border);
  border-left: 3px solid var(--slate-700);
  border-radius: var(--r-card);
  box-shadow: var(--sh-lg);
  min-width: 280px;
  max-width: 380px;
  animation: toast-in 240ms var(--e-out);
}
.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--error); }
.toast--info { border-left-color: var(--info); }
.toast__icon { flex-shrink: 0; margin-top: 1px; }
.toast__body { flex: 1; font-size: 13px; color: var(--ink); }
.toast__title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* Checkerboard striped placeholder */
.stripes {
  background-image: repeating-linear-gradient(
    135deg,
    var(--slate-50) 0, var(--slate-50) 10px,
    white 10px, white 20px
  );
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-card);
}

/* Tabs — pill segmented on a beige track */
.tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--slate-100);
  padding: 4px;
  border-radius: 999px;
  border: none;
}
.tab {
  position: relative;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-mute);
  cursor: pointer;
  background: transparent;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  transition: color 140ms var(--e-out), background 140ms var(--e-out);
}
.tab:hover { color: var(--ink); }
.tab[data-active="true"] {
  color: var(--ink);
  background: var(--surface);
  font-weight: 500;
  box-shadow: var(--sh-sm);
}
.tab[data-active="true"]::after { content: none; }

/* Tables */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
.table th {
  text-align: left;
  padding: 14px 16px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.table th:first-child { border-top-left-radius: var(--r-card); }
.table th:last-child  { border-top-right-radius: var(--r-card); }
.table td {
  padding: 16px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--ink);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table--hover tbody tr { cursor: pointer; transition: background 120ms var(--e-out); }
.table--hover tbody tr:hover { background: var(--slate-50); }

/* Stat card */
.stat {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat__label { font-size: 12px; color: var(--ink-mute); font-weight: 500; }
.stat__value { font-family: var(--font); font-size: 32px; font-weight: 500; color: var(--ink); letter-spacing: -0.025em; font-variant-numeric: tabular-nums; line-height: 1; }
.stat__unit  { font-size: 14px; color: var(--ink-mute); font-weight: 500; margin-left: 4px; }
.stat__meta  { font-size: 12px; color: var(--ink-mute); display: flex; align-items: center; gap: 6px; }

/* Banner */
.banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-card);
  font-size: 13px;
  border: 1px solid;
}
.banner--info    { background: var(--surface-alt); border-color: var(--border); color: var(--ink-soft); }
.banner--warning { background: var(--warning-soft); border-color: #e8d8a8; color: #6e5418; }
.banner--error   { background: var(--error-soft); border-color: #e8c5b5; color: #7a3520; }
.banner--success { background: var(--success-soft); border-color: #c5d4b5; color: #3c6b4a; }
.banner--accent  { background: var(--accent-soft); border-color: #e6c8ac; color: #7a4a2a; }

/* Floor plan */
.floorplan {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #FAFBFC;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  overflow: hidden;
  position: relative;
}

/* Utility */
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  font-family: var(--font-mono); font-size: 11px;
  background: var(--slate-50); color: var(--ink-mute);
  border: 1px solid var(--border); border-radius: 3px;
}

/* Scrollbar polish */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--slate-200);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--slate-300); }

/* Fade transitions for screen changes */
.screen-fade-enter { opacity: 0; transform: translateY(4px); }
.screen-fade-enter-active { opacity: 1; transform: translateY(0); transition: opacity 200ms var(--e-out), transform 200ms var(--e-out); }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-up { animation: fadeInUp 240ms var(--e-out) both; }

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
.animate-scale-in { animation: scaleIn 200ms var(--e-out) both; }

/* Drag chip */
.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--r-card);
  cursor: grab;
  transition: all 140ms var(--e-out);
  user-select: none;
}
.chip:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--sh-sm); }
.chip[data-state="unmapped"] { border-color: var(--accent); background: var(--accent-soft); }
.chip[data-state="mapped"] { border-color: var(--border-strong); background: var(--surface); }
.chip[data-dragging="true"] { opacity: 0.4; }
.chip.chip--ghost {
  pointer-events: none;
  position: fixed;
  z-index: 200;
  box-shadow: var(--sh-lg);
  transform: rotate(-1deg);
  opacity: 0.95;
}

.droptarget {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-card);
  padding: 14px;
  background: white;
  transition: border-color 160ms var(--e-out), background 160ms var(--e-out);
  min-height: 92px;
}
.droptarget[data-hover="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.droptarget[data-has-items="true"] { border-style: solid; border-color: var(--border); }

/* Room cards */
.room-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--r-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  position: relative;
  transition: border-color 140ms var(--e-out), box-shadow 140ms var(--e-out), transform 140ms var(--e-out), background 140ms var(--e-out);
}
.room-card:hover { border-color: var(--border-strong); box-shadow: var(--sh-sm); }
.room-card[data-state="unheated"] {
  background: var(--slate-50);
  color: var(--ink-mute);
}
.room-card[data-selected="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.room-card[data-merged="true"] {
  border-color: var(--slate-300);
  border-style: dashed;
  background: linear-gradient(180deg, #FFF 0%, var(--slate-50) 100%);
}
.room-card[data-dragover="true"] {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
  transform: scale(1.02);
}
.room-card[draggable="true"] { cursor: grab; }
.room-card[draggable="true"]:active { cursor: grabbing; }

.coil-icon circle { fill: none; stroke: currentColor; stroke-width: 1.6; }

/* Accent link */
.link-accent { color: var(--accent); cursor: pointer; font-weight: 500; }
.link-accent:hover { text-decoration: underline; }

/* Tweaks panel */
.tweaks-panel {
  position: fixed;
  bottom: 20px; right: 20px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--sh-lg);
  padding: 16px;
  z-index: 50;
  width: 260px;
  animation: fadeInUp 200ms var(--e-out);
}
.tweaks-panel h4 {
  margin: 0 0 12px 0;
  font-size: 13px; font-weight: 600;
  color: var(--ink);
  display: flex; justify-content: space-between; align-items: center;
}

.segmented {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.segmented button {
  flex: 1;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-mute);
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: all 140ms var(--e-out);
}
.segmented button[data-active="true"] {
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--sh-xs);
}

/* =========================================================
   Mobile responsive (≤ 900px)
   ========================================================= */
@media (max-width: 900px) {
  body { font-size: 14px; }

  /* Top bar collapses */
  .topbar { padding: 0 14px; gap: 10px; height: 52px; }
  .topbar > :nth-child(3) { display: none; } /* search */
  .topbar > :last-child { padding: 4px 8px !important; }
  .topbar > :last-child > div:nth-child(2) { display: none; } /* name/role text */
  .topbar > :last-child > svg:last-child { display: none; }

  /* Main page wrappers get tighter padding */
  main { padding: 18px 14px 48px !important; }

  /* Wizard: stack sidebar on top as a horizontal step strip */
  .app-shell { flex-direction: column; }
  .wizard-sidebar {
    width: 100%; min-width: 0; height: auto;
    padding: 10px 12px;
    position: sticky; top: 0; z-index: 15;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: block;
    overflow-x: auto;
  }
  .wizard-sidebar__brand {
    padding: 0 0 10px;
    margin-bottom: 10px;
  }
  /* Hide project meta block on mobile to save space */
  .wizard-sidebar > div:nth-child(2) { display: none; }
  /* Horizontal step chip rail */
  .wizard-sidebar > div:nth-last-child(2) {
    padding: 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .wizard-sidebar > div:nth-last-child(2)::-webkit-scrollbar { display: none; }
  .wizard-sidebar > div:nth-last-child(2) > div:first-child { display: none; } /* "Wizard" label */
  .wizard-sidebar > div:last-child { display: none; } /* autosave note */
  .wiz-step {
    flex-shrink: 0;
    padding: 6px 10px 6px 8px;
    border-radius: 999px;
    background: var(--slate-50);
    gap: 8px;
  }
  .wiz-step[data-state="active"] {
    background: var(--slate-700);
    color: white;
  }
  .wiz-step[data-state="active"]::before { display: none; }
  .wiz-step[data-state="active"] .wiz-step__num {
    background: white; color: var(--accent); border-color: white;
  }
  .wiz-step__label { font-size: 12px; }
  .wiz-step__num { width: 20px; height: 20px; font-size: 11px; }

  /* Wizard main */
  .wiz-main__header { padding: 18px 16px 12px; flex-direction: column; align-items: flex-start; gap: 6px; }
  .wiz-main__header h1 { font-size: 20px; }
  .wiz-main__header p { font-size: 13px; }
  .wiz-main__body { padding: 0 14px 16px; }
  .wiz-main__footer { padding: 10px 14px; gap: 8px; }
  .wiz-main__footer .btn { padding: 0 12px; }

  /* Generic grid collapses */
  .wiz-main__body > div[style*="grid-template-columns"],
  main > div[style*="grid-template-columns"],
  main div[style*="grid-template-columns: repeat(4"],
  main div[style*="grid-template-columns: repeat(3"],
  main div[style*="grid-template-columns: repeat(2"],
  main div[style*="grid-template-columns: 1fr 320px"],
  main div[style*="grid-template-columns: 180px 1fr 90px"] {
    grid-template-columns: 1fr !important;
  }

  /* Room cards: single column */
  .room-card { gridColumn: auto !important; }

  /* Tables: let them scroll horizontally */
  .card > table { display: block; overflow-x: auto; white-space: nowrap; }

  /* Stats: 2x2 instead of 4x1 */
  main > div[style*="repeat(4, 1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Scenario cards stack */
  .wiz-main__body > div[style*="repeat(3"] {
    grid-template-columns: 1fr !important;
  }

  /* Dashboard header stacks */
  main > div:first-child[style*="flex-end"] {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
  }

  /* Tabs scroll */
  .tabs { overflow-x: auto; white-space: nowrap; }
  .tabs::-webkit-scrollbar { display: none; }

  /* Dashboard filter row stacks */
  .card > div[style*="padding: 14px 16px"][style*="border-bottom"] {
    align-items: stretch !important;
  }
  /* Search input full-width on small screens */
  .card input[placeholder*="Search"] {
    width: 100% !important;
  }

  /* Tweaks panel */
  .tweaks-panel {
    left: 12px; right: 12px; bottom: 12px; width: auto;
  }

  /* Banner stacks */
  .banner { font-size: 12px; }

  /* Dropzone smaller */
  .dropzone { min-height: 160px; padding: 20px; }

  /* Segmented controls wrap */
  .segmented { flex-wrap: wrap; }
}

@media (max-width: 560px) {
  main > div[style*="repeat(4, 1fr)"],
  main > div[style*="repeat(2, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
  .wiz-main__header h1 { font-size: 18px; }
  .btn--lg { height: 40px; padding: 0 16px; font-size: 14px; }
}

/* =========================================================
   Dashboard table → stacked cards on phones (≤ 640px)
   ========================================================= */
@media (max-width: 640px) {
  /* Hide the table chrome */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td {
    display: block; width: 100%;
  }
  .table tbody tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin: 0 0 10px;
    padding: 12px 14px;
    box-shadow: var(--sh-sm);
  }
  .table--hover tbody tr:hover { background: var(--surface); }
  .table td {
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 28px;
  }
  .table td:last-child { border-bottom: none; padding-bottom: 0; }
  .table td:first-child { padding-top: 2px; padding-bottom: 8px;
                          border-bottom: 1px solid var(--border); }
  /* Pseudo-label from data-label */
  .table td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--ink-mute);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    flex-shrink: 0;
  }
  /* First cell (Project) — no label, full width content */
  .table td[data-label="Project"]::before { display: none; }
  .table td[data-label="Project"] > div { width: 100%; }
  /* Empty data-label (the actions cell) — push menu to right, hide pseudo */
  .table td[data-label=""]::before { display: none; }
  .table td[data-label=""] { justify-content: flex-end; }

  /* Quick stats row hidden on phone — too noisy */
  main > div[style*="repeat(4, 1fr)"]:not(:has(.btn)) {
    display: none !important;
  }
}

/* =========================================================
   Tweak overrides
   ========================================================= */
/* Accent palette — curated warm/earthen tones that match the Scandi base */
[data-tweak-accent="terracotta"] { --accent: #c78b5e; --accent-hover: #b0744a; --accent-soft: #f5e6d8; --accent-tint: #ebd2be; --sh-accent: 0 6px 18px -8px rgba(199,139,94,0.45); }
[data-tweak-accent="orange"]     { --accent: #d89367; --accent-hover: #bf7a4e; --accent-soft: #f7e8d8; --accent-tint: #efd5bd; --sh-accent: 0 6px 18px -8px rgba(216,147,103,0.45); }
[data-tweak-accent="moss"]       { --accent: #7a9667; --accent-hover: #637d52; --accent-soft: #e3ecd9; --accent-tint: #cbdabb; --sh-accent: 0 6px 18px -8px rgba(122,150,103,0.45); }
[data-tweak-accent="rust"]       { --accent: #a8553a; --accent-hover: #8a4027; --accent-soft: #f0dacd; --accent-tint: #e2bea8; --sh-accent: 0 6px 18px -8px rgba(168,85,58,0.45); }
[data-tweak-accent="indigo"]     { --accent: #4a5a7a; --accent-hover: #394767; --accent-soft: #dde2ec; --accent-tint: #c3cada; --sh-accent: 0 6px 18px -8px rgba(74,90,122,0.40); }
[data-tweak-accent="slate"]      { --accent: #5a5149; --accent-hover: #403831; --accent-soft: #e0dad3; --accent-tint: #c9c0b6; --sh-accent: 0 6px 18px -8px rgba(90,81,73,0.40); }

[data-tweak-radius="sharp"]   { --radius-scale: 0.25; }
[data-tweak-radius="default"] { --radius-scale: 1; }
[data-tweak-radius="soft"]    { --radius-scale: 2.2; }

[data-tweak-density="compact"]     { font-size: 12.5px; }
[data-tweak-density="comfortable"] { font-size: 14px; }
[data-tweak-density="cozy"]        { font-size: 15.5px; }
[data-tweak-density="compact"] .card { padding-block: 12px; padding-inline: 14px; }
[data-tweak-density="cozy"] .card    { padding-block: 24px; padding-inline: 26px; }
[data-tweak-density="compact"] .wiz-main__body { padding-top: 12px; }
[data-tweak-density="cozy"] .wiz-main__body    { padding-top: 32px; }
