/* --- Design system (base: enzo.html) — cores em OKLCH, tipografia Geist ---- */

@font-face {
  font-family: "Geist";
  src: url("/fonts/geist-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist";
  src: url("/fonts/geist-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;

  --bg: oklch(0.945 0.002 250);
  --surface: oklch(1 0 0);
  --surface-glass: oklch(1 0 0 / 0.86);
  --surface-2: oklch(0.965 0.002 250);
  --surface-3: oklch(0.935 0.004 250);
  --border: oklch(0.9 0.004 250);
  --border-strong: oklch(0.855 0.006 250);

  --text: oklch(0.25 0.012 250);
  --text-muted: oklch(0.48 0.012 250);
  --text-faint: oklch(0.6 0.01 250);

  --primary: oklch(0.53 0.18 253);
  --primary-hover: oklch(0.47 0.18 253);
  --primary-soft: oklch(0.53 0.18 253 / 0.12);
  --primary-contrast: oklch(0.99 0.01 253);

  --success: oklch(0.55 0.16 150);
  --success-soft: oklch(0.55 0.16 150 / 0.13);
  --warning: oklch(0.62 0.14 78);
  --warning-soft: oklch(0.62 0.14 78 / 0.14);
  --danger: oklch(0.54 0.2 25);
  --danger-soft: oklch(0.54 0.2 25 / 0.12);
  --info-soft: oklch(0.53 0.18 253 / 0.1);

  --shadow-sm: 0 1px 2px oklch(0.4 0.01 250 / 0.06);
  --shadow-md: 0 1px 2px oklch(0.4 0.01 250 / 0.06), 0 14px 34px oklch(0.4 0.01 250 / 0.09);
  --shadow-lg: 0 1px 2px oklch(0.4 0.01 250 / 0.08), 0 24px 60px oklch(0.4 0.01 250 / 0.16);

  --radius: 12px;
  --radius-lg: 18px;
  --sidebar-w: 256px;
  --font: "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Tema escuro: pelo sistema, salvo quando o usuario fixou o tema claro. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: oklch(0.2 0.006 250);
    --surface: oklch(0.255 0.008 250);
    --surface-glass: oklch(0.255 0.008 250 / 0.82);
    --surface-2: oklch(0.295 0.008 250);
    --surface-3: oklch(0.33 0.008 250);
    --border: oklch(0.35 0.008 250);
    --border-strong: oklch(0.42 0.01 250);

    --text: oklch(0.97 0.004 250);
    --text-muted: oklch(0.79 0.008 250);
    --text-faint: oklch(0.65 0.01 250);

    --primary: oklch(0.72 0.15 253);
    --primary-hover: oklch(0.79 0.14 253);
    --primary-soft: oklch(0.72 0.15 253 / 0.18);
    --primary-contrast: oklch(0.18 0.04 253);

    --success: oklch(0.78 0.15 152);
    --success-soft: oklch(0.78 0.15 152 / 0.18);
    --warning: oklch(0.83 0.14 82);
    --warning-soft: oklch(0.83 0.14 82 / 0.18);
    --danger: oklch(0.7 0.19 25);
    --danger-soft: oklch(0.7 0.19 25 / 0.16);
    --info-soft: oklch(0.72 0.15 253 / 0.14);

    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
    --shadow-md: 0 1px 2px oklch(0 0 0 / 0.3), 0 16px 40px oklch(0 0 0 / 0.32);
    --shadow-lg: 0 1px 2px oklch(0 0 0 / 0.4), 0 28px 64px oklch(0 0 0 / 0.45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: oklch(0.2 0.006 250);
  --surface: oklch(0.255 0.008 250);
  --surface-glass: oklch(0.255 0.008 250 / 0.82);
  --surface-2: oklch(0.295 0.008 250);
  --surface-3: oklch(0.33 0.008 250);
  --border: oklch(0.35 0.008 250);
  --border-strong: oklch(0.42 0.01 250);

  --text: oklch(0.97 0.004 250);
  --text-muted: oklch(0.79 0.008 250);
  --text-faint: oklch(0.65 0.01 250);

  --primary: oklch(0.72 0.15 253);
  --primary-hover: oklch(0.79 0.14 253);
  --primary-soft: oklch(0.72 0.15 253 / 0.18);
  --primary-contrast: oklch(0.18 0.04 253);

  --success: oklch(0.78 0.15 152);
  --success-soft: oklch(0.78 0.15 152 / 0.18);
  --warning: oklch(0.83 0.14 82);
  --warning-soft: oklch(0.83 0.14 82 / 0.18);
  --danger: oklch(0.7 0.19 25);
  --danger-soft: oklch(0.7 0.19 25 / 0.16);
  --info-soft: oklch(0.72 0.15 253 / 0.14);

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 1px 2px oklch(0 0 0 / 0.3), 0 16px 40px oklch(0 0 0 / 0.32);
  --shadow-lg: 0 1px 2px oklch(0 0 0 / 0.4), 0 28px 64px oklch(0 0 0 / 0.45);
}

*, *::before, *::after { box-sizing: border-box; }

/* O atributo `hidden` precisa vencer as classes que definem `display`
   (.alert, .field, #root); sem isto, elementos ocultos continuam visiveis. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background 400ms ease, color 400ms ease;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.018em; }
p { margin: 0 0 0.75rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--text); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
::-webkit-scrollbar-track { background: transparent; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- Boot ---------------------------------------------------------------- */

.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); }
.boot__spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-top-color: var(--primary);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Layout -------------------------------------------------------------- */

#root { display: flex; min-height: 100vh; }
#root[data-view="auth"] .sidebar,
#root[data-view="auth"] .topbar { display: none; }
#root[data-view="auth"] .shell { margin-left: 0; }
#root[data-view="auth"] .view { display: grid; place-items: center; padding: 1.5rem; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 1rem 0.75rem;
  background: var(--surface); border-right: 1px solid var(--border);
}

