/* ==========================================================================
   Design system - Gestão de Obras
   Tema próprio sobre Bootstrap 5.3 (via variáveis CSS). Referência:
   docs/design/DESIGN_SYSTEM.md e a página viva /design-system.
   ========================================================================== */

/* ---------- 1. Tokens (tema claro) ---------- */
:root {
  --c-bg: #f5f5f4;
  --c-surface: #ffffff;
  --c-surface-2: #fafaf9;
  --c-surface-3: #f0efee;
  --c-border: #e7e5e4;
  --c-border-strong: #a8a29e;
  --c-text: #1c1917;
  --c-muted: #57534e;
  --c-overlay: rgb(12 10 9 / 55%);

  --c-primary: #c2410c;
  --c-primary-hover: #9a3412;
  --c-on-primary: #ffffff;
  --c-primary-soft: #ffedd5;
  --c-primary-text: #9a3412;

  --c-success-fg: #166534;  --c-success-bg: #dcfce7;  --c-success: #15803d;
  --c-warning-fg: #854d0e;  --c-warning-bg: #fef3c7;  --c-warning: #b45309;
  --c-danger-fg: #991b1b;   --c-danger-bg: #fee2e2;   --c-danger: #b91c1c;
  --c-info-fg: #1e40af;     --c-info-bg: #dbeafe;     --c-info: #1d4ed8;
  --c-neutral-fg: #44403c;  --c-neutral-bg: #e7e5e4;  --c-neutral: #78716c;

  --c-toast-bg: #1c1917;
  --c-toast-text: #fafaf9;
  --c-focus: #2563eb;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  --sh-1: 0 1px 2px rgb(28 25 23 / 6%), 0 1px 3px rgb(28 25 23 / 8%);
  --sh-2: 0 4px 14px rgb(28 25 23 / 10%);
  --sh-3: 0 12px 32px rgb(28 25 23 / 18%);

  --dur-fast: 150ms;
  --dur: 200ms;
  --dur-slow: 300ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --touch: 48px;
  --topbar-h: 56px;
  --bottomnav-h: 68px;
  --sidebar-w: 256px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  color-scheme: light;
}

/* ---------- 2. Tema escuro (manual ou automático) ---------- */
:root[data-theme="dark"] {
  --c-bg: #0c0a09;
  --c-surface: #1c1917;
  --c-surface-2: #231f1d;
  --c-surface-3: #292524;
  --c-border: #3a3532;
  --c-border-strong: #78716c;
  --c-text: #f5f5f4;
  --c-muted: #b5aea8;
  --c-overlay: rgb(0 0 0 / 70%);
  --c-primary: #fb923c;
  --c-primary-hover: #fdba74;
  --c-on-primary: #1c1917;
  --c-primary-soft: #431407;
  --c-primary-text: #fdba74;
  --c-success-fg: #86efac;  --c-success-bg: #052e16;  --c-success: #22c55e;
  --c-warning-fg: #fcd34d;  --c-warning-bg: #422006;  --c-warning: #f59e0b;
  --c-danger-fg: #fca5a5;   --c-danger-bg: #450a0a;   --c-danger: #ef4444;
  --c-info-fg: #93c5fd;     --c-info-bg: #172554;     --c-info: #3b82f6;
  --c-neutral-fg: #d6d3d1;  --c-neutral-bg: #332e2b;  --c-neutral: #a8a29e;
  --c-toast-bg: #f5f5f4;
  --c-toast-text: #1c1917;
  --c-focus: #93c5fd;
  --sh-1: 0 1px 2px rgb(0 0 0 / 40%);
  --sh-2: 0 4px 14px rgb(0 0 0 / 45%);
  --sh-3: 0 12px 32px rgb(0 0 0 / 60%);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --c-bg: #0c0a09;
    --c-surface: #1c1917;
    --c-surface-2: #231f1d;
    --c-surface-3: #292524;
    --c-border: #3a3532;
    --c-border-strong: #78716c;
    --c-text: #f5f5f4;
    --c-muted: #b5aea8;
    --c-overlay: rgb(0 0 0 / 70%);
    --c-primary: #fb923c;
    --c-primary-hover: #fdba74;
    --c-on-primary: #1c1917;
    --c-primary-soft: #431407;
    --c-primary-text: #fdba74;
    --c-success-fg: #86efac;  --c-success-bg: #052e16;  --c-success: #22c55e;
    --c-warning-fg: #fcd34d;  --c-warning-bg: #422006;  --c-warning: #f59e0b;
    --c-danger-fg: #fca5a5;   --c-danger-bg: #450a0a;   --c-danger: #ef4444;
    --c-info-fg: #93c5fd;     --c-info-bg: #172554;     --c-info: #3b82f6;
    --c-neutral-fg: #d6d3d1;  --c-neutral-bg: #332e2b;  --c-neutral: #a8a29e;
    --c-toast-bg: #f5f5f4;
    --c-toast-text: #1c1917;
    --c-focus: #93c5fd;
    --sh-1: 0 1px 2px rgb(0 0 0 / 40%);
    --sh-2: 0 4px 14px rgb(0 0 0 / 45%);
    --sh-3: 0 12px 32px rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}

