:root {
  --accent: #7A8B68;
  --accent-hover: #677756;
  --accent-soft: rgba(122, 139, 104, 0.14);

  --bg: #F5F3EE;
  --surface: #FFFFFF;
  --surface-alt: #FAF9F6;
  --text: #18191C;
  --text-muted: #62656C;
  --border: #E4E0D8;
  --border-strong: #CEC8BC;

  --danger: #B94A48;
  --danger-soft: rgba(185, 74, 72, 0.12);
  --warning: #B07D2B;
  --warning-soft: rgba(176, 125, 43, 0.14);
  --success: #4F7749;
  --success-soft: rgba(79, 119, 73, 0.14);
  --info: #4C6E81;
  --info-soft: rgba(76, 110, 129, 0.14);

  --shadow-sm: 0 1px 2px rgba(18, 19, 22, 0.05);
  --shadow-md: 0 10px 30px rgba(18, 19, 22, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 260px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
}

[data-theme="dark"] {
  --bg: #121316;
  --surface: #1A1C20;
  --surface-alt: #212429;
  --text: #F4EFE6;
  --text-muted: #A1A5AE;
  --border: #2C3037;
  --border-strong: #3E434D;
  --accent-soft: rgba(122, 139, 104, 0.22);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.45);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Typography & Buttons */
h1, h2, h3, h4, p {
  margin: 0;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.btn-danger:hover:not(:disabled) {
  opacity: 0.9;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-alt);
}

/* Inputs & Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="search"],
.field select,
.field textarea,
.input,
.select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-checkbox-align {
  justify-content: flex-end;
  padding-bottom: 6px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

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

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

.field-span-2 {
  grid-column: span 2;
}

.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0;
}

.fieldset legend {
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.color-pair {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-pair input[type="color"] {
  width: 40px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  background: var(--danger-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.muted-text {
  color: var(--text-muted);
  font-size: 12px;
}

/* Auth Gate */
.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 40px;
  height: 44px;
  border-radius: 8px;
  flex-shrink: 0;
}

.auth-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.entra-login-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-microsoft {
  justify-content: center;
  font-weight: 500;
}

.auth-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  text-align: center;
}

.auth-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.auth-hint code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.auth-back-link {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}

.auth-back-link:hover {
  text-decoration: underline;
}

/* Admin Shell Layout */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-name {
  display: block;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
}

.brand-role {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.nav-badge.accent {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.sidebar-foot-note {
  font-size: 11px;
  color: var(--text-muted);
}

.main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

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

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 12px;
}

.user-badge-name {
  font-weight: 600;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.role-admin { background: var(--accent-soft); color: var(--accent); }
.role-editor { background: var(--info-soft); color: var(--info); }
.role-atendimento { background: var(--warning-soft); color: var(--warning); }

.badge-active { background: var(--success-soft); color: var(--success); }
.badge-inactive { background: var(--danger-soft); color: var(--danger); }
.badge-provider {
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.main-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Cards & KPI */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

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

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-meta {
  font-size: 11px;
  color: var(--text-muted);
}

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

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-alt);
}

tr:last-child td {
  border-bottom: none;
}

.table-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.piece-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.piece-title {
  font-weight: 600;
  color: var(--text);
}

.piece-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-exposicao { background: var(--success-soft); color: var(--success); }
.badge-sob_encomenda { background: var(--info-soft); color: var(--info); }
.badge-rascunho { background: var(--warning-soft); color: var(--warning); }
.badge-arquivado { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }

.badge-novo { background: var(--accent-soft); color: var(--accent); }
.badge-em_atendimento { background: var(--info-soft); color: var(--info); }
.badge-orcado { background: var(--success-soft); color: var(--success); }

.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 240px;
  flex-wrap: wrap;
}

.toolbar-filters .input {
  max-width: 320px;
}

.toolbar-filters .select {
  width: auto;
  min-width: 170px;
}

.toolbar-lead {
  color: var(--text-muted);
  font-size: 13px;
}

/* Checklist */
.checklist-list {
  display: flex;
  flex-direction: column;
}

