/* VAULT Studio · componentes e layout (padrão Apple para web, skill design-apple cap. 9) */

*, *::before, *::after { box-sizing: border-box; }
html { font-family: var(--font-sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; height: 100%; }
body { margin: 0; min-height: 100%; background: var(--bg-grouped); color: var(--label); font: var(--text-body); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-s); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }

/* Tipografia semântica */
.large-title { font: var(--text-large-title); font-weight: 700; letter-spacing: -0.2px; margin: 0; }
.title-1 { font: var(--text-title-1); font-weight: 700; margin: 0; }
.title-2 { font: var(--text-title-2); font-weight: 700; margin: 0; }
.title-3 { font: var(--text-title-3); font-weight: 600; margin: 0; }
.headline { font: var(--text-headline); margin: 0; }
.body { font: var(--text-body); margin: 0; }
.callout { font: var(--text-callout); margin: 0; }
.subhead { font: var(--text-subhead); margin: 0; }
.footnote { font: var(--text-footnote); color: var(--label-2); margin: 0; }
.secondary { color: var(--label-2); }
.tertiary { color: var(--label-3); }

/* App shell: sidebar (260) + detalhe */
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--bg-2); border-right: var(--hairline) solid var(--separator); display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4) var(--space-3); position: sticky; top: 0; height: 100vh; overflow: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.sidebar-brand .mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(145deg, var(--sys-orange), #c2410c); flex: none; }
.sidebar-brand .name { font: var(--text-headline); letter-spacing: .06em; }
.sidebar-section { display: flex; flex-direction: column; gap: 2px; }
.sidebar-section > .footnote { padding: 0 10px 4px; text-transform: none; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 10px; border-radius: var(--radius-s); color: var(--label); background: transparent; border: 0; text-align: left; width: 100%; font: var(--text-body); }
.nav-item svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.nav-item:hover { background: var(--fill-4); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--fill-2); font-weight: 600; }
.nav-item[aria-disabled="true"] { color: var(--label-3); pointer-events: none; }
.nav-item[aria-disabled="true"] svg { color: var(--label-3); }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-3); }
.status-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-s); background: var(--bg-grouped-2); font: var(--text-callout); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sys-gray3); flex: none; }
.status-dot.ok { background: var(--sys-green); }
.status-dot.warn { background: var(--sys-orange); }

.detail { min-width: 0; display: flex; flex-direction: column; }
.toolbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: 10px var(--gutter); background: var(--glass-bg); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border-bottom: var(--hairline) solid var(--separator); min-height: 52px; }
.toolbar .title-2 { margin-right: var(--space-2); }
.toolbar .spacer { flex: 1 1 auto; }
.toolbar-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.content { padding: var(--space-6) var(--gutter) var(--space-12); display: flex; flex-direction: column; gap: var(--space-6); }
.content.flush { padding: var(--space-4) var(--space-4) var(--space-6); }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3); }

/* Botões (um proeminente por contexto) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 0 14px; border-radius: var(--radius-s); border: 0; background: var(--fill-3); color: var(--label); font: var(--text-body); font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--fill-2); }
.btn:active { background: var(--fill); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--label)); }
.btn-tinted { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600; }
.btn-tinted:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.btn-plain { background: transparent; color: var(--accent); font-weight: 500; }
.btn-plain:hover { background: var(--fill-4); }
.btn-destructive { color: var(--sys-red); background: transparent; }
.btn-destructive:hover { background: color-mix(in srgb, var(--sys-red) 12%, transparent); }
.btn-destructive.filled { background: var(--sys-red); color: #fff; }
.btn-lg { min-height: 44px; padding: 0 18px; border-radius: var(--radius-m); font-size: 15px; }
.btn-icon { width: 32px; min-width: 32px; padding: 0; }
.btn-icon.lg { width: 44px; min-height: 44px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* Segmented control */
.segmented { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--fill-3); gap: 2px; }
.segmented button { min-height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--label); font: var(--text-body); font-weight: 500; }
.segmented button[aria-pressed="true"] { background: var(--bg-grouped-2); box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 0 0 var(--hairline) rgba(0,0,0,.06); font-weight: 600; }
.segmented.lg button { min-height: 36px; }

