/* =========================================================================
   Sistema da Loja — folha de estilo principal (v0.2)
   Paleta "ateliê": berinjela, papel lilás-acinzentado e o rosa da alfineteira
   como único acento. A etiqueta de roupa é a marca visual.
   Temas: claro, escuro (noite de ateliê) e automático (segue o aparelho).
   O servidor grava data-theme="light|dark" no <html>; sem o atributo, segue o sistema.
   ========================================================================= */

:root {
    color-scheme: light;
    --bg: #f3f1f5;
    --surface: #ffffff;
    --surface-2: #f8f6f9;
    --line: #e1dbe4;
    --line-strong: #cbc2cf;
    --text: #241a26;
    --muted: #6b6170;
    --heading: #2b1d2e;

    --brand: #2b1d2e;            /* menu lateral e vitrine do login */
    --brand-2: #3d2c41;
    --on-brand: #e9e1ec;
    --on-brand-muted: #b9aabd;
    --tag-paper: #fbf8fc;        /* a etiqueta é papel: clara nos dois temas */
    --tag-ink: #2b1d2e;

    --pin: #a3305c;
    --pin-strong: #862549;
    --pin-soft: #f7e6ee;
    --on-pin: #ffffff;

    --success: #2c7454;
    --success-soft: #e3f2ea;
    --warning: #8f5e10;
    --warning-soft: #fbf0dc;
    --danger: #a8281f;
    --danger-soft: #fbe5e3;

    --topbar-bg: rgba(243, 241, 245, 0.94);
    --pop-shadow: 0 12px 32px rgba(43, 29, 46, 0.18);
    --focus: 0 0 0 3px rgba(163, 48, 92, 0.35);

    --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
    --font-body: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;

    --fs-xs: 0.8rem;
    --fs-sm: 0.9rem;
    --fs-md: 1rem;
    --fs-lg: 1.25rem;
    --fs-xl: 1.563rem;
    --fs-2xl: 1.953rem;
    --fs-3xl: 2.441rem;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;

    --radius-control: 8px;
    --radius-panel: 12px;
    --sidebar-width: 15.5rem;
    --touch: 2.75rem;
}

/* Tema escuro — aplicado quando escolhido, ou pelo aparelho no modo automático. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #161017;
    --surface: #211923;
    --surface-2: #2a202d;
    --line: #3a2f3e;
    --line-strong: #56485b;
    --text: #eee6f0;
    --muted: #aa9daf;
    --heading: #f7f0f8;
    --brand: #0f0a10;
    --brand-2: #261b29;
    --on-brand: #e9e1ec;
    --on-brand-muted: #a594aa;
    --pin: #e0679a;
    --pin-strong: #ee8ab3;
    --pin-soft: #3b1d2b;
    --on-pin: #1b0f16;
    --success: #78cfa3;
    --success-soft: #17302a;
    --warning: #e9b862;
    --warning-soft: #36291a;
    --danger: #f3918a;
    --danger-soft: #3c1e1c;
    --topbar-bg: rgba(22, 16, 23, 0.92);
    --pop-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    --focus: 0 0 0 3px rgba(224, 103, 154, 0.5);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #161017;
        --surface: #211923;
        --surface-2: #2a202d;
        --line: #3a2f3e;
        --line-strong: #56485b;
        --text: #eee6f0;
        --muted: #aa9daf;
        --heading: #f7f0f8;
        --brand: #0f0a10;
        --brand-2: #261b29;
        --on-brand: #e9e1ec;
        --on-brand-muted: #a594aa;
        --pin: #e0679a;
        --pin-strong: #ee8ab3;
        --pin-soft: #3b1d2b;
        --on-pin: #1b0f16;
        --success: #78cfa3;
        --success-soft: #17302a;
        --warning: #e9b862;
        --warning-soft: #36291a;
        --danger: #f3918a;
        --danger-soft: #3c1e1c;
        --topbar-bg: rgba(22, 16, 23, 0.92);
        --pop-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
        --focus: 0 0 0 3px rgba(224, 103, 154, 0.5);
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--fs-md);
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
a { color: var(--pin); }
a:hover { color: var(--pin-strong); }
code { font-size: 0.92em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
:focus-visible { outline: none; box-shadow: var(--focus); }
img { max-width: 100%; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap;
}
.skip-link {
    position: absolute; left: var(--space-4); top: -3rem;
    background: var(--surface); color: var(--heading);
    padding: var(--space-2) var(--space-4); border-radius: var(--radius-control);
    z-index: 100;
}
.skip-link:focus { top: var(--space-4); }

/* ---------- Etiqueta (marca) ---------- */
.tag {
    --tag-hole: var(--brand);
    position: relative;
    display: inline-flex;
    align-items: center;
    background: var(--tag-paper);
    color: var(--tag-ink);
    clip-path: polygon(1.4rem 0, 100% 0, 100% 100%, 1.4rem 100%, 0 50%);
    border-radius: 0 6px 6px 0;
    padding-left: 2.3rem;
    min-height: 3rem;
    max-width: 100%;
}
.tag__hole {
    position: absolute; left: 1rem; top: 50%;
    width: 0.55rem; height: 0.55rem; margin-top: -0.275rem;
    border-radius: 50%; background: var(--tag-hole);
}
.tag__body {
    position: relative; display: flex; align-items: center; min-width: 0;
    padding: var(--space-2) var(--space-4) var(--space-2) var(--space-3);
    margin: 0.3rem 0.3rem 0.3rem 0;
    border: 1.5px dashed rgba(43, 29, 46, 0.35);
    border-left: 0; border-radius: 0 4px 4px 0;
    min-height: 2.4rem;
}
.tag__name {
    font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600;
    letter-spacing: 0.01em; overflow-wrap: anywhere;
}
.tag__logo { display: block; max-height: 2.25rem; max-width: 9rem; object-fit: contain; }
.tag--lg { min-height: 7rem; padding-left: 3.6rem; clip-path: polygon(2.4rem 0, 100% 0, 100% 100%, 2.4rem 100%, 0 50%); }
.tag--lg .tag__hole { left: 1.5rem; width: 0.9rem; height: 0.9rem; margin-top: -0.45rem; }
.tag--lg .tag__body { padding: var(--space-4) var(--space-6) var(--space-4) var(--space-4); margin: 0.5rem 0.5rem 0.5rem 0; min-height: 6rem; }
.tag--lg .tag__name { font-size: var(--fs-3xl); }
.tag--lg .tag__logo { max-height: 5rem; max-width: 16rem; }