/* ---------- 3. Ponte para o Bootstrap ---------- */
:root, :root[data-theme] {
  --bs-body-bg: var(--c-bg);
  --bs-body-color: var(--c-text);
  --bs-body-font-family: var(--font-sans);
  --bs-body-font-size: 1rem;
  --bs-body-line-height: 1.5;
  --bs-border-color: var(--c-border);
  --bs-secondary-color: var(--c-muted);
  --bs-emphasis-color: var(--c-text);
  --bs-link-color: var(--c-primary-text);
  --bs-link-color-rgb: 154, 52, 18;
  --bs-link-hover-color: var(--c-primary-hover);
  --bs-border-radius: var(--r-md);
  --bs-focus-ring-color: var(--c-focus);
  --bs-secondary-bg: var(--c-surface-3);
  --bs-tertiary-bg: var(--c-surface-2);
  --bs-heading-color: var(--c-text);
}

/* ---------- 4. Tamanho da fonte (preferência do usuário) ---------- */
html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html[data-font="large"] { font-size: 112.5%; }
html[data-font="xlarge"] { font-size: 125%; }

/* ---------- 5. Base ---------- */
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.01em; }
h1, .h1 { font-size: 1.5rem; }
h2, .h2 { font-size: 1.25rem; }
h3, .h3 { font-size: 1.125rem; }
a { color: var(--c-primary-text); }
.text-muted, .muted { color: var(--c-muted) !important; }
:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden-focusable:focus { position: fixed !important; top: 8px; left: 8px; z-index: 2000;
  background: var(--c-surface); padding: .75rem 1rem; border-radius: var(--r-md); box-shadow: var(--sh-2); }
::selection { background: var(--c-primary-soft); }
img { max-width: 100%; }

.icon { flex-shrink: 0; vertical-align: middle; stroke: currentColor; }
.icon-spin { animation: spin 1s linear infinite; }

[x-cloak] { display: none !important; }

/* ---------- 6. Layout (mobile primeiro) ---------- */
.app-shell { min-height: 100dvh; }
.page {
  padding: 1rem calc(1rem + var(--safe-right)) calc(var(--bottomnav-h) + var(--safe-bottom) + 1.5rem)
    calc(1rem + var(--safe-left));
  max-width: 1200px;
  margin: 0 auto;
}
.page-bare { padding: calc(1.5rem + var(--safe-top)) 1rem calc(1.5rem + var(--safe-bottom)); max-width: 480px;
  margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; }
