/* =====================================================================
   CostMaster PRO — Stylesheet
   Design: identidade "ateliê premium" — inspirada no vocabulário visual
   da alfaiataria (linhas de corte, giz de alfaiate, régua) traduzido
   para uma interface de SaaS financeiro (Stripe/Linear/Notion).
   ===================================================================== */

/* ---------------------------- FONTS ---------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

/* ---------------------------- TOKENS ---------------------------------- */
:root {
  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --accent: #c9a227;       /* latão / giz dourado */
  --accent-ink: #8a6f19;
  --accent-2: #1f7a6c;     /* linha de costura teal */
  --danger: #a8394a;       /* alfinete / vinho */
  --success: #2f9e63;

  --gold-1: #f3d572;
  --gold-2: #c9a227;
  --gold-3: #8a6a12;
  --gradient-gold: linear-gradient(135deg, var(--gold-1) 0%, var(--gold-2) 55%, var(--gold-3) 100%);
  --gradient-gold-text: linear-gradient(135deg, #f8e39a 0%, var(--gold-1) 50%, var(--gold-2) 100%);
  --gradient-black: linear-gradient(160deg, #08080a 0%, #1c1c22 55%, #0a0a0c 100%);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 17, 21, 0.06), 0 1px 1px rgba(15,17,21,0.04);
  --shadow-md: 0 8px 24px rgba(15, 17, 21, 0.10);
  --shadow-lg: 0 16px 48px rgba(15, 17, 21, 0.16);
  --shadow-gold: 0 6px 20px rgba(201, 162, 39, 0.28);

  --transition: 180ms cubic-bezier(.4,0,.2,1);
  --sidebar-w: 264px;

  /* Ilustração decorativa original (vestido, fita métrica, tesoura, linha) usada
     como marca d'água — referencia o universo da confecção sem depender de fotos
     externas (evita problemas de licença e links quebrados no hospedeiro). */
  --fashion-watermark: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%20400%20400%27%3E%20%3Cg%20stroke%3D%27%23f3d572%27%20stroke-width%3D%272%27%20fill%3D%27none%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%20%3Cpath%20d%3D%27M200%2040%20q0%20-14%2014%20-14%20q14%200%2014%2014%27/%3E%20%3Cpath%20d%3D%27M150%2060%20L200%2046%20L250%2060%27/%3E%20%3Cpath%20d%3D%27M182%2060%20L138%20192%20Q132%20212%20158%20217%20L242%20217%20Q268%20212%20262%20192%20L218%2060%20Z%27/%3E%20%3Cpath%20d%3D%27M182%2060%20Q200%2082%20218%2060%27/%3E%20%3C/g%3E%20%3Cg%20stroke%3D%27%23c9a227%27%20stroke-width%3D%272%27%20fill%3D%27none%27%20stroke-linecap%3D%27round%27%3E%20%3Cpath%20d%3D%27M30%20300%20Q80%20258%20130%20300%20Q180%20342%20230%20300%20Q280%20258%20330%20300%27/%3E%20%3Cline%20x1%3D%2755%27%20y1%3D%27293%27%20x2%3D%2755%27%20y2%3D%27305%27/%3E%20%3Cline%20x1%3D%2785%27%20y1%3D%27278%27%20x2%3D%2785%27%20y2%3D%27290%27/%3E%20%3Cline%20x1%3D%27115%27%20y1%3D%27293%27%20x2%3D%27115%27%20y2%3D%27305%27/%3E%20%3Cline%20x1%3D%27155%27%20y1%3D%27320%27%20x2%3D%27155%27%20y2%3D%27332%27/%3E%20%3Cline%20x1%3D%27185%27%20y1%3D%27305%27%20x2%3D%27185%27%20y2%3D%27317%27/%3E%20%3Cline%20x1%3D%27215%27%20y1%3D%27320%27%20x2%3D%27215%27%20y2%3D%27332%27/%3E%20%3Cline%20x1%3D%27255%27%20y1%3D%27293%27%20x2%3D%27255%27%20y2%3D%27305%27/%3E%20%3Cline%20x1%3D%27285%27%20y1%3D%27278%27%20x2%3D%27285%27%20y2%3D%27290%27/%3E%20%3C/g%3E%20%3Cg%20stroke%3D%27%23f3d572%27%20stroke-width%3D%272%27%20fill%3D%27none%27%20stroke-linecap%3D%27round%27%3E%20%3Ccircle%20cx%3D%2755%27%20cy%3D%27345%27%20r%3D%2711%27/%3E%20%3Ccircle%20cx%3D%2755%27%20cy%3D%27378%27%20r%3D%2711%27/%3E%20%3Cpath%20d%3D%27M64%20350%20L128%20300%27/%3E%20%3Cpath%20d%3D%27M64%20373%20L128%20310%27/%3E%20%3C/g%3E%20%3Cg%20stroke%3D%27%23c9a227%27%20stroke-width%3D%272%27%20fill%3D%27none%27%3E%20%3Crect%20x%3D%27295%27%20y%3D%2795%27%20width%3D%2742%27%20height%3D%2762%27%20rx%3D%277%27/%3E%20%3Cellipse%20cx%3D%27316%27%20cy%3D%2795%27%20rx%3D%2721%27%20ry%3D%276%27/%3E%20%3Cellipse%20cx%3D%27316%27%20cy%3D%27157%27%20rx%3D%2721%27%20ry%3D%276%27/%3E%20%3Cpath%20d%3D%27M337%20122%20Q382%20132%20372%20175%20Q362%20208%20328%20198%27/%3E%20%3C/g%3E%20%3C/svg%3E");
}

html[data-theme="dark"] {
  --bg: #0b0b0d;
  --surface: rgba(23, 23, 27, 0.72);
  --surface-2: rgba(30, 30, 35, 0.85);
  --surface-3: rgba(39, 39, 46, 0.95);
  --border-soft: rgba(255, 255, 255, 0.08);
  --text-primary: #f1efe9;
  --text-secondary: #a3a0ac;
  --text-tertiary: #737080;
  --overlay: rgba(6, 6, 8, 0.78);
}

html[data-theme="light"] {
  --bg: #f7f6f2;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-2: rgba(241, 239, 232, 0.9);
  --surface-3: rgba(233, 230, 220, 0.95);
  --border-soft: rgba(20, 18, 14, 0.08);
  --text-primary: #1a1712;
  --text-secondary: #5c5850;
  --text-tertiary: #8a8577;
  --overlay: rgba(20, 18, 14, 0.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  width: 100%;
  height: 100%;
}
#app { position: relative; z-index: 1; }
::selection { background: var(--accent); color: #17130a; }
a { color: inherit; }
button, input, textarea, select { font-family: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-soft); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* Régua de alfaiate — motivo decorativo repetido (linha tracejada) */
.stitch-rule {
  height: 1px;
  background-image: repeating-linear-gradient(90deg, var(--border-soft) 0 6px, transparent 6px 12px);
}

/* ---------------------------- LAYOUT ---------------------------------- */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  /* A sidebar premium fica sempre no tema escuro dourado/preto, mesmo com o
     app no tema claro — reforça a identidade visual da marca. */
  --text-primary: #f5f3ec;
  --text-secondary: #c9c4b6;
  --text-tertiary: #8f8a7c;
  --border-soft: rgba(255, 255, 255, 0.09);
  --surface-2: rgba(255, 255, 255, 0.07);
  background: var(--gradient-black);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--fashion-watermark);
  background-repeat: no-repeat;
  background-position: bottom -30px right -50px;
  background-size: 320px;
  opacity: 0.16;
  pointer-events: none;
}
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(201, 162, 39, 0.35), transparent);
}
.sidebar > * { position: relative; z-index: 1; }

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 16px;
}
.sidebar__brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--gradient-gold);
  display: flex; align-items: center; justify-content: center;
  color: #191307;
  box-shadow: var(--shadow-gold);
}
.sidebar__brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar__brand-title {
  font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: 0.2px;
  background: var(--gradient-gold-text);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sidebar__brand-sub { font-size: 10.5px; color: var(--text-tertiary); letter-spacing: 0.6px; text-transform: uppercase; }

.sidebar__cut { margin: 4px 20px 14px; opacity: 0.6; }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.nav-link svg { flex-shrink: 0; }
.nav-link:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-link--active {
  background: linear-gradient(90deg, rgba(201, 162, 39, 0.22), rgba(201, 162, 39, 0.05));
  color: var(--gold-1);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--gold-2);
}
.nav-link--sub { padding-left: 22px; font-size: 12.5px; }
.sidebar__group-label {
  margin: 14px 12px 4px; padding: 0 12px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--text-tertiary);
}