/* Toggle (switch) */
.switch { appearance: none; -webkit-appearance: none; width: 40px; height: 24px; border-radius: 12px; background: var(--fill); position: relative; cursor: pointer; margin: 0; transition: background var(--dur-base) var(--ease-standard); flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--dur-base) var(--ease-standard); }
.switch:checked { background: var(--sys-green); }
.switch:checked::after { transform: translateX(16px); }
.switch:disabled { opacity: .4; }

/* Campos */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font: var(--text-callout); color: var(--label-2); }
.input, select.input, textarea.input { min-height: 32px; padding: 0 10px; border-radius: var(--radius-s); border: var(--hairline) solid var(--separator-opaque); background: var(--bg-grouped-2); color: var(--label); font: var(--text-body); width: 100%; }
.input::placeholder { color: var(--placeholder); }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.input.lg { min-height: 44px; font-size: 15px; }
select.input { padding-right: 28px; appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--label-2) 50%), linear-gradient(135deg, var(--label-2) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.search { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--fill-3); }
.search input { border: 0; background: transparent; flex: 1; min-width: 0; outline: none; }
.search svg { width: 14px; height: 14px; color: var(--label-2); }

/* Listas agrupadas (insetGrouped) e cards */
.group { background: var(--bg-grouped-2); border-radius: var(--radius-l); overflow: hidden; }
.group-header { font: var(--text-callout); color: var(--label-2); padding: 0 var(--space-4) var(--space-2); }
.group-footer { font: var(--text-footnote); color: var(--label-2); padding: var(--space-2) var(--space-4) 0; }
.row { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 8px var(--space-4); }
.row + .row { border-top: var(--hairline) solid var(--separator); margin-left: var(--space-4); padding-left: 0; }
.row .grow { flex: 1 1 auto; min-width: 0; }
.row .value { color: var(--label-2); text-align: right; }
.row .chevron { color: var(--label-3); width: 14px; height: 14px; }
.row.clickable { cursor: pointer; }
.row.clickable:hover { background: var(--fill-4); }
.row.selected { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.card { background: var(--bg-grouped-2); border-radius: var(--radius-l); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.card.pad-lg { padding: var(--space-6); }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.hstack { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-4); }
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); }
.kpi { background: var(--bg-grouped-2); border-radius: var(--radius-l); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.kpi .big { font: var(--text-title-1); font-weight: 700; }
.kpi.good .big { color: var(--sys-green); }
.kpi.warn .big { color: var(--sys-orange); }
.kpi.bad .big { color: var(--sys-red); }

/* Chips / badges */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--fill-3); font: var(--text-callout); font-weight: 500; color: var(--label); white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--on-accent); }
.chip.ok { background: color-mix(in srgb, var(--sys-green) 16%, transparent); color: var(--sys-green); }
.chip.warn { background: color-mix(in srgb, var(--sys-orange) 18%, transparent); color: var(--sys-orange); }
.chip.bad { background: color-mix(in srgb, var(--sys-red) 14%, transparent); color: var(--sys-red); }
.chip button { all: unset; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.select .chip { cursor: pointer; }
.chips.select .chip:hover:not(.on) { background: var(--fill-2); }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; box-shadow: inset 0 0 0 var(--hairline) rgba(0,0,0,.2); }
.sw-cinza { background: #C9CDD3; } .sw-preto { background: #2B2D31; } .sw-laranja { background: #F07A2C; } .sw-branco { background: #F4F4F4; } .sw-azul { background: #2F6FED; } .sw-vermelho { background: #D7263D; } .sw-verde { background: #2E9E5B; } .sw-amarelo { background: #E9C030; }

/* Tabelas */
.table-wrap { overflow-x: auto; background: var(--bg-grouped-2); border-radius: var(--radius-l); }
table.table { width: 100%; border-collapse: collapse; font: var(--text-body); }
table.table th { text-align: left; font: var(--text-callout); font-weight: 600; color: var(--label-2); padding: 10px 12px; border-bottom: var(--hairline) solid var(--separator); white-space: nowrap; }
table.table td { padding: 9px 12px; border-bottom: var(--hairline) solid var(--separator); vertical-align: top; }
table.table tr:last-child td { border-bottom: 0; }
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ok { color: var(--sys-green); font-weight: 600; }
.warn { color: var(--sys-orange); font-weight: 600; }
.bad { color: var(--sys-red); font-weight: 600; }

/* Avisos do motor de regras */
.notice { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--radius-m); background: var(--bg-grouped-2); font: var(--text-body); align-items: flex-start; }
.notice .icon { width: 18px; height: 18px; flex: none; margin-top: -1px; }
.notice.ok .icon { color: var(--sys-green); }
.notice.info .icon { color: var(--sys-blue); }
.notice.warn .icon { color: var(--sys-orange); }
.notice.error .icon { color: var(--sys-red); }
.notice .rule { color: var(--label-3); font: var(--text-footnote); margin-left: auto; white-space: nowrap; }