.page-header { display: flex; align-items: center; gap: .75rem; margin: .25rem 0 1rem; flex-wrap: wrap; }
.page-header h1 { margin: 0; flex: 1 1 auto; min-width: 0; }
.section { margin-top: 1.75rem; }
.section-title { display: flex; align-items: center; gap: .5rem; font-size: 1.125rem; margin: 0 0 .75rem; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack-lg { display: flex; flex-direction: column; gap: 1.25rem; }
.row-gap { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.grid-cards { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid-wide { display: grid; gap: 1rem; grid-template-columns: 1fr; }

/* TopBar */
.topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: .25rem;
  min-height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) calc(.5rem + var(--safe-right)) 0 calc(.5rem + var(--safe-left));
  background: color-mix(in srgb, var(--c-surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--c-border);
}
.topbar-title { flex: 1 1 auto; min-width: 0; margin: 0 .25rem; font-size: 1.125rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: .25rem; }

/* Bottom navigation */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--bottomnav-h) + var(--safe-bottom));
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  box-shadow: 0 -2px 12px rgb(28 25 23 / 6%);
}
.bottom-nav a, .bottom-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--bottomnav-h); min-width: var(--touch);
  color: var(--c-muted); text-decoration: none; font-size: .8125rem; font-weight: 600;
  background: none; border: 0; padding: 0; line-height: 1.2;
  transition: color var(--dur-fast) var(--ease);
}
.bottom-nav [aria-current="page"] { color: var(--c-primary-text); }
.bottom-nav [aria-current="page"] .icon { stroke-width: 2.5; }
.bottom-nav .nav-new { position: relative; }
.bottom-nav .nav-new .nav-new-btn {
  display: grid; place-items: center; width: 60px; height: 60px; margin-top: -26px;
  border-radius: 50%; background: var(--c-primary); color: var(--c-on-primary);
  box-shadow: 0 6px 16px rgb(194 65 12 / 40%); border: 4px solid var(--c-surface);
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.bottom-nav .nav-new:active .nav-new-btn { transform: scale(.94); }
.bottom-nav .nav-new span.nav-label { color: var(--c-primary-text); }

/* Sidebar (tablet/desktop) */
.sidebar { display: none; }
@media (min-width: 992px) {
  .bottom-nav { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: .25rem;
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1030;
    padding: calc(1rem + var(--safe-top)) .75rem 1rem calc(.75rem + var(--safe-left));
    background: var(--c-surface); border-right: 1px solid var(--c-border); overflow-y: auto;
  }
  .sidebar-brand { display: flex; align-items: center; gap: .625rem; padding: .25rem .5rem 1rem;
    font-weight: 800; font-size: 1.125rem; color: var(--c-text); text-decoration: none; }
  .sidebar-brand .brand-mark { display: grid; place-items: center; width: 40px; height: 40px;
    border-radius: var(--r-md); background: var(--c-primary); color: var(--c-on-primary); }
  .sidebar a.side-link {
    display: flex; align-items: center; gap: .75rem; min-height: var(--touch); padding: 0 .75rem;
    border-radius: var(--r-md); color: var(--c-text); text-decoration: none; font-weight: 600;
    transition: background var(--dur-fast) var(--ease);
  }
  .sidebar a.side-link:hover { background: var(--c-surface-3); }
  .sidebar a.side-link[aria-current="page"] { background: var(--c-primary-soft); color: var(--c-primary-text); }
  .sidebar .side-sep { height: 1px; background: var(--c-border); margin: .5rem .5rem; }
  .sidebar .side-heading { font-size: .8125rem; font-weight: 700; color: var(--c-muted); padding: .5rem .75rem 0;
    text-transform: uppercase; letter-spacing: .04em; }
  .with-sidebar { margin-left: var(--sidebar-w); }
  .page { padding: 1.5rem 2rem 2.5rem; }
  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .grid-wide { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1400px) { .grid-wide { grid-template-columns: repeat(3, 1fr); } }

/* ---------- 7. Botões ---------- */
.btn {
  --bs-btn-padding-x: 1.125rem; --bs-btn-padding-y: .625rem; --bs-btn-font-size: 1rem;
  --bs-btn-font-weight: 600; --bs-btn-border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--touch); line-height: 1.25; position: relative;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn-primary {
  --bs-btn-bg: var(--c-primary); --bs-btn-border-color: var(--c-primary); --bs-btn-color: var(--c-on-primary);
  --bs-btn-hover-bg: var(--c-primary-hover); --bs-btn-hover-border-color: var(--c-primary-hover);
  --bs-btn-hover-color: var(--c-on-primary); --bs-btn-active-bg: var(--c-primary-hover);
  --bs-btn-active-border-color: var(--c-primary-hover); --bs-btn-active-color: var(--c-on-primary);
  --bs-btn-disabled-bg: var(--c-primary); --bs-btn-disabled-border-color: var(--c-primary);
  --bs-btn-disabled-color: var(--c-on-primary);
}
.btn-secondary {
  --bs-btn-bg: var(--c-surface); --bs-btn-border-color: var(--c-border-strong); --bs-btn-color: var(--c-text);
  --bs-btn-hover-bg: var(--c-surface-3); --bs-btn-hover-border-color: var(--c-border-strong);
  --bs-btn-hover-color: var(--c-text); --bs-btn-active-bg: var(--c-surface-3);
  --bs-btn-active-color: var(--c-text); --bs-btn-active-border-color: var(--c-border-strong);
  --bs-btn-disabled-bg: var(--c-surface); --bs-btn-disabled-color: var(--c-muted);
  --bs-btn-disabled-border-color: var(--c-border);
}
.btn-ghost {
  --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-color: var(--c-primary-text);
  --bs-btn-hover-bg: var(--c-primary-soft); --bs-btn-hover-color: var(--c-primary-text);
  --bs-btn-active-bg: var(--c-primary-soft); --bs-btn-active-color: var(--c-primary-text);
  --bs-btn-hover-border-color: transparent; --bs-btn-active-border-color: transparent;
}
.btn-danger {
  --bs-btn-bg: var(--c-danger); --bs-btn-border-color: var(--c-danger); --bs-btn-color: #fff;
  --bs-btn-hover-bg: #991b1b; --bs-btn-hover-border-color: #991b1b; --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #991b1b; --bs-btn-active-color: #fff; --bs-btn-active-border-color: #991b1b;
}
:root[data-theme="dark"] .btn-danger { --bs-btn-color: #1c1917; --bs-btn-hover-color: #1c1917;
  --bs-btn-hover-bg: #fca5a5; --bs-btn-hover-border-color: #fca5a5; --bs-btn-active-color: #1c1917; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .btn-danger { --bs-btn-color: #1c1917; --bs-btn-hover-color: #1c1917;
    --bs-btn-hover-bg: #fca5a5; --bs-btn-hover-border-color: #fca5a5; --bs-btn-active-color: #1c1917; }
}
.btn-lg { --bs-btn-padding-y: .875rem; --bs-btn-font-size: 1.0625rem; min-height: 56px; }
.btn-block { width: 100%; }
.btn .btn-spinner { display: none; }
.btn.is-busy { pointer-events: none; }
.btn.is-busy .btn-spinner { display: inline-flex; }
.btn.is-busy .btn-icon { display: none; }

.icon-btn {
  display: inline-grid; place-items: center; position: relative;
  width: var(--touch); height: var(--touch); padding: 0; flex-shrink: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--c-text);
  text-decoration: none; transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--c-surface-3); color: var(--c-text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .count {
  position: absolute; top: 5px; right: 3px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: var(--r-pill); background: var(--c-danger); color: #fff; font-size: .75rem;
  font-weight: 700; line-height: 20px; text-align: center; border: 2px solid var(--c-surface);
}

/* ---------- 8. Cards ---------- */
.card-x {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg);
  box-shadow: var(--sh-1); padding: 1rem; color: var(--c-text);
}
.card-x.is-link { display: block; text-decoration: none; transition: transform var(--dur-fast) var(--ease),
  box-shadow var(--dur-fast) var(--ease); }
.card-x.is-link:hover { box-shadow: var(--sh-2); color: var(--c-text); }
.card-x.is-link:active { transform: scale(.985); }
.card-title-x { font-size: 1.125rem; font-weight: 700; margin: 0; }
.card-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.card-head .card-title-x { flex: 1 1 auto; min-width: 0; }

.module-card {
  display: flex; flex-direction: column; gap: .625rem; min-height: 124px; padding: 1rem;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg);
  box-shadow: var(--sh-1); color: var(--c-text); text-decoration: none;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.module-card:hover { box-shadow: var(--sh-2); color: var(--c-text); }
.module-card:active { transform: scale(.97); }
.module-card .mc-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: var(--r-md);
  background: var(--c-primary-soft); color: var(--c-primary-text); }