.sidebar__footer { padding: 14px 20px 20px; }
.lang-switch { display: flex; gap: 6px; }
.lang-option {
  flex: 1;
  padding: 7px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  cursor: pointer;
  transition: all var(--transition);
}
.lang-option:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.lang-option--active { color: var(--gold-1); border-color: var(--gold-2); background: rgba(201, 162, 39, 0.1); }
.sidebar__data-actions { display: flex; flex-direction: column; gap: 6px; }
.text-link {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--text-tertiary);
  padding: 4px 0;
  text-decoration: none;
  transition: color var(--transition);
}
.text-link:hover { color: var(--accent); }

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

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 1px 0 rgba(201, 162, 39, 0.18);
}
.search-field { position: relative; flex: 1; max-width: 360px; }
.search-field svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); }
.search-field input { width: 100%; padding: 9px 12px 9px 34px; }
.topbar__spacer { flex: 1; }
.icon-toggle {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border-soft); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary);
  transition: all var(--transition);
}
.icon-toggle:hover { color: var(--accent); border-color: var(--accent); }

.view-root { padding: 26px 28px 60px; max-width: 1440px; width: 100%; margin: 0 auto; }

.view-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.view-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.2px; }
.view-subtitle { margin: 0; color: var(--text-secondary); font-size: 13.5px; }