/* ---------- Botões ---------- */
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: var(--touch); padding: 0 var(--space-5);
    border: 1px solid var(--line); border-radius: var(--radius-control);
    background: var(--surface); color: var(--heading);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    white-space: nowrap;
}
.button:hover { border-color: var(--line-strong); color: var(--heading); background: var(--surface-2); }
.button[disabled], .button.is-busy { opacity: 0.65; cursor: progress; }
.button--primary { background: var(--pin); border-color: var(--pin); color: var(--on-pin); }
.button--primary:hover { background: var(--pin-strong); border-color: var(--pin-strong); color: var(--on-pin); }
.button--danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.button--danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.button--small { min-height: 2.25rem; padding: 0 var(--space-3); font-size: var(--fs-sm); }
.button--block { width: 100%; }

/* ---------- Formulários ---------- */
.form { display: grid; gap: var(--space-4); }
.form__row { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.form__group { border: 0; padding: 0; margin: 0; display: grid; gap: var(--space-4); min-width: 0; }
.form__group + .form__group {
    /* A linha é desenhada como fundo: numa borda, o navegador colocaria o título (legend) em cima dela. */
    background: linear-gradient(var(--line), var(--line)) no-repeat 0 0 / 100% 1px;
}
.form__group + .form__group > .form__legend { padding-top: var(--space-5); }
.form__legend { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; color: var(--heading); padding: 0; margin-bottom: var(--space-2); }

.field { display: grid; gap: var(--space-1); min-width: 0; align-content: start; }
.field--grow { flex: 1 1 14rem; }
.field--narrow { flex: 0 0 7rem; }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--heading); }
.field__help { font-size: var(--fs-xs); color: var(--muted); }
.field__input {
    width: 100%; min-height: var(--touch); padding: 0 var(--space-3);
    border: 1px solid var(--line); border-radius: var(--radius-control);
    background: var(--surface); color: var(--text); font: inherit;
}
textarea.field__input { min-height: 5rem; padding: var(--space-2) var(--space-3); resize: vertical; }
select.field__input { padding-right: var(--space-6); }
input[type="file"].field__input { padding: var(--space-2) var(--space-3); }
.field__input:hover { border-color: var(--line-strong); }
.field__input:focus { border-color: var(--pin); box-shadow: var(--focus); outline: none; }
.field.has-error .field__input { border-color: var(--danger); }
.field__group { display: flex; }
.field__group .field__input { border-radius: var(--radius-control) 0 0 var(--radius-control); }
.field__addon {
    flex: 0 0 auto; min-height: var(--touch); padding: 0 var(--space-4);
    border: 1px solid var(--line); border-left: 0;
    border-radius: 0 var(--radius-control) var(--radius-control) 0;
    background: var(--surface-2); color: var(--heading);
    font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.check { display: flex; align-items: flex-start; gap: var(--space-3); font-size: var(--fs-sm); cursor: pointer; }
.check input { width: 1.15rem; height: 1.15rem; margin: 0.15rem 0 0; accent-color: var(--pin); flex: 0 0 auto; }

.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-2); }
.actions--start { justify-content: flex-start; }