.module-card .mc-label { font-weight: 700; font-size: 1.0625rem; line-height: 1.25; }
.module-card .mc-summary { color: var(--c-muted); font-size: .9375rem; margin-top: auto; }
.module-card.is-disabled { opacity: .7; }
.module-card.is-disabled .mc-icon { background: var(--c-surface-3); color: var(--c-muted); }

.card-x.stat-card { display: flex; flex-direction: column; gap: .375rem; min-width: 0; }
.stat-card .stat-value { font-size: clamp(1.125rem, 5.2vw, 1.75rem); font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.stat-card .stat-label { color: var(--c-muted); font-weight: 600; }

.project-card { padding: 0; overflow: hidden; }
.project-card .pc-cover { position: relative; aspect-ratio: 2 / 1; background: var(--c-surface-3);
  display: grid; place-items: center; color: var(--c-muted); }
.project-card .pc-cover img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.project-card .pc-cover .status-badge { position: absolute; top: .75rem; left: .75rem; box-shadow: var(--sh-1); }
.project-card .pc-body { padding: 1rem; display: flex; flex-direction: column; gap: .625rem; }
.project-card .pc-meta { display: flex; align-items: center; gap: .375rem; color: var(--c-muted); }

.worker-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .5rem; }
.worker-card .wc-role { display: inline-flex; align-items: center; gap: .375rem; color: var(--c-muted); }

/* Lista em linhas */
.list-x { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg);
  box-shadow: var(--sh-1); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: .875rem; min-height: 64px; padding: .75rem 1rem;
  color: var(--c-text); text-decoration: none; border-bottom: 1px solid var(--c-border); }
.list-x > .list-item:last-child, .list-x > :last-child > .list-item { border-bottom: 0; }
a.list-item:hover, button.list-item:hover { background: var(--c-surface-2); color: var(--c-text); }
button.list-item { width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.list-item .li-main { flex: 1 1 auto; min-width: 0; }
.list-item .li-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.list-item .li-sub { display: block; color: var(--c-muted); font-size: .9375rem; overflow-wrap: anywhere; }
.list-item .li-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-md);
  background: var(--c-surface-3); color: var(--c-text); flex-shrink: 0; }
.list-item .chev { color: var(--c-muted); }

/* ---------- 9. Status (COR + ÍCONE + TEXTO) ---------- */
.status-badge {
  display: inline-flex; align-items: center; gap: .375rem; padding: .25rem .625rem .25rem .5rem;
  border-radius: var(--r-pill); font-size: .875rem; font-weight: 700; line-height: 1.3;
  background: var(--tone-bg); color: var(--tone-fg); white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tone-success { --tone-bg: var(--c-success-bg); --tone-fg: var(--c-success-fg); --tone: var(--c-success); }
.tone-warning { --tone-bg: var(--c-warning-bg); --tone-fg: var(--c-warning-fg); --tone: var(--c-warning); }
.tone-danger  { --tone-bg: var(--c-danger-bg);  --tone-fg: var(--c-danger-fg);  --tone: var(--c-danger); }
.tone-info    { --tone-bg: var(--c-info-bg);    --tone-fg: var(--c-info-fg);    --tone: var(--c-info); }
.tone-neutral { --tone-bg: var(--c-neutral-bg); --tone-fg: var(--c-neutral-fg); --tone: var(--c-neutral); }
.tone-primary { --tone-bg: var(--c-primary-soft); --tone-fg: var(--c-primary-text); --tone: var(--c-primary); }

.alert-x { display: flex; gap: .75rem; align-items: flex-start; padding: .875rem 1rem;
  border-radius: var(--r-lg); background: var(--tone-bg); color: var(--tone-fg); border: 1px solid transparent; }
.alert-x .alert-title { font-weight: 700; }
.alert-x .alert-body { flex: 1 1 auto; min-width: 0; }
.alert-x a { color: inherit; font-weight: 700; }

/* ProgressBar */
.progress-x { display: flex; flex-direction: column; gap: .375rem; }
.progress-x .px-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .9375rem; }
.progress-x .px-value { font-weight: 700; }
.progress-x .px-track { height: 10px; border-radius: var(--r-pill); background: var(--c-surface-3); overflow: hidden; }
.progress-x .px-bar { height: 100%; border-radius: inherit; background: var(--tone, var(--c-primary));
  transform-origin: left center; animation: grow-x var(--dur-slow) var(--ease) both; }
.progress-x.is-lg .px-track { height: 14px; }

/* StageTimeline e Timeline */
.stage-timeline, .timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.stage-timeline > li, .timeline > li { position: relative; display: flex; gap: .875rem; padding-bottom: 1.25rem; }
.stage-timeline > li:not(:last-child)::before, .timeline > li:not(:last-child)::before {
  content: ""; position: absolute; left: 21px; top: 46px; bottom: 2px; width: 2px; background: var(--c-border); }