/* ---------------------------- HERO BANNER (Dashboard) ---------------------------------- */
.hero-banner {
  position: relative;
  overflow: hidden;
  background: var(--gradient-black);
  border-radius: var(--radius-lg);
  padding: 48px 44px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.hero-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--fashion-watermark);
  background-repeat: no-repeat;
  background-position: right -60px center;
  background-size: 480px;
  opacity: 0.16;
  pointer-events: none;
}
.hero-banner::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at top left, rgba(201, 162, 39, 0.16), transparent 60%);
  pointer-events: none;
}
.hero-banner__content { position: relative; z-index: 1; max-width: 580px; }
.hero-banner__eyebrow {
  display: inline-block;
  font-size: 11.5px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  color: var(--gold-1); margin-bottom: 14px;
}
.hero-banner__title {
  font-family: var(--font-display); font-size: 34px; font-weight: 800; line-height: 1.14;
  letter-spacing: -0.3px;
  margin: 0 0 14px;
  background: var(--gradient-gold-text);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-banner__subtitle { font-size: 14.5px; line-height: 1.65; color: #c9c4b6; margin: 0 0 26px; max-width: 460px; font-weight: 500; }
.hero-banner__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn--on-dark {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
  color: #f1efe9;
}
.btn--on-dark:hover { border-color: var(--gold-1); color: var(--gold-1); }

@media (max-width: 640px) {
  .hero-banner { padding: 30px 24px; }
  .hero-banner__title { font-size: 24px; }
  .hero-banner::before { background-size: 300px; background-position: right -100px bottom -40px; }
}

/* ---------------------------- BUTTONS ---------------------------------- */
.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-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--gradient-gold); color: #191307; box-shadow: var(--shadow-gold); }
.btn--primary:hover { filter: brightness(1.08); box-shadow: 0 8px 26px rgba(201, 162, 39, 0.38); }
.btn--ghost { background: var(--surface); border-color: var(--border-soft); color: var(--text-primary); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(1.08); }
.btn--sm { padding: 6px 12px; font-size: 12.5px; }
.btn--block { width: 100%; }

.icon-btn {
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-soft); background: var(--surface);
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn--danger:hover { color: var(--danger); border-color: var(--danger); }

/* ---------------------------- INPUTS ---------------------------------- */
.input {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13.5px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.input--sm { padding: 6px 9px; font-size: 12.5px; }
.input--select { cursor: pointer; }
textarea.input { resize: vertical; min-height: 60px; font-family: var(--font-body); }

/* ---------------------------- CARDS ---------------------------------- */
.card {
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.card:hover { border-color: rgba(201, 162, 39, 0.22); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: transform var(--transition), border-color var(--transition);
}
.stat-card:hover { transform: translateY(-2px); border-color: rgba(201, 162, 39, 0.25); }
.stat-card::after {
  content: '';
  position: absolute; top: 14px; right: 14px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold-2);
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.6);
}
.stat-card__icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card__value { font-family: var(--font-mono); font-size: 18px; font-weight: 600; }
.stat-card__label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.chart-card { margin-bottom: 20px; }
.card__header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 6px; }
.card__header h3 { margin: 0; font-family: var(--font-display); font-size: 15px; }
.card__hint { font-size: 11.5px; color: var(--text-tertiary); }
.chart-wrap { position: relative; height: 220px; margin-bottom: 6px; }
.chart-wrap--line { height: 260px; }