.sidebar__brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.6rem 1rem; }
.brand__mark {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none;
  border-radius: 11px; background: var(--primary); color: var(--primary-contrast);
  font-weight: 700; font-size: 15px;
}
.brand__name { font-weight: 650; letter-spacing: -0.02em; }
.brand__dot { color: var(--primary); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav__group { padding: 0.9rem 0.65rem 0.3rem; font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.nav__item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.5rem 0.65rem; border-radius: 8px;
  color: var(--text-muted); text-decoration: none; font-size: 14px; font-weight: 500;
  border: none; background: none; width: 100%; text-align: left; cursor: pointer; font-family: inherit;
}
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item { position: relative; }
.nav__item[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav__item[aria-current="page"]::before {
  content: ""; position: absolute; left: -0.75rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav__item svg { width: 18px; height: 18px; flex: none; }

.sidebar__foot { border-top: 1px solid var(--border); padding-top: 0.6rem; }
.theme-toggle {
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
  padding: 0.5rem 0.65rem; border-radius: 8px; border: none; background: none; cursor: pointer;
  color: var(--text-muted); font: inherit; font-size: 14px;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle__icon { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; background: linear-gradient(90deg, currentColor 50%, transparent 50%); flex: none; }

.shell { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1.5rem; min-height: 60px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { font-size: 17px; }
.topbar__spacer { flex: 1; }
.topbar__menu { display: none; }

.view { padding: 1.5rem; flex: 1; outline: none; }
.view__inner { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.25rem; }

.sidebar-backdrop { position: fixed; inset: 0; background: rgba(6, 9, 15, 0.5); z-index: 35; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  #root[data-sidebar="open"] .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .shell { margin-left: 0; }
  .topbar__menu { display: grid; }
  .view { padding: 1rem; }
}

/* --- Usuario no topo ----------------------------------------------------- */

.user-chip { display: flex; align-items: center; gap: 0.6rem; }
.user-chip__info { display: flex; flex-direction: column; line-height: 1.25; text-align: right; }
.user-chip__name { font-size: 13px; font-weight: 600; }
.user-chip__role { font-size: 12px; color: var(--text-muted); }
@media (max-width: 560px) { .user-chip__info { display: none; } }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; object-fit: cover;
  background: var(--surface-3); display: grid; place-items: center;
  font-size: 13px; font-weight: 650; color: var(--text-muted);
  border: 1px solid var(--border);
}
.avatar--lg { width: 64px; height: 64px; font-size: 22px; }
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }

/* --- Cartoes ------------------------------------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
}
.card__head {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.card__title { font-size: 15px; }
.card__desc { font-size: 13px; color: var(--text-muted); margin: 0.15rem 0 0; }
.card__body { padding: 1.25rem; }
.card__body--flush { padding: 0; }
.card__foot { padding: 0.9rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.page-head__text h2 { font-size: 20px; }
.page-head__text p { color: var(--text-muted); font-size: 14px; margin: 0.2rem 0 0; }

/* --- Estatisticas -------------------------------------------------------- */

.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat { padding: 1.1rem 1.25rem; }
.stat__label { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); }
.stat__value { font-size: 30px; font-weight: 640; letter-spacing: -0.035em; margin-top: 0.3rem; }
.stat__hint { font-size: 12.5px; color: var(--text-muted); margin-top: 0.15rem; }

/* --- Botoes -------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.5rem 0.9rem; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 550; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { opacity: 0.88; background: var(--danger); }
.btn--ghost { border-color: transparent; background: none; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--sm { padding: 0.32rem 0.6rem; font-size: 13px; }
.btn--block { width: 100%; }
.btn--google { background: var(--surface); color: var(--text); font-weight: 600; padding: 0.65rem 1rem; }
.btn--google svg { width: 18px; height: 18px; stroke: none; }

.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 8px; border: 1px solid transparent; background: none;
  color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* --- Formularios --------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; }
.field__label { font-size: 13px; font-weight: 600; }
.field__hint { font-size: 12.5px; color: var(--text-muted); }
.input, .select, .textarea {
  width: 100%; padding: 0.55rem 0.7rem; font: inherit; font-size: 14px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px;
}
.input:focus, .select:focus, .textarea:focus,
.btn:focus-visible, .nav__item:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
.input::placeholder { color: var(--text-faint); }

.code-input {
  font-family: var(--mono); font-size: 26px; letter-spacing: 0.4em;
  text-align: center; padding: 0.7rem 0.5rem 0.7rem 0.9rem;
}

.toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.toolbar .input, .toolbar .select { width: auto; min-width: 180px; }

/* --- Selecao multipla (menu suspenso) ------------------------------------- */

.mselect { position: relative; }
.mselect--empty {
  padding: 0.55rem 0.7rem; border: 1px dashed var(--border-strong);
  border-radius: 8px; color: var(--text-faint); font-size: 13.5px;
}

.mselect__trigger {
  display: flex; align-items: center; gap: 0.5rem; width: 100%; min-height: 40px;
  padding: 0.4rem 0.6rem 0.4rem 0.7rem; font: inherit; font-size: 14px;
  color: var(--text); background: var(--surface); text-align: left; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 8px;
}
.mselect__trigger:hover { border-color: var(--text-faint); }
.mselect__trigger:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.mselect[data-open="true"] .mselect__trigger { border-color: var(--primary); }

.mselect__value { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; flex: 1; min-width: 0; }
.mselect__value--empty { color: var(--text-faint); }

.mselect__chevron { width: 16px; height: 16px; flex: none; color: var(--text-muted); transition: transform 0.15s ease; }
.mselect[data-open="true"] .mselect__chevron { transform: rotate(180deg); }

.mselect__panel {
  margin-top: 0.35rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-md);
  overflow: hidden;
}
.mselect__search { border: none; border-bottom: 1px solid var(--border); border-radius: 0; }
.mselect__search:focus { outline: none; border-bottom-color: var(--primary); }

.mselect__list { max-height: 240px; overflow-y: auto; padding: 0.25rem; }

.mselect__option {
  display: flex; align-items: flex-start; gap: 0.6rem;
  padding: 0.5rem 0.6rem; border-radius: 8px; cursor: pointer;
}
.mselect__option:hover { background: var(--surface-2); }
.mselect__option input { margin-top: 0.15rem; flex: none; }
.mselect__option-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; flex: 1; }
.mselect__option-name { font-size: 14px; font-weight: 550; }
.mselect__option-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.4; }
.mselect__option:has(input:checked) { background: var(--primary-soft); }
.mselect__option:has(input:checked) .mselect__option-name { color: var(--primary); }