.stage-timeline > li.is-done:not(:last-child)::before { background: var(--c-success); }
.st-dot { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--tone-bg); color: var(--tone-fg); flex-shrink: 0; position: relative; z-index: 1; }
.st-body { flex: 1 1 auto; min-width: 0; padding-top: .25rem; }
.st-title { font-weight: 700; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.st-sub { color: var(--c-muted); font-size: .9375rem; }
.stage-timeline details > summary { list-style: none; cursor: pointer; border-radius: var(--r-md); }
.stage-timeline details > summary::-webkit-details-marker { display: none; }
.stage-timeline details[open] .st-more { animation: fade-in var(--dur) var(--ease); }
.st-more { margin-top: .5rem; padding: .75rem; border-radius: var(--r-md); background: var(--c-surface-2);
  border: 1px solid var(--c-border); }
.timeline .tl-time { color: var(--c-muted); font-size: .875rem; font-weight: 600; }

/* ---------- 10. Fotos ---------- */
.photo-grid { display: grid; gap: 6px; grid-template-columns: repeat(3, 1fr); }
@media (min-width: 576px) { .photo-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 992px) { .photo-grid { grid-template-columns: repeat(6, 1fr); gap: 8px; } }
.photo-grid .pg-item { position: relative; aspect-ratio: 1; border-radius: var(--r-md); overflow: hidden;
  background: var(--c-surface-3); border: 0; padding: 0; display: block; }
.photo-grid .pg-item img { width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform var(--dur) var(--ease); }
.photo-grid .pg-item:active img { transform: scale(.97); }
.photo-grid .pg-item .pg-flag { position: absolute; top: 6px; right: 6px; display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%; background: rgb(0 0 0 / 55%); color: #fde68a; }
.photo-placeholder { display: grid; place-items: center; width: 100%; height: 100%; color: var(--c-muted); }

dialog.photo-viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: #000; color: #fff; }
dialog.photo-viewer::backdrop { background: #000; }
.pv-stage { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; touch-action: none; }
.pv-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none;
  transition: opacity var(--dur) var(--ease); will-change: transform; }
.pv-top, .pv-bottom { position: absolute; left: 0; right: 0; z-index: 2; display: flex; align-items: center; gap: .5rem;
  padding: calc(.5rem + var(--safe-top)) .5rem .5rem; background: linear-gradient(rgb(0 0 0 / 70%), transparent); }
.pv-top { top: 0; }
.pv-bottom { bottom: 0; flex-direction: column; align-items: stretch; padding: 2rem 1rem calc(1rem + var(--safe-bottom));
  background: linear-gradient(transparent, rgb(0 0 0 / 80%)); }
.pv-top .icon-btn, .pv-nav { color: #fff; background: rgb(0 0 0 / 35%); }
.pv-top .icon-btn:hover, .pv-nav:hover { background: rgb(255 255 255 / 18%); color: #fff; }
.pv-counter { flex: 1; text-align: center; font-weight: 600; }
.pv-nav { position: absolute; top: 50%; z-index: 2; transform: translateY(-50%); }
.pv-prev { left: .5rem; } .pv-next { right: .5rem; }
.pv-caption { font-weight: 600; }
.pv-meta { color: #d6d3d1; font-size: .9375rem; }

/* UploadQueue */
.upload-queue { display: flex; flex-direction: column; gap: .5rem; }
.uq-summary { display: flex; flex-direction: column; gap: .5rem; }
.uq-item { display: flex; align-items: center; gap: .75rem; padding: .625rem; background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--r-md); }
.uq-thumb { width: 56px; height: 56px; border-radius: var(--r-sm); object-fit: cover; background: var(--c-surface-3);
  flex-shrink: 0; display: grid; place-items: center; color: var(--c-muted); }
.uq-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .375rem; }
.uq-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 11. Formulários ---------- */
.field { display: flex; flex-direction: column; gap: .375rem; }
.field > label, .field-label { font-weight: 600; }
.field .req { color: var(--c-danger-fg); }
.form-control, .form-select {
  min-height: 52px; font-size: 1rem; padding: .75rem .875rem; border-radius: var(--r-md);
  background-color: var(--c-surface); color: var(--c-text); border: 1.5px solid var(--c-border-strong);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.form-control::placeholder { color: var(--c-muted); opacity: .85; }
.form-control:focus, .form-select:focus { border-color: var(--c-primary); background-color: var(--c-surface);
  color: var(--c-text); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-primary) 22%, transparent); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--c-danger); background-image: none;
  padding-right: .875rem; }
.form-control.is-invalid:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-danger) 22%, transparent); }
.field-error { display: flex; align-items: flex-start; gap: .375rem; color: var(--c-danger-fg); font-weight: 600;
  font-size: .9375rem; animation: fade-in var(--dur) var(--ease); }
.field-help { color: var(--c-muted); font-size: .9375rem; }
.input-affix { position: relative; display: flex; align-items: stretch; }
.input-affix .affix { position: absolute; left: .875rem; top: 50%; transform: translateY(-50%); color: var(--c-muted);
  font-weight: 700; pointer-events: none; display: flex; }
.input-affix .form-control { padding-left: 2.75rem; }
.input-affix .affix-end { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }
.input-affix.has-end .form-control { padding-right: 3.25rem; }
.money-input .form-control { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.125rem; }
.form-actions { display: flex; flex-direction: column-reverse; gap: .75rem; margin-top: .5rem; }
@media (min-width: 576px) { .form-actions { flex-direction: row; justify-content: flex-end; } }

.check-x { display: flex; align-items: center; gap: .75rem; min-height: var(--touch); cursor: pointer; font-weight: 600; }
.check-x input { width: 24px; height: 24px; accent-color: var(--c-primary); flex-shrink: 0; margin: 0; }

.search-x { position: relative; }
.search-x .form-control { padding-left: 2.875rem; border-radius: var(--r-pill); }
.search-x .icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--c-muted); pointer-events: none; }