/* ---------------------------- TOOLBAR / GRID ---------------------------------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar__filters { display: flex; gap: 10px; }

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

.product-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 40%, var(--border-soft)); }
.product-card__photo { width: 100%; height: 150px; object-fit: cover; display: block; background: var(--surface-2); }
.product-card__photo--placeholder { display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); }
.product-card__body { padding: 14px 16px 16px; }
.product-card__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.product-card__name { margin: 0; font-family: var(--font-display); font-size: 14.5px; font-weight: 600; }
.product-card__sku { margin: 4px 0 12px; font-size: 11.5px; color: var(--text-tertiary); font-family: var(--font-mono); }
.badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 20px;
  background: color-mix(in srgb, var(--accent-2) 18%, transparent); color: var(--accent-2);
  flex-shrink: 0;
}
.product-card__prices { display: flex; justify-content: space-between; padding-top: 10px; border-top: 1px dashed var(--border-soft); }
.product-card__price-label { display: block; font-size: 10.5px; color: var(--text-tertiary); margin-bottom: 2px; }
.product-card__price-value { font-family: var(--font-mono); font-size: 14px; font-weight: 600; }
.product-card__price-value--accent { color: var(--accent); }
.product-card__actions { display: flex; gap: 6px; margin-top: 12px; }

.empty-state {
  grid-column: 1/-1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-lg);
}
.empty-state__icon { color: var(--accent); margin-bottom: 14px; opacity: 0.85; }
.empty-state h3 { margin: 0 0 6px; font-family: var(--font-display); color: var(--text-primary); }
.empty-state p { margin: 0 0 18px; font-size: 13px; }
.empty-hint { color: var(--text-tertiary); font-size: 13px; text-align: center; padding: 20px 0; }

/* ---------------------------- FORM LAYOUT ---------------------------------- */
.form-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: flex-start; }
.form-columns { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.form-section__title {
  font-family: var(--font-display); font-size: 15px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 4px; color: var(--text-primary);
}
.form-section__title svg { color: var(--accent); }
.form-section__optional { font-size: 11px; font-weight: 500; color: var(--text-tertiary); margin-left: 2px; }

.form-section--collapsible summary.form-section__title {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.form-section--collapsible summary.form-section__title::-webkit-details-marker { display: none; }
.form-section--collapsible summary.form-section__title::after {
  content: '▾';
  margin-left: auto;
  color: var(--text-tertiary);
  transition: transform var(--transition);
}
.form-section--collapsible[open] summary.form-section__title::after { transform: rotate(180deg); }
.form-section--collapsible > *:not(summary) { margin-top: 14px; }
.form-section__hint { margin: 0 0 14px; font-size: 12px; color: var(--text-tertiary); }
.form-section__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.form-section__header .form-section__title { margin: 0; }

.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
.form-grid--5 { grid-template-columns: repeat(5, 1fr); }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field--full { grid-column: 1 / -1; }
.form-field--action { justify-content: flex-end; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-primary); cursor: pointer; }
.checkbox-label input { width: 16px; height: 16px; accent-color: var(--accent); }
.acabamento-field { gap: 8px; }

.form-field--photo { grid-column: span 1; }
.photo-upload {
  width: 100%; aspect-ratio: 4/3;
  border: 1.5px dashed var(--border-soft);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: pointer;
  background: var(--surface-2);
  transition: border-color var(--transition);
}
.photo-upload:hover { border-color: var(--accent); }
.photo-upload img { width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-tertiary); font-size: 11.5px; }

