:root {
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto,
    Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --surface-3: #f3f5fb;
  --text: #0f172a;
  --muted: #475569;
  --muted-2: #64748b;
  --border: rgba(15, 23, 42, 0.14);
  --border-2: rgba(15, 23, 42, 0.09);

  --shadow-1: 0 18px 60px rgba(15, 23, 42, 0.12);
  --shadow-2: 0 12px 28px rgba(15, 23, 42, 0.12);

  --accent: #1d4ed8;
  --accent-2: #f97316;
  --danger: #dc2626;
  --focus: rgba(29, 78, 216, 0.35);

  --badge-green-bg: rgba(16, 185, 129, 0.16);
  --badge-green-fg: #047857;
  --badge-amber-bg: rgba(245, 158, 11, 0.18);
  --badge-amber-fg: #92400e;
  --badge-red-bg: rgba(239, 68, 68, 0.16);
  --badge-red-fg: #b91c1c;
  --badge-blue-bg: rgba(56, 189, 248, 0.18);
  --badge-blue-fg: #075985;

  --missing-bg: rgba(245, 158, 11, 0.08);
  --missing-ring: rgba(245, 158, 11, 0.5);

  --head-1-h: 36px;
  --head-2-h: 46px;

  --w-idx: 56px;
  --w-room: 176px;
  --w-opening: 232px;
  --w-type: 124px;

  --left-room: var(--w-idx);
  --left-opening: calc(var(--w-idx) + var(--w-room));
  --left-type: calc(var(--w-idx) + var(--w-room) + var(--w-opening));
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 18% 0%, rgba(29, 78, 216, 0.11), transparent 62%),
    radial-gradient(900px 560px at 86% 14%, rgba(249, 115, 22, 0.11), transparent 58%),
    radial-gradient(900px 560px at 74% 94%, rgba(20, 184, 166, 0.11), transparent 58%),
    repeating-linear-gradient(
      0deg,
      rgba(15, 23, 42, 0.03),
      rgba(15, 23, 42, 0.03) 1px,
      transparent 1px,
      transparent 26px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(15, 23, 42, 0.02),
      rgba(15, 23, 42, 0.02) 1px,
      transparent 1px,
      transparent 26px
    ),
    var(--bg);
}

.mono {
  font-family: var(--font-mono);
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-2);
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
}

.mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(29, 78, 216, 0.15), rgba(249, 115, 22, 0.15));
  border: 1px solid rgba(15, 23, 42, 0.08);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 10px;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.12);
}

.mark__dot {
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(29, 78, 216, 0.75), rgba(29, 78, 216, 0.12));
}

.mark__dot:nth-child(2) {
  background: linear-gradient(180deg, rgba(249, 115, 22, 0.72), rgba(249, 115, 22, 0.12));
}

.mark__dot:nth-child(3) {
  background: linear-gradient(180deg, rgba(20, 184, 166, 0.72), rgba(20, 184, 166, 0.12));
}

.mark__dot:nth-child(4) {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.32), rgba(15, 23, 42, 0.06));
}

.topbar__title h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.topbar__title p {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: var(--muted-2);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease,
    background 120ms ease, color 120ms ease, opacity 120ms ease;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(15, 23, 42, 0.18);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.btn:active:not(:disabled) {
  transform: translateY(0px);
}

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

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus);
}

.btn--primary {
  background: linear-gradient(180deg, rgba(29, 78, 216, 0.98), rgba(29, 78, 216, 0.92));
  border-color: rgba(29, 78, 216, 0.32);
  color: white;
}

.btn--danger {
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.98), rgba(220, 38, 38, 0.9));
  border-color: rgba(220, 38, 38, 0.3);
  color: white;
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.5);
  box-shadow: none;
}

.btn--file {
  position: relative;
  overflow: hidden;
}

.btn--file input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.quote-strip {
  padding: 14px 20px 2px 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: stretch;
}

.quote-pill {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  min-width: 210px;
}

.quote-pill__label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
}

.quote-pill__value {
  display: block;
  margin-top: 4px;
  font-weight: 650;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 14px 14px 18px 14px;
  align-items: start;
}

body.panel-open .workspace {
  grid-template-columns: minmax(0, 1fr) 420px;
}

.sheet__frame {
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 22px;
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.sheet__hint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  color: var(--muted);
  font-size: 12px;
}

.hint-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(20, 184, 166, 0.95), rgba(20, 184, 166, 0.25));
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.12);
}