/* Montador: paleta · viewport · inspetor */
.builder { display: grid; grid-template-columns: 280px minmax(0, 1fr) 320px; gap: var(--space-4); align-items: start; }
.palette, .inspector { background: var(--bg-grouped-2); border-radius: var(--radius-l); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3); max-height: calc(100vh - 140px); overflow: auto; position: sticky; top: 68px; }
.viewport { position: relative; background: var(--scene-bg); border-radius: var(--radius-l); min-height: 560px; height: calc(100vh - 230px); overflow: hidden; }
.viewport canvas { display: block; width: 100%; height: 100%; outline: none; }
.viewport.dropping { box-shadow: inset 0 0 0 2px var(--accent); }
.viewport .overlay-tl { position: absolute; left: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.viewport .overlay-tr { position: absolute; right: 12px; top: 12px; display: flex; gap: 6px; }
.viewport .overlay-br { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; }
.viewport .overlay-bl { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 6px; pointer-events: none; }
.viewport .glass-chip { background: var(--glass-bg); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border-radius: var(--radius-pill); padding: 5px 10px; font: var(--text-callout); box-shadow: 0 0 0 var(--hairline) rgba(0,0,0,.08); pointer-events: auto; }
.viewport .btn { background: var(--glass-bg); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); box-shadow: 0 0 0 var(--hairline) rgba(0,0,0,.08); }
.viewport .btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.part { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-m); background: var(--bg-grouped-3); cursor: grab; border: var(--hairline) solid transparent; }
.part:hover { border-color: var(--separator-opaque); }
.part:active { cursor: grabbing; }
.part .grip { width: 8px; height: 22px; border-radius: 2px; background: repeating-linear-gradient(var(--label-3) 0 2px, transparent 2px 5px); flex: none; }
.part .meta { font: var(--text-footnote); color: var(--label-2); }
.part .fit { margin-left: auto; font: var(--text-footnote); font-weight: 600; }
.part[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.floors { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--bg-grouped-2); border-radius: var(--radius-l); padding: 10px 12px; }
.floor { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 10px; border-radius: var(--radius-s); background: var(--bg-grouped-3); border: 0; color: var(--label); font: var(--text-body); }
.floor[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent) inset; font-weight: 600; }
.floor .swatch { width: 10px; height: 10px; }
.stats { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px 14px; font: var(--text-callout); color: var(--label-2); font-variant-numeric: tabular-nums; }
.inspector h3 { margin: 0; }
.inspector .field + .field { margin-top: 4px; }
.option-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 36px; }
.option-row .label { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.option-row .label small { font: var(--text-footnote); color: var(--label-2); }

/* Grade de furos (interior) */
.holes { position: relative; background: #2B2D31; border-radius: 10px; box-shadow: inset 0 0 0 14px #3A3D42; padding: 14px; display: inline-block; }
.holes svg { display: block; }

/* Sheets e alertas */
dialog { border: 0; padding: 0; background: transparent; color: var(--label); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.sheet { background: var(--bg-grouped-2); border-radius: var(--radius-xl); padding: var(--space-6); width: min(560px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: var(--space-4); box-shadow: 0 24px 64px rgba(0,0,0,.25); }
.alert { background: var(--bg-grouped-2); border-radius: var(--radius-l); padding: var(--space-5); width: min(320px, calc(100vw - 32px)); text-align: center; display: flex; flex-direction: column; gap: var(--space-3); }
.alert .actions { display: flex; gap: 8px; justify-content: center; }
.alert .actions .btn { flex: 1; }
.sheet .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* Templates de início */
.template { display: flex; flex-direction: column; gap: 8px; padding: var(--space-4); border-radius: var(--radius-l); background: var(--bg-grouped-2); border: 0; text-align: left; color: var(--label); cursor: pointer; min-height: 150px; }
.template:hover { background: var(--bg-grouped-3); box-shadow: 0 0 0 2px var(--accent) inset; }
.template svg { width: 100%; height: 72px; }
.template ul { margin: 0; padding-left: 16px; font: var(--text-callout); color: var(--label-2); }
.project-card { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--bg-grouped-2); border-radius: var(--radius-l); }
.project-card .thumb { width: 56px; height: 56px; border-radius: 12px; background: var(--fill-3); display: grid; place-items: center; flex: none; }
.project-card .thumb svg { width: 36px; height: 36px; }
.project-card .info { flex: 1; min-width: 0; }
.project-card .info .footnote { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; padding: var(--space-10) var(--space-4); display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.empty svg { width: 48px; height: 48px; color: var(--label-3); }

/* Progresso */
progress { appearance: none; -webkit-appearance: none; width: 100%; height: 4px; border: 0; border-radius: 2px; background: var(--fill); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--fill); border-radius: 2px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 2px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--fill); border-top-color: var(--accent); animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Guia */
.step { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: var(--radius-s); }
.step.done { color: var(--label-2); }
.step input[type="checkbox"] { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); }

/* Responsivo */
@media (max-width: 1180px) {
  .builder { grid-template-columns: 260px minmax(0, 1fr); }
  .inspector { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; transform: translateX(-100%); transition: transform var(--dur-base) var(--ease-standard); z-index: 40; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  .sidebar-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 39; display: none; }
  .sidebar-scrim.open { display: block; }
  .menu-btn { display: inline-flex; }
}
@media (min-width: 1025px) { .menu-btn { display: none; } .sidebar-scrim { display: none !important; } }
@media (max-width: 767px) {
  .builder { grid-template-columns: 1fr; }
  .palette { position: static; max-height: none; }
  .viewport { height: 60vh; min-height: 380px; }
  .toolbar { padding: 8px var(--gutter); }
  .content { padding: var(--space-4) var(--gutter) var(--space-10); }
}

/* Pré-visualização das placas (Exportar) */
.plate-row { align-items: flex-start; gap: var(--space-3); }
.plate-preview { width: 132px; flex: 0 0 132px; aspect-ratio: 1 / 1; border-radius: var(--radius-s); overflow: hidden; }
.plate-preview .bed { fill: var(--bg-grouped-3); stroke: var(--separator); stroke-width: 1.5; }
.plate-preview .gridline { stroke: var(--separator); stroke-opacity: .35; stroke-width: 0.8; }
.plate-preview .piece { stroke: rgba(0, 0, 0, .35); stroke-width: 1; }
@media (max-width: 767px) { .plate-preview { width: 96px; flex-basis: 96px; } }