.segmented { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.segmented__option {
  flex: 1; min-width: 200px;
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  cursor: pointer; color: var(--text-secondary);
  transition: all var(--transition);
}
.segmented__option input { display: none; }
.segmented__option.is-active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.segmented__hint { font-weight: 400; color: var(--text-tertiary); font-size: 11.5px; }

.table-wrap { overflow-x: auto; margin-top: 12px; }
.dyn-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dyn-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-tertiary); font-weight: 700;
  padding: 8px 10px; border-bottom: 1px solid var(--border-soft);
}
.dyn-table td { padding: 6px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.dyn-table__subtotal { font-family: var(--font-mono); font-weight: 600; white-space: nowrap; }
.dyn-table__index { font-family: var(--font-mono); color: var(--text-tertiary); font-size: 12px; }

.color-field { display: flex; align-items: center; gap: 6px; }
.color-swatch {
  width: 28px; height: 28px; flex-shrink: 0;
  border: 1px solid var(--border-soft); border-radius: 6px;
  padding: 0; cursor: pointer; background: none;
}
.color-swatch::-webkit-color-swatch-wrapper { padding: 2px; }
.color-swatch::-webkit-color-swatch { border-radius: 4px; border: none; }
.color-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 4px; vertical-align: middle;
  box-shadow: 0 0 0 1px var(--border-soft);
}
.ficha-list__divider {
  background: none !important; border: none !important; padding: 10px 0 0 !important;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-tertiary);
}

.form-actions { display: flex; justify-content: flex-end; margin-top: 20px; }

/* ---------------------------- SUMMARY PANEL (sticky) ---------------------------------- */
.summary-panel { position: sticky; top: 84px; }
.summary-panel__inner {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-md);
}
.summary-panel__title { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 14px; margin: 0 0 14px; }
.summary-panel__title svg { color: var(--accent); }

.summary-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.mini-card { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.mini-card__label { display: block; font-size: 10px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.3px; }
.mini-card__value { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }

.summary-final { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border-soft); }
.summary-final__row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 13px; color: var(--text-secondary); }
.summary-final__row strong { font-family: var(--font-mono); color: var(--text-primary); font-size: 13.5px; }
.summary-final__row--total strong { font-size: 16px; }
.summary-final__row--highlight { background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 4px; }
.summary-final__row--highlight strong { color: var(--accent); font-size: 17px; }
.summary-final__meta { display: flex; justify-content: space-between; margin-top: 10px; font-size: 11px; color: var(--text-tertiary); flex-wrap: wrap; gap: 6px; }

.summary-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

/* ---------------------------- TABS (Cadastros) ---------------------------------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border-soft); }
.tab {
  padding: 9px 16px; border: none; background: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-tertiary);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  text-decoration: none; display: inline-block;
  transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--text-primary); }
.tab--active { color: var(--accent); border-color: var(--accent); }

/* ---------------------------- TOASTS ---------------------------------- */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13px; color: var(--text-primary);
  opacity: 0; transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms ease;
  max-width: 320px;
}
.toast--show { opacity: 1; transform: translateY(0); }
.toast--success .toast__icon { color: var(--success); }
.toast--error .toast__icon { color: var(--danger); }
.toast--warning .toast__icon { color: var(--accent); }
.toast--info .toast__icon { color: var(--accent-2); }