.sheet__scroll {
  width: 100%;
  overflow: auto;
  background: rgba(255, 255, 255, 0.92);
}

.sheet__scroll:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 4px var(--focus);
}

.sheet__table {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.sheet__table th,
.sheet__table td {
  border-right: 1px solid rgba(15, 23, 42, 0.08);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  padding: 8px 10px;
  vertical-align: middle;
  background: white;
  white-space: nowrap;
}

.sheet__table th {
  font-weight: 700;
  color: #334155;
}

.head--groups th {
  position: sticky;
  top: 0;
  height: var(--head-1-h);
  z-index: 60;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 11px;
  background: linear-gradient(180deg, rgba(243, 245, 251, 0.96), rgba(243, 245, 251, 0.78));
}

.head--labels th {
  position: sticky;
  top: var(--head-1-h);
  height: var(--head-2-h);
  z-index: 70;
  background: linear-gradient(180deg, rgba(250, 250, 252, 0.98), rgba(250, 250, 252, 0.86));
}

.head__group {
  text-align: left;
  border-bottom: 1px solid rgba(15, 23, 42, 0.09);
}

.head__group--basics {
  box-shadow: inset 0 -2px 0 rgba(29, 78, 216, 0.18);
}

.head__group--size {
  box-shadow: inset 0 -2px 0 rgba(20, 184, 166, 0.18);
}

.head__group--specs {
  box-shadow: inset 0 -2px 0 rgba(249, 115, 22, 0.2);
}

.head__group--finish {
  box-shadow: inset 0 -2px 0 rgba(15, 23, 42, 0.14);
}

.head__group--vendor {
  box-shadow: inset 0 -2px 0 rgba(56, 189, 248, 0.2);
}

.head__group--media {
  box-shadow: inset 0 -2px 0 rgba(239, 68, 68, 0.18);
}

.sticky-col {
  position: sticky;
  z-index: 40;
}

.head--labels .sticky-col {
  z-index: 95;
}

.col-idx {
  left: 0;
  min-width: var(--w-idx);
  width: var(--w-idx);
  text-align: right;
  color: #64748b;
  font-family: var(--font-mono);
  font-size: 11px;
  background: linear-gradient(180deg, rgba(250, 250, 252, 1), rgba(250, 250, 252, 0.9));
}

.col-room {
  left: var(--left-room);
  min-width: var(--w-room);
  width: var(--w-room);
  background: white;
}

.head--labels .col-room {
  background: linear-gradient(180deg, rgba(250, 250, 252, 1), rgba(250, 250, 252, 0.9));
}

.col-opening {
  left: var(--left-opening);
  min-width: var(--w-opening);
  width: var(--w-opening);
  background: white;
}

.head--labels .col-opening {
  background: linear-gradient(180deg, rgba(250, 250, 252, 1), rgba(250, 250, 252, 0.9));
}

.col-type {
  left: var(--left-type);
  min-width: var(--w-type);
  width: var(--w-type);
  background: white;
}

.head--labels .col-type {
  background: linear-gradient(180deg, rgba(250, 250, 252, 1), rgba(250, 250, 252, 0.9));
}

.col-idx,
.col-room,
.col-opening,
.col-type {
  box-shadow: 2px 0 0 rgba(15, 23, 42, 0.06);
}

.group-row td {
  padding: 0;
  background: linear-gradient(90deg, rgba(248, 250, 252, 0.98), rgba(248, 250, 252, 0.78));
}

.group-row__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 10px 10px;
  gap: 10px;
}

.group-row__left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.group-row__bar {
  width: 10px;
  height: 28px;
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.04);
}

.group-row__name {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.group-row__count {
  margin-left: 10px;
  font-size: 11px;
  color: var(--muted-2);
  font-family: var(--font-mono);
}

.group-row__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-btn {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.mini-btn:hover {
  border-color: rgba(15, 23, 42, 0.2);
  transform: translateY(-1px);
}

.data-row {
  cursor: pointer;
}

.data-row:hover td {
  background: #fbfcff;
}

.data-row.is-selected td {
  background: rgba(29, 78, 216, 0.06);
}

.data-row.is-selected .sticky-col {
  background: rgba(29, 78, 216, 0.08);
}

.data-row:focus-visible {
  outline: none;
}

.data-row:focus-visible td {
  box-shadow: inset 0 0 0 3px var(--focus);
}

.cell {
  min-width: 140px;
}

.cell--narrow {
  min-width: 110px;
}

.cell--tight {
  min-width: 86px;
}

.cell--center {
  text-align: center;
  min-width: 90px;
}

.cell--readonly {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #64748b;
  background: #fbfcff;
}

.cell--mono {
  font-family: var(--font-mono);
}

.input-cell,
.select-cell {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  padding: 7px 8px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.9);
  transition: box-shadow 120ms ease, border-color 120ms ease, background 120ms ease;
}

.input-cell:focus,
.select-cell:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus);
  border-color: rgba(29, 78, 216, 0.35);
  background: white;
}