/* ---------- Avisos ---------- */
.alert {
    padding: var(--space-3) var(--space-4); border-radius: var(--radius-control);
    border-left: 4px solid currentColor; margin-bottom: var(--space-4); font-size: var(--fs-sm);
}
.alert p + p { margin-top: var(--space-2); }
.alert--success { background: var(--success-soft); color: var(--success); }
.alert--warning { background: var(--warning-soft); color: var(--warning); }
.alert--error { background: var(--danger-soft); color: var(--danger); }
.alert__title { font-weight: 700; }
.alert__list { margin: var(--space-2) 0 0; padding-left: var(--space-5); }

/* ---------- Seletor de tema ---------- */
.theme-switch {
    display: inline-flex; padding: 3px; gap: 2px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.theme-switch__option {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-width: 2.35rem; min-height: 2.35rem; padding: 0 var(--space-2);
    border: 0; border-radius: 999px; background: transparent; color: var(--muted);
    font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.theme-switch__option:hover { color: var(--heading); background: var(--surface-2); }
.theme-switch__option[aria-pressed="true"] { background: var(--pin); color: var(--on-pin); }
.theme-switch__icon { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; }
.theme-switch--labels { display: flex; width: 100%; max-width: 26rem; }
.theme-switch--labels .theme-switch__option { flex: 1 1 0; padding: 0 var(--space-2); min-width: 0; }
.theme-switch:not(.theme-switch--labels) .theme-switch__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth__showcase {
    background: var(--brand); color: var(--on-brand);
    display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
    gap: var(--space-5); padding: var(--space-7) clamp(2rem, 6vw, 5rem);
}
.auth__caption { font-family: var(--font-display); font-size: var(--fs-lg); line-height: 1.6; max-width: 26ch; color: var(--on-brand-muted); }
.auth__panel { position: relative; display: flex; align-items: center; justify-content: center; padding: var(--space-7) var(--space-5) var(--space-6); min-width: 0; }
.auth__theme { position: absolute; top: var(--space-4); right: var(--space-4); }
.login { width: 100%; max-width: 24rem; min-width: 0; }
.login__title { font-family: var(--font-display); font-size: var(--fs-2xl); color: var(--heading); }
.login__hint { color: var(--muted); margin: var(--space-2) 0 var(--space-5); font-size: var(--fs-sm); }

/* ---------- Estrutura (menu lateral + área de trabalho) ---------- */
.shell { min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width);
    background: var(--brand); color: var(--on-brand);
    display: flex; flex-direction: column; z-index: 40;
}
.sidebar__brand { padding: var(--space-5) var(--space-4) var(--space-4); }
.sidebar__nav { flex: 1; overflow-y: auto; padding: var(--space-2) var(--space-3); }
.sidebar__nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidebar__link {
    display: flex; align-items: center; min-height: var(--touch); padding: 0 var(--space-3);
    border-radius: var(--radius-control); color: var(--on-brand-muted); text-decoration: none;
    font-size: var(--fs-sm); font-weight: 500;
}
.sidebar__link:hover { background: var(--brand-2); color: #fff; }
.sidebar__link.is-active { background: var(--tag-paper); color: var(--tag-ink); font-weight: 700; }
.sidebar__user { padding: var(--space-4); border-top: 1px dashed rgba(233, 225, 236, 0.25); }
.sidebar__user-name { font-weight: 600; font-size: var(--fs-sm); color: #fff; }
.sidebar__user-role { font-size: var(--fs-xs); color: var(--on-brand-muted); margin-bottom: var(--space-3); }
.sidebar__user-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.sidebar__button {
    display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0 var(--space-3);
    border: 1px solid rgba(233, 225, 236, 0.35); border-radius: var(--radius-control);
    background: transparent; color: var(--on-brand); text-decoration: none;
    font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
.sidebar__button:hover { background: var(--brand-2); color: #fff; }

.workspace { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: var(--space-3);
    min-height: 4rem; padding: 0 var(--space-6);
    background: var(--topbar-bg); border-bottom: 1px solid var(--line);
    backdrop-filter: blur(6px);
}
.topbar__title { font-family: var(--font-display); font-size: var(--fs-xl); color: var(--heading); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__menu {
    display: none; width: var(--touch); height: var(--touch); flex: 0 0 auto;
    border: 1px solid var(--line); border-radius: var(--radius-control);
    background: var(--surface); cursor: pointer; position: relative;
}
.topbar__menu-bars, .topbar__menu-bars::before, .topbar__menu-bars::after {
    position: absolute; left: 50%; width: 1.1rem; height: 2px; margin-left: -0.55rem;
    background: var(--heading); border-radius: 2px; content: "";
}
.topbar__menu-bars { top: 50%; margin-top: -1px; }
.topbar__menu-bars::before { top: -6px; }
.topbar__menu-bars::after { top: 6px; }

.content { flex: 1; width: 100%; max-width: 72rem; padding: var(--space-6); }
.content:focus { outline: none; }
.backdrop { position: fixed; inset: 0; background: rgba(15, 10, 16, 0.55); z-index: 30; }

/* ---------- Cabeçalho de página, filtros, tabelas ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-5); margin-bottom: var(--space-5); }
.page-head__title { font-family: var(--font-display); font-size: var(--fs-2xl); color: var(--heading); }
.page-head__text { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--space-1); max-width: 60ch; }
.back-link { display: inline-block; font-size: var(--fs-sm); margin-bottom: var(--space-2); text-decoration: none; }
.back-link:hover { text-decoration: underline; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); margin-bottom: var(--space-4); }
.filters .field { flex: 1 1 11rem; }
.filters .field--search { flex: 3 1 16rem; }
.filters__extra { display: contents; }
.filters__toggle { display: none; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
    text-align: left; font-weight: 600; color: var(--muted); font-size: var(--fs-xs);
    padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); background: var(--surface-2);
    white-space: nowrap;
}
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table__primary { font-weight: 600; color: var(--heading); text-decoration: none; }
.table__primary:hover { color: var(--pin); }
.table__sub { display: block; color: var(--muted); font-size: var(--fs-xs); }
.table__right, .table th.table__right { text-align: right; white-space: nowrap; }
.empty { padding: var(--space-6) var(--space-5); text-align: center; color: var(--muted); }
.empty__title { font-family: var(--font-display); font-size: var(--fs-lg); color: var(--heading); margin-bottom: var(--space-2); }

.badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.15rem 0.6rem; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600;
    background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.badge--ativo { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge--inativo { background: var(--surface-2); color: var(--muted); }
.badge--alerta { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge--erro { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge--master { background: var(--pin-soft); color: var(--pin); border-color: transparent; }
.badges { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---------- Painéis ---------- */
.welcome { margin-bottom: var(--space-6); max-width: 60ch; }
.welcome__title { font-family: var(--font-display); font-size: var(--fs-2xl); color: var(--heading); margin-bottom: var(--space-2); }
.welcome__note { font-size: var(--fs-sm); color: var(--muted); margin-top: var(--space-2); }

.grid { display: grid; gap: var(--space-5); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); align-items: start; }
.grid--aside { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.stack { display: grid; gap: var(--space-5); align-content: start; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); padding: var(--space-5); min-width: 0; }
.panel--danger { border-color: var(--danger); border-style: dashed; }
.panel--spaced { margin-bottom: var(--space-5); }
.panel__title { font-family: var(--font-display); font-size: var(--fs-lg); color: var(--heading); margin-bottom: var(--space-3); }
.panel__text { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--space-4); max-width: 65ch; }

.details { margin: 0; display: grid; gap: var(--space-3); font-size: var(--fs-sm); }
.details div { display: flex; justify-content: space-between; gap: var(--space-4); border-bottom: 1px dashed var(--line); padding-bottom: var(--space-2); }
.details div:last-child { border-bottom: 0; padding-bottom: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; text-align: right; font-weight: 600; color: var(--heading); overflow-wrap: anywhere; }

.checklist { margin: 0; display: grid; }
.checklist__row {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-1) var(--space-4);
    padding: var(--space-3) 0 var(--space-3) var(--space-5); border-bottom: 1px solid var(--line);
    position: relative; font-size: var(--fs-sm);
}
.checklist__row:last-child { border-bottom: 0; }
.checklist__row::before {
    content: ""; position: absolute; left: 0; top: 1.05rem;
    width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--success);
}
.checklist__row.is-warning::before { background: var(--warning); }
.checklist__row.is-error::before { background: var(--danger); }
.checklist__row dt { font-weight: 600; color: var(--heading); }
.checklist__row dd { margin: 0; color: var(--muted); text-align: right; }
.checklist__row.is-warning dd { color: var(--warning); }
.checklist__row.is-error dd { color: var(--danger); }

.modules { list-style: none; margin: 0; padding: 0; display: grid; }
.modules__item {
    display: flex; justify-content: space-between; gap: var(--space-3);
    padding: var(--space-2) 0; border-bottom: 1px dashed var(--line);
    font-size: var(--fs-sm); color: var(--muted);
}
.modules__item:last-child { border-bottom: 0; }
.modules__item.is-on { color: var(--text); }
.modules__state { font-size: var(--fs-xs); }
.modules__item.is-on .modules__state { color: var(--success); font-weight: 600; }

.activity { list-style: none; margin: 0; padding: 0; display: grid; font-size: var(--fs-sm); }
.activity li { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px dashed var(--line); }
.activity li:last-child { border-bottom: 0; }
.activity__when { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }

.logo-preview {
    display: flex; align-items: center; justify-content: center; min-height: 7rem;
    border: 1.5px dashed var(--line-strong); border-radius: var(--radius-control);
    background: var(--tag-paper); padding: var(--space-4); margin-bottom: var(--space-4);
}
.logo-preview img { max-height: 5rem; object-fit: contain; }
.logo-preview__empty { color: #6b6170; font-size: var(--fs-sm); }

/* ---------- Matriz de permissões ---------- */
.perm-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.perm-table th, .perm-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.perm-table thead th { background: var(--surface-2); font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.perm-table .perm-table__role { width: 8.5rem; text-align: center; }
.perm-table td.perm-table__role input { width: 1.25rem; height: 1.25rem; accent-color: var(--pin); cursor: pointer; }
.perm-table__group th {
    background: var(--bg); font-family: var(--font-display); font-size: var(--fs-md);
    color: var(--heading); font-weight: 600; padding-top: var(--space-4);
}
.perm-table__slug { display: block; font-size: var(--fs-xs); color: var(--muted); }
.perm-table__lock { font-size: var(--fs-xs); color: var(--pin); font-weight: 600; }

.override { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-control); overflow: hidden; }
.override label { position: relative; }
.override input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.override span { display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0 var(--space-3); font-size: var(--fs-xs); font-weight: 600; color: var(--muted); border-left: 1px solid var(--line); }
.override label:first-child span { border-left: 0; }
.override input:checked + span { background: var(--surface-2); color: var(--heading); }
.override input[value="grant"]:checked + span { background: var(--success-soft); color: var(--success); }
.override input[value="deny"]:checked + span { background: var(--danger-soft); color: var(--danger); }
.override input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--pin); }

/* ---------- Fase 3: CRM ---------- */
.page-head__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* Ficha técnica da cliente: medidas de compra, no espírito da etiqueta */
.ficha {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel);
    margin-bottom: var(--space-5); overflow: hidden;
}
.ficha__item {
    display: grid; gap: var(--space-1); padding: var(--space-4) var(--space-5);
    border-right: 1.5px dashed var(--line); border-bottom: 1.5px dashed var(--line); margin: 0 -1.5px -1.5px 0;
}
.ficha__label { font-size: var(--fs-xs); color: var(--muted); }
.ficha__value { font-family: var(--font-display); font-size: var(--fs-lg); color: var(--heading); font-variant-numeric: tabular-nums; }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-4); font-size: var(--fs-sm); color: var(--muted); }
.pager__links { display: flex; align-items: center; gap: var(--space-3); }

