/* Panel components. Dense, practical, white surfaces, no gradients.
   Everything a screen needs should be here; add screen-specific rules at the end of this file
   under a comment with the screen name. */

/* ---------- layout ---------- */
.panel-body { background: var(--c-surface-alt); }
.panel { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.panel__sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--c-surface); border-right: 1px solid var(--c-border); padding: var(--space-4) var(--space-3); display: flex; flex-direction: column; }
.panel__main { padding: var(--space-5) var(--space-6) var(--space-7); min-width: 0; }
.brand { display: flex; align-items: center; gap: var(--space-2); font: 600 17px/1 var(--font-heading); color: var(--c-primary); text-decoration: none; padding: var(--space-1) var(--space-2) var(--space-4); }
.brand__mark { width: 28px; height: 28px; flex: none; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--c-text-muted); margin: var(--space-4) var(--space-2) var(--space-1); }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-link { display: flex; align-items: center; gap: var(--space-3); padding: 7px var(--space-2); border-radius: var(--radius-sm); color: var(--c-text); text-decoration: none; font-size: 14px; }
.nav-link:hover { background: var(--c-surface-alt); }
.nav-link.is-active { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 600; }
.nav-badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: var(--radius-pill); background: var(--c-primary); color: #fff; font-size: 11px; font-weight: 600; text-align: center; }
.nav-badge--warn { background: var(--c-warning); }
.sidebar-foot { margin-top: auto; padding: var(--space-4) var(--space-2) 0; display: grid; gap: var(--space-3); border-top: 1px solid var(--c-border); }
.sidebar-user { margin: 0; font-size: 13px; }
.sidebar-user small { color: var(--c-text-muted); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.page-head h1 { font-size: 26px; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--c-text-muted); }
.page-head__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---------- icons, buttons ---------- */
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 14px/1 var(--font-body); padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; background: var(--c-surface); color: var(--c-text); border-color: var(--c-border); }
.btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn--primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn--primary:hover { background: var(--c-primary-hover); color: #fff; }
.btn--accent { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--c-primary); }
.btn--ghost:hover { background: var(--c-primary-soft); }
.btn--danger { color: var(--c-danger); }
.btn--danger:hover { border-color: var(--c-danger); color: var(--c-danger); }
.btn--success { background: var(--c-success); border-color: var(--c-success); color: #fff; }
.btn--whatsapp { background: #1f9d61; border-color: #1f9d61; color: #fff; }
.btn--sm { padding: 6px 10px; font-size: 13px; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text); cursor: pointer; }
.icon-btn:hover { color: var(--c-primary); border-color: var(--c-primary); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---------- cards, stats, grids ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: var(--space-5); box-shadow: var(--shadow-sm); min-width: 0; }
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card--flush .card__head { padding: var(--space-4) var(--space-5) 0; }
.card__head h2, .card__title { font-size: 16px; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.stat { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); }
.stat__label { font-size: 13px; color: var(--c-text-muted); margin: 0; }
.stat__value { font: 600 26px/1.2 var(--font-heading); margin: 4px 0 0; }
.stat__note { font-size: 12px; color: var(--c-text-muted); margin: 2px 0 0; }
.grid { display: grid; gap: var(--space-4); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: var(--space-4); align-items: start; }
.stack { display: grid; gap: var(--space-4); }
.muted { color: var(--c-text-muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.strong { font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px var(--space-4); border-bottom: 1px solid var(--c-border); white-space: nowrap; background: var(--c-surface-alt); }
.table td { padding: 10px var(--space-4); border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover { background: var(--c-surface-alt); }
.table tfoot td { font-weight: 600; border-top: 1px solid var(--c-border); }

/* ---------- badges, chips, tabs ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--c-surface-alt); color: var(--c-text-muted); }
.badge--stage-0 { background: var(--stage-0-bg); color: var(--stage-0-fg); }
.badge--stage-1 { background: var(--stage-1-bg); color: var(--stage-1-fg); }
.badge--stage-2 { background: var(--stage-2-bg); color: var(--stage-2-fg); }
.badge--stage-3 { background: var(--stage-3-bg); color: var(--stage-3-fg); }
.badge--stage-4 { background: var(--stage-4-bg); color: var(--stage-4-fg); }
.badge--stage-5 { background: var(--stage-5-bg); color: var(--stage-5-fg); }
.badge--success { background: #e6f5ec; color: #1b7a4c; }
.badge--warning { background: #fdf1dd; color: #9a620a; }
.badge--danger { background: #fbe9e8; color: #b0322d; }
.badge--info { background: var(--c-primary-soft); color: var(--c-primary); }
.badge--accent { background: var(--c-accent-soft); color: #047a8a; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-pill); border: 1px solid var(--c-border); background: var(--c-surface); font-size: 13px; color: var(--c-text); text-decoration: none; cursor: pointer; }
.chip:hover { border-color: var(--c-primary); }
.chip.is-active, .chip[aria-pressed="true"] { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.chip__count { font-size: 11px; opacity: .8; }
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--c-border); margin-bottom: var(--space-4); overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: none; font: 600 14px var(--font-body); color: var(--c-text-muted); border-bottom: 2px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.tab.is-active, .tab[aria-selected="true"] { color: var(--c-primary); border-bottom-color: var(--c-primary); }

/* ---------- toolbar, forms ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.search { position: relative; flex: 1 1 240px; max-width: 380px; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--c-text-muted); }
.search input[type] { padding-left: 34px; }
input[type=text], input[type=search], input[type=tel], input[type=email], input[type=number], input[type=date], input[type=time], input[type=password], input[type=url], select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--c-text); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: 9px 11px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: var(--focus-ring); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--c-primary); }
.form-stack { display: grid; gap: var(--space-4); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field--check label { display: flex; align-items: center; gap: var(--space-2); font-weight: 500; }
.field__help { color: var(--c-text-muted); font-size: 12px; }
.field__error { color: var(--c-danger); font-size: 12px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--c-danger); }
.req { color: var(--c-danger); }
.inline-input { width: 110px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: 14px; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--c-border); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked { background: var(--c-primary); }
.switch input:checked::after { transform: translateX(16px); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--c-border); border-radius: var(--radius-sm); overflow: hidden; }
.stepper button { width: 32px; height: 32px; border: 0; background: var(--c-surface-alt); cursor: pointer; display: grid; place-items: center; color: var(--c-text); }
.stepper button:hover { color: var(--c-primary); }
.stepper input, .stepper output { width: 46px; text-align: center; border: 0; border-radius: 0; padding: 6px 0; font-variant-numeric: tabular-nums; }
.alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); font-size: 14px; background: var(--c-primary-soft); color: var(--c-primary); }
.alert--danger { background: #fbe9e8; color: #b0322d; }
.alert--warning { background: #fdf1dd; color: #9a620a; }
.alert--success { background: #e6f5ec; color: #1b7a4c; }

/* ---------- progress, stepper (stages), lists ---------- */
.progress { height: 8px; border-radius: 999px; background: var(--c-surface-alt); border: 1px solid var(--c-border); overflow: hidden; }
.progress__bar { display: block; height: 100%; background: var(--c-accent); border-radius: 999px; }
.stage-steps { display: flex; list-style: none; margin: 0; padding: 0; counter-reset: step; }
.stage-steps li { flex: 1; position: relative; text-align: center; font-size: 12px; color: var(--c-text-muted); padding-top: 30px; }
.stage-steps li::before { counter-increment: step; content: counter(step); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--c-surface); border: 2px solid var(--c-border); font-weight: 600; z-index: 1; }
.stage-steps li::after { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--c-border); }
.stage-steps li:first-child::after { display: none; }
.stage-steps li.is-done { color: var(--c-text); }
.stage-steps li.is-done::before { background: var(--c-primary); border-color: var(--c-primary); color: #fff; content: "✓"; }
.stage-steps li.is-done::after { background: var(--c-primary); }
.stage-steps li.is-current::before { background: var(--c-accent); border-color: var(--c-accent); color: #fff; content: counter(step); }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--c-border); }
.row:last-child { border-bottom: 0; }
.row__main { flex: 1; min-width: 0; }
.row__title { font-weight: 600; margin: 0; }
.row__meta { font-size: 13px; color: var(--c-text-muted); margin: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--c-primary-soft); color: var(--c-primary); font-weight: 600; font-size: 13px; flex: none; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--space-4); margin: 0; font-size: 14px; }
.dl dt { color: var(--c-text-muted); }
.dl dd { margin: 0; }
.totals { margin: 0; display: grid; gap: 4px; font-size: 14px; }
.totals div { display: flex; justify-content: space-between; }
.totals .totals__grand { font: 600 18px var(--font-heading); border-top: 1px solid var(--c-border); padding-top: var(--space-2); margin-top: var(--space-1); }
.empty { text-align: center; color: var(--c-text-muted); padding: var(--space-6) var(--space-4); }
.empty .icon { width: 32px; height: 32px; margin: 0 auto var(--space-2); display: block; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 60px; align-items: center; gap: var(--space-3); font-size: 13px; margin-bottom: var(--space-2); }
.bar-row__bar { display: block; height: 10px; background: var(--c-surface-alt); border-radius: 999px; overflow: hidden; }
.bar-row__fill { display: block; height: 100%; background: var(--c-primary); border-radius: 999px; }
.stars { color: #e5a50a; letter-spacing: 1px; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---------- drawer, modal, sheet, toasts ---------- */
.drawer { position: fixed; inset: 0; z-index: 200; visibility: hidden; }
.drawer.is-open { visibility: visible; }
.drawer__backdrop { position: absolute; inset: 0; background: rgba(20, 38, 58, .35); opacity: 0; transition: opacity .2s; }
.drawer.is-open .drawer__backdrop { opacity: 1; }
.drawer__panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--c-surface); box-shadow: var(--shadow-lg); overflow-y: auto; padding: var(--space-5); transform: translateX(100%); transition: transform .22s ease; }
.drawer.is-open .drawer__panel { transform: none; }
.drawer__close { position: absolute; top: var(--space-4); right: var(--space-4); }
.drawer h2 { font-size: 20px; padding-right: 48px; }
.drawer section { padding: var(--space-4) 0; border-top: 1px solid var(--c-border); }
.drawer section h3 { font-size: 14px; margin-bottom: var(--space-3); }
.modal { border: 0; border-radius: var(--radius-lg); padding: var(--space-5); width: min(640px, calc(100% - 32px)); box-shadow: var(--shadow-lg); }
.modal::backdrop { background: rgba(20, 38, 58, .35); }
.modal__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); }
.modal__head h2 { margin: 0; font-size: 20px; }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); }
.toasts { position: fixed; right: var(--space-4); bottom: var(--space-4); display: grid; gap: var(--space-2); z-index: 300; }
.toast { background: var(--c-text); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); font-size: 14px; animation: toast-in .2s ease; }
.toast--success { background: var(--c-success); }
.toast--error { background: var(--c-danger); }
.toast--warning { background: var(--c-warning); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.bottom-bar, .sheet { display: none; }

/* ---------- auth ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; background: var(--c-surface-alt); padding: var(--space-4); }
.auth-card { width: min(400px, 100%); display: grid; gap: var(--space-4); }
.auth-card h1 { font-size: 22px; margin: 0; }

/* ---------- print ---------- */
@media print {
  .panel__sidebar, .bottom-bar, .page-head__actions, .toasts, .skip-link, .no-print { display: none !important; }
  .panel { display: block; }
  .panel__main { padding: 0; }
  .panel-body { background: #fff; }
}

/* ---------- phone ---------- */
@media (max-width: 1100px) {
  .grid-main-side { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .panel { grid-template-columns: 1fr; }
  .panel__sidebar { display: none; }
  .panel__main { padding: var(--space-4) var(--space-4) 96px; }
  .page-head h1 { font-size: 22px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
  .stat { padding: var(--space-3) var(--space-4); }
  .stat__value { font-size: 21px; }
  .table .hide-sm { display: none; }
  .bottom-bar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 150; background: var(--c-surface); border-top: 1px solid var(--c-border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-bar__link { display: grid; justify-items: center; gap: 2px; font: 500 11px var(--font-body); color: var(--c-text-muted); text-decoration: none; background: none; border: 0; padding: 4px; cursor: pointer; }
  .bottom-bar__link.is-active { color: var(--c-primary); }
  .bottom-bar__link .icon { width: 22px; height: 22px; }
  .sheet[open] { display: block; position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; border: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); }
  .sheet::backdrop { background: rgba(20, 38, 58, .35); }
  .sheet__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-3); }
  .sheet__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1); }
  .sheet__list a { display: flex; align-items: center; gap: var(--space-2); padding: 12px; border-radius: var(--radius-sm); color: var(--c-text); text-decoration: none; background: var(--c-surface-alt); }
  .sheet__foot { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-4); }
  .drawer__panel { width: 100%; }
  .toasts { bottom: 84px; left: var(--space-4); }
}
@media (prefers-reduced-motion: reduce) { .drawer__panel, .drawer__backdrop, .toast { transition: none; animation: none; } }

/* ===== Screen-specific rules below this line (one comment header per screen) ===== */