.input-cell.is-missing {
  background: var(--missing-bg);
  border-color: rgba(245, 158, 11, 0.25);
}

.input-cell.is-missing:focus {
  box-shadow: 0 0 0 4px var(--missing-ring);
  border-color: rgba(245, 158, 11, 0.3);
}

.checkbox-cell {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.pill-btn {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.035);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 800;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
}

.pill-btn:hover {
  background: rgba(29, 78, 216, 0.07);
  border-color: rgba(29, 78, 216, 0.2);
}

.status-cell {
  display: grid;
  gap: 6px;
  min-width: 150px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.01em;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(15, 23, 42, 0.04);
  color: #334155;
}

.badge--needs {
  background: var(--badge-red-bg);
  color: var(--badge-red-fg);
  border-color: rgba(239, 68, 68, 0.22);
}

.badge--measured {
  background: var(--badge-amber-bg);
  color: var(--badge-amber-fg);
  border-color: rgba(245, 158, 11, 0.28);
}

.badge--ready {
  background: var(--badge-green-bg);
  color: var(--badge-green-fg);
  border-color: rgba(16, 185, 129, 0.26);
}

.meter {
  height: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(29, 78, 216, 0.95), rgba(20, 184, 166, 0.85));
}

.panel {
  display: none;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 22px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 110px);
}

body.panel-open .panel {
  display: block;
}

.panel__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 12px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.66);
  backdrop-filter: blur(16px);
}

.panel__kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.panel__title h2 {
  margin: 6px 0 0 0;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.panel__close {
  display: inline-flex;
}

.panel__empty {
  padding: 16px;
}

.empty-card {
  border: 1px dashed rgba(15, 23, 42, 0.18);
  background: rgba(248, 250, 252, 0.8);
  border-radius: 18px;
  padding: 16px;
}

.empty-card__title {
  margin: 0;
  font-weight: 900;
}

.empty-card__body {
  margin: 8px 0 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.panel__content {
  padding: 16px;
  overflow: auto;
}

.panel-section + .panel-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.panel-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-section__head h3 {
  margin: 0;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.panel-section__sub {
  margin: 0;
  font-size: 11px;
  color: var(--muted-2);
}

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

.status-inline__pct {
  font-size: 11px;
  color: var(--muted-2);
}

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

.field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #334155;
}

.field span {
  font-weight: 700;
  font-size: 11px;
  color: var(--muted-2);
}

.field--full {
  grid-column: 1 / -1;
}

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

.input,
.select,
.textarea {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  transition: box-shadow 120ms ease, border-color 120ms ease, background 120ms ease;
}

.textarea {
  font-family: var(--font-sans);
  resize: vertical;
  min-height: 110px;
  line-height: 1.55;
  font-weight: 600;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus);
  border-color: rgba(29, 78, 216, 0.35);
  background: white;
}

.check {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.photos-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

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

.photo-card {
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.photo-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.photo-card__meta {
  padding: 10px 10px 12px 10px;
  display: grid;
  gap: 8px;
}

.photo-card__name {
  font-size: 11px;
  color: #334155;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-card__remove {
  border: 1px solid rgba(220, 38, 38, 0.22);
  background: rgba(255, 255, 255, 0.7);
  color: #b91c1c;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.photo-card__remove:hover {
  background: rgba(220, 38, 38, 0.08);
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 500;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .panel {
    position: fixed;
    inset: auto 12px 12px 12px;
    top: auto;
    max-height: calc(100vh - 24px);
    transform: translateY(120%);
    transition: transform 160ms ease;
    z-index: 600;
  }

  body.drawer-open .panel {
    transform: translateY(0%);
  }

  .panel__close {
    display: inline-flex;
  }

  body.drawer-open .drawer-scrim {
    display: block;
  }

  .drawer-scrim[hidden] {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .mini-btn,
  .panel {
    transition: none;
  }
}