/* Chips */
.chips { display: flex; gap: .5rem; overflow-x: auto; padding: 2px 2px .5rem; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { position: relative; flex-shrink: 0; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; pointer-events: none; }
.chip label, a.chip-link {
  display: inline-flex; align-items: center; gap: .375rem; min-height: var(--touch); padding: 0 1rem;
  border-radius: var(--r-pill); border: 1.5px solid var(--c-border-strong); background: var(--c-surface);
  color: var(--c-text); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.chip input:checked + label, a.chip-link[aria-current="true"] {
  background: var(--c-primary-soft); border-color: var(--c-primary); color: var(--c-primary-text); }
.chip input:focus-visible + label { outline: 3px solid var(--c-focus); outline-offset: 2px; }

/* Seletor em grade de ícones (ex.: categoria da despesa) */
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: .5rem; }
.icon-picker .chip label { flex-direction: column; justify-content: center; width: 100%; min-height: 88px;
  border-radius: var(--r-lg); white-space: normal; text-align: center; line-height: 1.2; padding: .5rem; }

/* ---------- 12. Avatar ---------- */
.avatar { display: inline-grid; place-items: center; flex-shrink: 0; border-radius: 50%; overflow: hidden;
  width: 40px; height: 40px; font-weight: 700; font-size: .9375rem; background: var(--av-bg); color: var(--av-fg);
  text-decoration: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: .8125rem; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.5rem; }
.avatar-xl { width: 96px; height: 96px; font-size: 2rem; }
.av-0 { --av-bg: #ffedd5; --av-fg: #9a3412; } .av-1 { --av-bg: #dbeafe; --av-fg: #1e40af; }
.av-2 { --av-bg: #dcfce7; --av-fg: #166534; } .av-3 { --av-bg: #f3e8ff; --av-fg: #6b21a8; }
.av-4 { --av-bg: #fce7f3; --av-fg: #9d174d; } .av-5 { --av-bg: #e0f2fe; --av-fg: #075985; }

/* ---------- 13. Diálogos: Modal, BottomSheet, ConfirmationDialog ---------- */
dialog.modal-x, dialog.sheet {
  border: 0; padding: 0; color: var(--c-text); background: var(--c-surface); box-shadow: var(--sh-3);
  max-height: calc(100dvh - 2rem); overflow: auto;
}
dialog.modal-x::backdrop, dialog.sheet::backdrop { background: var(--c-overlay); animation: fade-in var(--dur) var(--ease); }
dialog.modal-x { width: min(560px, calc(100vw - 2rem)); border-radius: var(--r-xl); }
dialog.modal-x[open] { animation: pop-in var(--dur) var(--ease); }
dialog.sheet { width: 100%; max-width: 640px; margin: auto auto 0; border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding-bottom: var(--safe-bottom); max-height: 88dvh; }
dialog.sheet[open] { animation: sheet-up var(--dur-slow) var(--ease); }
@media (min-width: 992px) { dialog.sheet { margin: auto; border-radius: var(--r-xl); } }
.dialog-head { display: flex; align-items: center; gap: .5rem; padding: 1rem 1rem .5rem 1.25rem; }
.dialog-head h2 { flex: 1; margin: 0; font-size: 1.25rem; }
.dialog-body { padding: .5rem 1.25rem 1.25rem; }
.dialog-actions { display: flex; flex-direction: column-reverse; gap: .5rem; padding: 0 1.25rem 1.25rem; }
@media (min-width: 576px) { .dialog-actions { flex-direction: row; justify-content: flex-end; } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--c-border-strong); margin: .625rem auto 0; }
.confirm-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--tone-bg); color: var(--tone-fg); margin-bottom: .75rem; }

.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
@media (min-width: 420px) { .action-grid { grid-template-columns: repeat(4, 1fr); } }
.action-tile { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: .5rem;
  min-height: 108px; padding: .75rem .25rem; border-radius: var(--r-lg); color: var(--c-text); text-decoration: none;
  text-align: center; font-weight: 600; font-size: .9375rem; line-height: 1.2; border: 0; background: none;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.action-tile:hover { background: var(--c-surface-3); color: var(--c-text); }
.action-tile:active { transform: scale(.95); }
.action-tile .at-icon { display: grid; place-items: center; width: 60px; height: 60px; border-radius: var(--r-lg);
  background: var(--c-primary-soft); color: var(--c-primary-text); }
.action-tile.is-disabled .at-icon { background: var(--c-surface-3); color: var(--c-muted); }
.action-tile .soon { font-size: .75rem; color: var(--c-muted); font-weight: 600; }

/* ---------- 14. Toast ---------- */
.toast-region { position: fixed; z-index: 1090; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + .75rem); width: min(520px, calc(100vw - 1.5rem));
  display: flex; flex-direction: column; gap: .5rem; pointer-events: none; }
@media (min-width: 992px) { .toast-region { bottom: 1.5rem; left: auto; right: 1.5rem; transform: none; } }
.toast-x { display: flex; align-items: center; gap: .75rem; padding: .75rem .75rem .75rem 1rem; border-radius: var(--r-lg);
  background: var(--c-toast-bg); color: var(--c-toast-text); box-shadow: var(--sh-3); pointer-events: auto;
  font-weight: 600; animation: toast-in var(--dur) var(--ease); }
.toast-x.is-leaving { animation: toast-out var(--dur) var(--ease) forwards; }
.toast-x .toast-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--tone-bg); color: var(--tone-fg); flex-shrink: 0; }
.toast-x .toast-msg { flex: 1; min-width: 0; }
.toast-x .toast-action { color: var(--c-toast-text); background: transparent; border: 1.5px solid currentColor;
  border-radius: var(--r-md); min-height: 40px; padding: 0 .75rem; font-weight: 700; }