.mselect__noresult { padding: 1rem 0.6rem; text-align: center; color: var(--text-faint); font-size: 13px; }

/* --- Tabelas ------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 12px; font-weight: 650; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-faint);
  padding: 0.65rem 1.25rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.cell-user { display: flex; align-items: center; gap: 0.6rem; }
.cell-user__name { font-weight: 550; }
.cell-user__email { font-size: 12.5px; color: var(--text-muted); }
.cell-actions { display: flex; gap: 0.35rem; justify-content: flex-end; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* --- Distintivos --------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.12rem 0.5rem; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-muted);
}
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--primary { background: var(--primary-soft); color: var(--primary); }
.badge--info { background: var(--info-soft); color: var(--primary); }
.badge-list { display: flex; gap: 0.3rem; flex-wrap: wrap; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* --- Estados ------------------------------------------------------------- */

.empty { padding: 3rem 1.5rem; text-align: center; color: var(--text-muted); }
.empty__title { font-weight: 600; color: var(--text); margin-bottom: 0.2rem; }
.skeleton { height: 14px; border-radius: 6px; background: var(--surface-3); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.alert {
  display: flex; gap: 0.6rem; padding: 0.75rem 0.9rem; border-radius: var(--radius);
  font-size: 13.5px; border: 1px solid transparent; margin-bottom: 1rem;
}
.alert--error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert--warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert--info { background: var(--info-soft); color: var(--text); border-color: var(--border); }
.alert--success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }

/* --- Autenticacao -------------------------------------------------------- */

.auth-card { width: 100%; max-width: 420px; padding: 2rem; text-align: center; }
.auth-card .brand__mark { width: 44px; height: 44px; font-size: 20px; margin: 0 auto 1rem; }
.auth-card h2 { font-size: 21px; }
.auth-card > p { color: var(--text-muted); font-size: 14px; margin-top: 0.4rem; }
.auth-card form { margin-top: 1.5rem; text-align: left; }
.auth-foot { margin-top: 1.5rem; font-size: 12.5px; color: var(--text-faint); }

.qr {
  width: 200px; height: 200px; margin: 0 auto; padding: 10px;
  background: #fff; border-radius: 12px; border: 1px solid var(--border);
}
.qr svg { width: 100%; height: 100%; stroke: none; }

.secret-box {
  font-family: var(--mono); font-size: 13.5px; letter-spacing: 0.08em; word-break: break-all;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem 0.75rem; text-align: center;
}

.recovery-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.45rem;
  font-family: var(--mono); font-size: 13.5px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.85rem;
}
.recovery-grid span { text-align: center; }
.recovery-grid span.used { text-decoration: line-through; opacity: 0.45; }

.steps { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; justify-content: center; }
.step { width: 30px; height: 3px; border-radius: 2px; background: var(--border-strong); }
.step[data-on="1"] { background: var(--primary); }

/* --- Matriz de permissoes ------------------------------------------------ */

.matrix th.matrix__role { text-align: center; }

/* Grupos recolhiveis por categoria dentro da matriz */
.matrix__group td { background: var(--surface-2); }
.matrix__group td:first-child { padding: 0; }
.matrix__rootbox { accent-color: var(--primary); }
.matrix__toggle {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  padding: 0.6rem 1.25rem; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 650; color: var(--text); text-align: left;
}
.matrix__toggle:hover { background: var(--surface-3); }
.matrix__toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.matrix__chevron {
  width: 16px; height: 16px; flex: none; color: var(--text-muted);
  transition: transform 0.15s ease;
}
.matrix__toggle[aria-expanded="true"] .matrix__chevron { transform: rotate(90deg); }
.matrix td.matrix__cell { text-align: center; }
.matrix tbody td:first-child { min-width: 240px; }
.perm__name { font-weight: 550; }
.perm__key { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.5; }

/* --- Modal --------------------------------------------------------------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(6, 9, 15, 0.55); padding: 1rem; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 560px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); margin: auto;
}
.modal--wide { max-width: 760px; }
.modal__head { display: flex; align-items: flex-start; gap: 0.75rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal__title { font-size: 16px; }
.modal__desc { font-size: 13px; color: var(--text-muted); margin: 0.15rem 0 0; }
.modal__body { padding: 1.25rem; max-height: min(65vh, 640px); overflow-y: auto; }
.modal__foot { display: flex; gap: 0.6rem; justify-content: flex-end; padding: 1rem 1.25rem; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* --- Avisos flutuantes --------------------------------------------------- */

.toasts { position: fixed; bottom: 1rem; right: 1rem; z-index: 90; display: flex; flex-direction: column; gap: 0.5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast {
  display: flex; gap: 0.6rem; align-items: flex-start;
  padding: 0.7rem 0.9rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); font-size: 13.5px;
  animation: toast-in 0.18s ease-out;
}
.toast--error { border-left: 3px solid var(--danger); }
.toast--success { border-left: 3px solid var(--success); }
.toast--info { border-left: 3px solid var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* --- Utilitarios --------------------------------------------------------- */

.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.pagination { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