/* ---------------------------- MODAL ---------------------------------- */
#modal-root { position: fixed; inset: 0; z-index: 300; display: none; }
#modal-root.is-open { display: block; }
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn 160ms ease;
}
.modal-card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg); padding: 24px; max-width: 420px; width: 100%;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 180ms cubic-bezier(.4,0,.2,1);
}
.modal-card h3 { margin: 0 0 10px; font-family: var(--font-display); }
.modal-card p { margin: 0; color: var(--text-secondary); font-size: 13.5px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

.is-hidden { display: none !important; }

/* ---------------------------- LOADING / FATAL ERROR ---------------------------------- */
.loading-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  min-height: 60vh;
  gap: 14px;
  color: var(--text-secondary);
}
.loading-screen__spinner {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid var(--border-soft);
  border-top-color: var(--accent);
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-screen--error { max-width: 480px; margin: 0 auto; gap: 10px; }
.loading-screen__icon { color: var(--danger); margin-bottom: 4px; }
.loading-screen h2 { margin: 0; font-family: var(--font-display); color: var(--text-primary); }
.loading-screen__detail { font-size: 11px; font-family: var(--font-mono); color: var(--text-tertiary); }

/* ---------------------------- FICHA TÉCNICA (sheet) ---------------------------- */
.ficha-sheet {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-sm);
}
.ficha-sheet__header { display: flex; align-items: center; gap: 16px; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px dashed var(--border-soft); }
.ficha-sheet__photo { width: 72px; height: 72px; border-radius: var(--radius-md); object-fit: cover; background: var(--surface-2); }
.ficha-sheet__photo--placeholder { display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); }
.ficha-sheet__title { margin: 0 0 4px; font-family: var(--font-display); font-size: 19px; }
.ficha-sheet__meta { margin: 0; font-size: 12.5px; color: var(--text-secondary); font-family: var(--font-mono); }

.ficha-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.ficha-block__title { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 14px; margin: 0 0 10px; }
.ficha-block__title svg { color: var(--accent); }
.ficha-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ficha-list li {
  font-size: 13px; color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--accent);
}
.ficha-list li strong { color: var(--text-primary); font-family: var(--font-mono); }

.ficha-total {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.ficha-total__label { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; color: var(--accent-ink); margin-bottom: 6px; }
html[data-theme="dark"] .ficha-total__label { color: var(--accent); }
.ficha-total__equation { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--text-primary); word-break: break-word; }

@media (max-width: 700px) {
  .ficha-grid { grid-template-columns: 1fr; }
  .ficha-sheet__header { flex-direction: column; align-items: flex-start; }
}

.color-breakdown { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.color-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}
.color-dot--lg { width: 22px; height: 22px; flex-shrink: 0; }
.color-card__name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.color-card__meta { font-size: 11px; color: var(--text-tertiary); }
.color-card__value { margin-left: auto; font-family: var(--font-mono); font-weight: 700; font-size: 13px; }

/* ---------------------------- RESPONSIVE ---------------------------------- */
@media (max-width: 1180px) {
  .form-layout { grid-template-columns: 1fr; }
  .summary-panel { position: static; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; bottom: 0; top: auto; width: 100%; height: auto; flex-direction: row; border-right: none; border-top: 1px solid var(--border-soft); z-index: 100; }
  .sidebar__brand, .sidebar__footer, .sidebar__cut, .sidebar__group-label { display: none; }
  .sidebar__nav { flex-direction: row; overflow-x: auto; padding: 8px 10px; }
  .nav-link { flex-direction: column; gap: 4px; font-size: 10.5px; padding: 8px 10px; }
  .nav-link--sub { padding-left: 10px; }
  .main { padding-bottom: 64px; }
  .view-root { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid--5 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .search-field { max-width: none; }
}

@media (max-width: 520px) {
  .form-grid, .form-grid--5 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: 1fr; }
}