.toast-x .icon-btn { color: var(--c-toast-text); width: 40px; height: 40px; }
.toast-x .icon-btn:hover { background: rgb(127 127 127 / 25%); }

/* ---------- 15. Empty state, Skeleton, Offline ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .5rem;
  padding: 2rem 1rem; }
.empty-state .es-icon { display: grid; place-items: center; width: 96px; height: 96px; border-radius: 50%;
  background: var(--c-primary-soft); color: var(--c-primary-text); margin-bottom: .5rem; }
.empty-state h2 { font-size: 1.25rem; margin: 0; }
.empty-state p { color: var(--c-muted); margin: 0 0 .75rem; max-width: 34ch; }

.skeleton { position: relative; overflow: hidden; background: var(--c-surface-3); border-radius: var(--r-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--c-surface) 60%, transparent), transparent);
  animation: shimmer 1.2s infinite; }
.skeleton-line { height: 1rem; margin: .5rem 0; }
.skeleton-title { height: 1.375rem; width: 60%; }
.skeleton-block { height: 120px; border-radius: var(--r-md); }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }
.htmx-request .hide-on-request, .htmx-request.hide-on-request { display: none; }

.offline-banner { position: fixed; z-index: 1080; left: 0; right: 0; top: 0;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  padding: calc(.5rem + var(--safe-top)) 1rem .5rem; font-weight: 700;
  background: var(--c-warning-bg); color: var(--c-warning-fg); border-bottom: 1px solid var(--c-warning);
  animation: slide-down var(--dur) var(--ease); }
.offline-banner[hidden] { display: none; }

/* ---------- 16. Utilitários ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: .375rem 1rem; margin: 0; }
.kv dt { color: var(--c-muted); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.divider { height: 1px; background: var(--c-border); margin: 1rem 0; border: 0; }
.nowrap { white-space: nowrap; }
.fw-800 { font-weight: 800; }
.tabular { font-variant-numeric: tabular-nums; }
.swatch { height: 56px; border-radius: var(--r-md); border: 1px solid var(--c-border); }
.icon-cell { display: flex; flex-direction: column; align-items: center; gap: .375rem; padding: .75rem .25rem;
  border-radius: var(--r-md); background: var(--c-surface); border: 1px solid var(--c-border); font-size: .8125rem;
  text-align: center; overflow-wrap: anywhere; }
.icon-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: .5rem; }
.brand-hero { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 1rem; border-radius: var(--r-xl);
  background: var(--c-primary); color: var(--c-on-primary); box-shadow: var(--sh-2); }
pre.json { background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: .75rem;
  font-size: .875rem; white-space: pre-wrap; overflow-wrap: anywhere; margin: .5rem 0 0; color: var(--c-text); }
.pagination-x { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: 1rem; }

/* Entrada suave dos cards */
.enter > * { animation: rise-in var(--dur-slow) var(--ease) both; }
.enter > *:nth-child(2) { animation-delay: 30ms; } .enter > *:nth-child(3) { animation-delay: 60ms; }
.enter > *:nth-child(4) { animation-delay: 90ms; } .enter > *:nth-child(n+5) { animation-delay: 120ms; }

/* ---------- 17. Animações ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes slide-down { from { transform: translateY(-100%); } to { transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(12px); } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Reduzir animações: preferência do sistema OU do usuário */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .skeleton::after { display: none; }
}
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after {
  animation-duration: .01ms !important; animation-iteration-count: 1 !important;
  transition-duration: .01ms !important; scroll-behavior: auto !important; }
html[data-motion="reduce"] .skeleton::after { display: none; }

