/* Ateliê de Pins — UI refresh 2.0
   Camada visual complementar. Mantém os fluxos e seletores existentes. */
:root {
  --paper: #0b0d10;
  --surface: #15181d;
  --surface-raised: #1b1f26;
  --surface-soft: #111419;
  --ink: #f7f4ec;
  --muted: #b8bdc8;
  --muted-strong: #d3d6dd;
  --line: #343943;
  --line-strong: #515866;
  --accent: #ddb854;
  --accent-hover: #edcb72;
  --accent-light: #332b18;
  --accent-ink: #171208;
  --green: #9bd6a5;
  --red: #ffaaa1;
  --soft-red: #3b2022;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .28);
  --shadow-md: 0 14px 34px rgb(0 0 0 / .28);
  --shadow-lg: 0 28px 80px rgb(0 0 0 / .52);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition-fast: 160ms ease;
  color-scheme: dark;
  font-size: 16px;
}

html { background: var(--paper); scroll-behavior: smooth; }
body { min-width: 320px; background: var(--paper); color: var(--ink); }
body, button, input, select, textarea { font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
h1, .modal-head h2, .empty-state h2, .brand { font-family: Georgia, "Times New Roman", serif; }
h1 { font-size: clamp(2rem, 3.2vw, 2.75rem); letter-spacing: -.035em; text-wrap: balance; }
h2, h3, p { text-wrap: pretty; }

button, a, input, select, textarea { outline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.sidebar {
  width: 248px;
  padding: 30px 20px 18px;
  background: linear-gradient(180deg, #12151a 0%, #0e1115 100%);
  border-right-color: var(--line);
}
.app-shell { margin-left: 248px; }
.brand { font-size: 1.75rem; }
.brand-mark { border-color: #6d5a2c; background: #1d1a12; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .025); }
.workspace-label { margin: 30px 0 16px; color: var(--muted); font-size: .6875rem; }
.nav-item {
  position: relative;
  min-height: 46px;
  margin-bottom: 4px;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: .875rem;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}
.nav-item:hover { background: #1c2027; border-color: #292e37; color: var(--ink); }
.nav-item.active { background: var(--accent-light); border-color: #5a4923; color: var(--accent-hover); }
.nav-item.active::before { content: ""; position: absolute; left: -6px; width: 3px; height: 22px; border-radius: 999px; background: var(--accent); }
.nav-item.active::after { display: none; }
.nav-count { min-width: 22px; padding: 2px 6px; border-radius: 999px; background: #282d35; color: var(--muted-strong); text-align: center; }
.sidebar-note { padding: 22px 12px; }
.sidebar-note p { color: #c1b9a7; }
.workspace-user { border-top-color: var(--line); min-height: 62px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  height: 68px;
  padding: 0 clamp(20px, 3vw, 42px);
  background: rgb(13 16 20 / .92);
  border-bottom-color: var(--line);
  backdrop-filter: blur(14px);
}
.breadcrumb { font-size: .75rem; }
.connection-label { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); color: var(--muted-strong); font-size: .75rem; }
.live-dot { width: 7px; height: 7px; background: #7ec78a; box-shadow: 0 0 0 3px rgb(126 199 138 / .12); }
.warning-dot { background: #e09b67; box-shadow: 0 0 0 3px rgb(224 155 103 / .12); }
.icon-button { min-width: 44px; width: 44px; height: 44px; color: var(--muted); transition: color var(--transition-fast), background var(--transition-fast); }
.icon-button:hover { background: #232831; color: var(--ink); }

main { max-width: 1600px; min-height: calc(100vh - 116px); padding: 38px clamp(20px, 3vw, 44px) 80px; }
.page-heading { align-items: center; margin-bottom: 30px; }
.page-heading p { max-width: 680px; color: var(--muted); font-size: .875rem; line-height: 1.65; }
.eyebrow { margin-bottom: 10px; color: var(--accent); font-size: .6875rem; letter-spacing: .16em; }
.heading-actions { padding-top: 0; }

.btn {
  min-height: 44px;
  padding: 10px 16px;
  border-color: var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--ink);
  font-size: .75rem;
  box-shadow: var(--shadow-sm);
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.btn:hover:not(:disabled) { background: #242a33; border-color: #747d8d; box-shadow: 0 5px 16px rgb(0 0 0 / .22); }
.btn:active:not(:disabled) { transform: none; background: #111419; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-small { min-height: 40px; }
.btn-quiet { box-shadow: none; }
.btn-danger { color: var(--red); }
button:disabled, .btn:disabled { opacity: .48; }

.stats { gap: 14px; margin-bottom: 34px; }
.stat {
  min-height: 126px;
  padding: 19px 20px;
  background: linear-gradient(145deg, var(--surface-raised), var(--surface));
  border-color: var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.stat::after { content: ""; position: absolute; inset: auto 20px 0; height: 2px; border-radius: 2px 2px 0 0; background: linear-gradient(90deg, var(--accent), transparent); opacity: .65; }
.stat-label { color: var(--muted-strong); font-size: .75rem; }
.stat-label svg { color: var(--accent); }
.stat-value { color: var(--ink); font-size: 2rem; font-variant-numeric: tabular-nums; }
.stat-meta { color: var(--muted); font-size: .6875rem; }

.section-heading { margin-bottom: 14px; }
.section-heading h2 { font-size: 1rem; }
.section-heading small, .count-chip { font-size: .75rem; }
.count-chip { border-color: var(--line-strong); background: var(--surface-raised); color: var(--muted-strong); }
.filterbar { padding: 14px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-soft); }
.search-wrap input { min-height: 46px; }
input, select, textarea {
  min-height: 44px;
  border-color: var(--line-strong);
  background: #101318;
  color: var(--ink);
  font-size: .8125rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
input:hover, select:hover, textarea:hover { border-color: #687181; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #12161c; box-shadow: 0 0 0 3px rgb(221 184 84 / .12); }
input::placeholder, textarea::placeholder { color: #8d94a1; opacity: 1; }
.select-all { min-height: 36px; margin-bottom: 12px; color: var(--muted-strong); font-size: .75rem; }
.select-all label { display: inline-flex; align-items: center; gap: 9px; min-height: 36px; cursor: pointer; }

.product-grid { grid-template-columns: repeat(auto-fill, minmax(224px, 1fr)); gap: 18px; }
.product-card { border-color: var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast); }
.product-card:hover { border-color: #6e603a; background: #181c22; box-shadow: var(--shadow-md); }
.product-card.selected { border-color: var(--accent); background: #1c1a13; box-shadow: 0 0 0 2px rgb(221 184 84 / .18), var(--shadow-md); }
.product-visual { aspect-ratio: 4 / 5; background: #0f1217; }
.product-visual img { transition: filter var(--transition-fast); }
.product-card:hover .product-visual img { filter: brightness(1.04); }
.card-check { width: 36px; height: 36px; top: 10px; left: 10px; border-color: #77706a; background: rgb(10 12 15 / .88); }
.card-check input, input[type="checkbox"] { width: 18px; height: 18px; }
.visual-label { bottom: 10px; left: 10px; padding: 5px 8px; background: rgb(10 12 15 / .88); color: #f0ece1; font-size: .625rem; }
.card-body { padding: 16px; }
.card-category { color: var(--muted); font-size: .625rem; }
.card-title { min-height: 42px; color: var(--ink); font-size: .875rem; line-height: 1.5; }
.card-bottom { margin-top: 14px; }
.card-action { min-height: 36px; padding: 6px 4px 6px 8px; color: var(--accent-hover); font-size: .75rem; border-radius: 6px; }
.card-action:hover { background: var(--accent-light); }
.badge { min-height: 24px; padding: 4px 8px; border-color: rgb(255 255 255 / .08); font-size: .625rem; }
.affiliate-state { margin-top: 11px; font-size: .625rem; line-height: 1.3; }
.card-error { font-size: .75rem; }

.bulk-bar { bottom: 20px; padding: 14px 16px; border-color: #766333; border-radius: var(--radius-md); background: rgb(22 24 29 / .96); box-shadow: var(--shadow-lg); backdrop-filter: blur(18px); }
.bulk-label { color: var(--muted-strong); font-size: .8125rem; }
.bulk-label > span { background: var(--accent); color: var(--accent-ink); }
.bulk-actions .btn { min-height: 40px; font-size: .75rem; }

.panel, .integration-card, .timeline-item, .table-wrap { border-color: var(--line); background: var(--surface); box-shadow: var(--shadow-sm); }
.panel, .integration-card { border-radius: var(--radius-md); }
.panel-title p, .integration-card p, .account-agenda-head p, .timeline-text small { color: var(--muted); font-size: .75rem; }
.integration-card { padding: 22px; }
.integration-card:hover { border-color: var(--line-strong); }
.integration-card.disabled { background: var(--surface-soft); }
.integration-footnote, .account-list { border-color: var(--line); }
.account-row { min-height: 50px; }
.account-avatar { width: 36px; height: 36px; background: #252a32; color: var(--muted-strong); }

.field { gap: 8px; }
.field label, .field-label { color: var(--muted-strong); font-size: .75rem; }
.field small, .help, .settings-note { color: var(--muted); font-size: .75rem; }
.form-grid { gap: 20px; }
.form-actions { gap: 10px; }
.radio-option { min-height: 64px; background: var(--surface-soft); border-color: var(--line); }
.radio-option:hover { border-color: var(--line-strong); }
.radio-option strong { font-size: .8125rem; }
.radio-option small { font-size: .75rem; }

.table-wrap { overflow: auto; }
table { min-width: 720px; font-size: .8125rem; }
th { position: sticky; top: 0; z-index: 1; padding: 14px 16px; background: #11151a; color: var(--muted-strong); font-size: .6875rem; }
td { padding: 15px 16px; border-color: var(--line); }
tr:hover td { background: #1b2027; }

.notice { border-color: #5a4b27; background: #282315; color: #ead8a4; font-size: .8125rem; }
.notice.success { border-color: #42614a; background: #1b2b21; color: #b7dfbd; }
.notice.error { border-color: #704044; background: #352023; color: #ffc0ba; }
.empty-state { border-color: var(--line-strong); background: var(--surface-soft); }
.empty-state p { color: var(--muted); font-size: .875rem; }

dialog { border-color: var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgb(3 5 8 / .78); backdrop-filter: blur(5px); }
.modal-head { background: var(--surface); border-color: var(--line); }
.modal-head h2 { font-size: 1.875rem; }
.modal-head p { color: var(--muted); font-size: .8125rem; }
.modal-body { background: var(--surface); }
.modal-tabs { padding: 4px; border-radius: 10px; background: #101318; }
.modal-tab { min-height: 40px; padding: 8px 14px; background: transparent; color: var(--muted); }
.modal-tab:hover { color: var(--ink); }
.modal-tab.active { background: var(--accent-light); color: var(--accent-hover); }
.compare-image { background: #0e1115; border: 1px solid var(--line); }
.batch-info, .preview-info { background: var(--surface-soft); border: 1px solid var(--line); }

.toast-region { right: 20px; bottom: 20px; }
.toast { max-width: 420px; padding: 14px 16px; border: 1px solid #4f694f; background: #203022; color: #e7f4e7; box-shadow: var(--shadow-md); font-size: .8125rem; }
.toast.error { border-color: #824c50; background: #4a2528; color: #ffe0dc; }
.spinner { border-color: #69717d; border-top-color: var(--accent); }
.progress-track { height: 6px; background: #292e35; }
.progress-fill { background: var(--accent); }
.app-footer { color: var(--muted); border-color: var(--line); font-size: .6875rem; }

.market-card { border-color: var(--line); background: var(--surface-soft); }
.market-card:hover { border-color: #6e603a; }
.market-card img { background: #f5f5f3; }
.market-title { font-size: .8125rem; }
.market-selection { background: var(--surface); }
.affiliate-auto { background: var(--surface-soft); }
.affiliate-result { border-color: var(--line); }

@media (max-width: 1150px) {
  .sidebar { width: 208px; }
  .app-shell { margin-left: 208px; }
  .sidebar-note { display: none; }
}

@media (max-width: 850px) {
  .sidebar { width: 76px; }
  .app-shell { margin-left: 76px; }
  .nav-item { min-height: 48px; }
  .page-heading { align-items: flex-start; }
  .heading-actions { width: 100%; justify-content: flex-start; }
  .integration-grid { grid-template-columns: 1fr; }
}

@media (max-width: 580px) {
  :root { font-size: 16px; }
  .sidebar { height: calc(70px + env(safe-area-inset-bottom)); padding: 4px 6px env(safe-area-inset-bottom); background: rgb(14 17 21 / .97); border-top-color: var(--line); backdrop-filter: blur(18px); }
  .sidebar nav { gap: 2px; }
  .nav-item { min-height: 58px; padding: 7px 2px; color: var(--muted); }
  .nav-item.active { background: var(--accent-light); color: var(--accent-hover); }
  .nav-label { font-size: .625rem; }
  .app-shell { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .topbar { height: 58px; padding: 0 14px; }
  .connection-label { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .breadcrumb > span, .breadcrumb > span + strong { display: none; }
  main { padding: 24px 16px 42px; }
  .page-heading { margin-bottom: 24px; }
  .page-heading p { font-size: .8125rem; }
  .heading-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .heading-actions .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { min-height: 118px; padding: 15px; }
  .stat-value { font-size: 1.75rem; }
  .stat-label { font-size: .6875rem; }
  .stat-meta { font-size: .625rem; }
  .section-heading { align-items: flex-start; }
  .section-heading > small { display: none; }
  .filterbar { padding: 10px; }
  .product-grid { grid-template-columns: 1fr; gap: 14px; }
  .product-card { display: grid; grid-template-columns: 116px minmax(0, 1fr); min-height: 170px; }
  .product-visual { height: 100%; min-height: 170px; aspect-ratio: auto; }
  .card-body { display: flex; flex-direction: column; padding: 14px; }
  .card-title { min-height: 0; font-size: .8125rem; }
  .card-bottom { margin-top: auto; }
  .affiliate-state { white-space: normal; }
  .visual-label { display: none; }
  .bulk-bar { bottom: calc(78px + env(safe-area-inset-bottom)); }
  .bulk-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .bulk-actions .btn { min-height: 44px; }
  .panel, .integration-card { padding: 18px; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn, .form-actions button[type="submit"] { flex: 1; }
  dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); border-radius: 14px; }
  .modal-head { padding: 20px 18px 16px; }
  .modal-body { padding: 18px; }
  .modal-head h2 { font-size: 1.625rem; }
  .image-compare { grid-template-columns: 1fr; }
  .toast-region { right: 12px; left: 12px; bottom: calc(82px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  .app-footer { padding: 14px 16px; }
}

@media (max-width: 390px) {
  .stats { grid-template-columns: 1fr; }
  .stat { min-height: 104px; }
  .heading-actions { grid-template-columns: 1fr; }
  .heading-actions .btn { grid-column: auto !important; }
  .product-card { grid-template-columns: 104px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (forced-colors: active) {
  .nav-item.active, .product-card.selected, .btn-primary { border: 2px solid CanvasText; }
  .live-dot { outline: 1px solid CanvasText; }
}