.checklist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.checklist-row:last-child {
  border-bottom: none;
}

.checklist-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.missing-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--warning-soft);
  color: var(--warning);
  font-weight: 500;
}

/* Cards Grids (Environments & Materials) */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}

.env-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.env-card-img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  background: var(--surface-alt);
}

.env-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.env-card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.material-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.material-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.material-swatch {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.material-actions {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Inquiries */
.inquiries-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.inquiry-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.inquiry-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.inquiry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.inquiry-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inquiry-note-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
}

.inquiry-controls {
  display: grid;
  grid-template-columns: 200px 1fr auto;
  gap: 12px;
  align-items: end;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Settings & Backup */
.settings-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  align-items: start;
}

.settings-layout .form-grid {
  padding: 20px;
}

.backup-actions {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.backup-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.backup-block h4 {
  font-size: 14px;
}

.backup-block p {
  font-size: 12px;
  color: var(--text-muted);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}

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

.file-input {
  font-size: 12px;
  max-width: 100%;
}

/* Image Picker & Swatches Picker */
.image-picker-layout {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 14px;
  align-items: start;
}

.image-preview-box {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface-alt);
}

.image-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-picker-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.asset-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.asset-thumb-btn {
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  width: 52px;
  height: 52px;
  cursor: pointer;
  background: var(--surface-alt);
}

.asset-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.asset-thumb-btn.selected {
  border-color: var(--accent);
}

.swatches-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}

.swatch-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
}

.swatch-option:hover {
  background: var(--surface-alt);
}

.swatch-dot {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.pieces-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

/* Mattress Editor */
.mattress-toggle-row {
  margin-bottom: 10px;
}

.mattress-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.layers-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.layers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layer-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 13, 16, 0.55);
  backdrop-filter: blur(2px);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-xs { max-width: 420px; }
.modal-sm { max-width: 500px; }
.modal-md { max-width: 680px; }
.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1180px; }

/* Piece Editor 2-Column Split & Live Preview */
.piece-editor-split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.95fr);
  gap: 20px;
  padding: 20px;
  overflow-y: auto;
  align-items: start;
}

.piece-editor-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.piece-editor-form .modal-footer {
  margin: 4px -4px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.piece-live-preview {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

.preview-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.preview-pane-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.preview-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.preview-vitrine-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.preview-card-media {
  position: relative;
  width: 100%;
  height: 180px;
  background: var(--bg);
  overflow: hidden;
}

.preview-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-card-media .badge {
  position: absolute;
  top: 10px;
  left: 10px;
  backdrop-filter: blur(4px);
}

.preview-card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-card-cat {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.preview-card-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

.preview-card-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.preview-swatches {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 2px;
}

.preview-swatch-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

.preview-card-dims {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.preview-ficha-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-ficha-summary {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.preview-ficha-specs {
  font-size: 12px;
  color: var(--text-muted);
  white-space: pre-line;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.preview-mattress-box {
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-firmness-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.preview-firmness-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  overflow: hidden;
}

.preview-firmness-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.15s ease;
}

.preview-firmness-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.preview-layers-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text);
}

/* Settings Tabs Section */
.settings-tabs-section {
  padding: 0 20px 20px;
}

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

.settings-tab-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-alt);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
}

.toast.error {
  background: var(--danger);
  color: #FFFFFF;
}

.toast.success {
  background: var(--accent);
  color: #FFFFFF;
}

.empty-state {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.mobile-only {
  display: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 13, 16, 0.5);
  z-index: 35;
}

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-columns,
  .settings-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .mobile-only {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .form-grid,
  .form-grid-3,
  .image-picker-layout,
  .inquiry-controls,
  .piece-editor-split,
  .settings-tabs-grid {
    grid-template-columns: 1fr;
  }
  .piece-live-preview {
    position: static;
  }
  .field-span-2 {
    grid-column: span 1;
  }
  .topbar {
    padding: 12px 16px;
  }
  .main-content {
    padding: 16px;
  }
}