/* ---------- Fase 2 ---------- */
.rotate-180 { transform: rotate(180deg); }
.form-range { accent-color: var(--c-primary); height: 2rem; }
.form-range::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -10px; background: var(--c-primary); }
.form-range::-moz-range-thumb { width: 28px; height: 28px; background: var(--c-primary); }
.form-range::-webkit-slider-runnable-track { height: 8px; background: var(--c-surface-3); }
.stage-timeline summary .progress-x { margin-top: .5rem; }
.stat-card.is-muted .stat-value { color: var(--c-muted); font-size: 1.125rem; }
/* ---------- Fase 4 ---------- */
.money-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.money-grid > div { display: flex; flex-direction: column; gap: .125rem; min-width: 0; }
.money-grid strong { font-size: 1.0625rem; overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
  .money-grid { grid-template-columns: 1fr; gap: .25rem; }
  .money-grid > div { flex-direction: row; justify-content: space-between; align-items: baseline; gap: .5rem; }
}
.icon-picker .chip label span { overflow-wrap: break-word; hyphens: auto; font-size: .875rem; }
.li-top { display: flex; align-items: baseline; gap: .5rem; }
.li-top .li-title { flex: 1 1 auto; min-width: 0; }
.li-top { justify-content: space-between; }
.big-money .form-control { font-size: 1.75rem; min-height: 64px; }
details.more > summary { list-style: none; cursor: pointer; }
details.more > summary::-webkit-details-marker { display: none; }
/* ---------- Fase 5 ---------- */
.stepper { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.stepper::-webkit-scrollbar { display: none; }
.stepper .step { flex: 1 1 0; min-width: 72px; display: flex; flex-direction: column; align-items: center; gap: .25rem;
  text-align: center; font-size: .8125rem; font-weight: 600; color: var(--c-muted); position: relative; }
.stepper .step:not(:last-child)::after { content: ""; position: absolute; top: 18px; left: calc(50% + 20px);
  right: calc(-50% + 20px); height: 2px; background: var(--c-border); }
.stepper .step.is-done:not(:last-child)::after { background: var(--c-success); }
.step-dot { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--c-surface-3); color: var(--c-muted); position: relative; z-index: 1; }
.step.is-done .step-dot { background: var(--c-success-bg); color: var(--c-success-fg); }
.step.is-current .step-dot { background: var(--c-primary); color: var(--c-on-primary); box-shadow: 0 0 0 4px var(--c-primary-soft); }
.step.is-current { color: var(--c-text); }
.step.is-skipped .step-dot { opacity: .5; border: 2px dashed var(--c-border-strong); background: transparent; }
.stepper.is-mini .step { min-width: 28px; }
.stepper.is-mini .step-dot { width: 26px; height: 26px; }
.stepper.is-mini .step:not(:last-child)::after { top: 12px; left: calc(50% + 14px); right: calc(-50% + 14px); }
.stepper.is-vertical { flex-direction: column; gap: 0; }
.stepper.is-vertical .step { flex-direction: row; text-align: left; min-height: 52px; font-size: 1rem; }
.stepper.is-vertical .step:not(:last-child)::after { top: 38px; bottom: -14px; left: 17px; right: auto; width: 2px; height: auto; }
.issue-card-top { display: flex; gap: .875rem; color: var(--c-text); text-decoration: none; }
.issue-thumb { width: 88px; height: 88px; border-radius: var(--r-md); overflow: hidden; flex-shrink: 0; display: grid;
  place-items: center; background: var(--c-surface-3); color: var(--c-muted); }
.issue-thumb img { width: 100%; height: 100%; object-fit: cover; }
.issue-main { flex: 1 1 auto; min-width: 0; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 1fr); gap: 1rem; overflow-x: auto; padding-bottom: .5rem; }
.board-col { background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: .75rem; display: flex; flex-direction: column; gap: .75rem; }
.before-after { position: relative; border-radius: var(--r-lg); overflow: hidden; background: #000; aspect-ratio: 4 / 3; touch-action: pan-y; }
.ba-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ba-after { position: absolute; inset: 0; }
.ba-label { position: absolute; top: .75rem; padding: .25rem .625rem; border-radius: var(--r-pill); background: rgb(0 0 0 / 60%); color: #fff; font-weight: 700; font-size: .875rem; }
.ba-left { left: .75rem; } .ba-right { right: .75rem; }
.ba-handle { position: absolute; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: #fff; box-shadow: 0 0 8px rgb(0 0 0 / 50%); pointer-events: none; }
.ba-range { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
.cal { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.cal th { text-align: center; font-size: .8125rem; color: var(--c-muted); font-weight: 700; }
.cal td { padding: 0; }
.cal a { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px; min-height: 52px; padding: .375rem 0;
  border-radius: var(--r-md); text-decoration: none; color: var(--c-text); background: var(--c-surface); border: 1px solid var(--c-border); font-weight: 600; }
.cal a.is-other { opacity: .45; }
.cal a.is-today { border: 2px solid var(--c-primary); }
.cal a[aria-current="date"] { background: var(--c-primary-soft); }
.cal .dots { display: flex; gap: 2px; }
.cal .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c-info); }
.time-col { width: 3.5rem; flex-shrink: 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.presence { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.presence label { display: flex; align-items: center; gap: .5rem; min-height: 56px; padding: .5rem .75rem; border: 1.5px solid var(--c-border-strong);
  border-radius: var(--r-md); cursor: pointer; font-weight: 600; background: var(--c-surface); }
.presence input { width: 22px; height: 22px; accent-color: var(--c-primary); }
.presence label:has(input:checked) { background: var(--c-primary-soft); border-color: var(--c-primary); }
.cover-actions { position: absolute; right: .75rem; bottom: .75rem; display: flex; gap: .5rem; }
.cover-actions .btn { box-shadow: var(--sh-2); }
.segmented { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 4px; padding: 4px; margin-bottom: 1rem;
  background: var(--c-surface-3); border-radius: var(--r-lg); }
.segmented a { display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--touch);
  border-radius: var(--r-md); color: var(--c-muted); font-weight: 700; text-decoration: none; min-width: 0; }
.segmented a[aria-current="page"] { background: var(--c-surface); color: var(--c-primary-text); box-shadow: var(--sh-1); }
.segmented a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-whatsapp { --bs-btn-bg: #128c4a; --bs-btn-border-color: #128c4a; --bs-btn-color: #fff;
  --bs-btn-hover-bg: #0e7a3f; --bs-btn-hover-border-color: #0e7a3f; --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #0e7a3f; --bs-btn-active-color: #fff; }
.icon-btn.whatsapp { color: #128c4a; background: #e8f7ee; }
:root[data-theme="dark"] .icon-btn.whatsapp { color: #86efac; background: #052e16; }
.stage-crew { display: flex; flex-wrap: wrap; gap: .375rem .75rem; margin-top: .375rem; }
.stage-crew .crew { display: inline-flex; align-items: center; gap: .25rem; font-weight: 600; }