.tabs { display: flex; flex-wrap: wrap; gap: var(--space-1); border-bottom: 1px solid var(--line); margin-bottom: var(--space-4); }
.tabs__item {
    padding: var(--space-3) var(--space-4); color: var(--muted); text-decoration: none; font-size: var(--fs-sm); font-weight: 600;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs__item:hover { color: var(--heading); }
.tabs__item.is-active { color: var(--pin); border-bottom-color: var(--pin); }

.field--choices { border: 0; padding: 0; margin: 0; }
.choices { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); padding-top: var(--space-1); }
.inline-form { display: inline; }
.inline-form + .inline-form { margin-left: var(--space-2); }
.note { font-size: var(--fs-sm); line-height: 1.6; overflow-wrap: anywhere; }
.field__help.is-warning { color: var(--warning); font-weight: 600; }
.field__help.is-warning a { color: inherit; }
.table__right .table__sub { text-align: right; }

.birthdays { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.birthdays li { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px dashed var(--line); font-size: var(--fs-sm); }
.birthdays li:last-child { border-bottom: 0; }
.birthdays a { font-weight: 600; color: var(--heading); text-decoration: none; }
.birthdays a:hover { color: var(--pin); }

/* ---------- Fase 4: produtos e estoque ---------- */
.swatch {
    display: inline-block; width: 0.95rem; height: 0.95rem; border-radius: 50%; flex: 0 0 auto;
    border: 1px solid var(--muted); background: var(--surface-2); vertical-align: -0.12rem;
}
.swatch--pattern { background: repeating-linear-gradient(45deg, var(--pin) 0 3px, var(--tag-paper) 3px 6px); }
.variant-cell { display: inline-flex; align-items: center; gap: var(--space-2); }
.product-cell { display: flex; align-items: center; gap: var(--space-3); }
.thumb { width: 2.75rem; height: 2.75rem; border-radius: var(--radius-control); object-fit: cover; flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface-2); }
.thumb--empty { display: inline-block; background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, var(--bg) 6px 12px); }
.check--chip {
    align-items: center; padding: 0.4rem 0.75rem; border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); min-height: 2.5rem;
}
.check--chip input { margin: 0; }
.check--chip:has(input:checked) { border-color: var(--pin); background: var(--pin-soft); color: var(--heading); }
.check--center { align-self: flex-end; min-height: var(--touch); align-items: center; }
.choices--stack { flex-direction: column; gap: var(--space-3); }
.field__input--color { padding: 0.25rem; height: var(--touch); cursor: pointer; }
.field__input--money { font-variant-numeric: tabular-nums; }
.photo { display: flex; align-items: center; justify-content: center; aspect-ratio: 1 / 1; margin-bottom: var(--space-4);
    border-radius: var(--radius-control); overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo--empty { border-style: dashed; color: var(--muted); font-size: var(--fs-sm); }
.qty { font-variant-numeric: tabular-nums; }
.qty--in { color: var(--success); }
.qty--out { color: var(--danger); }
.entry-grid td { vertical-align: middle; }
.qty-input { width: 6rem; text-align: right; margin-left: auto; font-variant-numeric: tabular-nums; }
.entry-total { font-family: var(--font-display); font-size: var(--fs-lg); color: var(--heading); margin: var(--space-4) 0; }
.table tr.is-muted td { opacity: 0.6; }
.note--spaced { margin-top: var(--space-4); }
.nowrap { white-space: nowrap; }

/* ---------- Fase 5: venda rápida, recibo e painel ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(19rem, 1fr); gap: var(--space-5); align-items: start; }
.pos__main, .pos__side { display: grid; gap: var(--space-4); min-width: 0; }
.pos__side { position: sticky; top: 5rem; }
.pos__checkout { scroll-margin-top: 5rem; }
.pos__search { position: relative; }
.pos__search-input { min-height: 3.25rem; font-size: var(--fs-lg); border-width: 1.5px; }
.pos__results {
    list-style: none; margin: var(--space-2) 0 0; padding: var(--space-2); position: absolute; left: 0; right: 0; z-index: 15;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); box-shadow: var(--pop-shadow);
    max-height: 60vh; overflow-y: auto;
}
.pos__result {
    display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 3.5rem; padding: var(--space-2) var(--space-3);
    border: 0; border-radius: var(--radius-control); background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.pos__result:hover:not([disabled]), .pos__result:focus-visible { background: var(--surface-2); }
.pos__result[disabled] { opacity: 0.55; cursor: not-allowed; }
.pos__result-text { flex: 1; display: grid; min-width: 0; }
.pos__result-text span, .pos__result-price span { font-size: var(--fs-xs); color: var(--muted); }
.pos__result-price { display: grid; text-align: right; white-space: nowrap; }
.pos__result-price .is-out { color: var(--danger); font-weight: 600; }
.pos__result-empty { padding: var(--space-3); color: var(--muted); font-size: var(--fs-sm); }
.pos__count { font-family: var(--font-body); font-size: var(--fs-sm); color: var(--muted); font-weight: 400; }
.pos__empty { color: var(--muted); font-size: var(--fs-sm); padding: var(--space-5) 0; text-align: center; border: 1.5px dashed var(--line); border-radius: var(--radius-control); }
.cart { list-style: none; margin: 0; padding: 0; display: grid; }
.cart__line {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "info qty total" "info remove remove";
    gap: var(--space-1) var(--space-4); align-items: center; padding: var(--space-3) 0; border-bottom: 1px dashed var(--line);
}
.cart__line:last-child { border-bottom: 0; }
.cart__info { grid-area: info; display: grid; min-width: 0; }
.cart__info span { font-size: var(--fs-xs); color: var(--muted); }
.cart__qty { grid-area: qty; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; }
.cart__btn { width: 2.5rem; height: 2.5rem; border: 0; background: transparent; color: var(--heading); font-size: var(--fs-lg); cursor: pointer; border-radius: 999px; }
.cart__btn:hover:not([disabled]) { background: var(--surface-2); }
.cart__btn[disabled] { opacity: 0.35; }
.cart__n { min-width: 1.75rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.cart__total { grid-area: total; text-align: right; font-variant-numeric: tabular-nums; min-width: 6rem; }
.cart__remove { grid-area: remove; justify-self: end; border: 0; background: none; color: var(--muted); font: inherit; font-size: var(--fs-xs); cursor: pointer; text-decoration: underline; padding: 0; }
.pos__chosen { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.pos__chosen div { display: grid; }
.pos__chosen span { font-size: var(--fs-xs); color: var(--muted); }
.pos__customers { list-style: none; margin: var(--space-2) 0; padding: 0; display: grid; gap: 2px; }
.pos__customer { width: 100%; display: grid; text-align: left; padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.pos__customer:hover { border-color: var(--pin); }
.pos__customer span { font-size: var(--fs-xs); color: var(--muted); }
.payrow { display: grid; gap: var(--space-2); padding-bottom: var(--space-3); margin-bottom: var(--space-3); border-bottom: 1px dashed var(--line); }
.payrow .field--narrow { flex: 0 1 7.5rem; }
.payrow__troco { align-self: end; min-height: var(--touch); display: flex; align-items: center; font-size: var(--fs-sm); }
.pos__total { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.pos__total span { color: var(--muted); }
.pos__total strong { font-family: var(--font-display); font-size: var(--fs-2xl); color: var(--heading); font-variant-numeric: tabular-nums; }
.pos__remaining { font-size: var(--fs-sm); color: var(--success); margin: var(--space-1) 0 var(--space-3); min-height: 1.3em; }
.pos__remaining.is-pending { color: var(--warning); font-weight: 600; }
.pos__checkout .field { margin-bottom: var(--space-3); }
.pos__finish { min-height: 3.25rem; font-size: var(--fs-md); }

.receipt__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-4); padding-bottom: var(--space-4); border-bottom: 1.5px dashed var(--line); }
.receipt__head .tag { --tag-hole: var(--surface); }
.receipt__meta { font-size: var(--fs-sm); text-align: right; display: grid; gap: 2px; color: var(--muted); }
.receipt__meta strong { color: var(--heading); }
.receipt__items { width: 100%; border-collapse: collapse; margin: var(--space-4) 0; font-size: var(--fs-sm); }
.receipt__items th { text-align: left; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
.receipt__items th.table__right { text-align: right; }
.receipt__items td { padding: var(--space-2) 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
.receipt__items td + td, .receipt__items th + th { padding-left: var(--space-3); }
.receipt__totals { margin: 0; display: grid; gap: var(--space-2); font-size: var(--fs-sm); }
.receipt__totals div { display: flex; justify-content: space-between; gap: var(--space-3); }
.receipt__totals dt { color: var(--muted); }
.receipt__totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.receipt__grand { padding: var(--space-2) 0; border-top: 1.5px dashed var(--line); border-bottom: 1.5px dashed var(--line); }
.receipt__grand dt, .receipt__grand dd { font-family: var(--font-display); font-size: var(--fs-lg); color: var(--heading); }
.receipt__note { margin-top: var(--space-4); }
.receipt__foot { margin-top: var(--space-5); text-align: center; font-size: var(--fs-xs); color: var(--muted); }

.today {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-4);
    background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--pin); border-radius: var(--radius-panel);
    padding: var(--space-5); margin-bottom: var(--space-5);
}
.today__label { font-size: var(--fs-sm); color: var(--muted); }
.today__value { font-family: var(--font-display); font-size: var(--fs-2xl); color: var(--heading); font-variant-numeric: tabular-nums; }
.today__sub { font-size: var(--fs-sm); color: var(--muted); }
.today__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* ---------- Instalador ---------- */
.install { min-height: 100vh; padding: var(--space-6) var(--space-4); }
.install__frame { max-width: 44rem; margin: 0 auto; }
.install .tag { --tag-hole: var(--bg); justify-self: start; }
.install__header { display: grid; gap: var(--space-5); margin-bottom: var(--space-5); }
.stepper { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.stepper__item { display: flex; align-items: center; gap: var(--space-2); color: var(--muted); font-size: var(--fs-sm); }
.stepper__number {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.75rem; height: 1.75rem; border-radius: 50%;
    border: 1.5px dashed currentColor; font-weight: 700; font-size: var(--fs-xs);
}
.stepper__item.is-current { color: var(--pin); font-weight: 700; }
.stepper__item.is-current .stepper__number { border-style: solid; background: var(--pin); border-color: var(--pin); color: var(--on-pin); }
.stepper__item.is-done { color: var(--success); }
.stepper__item.is-done .stepper__number { border-style: solid; }

/* ---------- Página de erro ---------- */
.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-5); }
.error-page__box { max-width: 34rem; }
.error-page__code { font-family: var(--font-display); font-size: var(--fs-3xl); color: var(--pin); line-height: 1; }
.error-page__title { font-family: var(--font-display); font-size: var(--fs-2xl); color: var(--heading); margin: var(--space-3) 0; }
.error-page__text { color: var(--muted); margin-bottom: var(--space-4); }
.error-page__ref { font-size: var(--fs-sm); margin-bottom: var(--space-5); }
.error-page__debug {
    margin-top: var(--space-5); padding: var(--space-4); background: var(--brand); color: var(--on-brand);
    border-radius: var(--radius-control); font-size: var(--fs-xs); overflow-x: auto; white-space: pre-wrap;
}

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
    .grid--aside { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
    .pos { grid-template-columns: minmax(0, 1fr); padding-bottom: 4.5rem; }
    .pos__side { position: static; }
    .pos__jump:not([hidden]) {
        position: fixed; left: var(--space-3); right: var(--space-3); bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); z-index: 25;
        display: flex; align-items: center; gap: var(--space-3); min-height: 3.25rem; padding: 0 var(--space-4);
        background: var(--pin); color: var(--on-pin); border-radius: var(--radius-panel); text-decoration: none; box-shadow: var(--pop-shadow);
    }
    .pos__jump strong, .pos__jump span { white-space: nowrap; }
    .pos__jump strong { font-variant-numeric: tabular-nums; }
    .pos__jump-cta { margin-left: auto; font-weight: 700; }
}
.pos__jump { display: none; }
@media (max-width: 900px) { .pos__jump:not([hidden]) { display: flex; } }
@media (max-width: 560px) {
    .cart__line { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "info info" "qty total" "remove remove"; row-gap: var(--space-2); }
    .cart__remove { justify-self: start; }
}
@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
    .sidebar.is-open { transform: none; }
    .workspace { margin-left: 0; }
    .topbar { padding: 0 var(--space-4); }
    .topbar__menu { display: inline-block; }
    .content { padding: var(--space-5) var(--space-4); }
}
@media (max-width: 760px) {
    .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .auth__showcase { padding: var(--space-6) var(--space-5); gap: var(--space-3); }
    .auth__showcase .tag--lg { min-height: 5rem; }
    .auth__showcase .tag--lg .tag__body { min-height: 4rem; padding: var(--space-3) var(--space-5) var(--space-3) var(--space-3); }
    .auth__showcase .tag--lg .tag__name { font-size: var(--fs-2xl); }
    .auth__caption { font-size: var(--fs-md); }
    .auth__panel { align-items: flex-start; padding-top: var(--space-6); }
    .auth__theme { position: static; margin-bottom: var(--space-5); }
    .auth__panel { flex-direction: column; align-items: stretch; }
    .auth__panel .login { max-width: none; }
    .checklist__row dd { text-align: left; }
    .actions { justify-content: stretch; }
    .actions .button { flex: 1 1 auto; }
    .page-head__title { font-size: var(--fs-xl); }
    .filters__toggle { display: inline-flex; }
    .filters__extra { display: none; width: 100%; }
    .filters.is-expanded .filters__extra { display: grid; gap: var(--space-3); }
    .topbar .theme-switch__option { min-width: 2.1rem; min-height: 2.1rem; }

    /* Tabelas viram cartões no celular */
    .table--cards thead { display: none; }
    .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
    .table--cards tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
    .table--cards tr:last-child { border-bottom: 0; }
    .table--cards td { border: 0; padding: var(--space-1) 0; display: flex; justify-content: space-between; gap: var(--space-3); }
    .table--cards td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-xs); margin-right: auto; }
    .table--cards td[data-label] { flex-wrap: wrap; justify-content: flex-end; align-items: baseline; column-gap: var(--space-2); }
    .table--cards td[data-label] .table__sub { display: inline; }
    .table--cards td.table__lead { display: block; }
    .table--cards td.table__lead::before { content: none; }

    .perm-table .perm-table__role { width: 5rem; }
    .table--cards td.table__right { text-align: left; }
    .ficha__item { padding: var(--space-3) var(--space-4); }
    .ficha__value { font-size: var(--fs-md); }
    .qty-input { width: 100%; }
    .entry-grid td { display: table-cell; }
    .perm-table th, .perm-table td { padding: var(--space-2) var(--space-3); }
}
@media (max-width: 420px) {
    .theme-switch--labels .theme-switch__option { gap: 0.3rem; padding: 0 0.25rem; font-size: var(--fs-xs); }
    .theme-switch--labels .theme-switch__icon { width: 0.95rem; height: 0.95rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
    .sidebar, .topbar, .backdrop, .no-print, .alert, .skip-link { display: none !important; }
    .workspace { margin: 0; }
    body, .content { background: #fff; color: #000; padding: 0; }
    .grid--aside { display: block; }
    .receipt { border: 0; padding: 0; max-width: 22rem; margin: 0 auto; }
    .receipt__meta, .receipt__totals dt, .receipt__foot, .table__sub { color: #333; }
}
