/* =========================================================
   FILE: public/css/app-base.css
   Base visual global obligatoria del sistema.

   Este archivo contiene únicamente la estructura visual
   común y estable de app-base.

   Debe incluir:
   - tokens base
   - reset
   - layout general
   - header global
   - navegación principal y dropdowns globales
   - menú de usuario
   - footer
   - estructura común de página
   - cards
   - alertas
   - botones y acciones compactas
   - tablas base
   - formularios base
   - pantallas públicas
   - selector de empresa
   - breadcrumb
   - responsive global

   No debe incluir:
   - estilos específicos de módulos
   - calendario de appointments
   - patrones reutilizables avanzados de show/index
   - summaries, tabs internas o visuales analíticas
   ========================================================= */

/* =========================================================
   1. Tokens base
   Colores, espaciados, radios y sombras reutilizables.

   Esta sección define la paleta y las medidas base del
   sistema. Debe concentrar variables transversales que
   puedan utilizarse en cualquier módulo o pantalla.
   ========================================================= */

:root {
    --color-bg: #f5f7fb;
    --color-surface: #ffffff;
    --color-surface-muted: #f8fafc;
    --color-surface-glass: rgba(255, 255, 255, 0.82);
    --color-surface-glass-muted: rgba(255, 255, 255, 0.72);
    --color-surface-glass-strong: rgba(255, 255, 255, 0.98);
    --color-surface-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.94));
    --color-surface-gradient-soft: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(248, 250, 252, 0.96));
    --color-border: #d9e1ec;
    --color-border-soft: rgba(217, 225, 236, 0.86);
    --color-border-muted: rgba(148, 163, 184, 0.28);
    --color-text: #1f2937;
    --color-muted: #6b7280;
    --color-text-muted: #6b7280;
    --color-text-muted-strong: #64748b;
    --color-text-subtle: #9ca3af;
    --color-text-inverse: #ffffff;

    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-subtle: rgba(37, 99, 235, 0.06);
    --color-primary-soft: rgba(37, 99, 235, 0.12);
    --color-primary-subtle-strong: rgba(37, 99, 235, 0.1);
    --color-primary-surface-soft: rgba(37, 99, 235, 0.08);
    --color-primary-border-muted: rgba(37, 99, 235, 0.18);
    --color-primary-border-subtle: rgba(37, 99, 235, 0.14);
    --color-primary-border-soft: rgba(37, 99, 235, 0.22);
    --color-primary-strong: #1d4ed8;
    --focus-ring-primary: rgba(37, 99, 235, 0.28);

    --color-secondary: #e5e7eb;
    --color-secondary-hover: #d1d5db;

    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;

    --color-success: #166534;
    --color-success-hover: #14532d;

    --color-success-bg: #ecfdf3;
    --color-success-border: #a7f3d0;
    --color-success-text: #065f46;

    --color-error-bg: #fef2f2;
    --color-error-border: #fecaca;
    --color-error-text: #991b1b;
    --color-invalid-bg: #fffaf5;
    --color-invalid-border: #f2c7a5;
    --color-invalid-border-focus: #e8b07d;

    --color-warning-soft: #fef3c7;
    --color-warning-text: #92400e;

    --color-info-soft: #dbeafe;
    --color-info-text: #1d4ed8;

    --color-done-soft: #dcfce7;
    --color-done-text: #166534;

    --color-cancelled-soft: #e5e7eb;
    --color-cancelled-text: #4b5563;

    --color-purple-soft: #ede9fe;
    --color-purple-text: #6d28d9;

    --color-danger-soft: #fee2e2;
    --color-danger-strong: #b91c1c;

    --chart-pending: #f59e0b;
    --chart-in-progress: var(--color-primary);
    --chart-done: #16a34a;
    --chart-cancelled: var(--color-muted);

    --role-owner: #e55353;
    --role-admin: var(--chart-pending);
    --role-sales: #22c55e;
    --role-operator: #3b82f6;
    --role-administrator: #eab308;

    --color-track: #e5e7eb;
    --color-surface-hover: #f9fafb;
    --color-action-muted-hover: rgba(15, 23, 42, 0.06);
    --color-overlay-backdrop: rgba(0, 0, 0, 0.45);
    --color-scrollbar-thumb: rgba(148, 163, 184, 0.45);
    --color-scrollbar-thumb-strong: rgba(148, 163, 184, 0.55);
    --color-table-row-hover-wash: rgba(37, 99, 235, 0.035);
    --color-muted-action-hover: rgba(107, 114, 128, 0.12);
    --color-tooltip-surface: #111827;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 20px rgba(15, 23, 42, 0.055);
    --shadow-dropdown: 0 10px 30px rgba(15, 23, 42, 0.1);
    --shadow-header: 0 1px 2px rgba(15, 23, 42, 0.035);
    --shadow-hover-soft: 0 8px 22px rgba(15, 23, 42, 0.055);
    --shadow-primary-soft: 0 1px 2px rgba(37, 99, 235, 0.06);
    --shadow-primary-sm: 0 1px 2px rgba(37, 99, 235, 0.12);
    --shadow-primary-xs: 0 1px 2px rgba(37, 99, 235, 0.08);
    --shadow-primary-md: 0 8px 20px rgba(37, 99, 235, 0.16);
    --shadow-success-sm: 0 1px 2px rgba(22, 101, 52, 0.12);
    --shadow-success-md: 0 8px 20px rgba(22, 101, 52, 0.16);
    --shadow-danger-sm: 0 1px 2px rgba(220, 38, 38, 0.12);
    --shadow-danger-md: 0 8px 20px rgba(220, 38, 38, 0.16);
    --shadow-focus-invalid: 0 0 0 2px rgba(232, 176, 125, 0.18);
    --shadow-horizontal-scroll-viewport:
        inset 0 2px 8px rgba(255, 255, 255, 0.16),
        inset 0 -2px 8px rgba(15, 23, 42, 0.05);
    --shadow-tooltip: 0 10px 24px rgba(15, 23, 42, 0.18);

    --radius: 8px;
    --radius-md: 8px;
    --radius-pill: 999px;

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

/* =========================================================
   2. Reset y base
   Normalización mínima del documento.

   Esta sección resuelve comportamiento global del navegador
   y define la base tipográfica y de lectura del sistema.
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    overflow: hidden;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* =========================================================
   3. Layout general
   Estructura principal de la aplicación.

   Esta sección define el contenedor global y el reparto
   vertical de header, contenido y footer. También controla
   el scroll principal de la aplicación.
   ========================================================= */

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.app-shell {
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.app-main {
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-5) 0;
}

.app-main>.container {
    min-height: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-main>.container>.page:last-child {
    margin-bottom: var(--space-6);
}

/* =========================================================
   4. Header global
   Barra superior principal del sistema.
   ========================================================= */

.app-header {
    background: var(--color-surface-gradient);
    border-bottom: 1px solid var(--color-border-soft);
    box-shadow: var(--shadow-header);
}

.app-header-inner {
    min-height: 64px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-4);
}

.app-brand {
    min-width: 0;
    display: flex;
    align-items: center;
}

.app-brand-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--color-text);
    text-decoration: none;
    line-height: 1;
}

.app-brand-link:hover {
    text-decoration: none;
}

.app-brand__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    flex: 0 0 auto;
}

.app-brand__icon svg {
    display: block;
    width: 28px;
    height: 28px;
    overflow: visible;
}

.app-brand__icon .app-logo-active {
    transform-box: fill-box;
    transform-origin: center;
    transition:
        transform 180ms ease,
        filter 180ms ease,
        opacity 180ms ease;
}

.app-brand-link:hover .app-logo-active,
.app-brand-link:focus-visible .app-logo-active {
    transform: translateY(-0.5px) scale(1.03);
}

.app-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    flex-wrap: nowrap;
}

.app-company {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
}

.app-company-label {
    font-size: 0.72rem;
    color: var(--color-muted);
}

.app-company-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text);
}

/* =========================================================
   5. Navegación principal
   Links y agrupaciones de navegación global.
   ========================================================= */

.app-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.app-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 38px;
    padding: 0.48rem 0.7rem;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--color-text);
    text-decoration: none;
    white-space: nowrap;
    font-size: 0.92rem;
    line-height: 1.1;
    transition:
        background-color 150ms ease,
        border-color 150ms ease,
        color 150ms ease,
        box-shadow 150ms ease,
        transform 150ms ease;
}

.app-nav-link:hover {
    background: var(--color-primary-subtle);
    border-color: var(--color-primary-subtle-strong);
    color: var(--color-primary);
    text-decoration: none;
    transform: translateY(-1px);
}

.app-nav-link.is-active {
    background: var(--color-primary-subtle-strong);
    border-color: var(--color-primary-border-subtle);
    color: var(--color-primary);
    font-weight: 700;
    box-shadow: var(--shadow-primary-soft);
}

.app-nav-link__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.05rem;
    height: 1.05rem;
    color: currentColor;
    opacity: 0.82;
    flex: 0 0 auto;
}

.app-nav-link__icon svg {
    display: block;
    width: 1.05rem;
    height: 1.05rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-nav-link.is-active .app-nav-link__icon,
.app-nav-link:hover .app-nav-link__icon {
    opacity: 1;
}

.app-nav-dropdown {
    position: relative;
}

.app-nav-dropdown summary {
    list-style: none;
    cursor: pointer;
}

.app-nav-dropdown summary::-webkit-details-marker {
    display: none;
}

.app-nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.55rem);
    left: 0;
    min-width: 210px;
    background: var(--color-surface-glass-strong);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--shadow-dropdown);
    padding: 0.4rem;
    display: none;
    z-index: 100;
}

.app-nav-dropdown[open] .app-nav-dropdown-menu {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.app-nav-dropdown-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 38px;
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    color: var(--color-text);
    text-decoration: none;
    white-space: nowrap;
    font-size: 0.92rem;
    transition:
        background-color 150ms ease,
        color 150ms ease;
}

.app-nav-dropdown-link:hover {
    background: var(--color-bg);
    color: var(--color-primary);
    text-decoration: none;
}

.app-nav-dropdown-link.is-active {
    background: var(--color-primary-subtle-strong);
    color: var(--color-primary);
    font-weight: 700;
}

/* =========================================================
   6. Menú de usuario
   Dropdown de acciones del usuario autenticado.
   ========================================================= */

.app-user-dropdown {
    position: relative;
}

.app-user-dropdown summary {
    list-style: none;
    cursor: pointer;
}

.app-user-dropdown summary::-webkit-details-marker {
    display: none;
}

.app-user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 42px;
    padding: 0.42rem 0.75rem 0.42rem 0.52rem;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-surface-glass);
    color: var(--color-text);
    transition:
        background-color 150ms ease,
        border-color 150ms ease,
        box-shadow 150ms ease;
}

.app-user-trigger:hover {
    background: var(--color-surface);
    border-color: var(--color-primary-border-muted);
    box-shadow: var(--shadow-hover-soft);
}

.app-user-trigger-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 999px;
    background: var(--color-primary-surface-soft);
    color: var(--color-primary);
    flex: 0 0 auto;
}

.app-user-trigger-icon svg {
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-user-trigger-text {
    display: flex;
    flex-direction: column;
    line-height: 1.12;
    text-align: left;
}

.app-user-trigger-label {
    font-size: 0.68rem;
    color: var(--color-muted);
}

.app-user-trigger-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--color-text);
}

.app-user-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.55rem);
    right: 0;
    min-width: 230px;
    background: var(--color-surface-glass-strong);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--shadow-dropdown);
    padding: 0.4rem;
    display: none;
    z-index: 100;
}

.app-user-dropdown[open] .app-user-dropdown-menu {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.app-user-dropdown-link,
.app-user-dropdown-button {
    display: block;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--color-text);
    text-align: left;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
}

.app-user-dropdown-link:hover,
.app-user-dropdown-button:hover {
    background: var(--color-bg);
    color: var(--color-primary);
    text-decoration: none;
}

.app-user-dropdown-link.is-active {
    background: var(--color-primary-subtle-strong);
    color: var(--color-primary);
    font-weight: 700;
}

.app-user-dropdown-divider {
    height: 1px;
    margin: 0.25rem 0;
    background: var(--color-border);
}

/* =========================================================
   7. Footer global
   Pie de aplicación común a todas las pantallas internas.
   ========================================================= */

.app-footer {
    border-top: 1px solid var(--color-border-soft);
    background: var(--color-surface-gradient-soft);
}

.app-footer-inner {
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 0 var(--space-4);
}

.app-footer-main {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.app-footer-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    color: var(--color-muted);
    opacity: 0.78;
}

.app-footer-mark svg {
    display: block;
    width: 1rem;
    height: 1rem;
}

.app-footer-brand {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--color-text-muted-strong);
    letter-spacing: -0.01em;
}

.app-footer-version {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0.18rem 0.55rem;
    border: 1px solid var(--color-border-muted);
    border-radius: 999px;
    background: var(--color-surface-glass-muted);
    color: var(--color-muted);
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.1;
}

/* =========================================================
   8. Estructura de página
   Esqueleto común para index, show, create y edit.

   Esta sección define la jerarquía visual base de una
   pantalla interna.
   ========================================================= */

.page {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
}

.page-header.vertical {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.page-title {
    margin: 0;
    font-size: 1.75rem;
    line-height: 1.2;
}

.page-subtitle {
    margin: var(--space-2) 0 0;
    color: var(--color-muted);
    font-size: 0.95rem;
}

.page-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    align-items: center;
}

.page-header.vertical .page-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.app-modal[hidden] {
    display: none !important;
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.app-modal__backdrop {
    position: absolute;
    inset: 0;
    background: var(--color-overlay-backdrop);
}

.app-modal__dialog {
    position: relative;
    width: min(100%, 640px);
    max-height: calc(100dvh - 2rem);
    overflow: auto;
    z-index: 1;
}

.app-modal__dialog--sm {
    max-width: 420px;
}

.app-modal__dialog--md {
    max-width: 640px;
}

.app-modal__dialog--lg {
    max-width: 860px;
}

.app-modal__dialog--xl {
    max-width: 1100px;
}

.app-modal__card {
    margin: 0;
}

.app-modal__body {
    max-height: calc(100dvh - 10rem);
    overflow: auto;
}

.app-modal__footer {
    margin-top: var(--space-4);
}

body.app-modal-open {
    overflow: hidden;
}

@media (max-width: 640px) {
    .app-modal {
        align-items: flex-end;
        padding: var(--space-2);
    }

    .app-modal__dialog {
        width: 100%;
        max-width: none;
        max-height: calc(100dvh - var(--space-4));
    }

    .app-modal__body {
        max-height: calc(100dvh - 9rem);
    }

    .app-modal__card .card-header {
        padding: var(--space-3) var(--space-4);
    }

    .app-modal__card .card-body {
        padding: var(--space-4);
    }

    .app-modal__card .card-toolbox {
        flex-shrink: 0;
    }
}

/* =========================================================
   9. Cards
   Bloques principales de contenido.

   Esta sección concentra el contenedor visual estándar del
   sistema.
   ========================================================= */

.card {
    min-width: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-body {
    padding: var(--space-5);
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
}

.card-header__main {
    flex: 1 1 auto;
    min-width: 0;
}

.card-toolbox {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.card-title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.2;
}

.card-subtitle {
    margin: 0.25rem 0 0;
    color: var(--color-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.card-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
}

.card-tool:hover {
    background: var(--color-surface-hover);
}

.card-tool .icon-expand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s ease;
}

.card-tool[aria-expanded="false"] .icon-expand {
    transform: rotate(-90deg);
}

.card-tool[aria-expanded="true"] .icon-expand {
    transform: rotate(0deg);
}

.card-header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

/* =========================================================
   10. Alertas
   Mensajes globales de éxito, error y validación.
   ========================================================= */

.alert {
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.alert-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
}

.alert-body {
    flex: 1;
    min-width: 0;
}

.alert-title {
    font-weight: 700;
    margin-bottom: var(--space-2);
}

.alert-list {
    margin: 0;
    padding-left: 1.25rem;
}

.alert-list li+li {
    margin-top: 0.2rem;
}

.alert-dismiss {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: -0.15rem -0.15rem 0 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.72;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

.alert-dismiss:hover {
    background: var(--color-action-muted-hover);
    opacity: 1;
}

.alert-dismiss:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    opacity: 1;
}

.alert.is-closing {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.alert-success {
    background: var(--color-success-bg);
    border-color: var(--color-success-border);
    color: var(--color-success-text);
}

.alert-error {
    background: var(--color-error-bg);
    border-color: var(--color-error-border);
    color: var(--color-error-text);
}

/* =========================================================
   11. Botones y acciones compactas
   Acciones visibles principales y acciones breves.
   ========================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.42rem;
    min-height: 2.35rem;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 0.58rem 0.92rem;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.15;
    font-family: inherit;
    white-space: nowrap;
    transition:
        background-color 150ms ease,
        border-color 150ms ease,
        color 150ms ease,
        box-shadow 150ms ease,
        transform 150ms ease;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.btn svg {
    display: inline-block;
    width: 0.95rem;
    height: 0.95rem;
    flex: 0 0 auto;
}

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-text-inverse);
    box-shadow: var(--shadow-primary-sm);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    box-shadow: var(--shadow-primary-md);
}

.btn-secondary {
    background: var(--color-surface-glass);
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover {
    background: var(--color-surface);
    border-color: var(--color-primary-border-soft);
    color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--color-success);
    border-color: var(--color-success);
    color: var(--color-text-inverse);
    box-shadow: var(--shadow-success-sm);
}

.btn-success:hover {
    background: var(--color-success-hover);
    border-color: var(--color-success-hover);
    box-shadow: var(--shadow-success-md);
}

.btn-danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: var(--color-text-inverse);
    box-shadow: var(--shadow-danger-sm);
}

.btn-danger:hover {
    background: var(--color-danger-hover);
    border-color: var(--color-danger-hover);
    box-shadow: var(--shadow-danger-md);
}

.btn-link {
    min-height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-primary);
    font-weight: 700;
    box-shadow: none;
}

.btn-link:hover {
    transform: none;
    box-shadow: none;
}

.btn.disabled,
.btn[aria-disabled="true"] {
    opacity: 0.6;
    pointer-events: none;
}

.compact-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.compact-actions-cell {
    text-align: right;
    white-space: nowrap;
}

.btn-icon {
    width: 2.25rem;
    min-width: 2.25rem;
    height: 2.25rem;
    min-height: 2.25rem;
    padding: 0;
    border-radius: 999px;
}

.btn-icon svg {
    width: 0.95rem;
    height: 0.95rem;
}

.btn-sm {
    min-height: 2.1rem;
    padding: 0.45rem 0.72rem;
    font-size: 0.86rem;
}

.btn-tool {
    min-height: 1.85rem;
    min-width: 1.85rem;
    padding: 0.28rem;
}

.btn-tool svg {
    width: 0.88rem;
    height: 0.88rem;
}

/* =========================================================
   12. Tablas
   Base tabular reutilizable del sistema.

   Esta sección define estructura, lectura, alineación y
   comportamiento base de tablas.
   ========================================================= */

.table-wrap {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
}

.table th,
.table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: top;
}

.table th {
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: 0.9rem;
    color: var(--color-muted);
    font-weight: 700;
    background: var(--color-surface-muted);
}

.table tbody tr {
    transition: background 0.15s ease;
}

.table tbody tr:hover {
    background: var(--color-surface-muted);
}

.table tr:last-child td {
    border-bottom: 0;
}

/* =========================================================
   13. Formularios base
   Campos y grupos reutilizables del sistema.

   Esta sección define inputs, labels, ayudas, errores y
   acciones de formularios comunes.
   ========================================================= */

.form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-label {
    font-weight: 600;
}

.form-control {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    line-height: 1.2;
    box-sizing: border-box;
}

select.form-control {
    height: 2.75rem;
    padding-right: 2.25rem;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

.form-help {
    color: var(--color-muted);
    font-size: 0.875rem;
}

.form-help.is-error {
    color: var(--color-error-text);
}

.form-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    padding-top: var(--space-2);
}

.form-checkbox {
    width: auto;
    min-height: auto;
}

.form-control.is-invalid {
    border-color: var(--color-invalid-border);
    background: var(--color-invalid-bg);
}

.form-control.is-invalid:focus {
    outline: none;
    border-color: var(--color-invalid-border-focus);
    box-shadow: var(--shadow-focus-invalid);
}

.inline-form {
    display: inline;
}

/* =========================================================
   14. Pantallas públicas y acceso
   Layout para welcome, login, register e invitaciones.
   ========================================================= */

.welcome-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.public-panel {
    width: 100%;
    max-width: 520px;
}

.public-panel--sm {
    max-width: 400px;
}

.public-panel--md {
    max-width: 520px;
}

.public-panel--lg {
    max-width: 560px;
}

.public-text {
    margin: 0;
}

.public-text+.public-text {
    margin-top: var(--space-2);
}

.public-actions {
    margin-top: var(--space-3);
}

/* =========================================================
   15. Selector de empresa
   Selección inicial de tenant o empresa activa.
   ========================================================= */

.tenant-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.tenant-option {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 0.9rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.tenant-option:hover {
    border-color: var(--color-primary);
    background: var(--color-surface-hover);
}

.tenant-option-name {
    font-weight: 600;
}

.tenant-option-meta {
    color: var(--color-muted);
    font-size: 0.9rem;
}

/* =========================================================
   16. Breadcrumb
   Navegación contextual base.

   Esta sección define el patrón visual de breadcrumb del
   sistema.
   ========================================================= */

.breadcrumb {
    margin-bottom: var(--space-2);
}

.breadcrumb-list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-muted);
    font-size: 0.9rem;
}

.breadcrumb-item:not(:last-child)::after {
    content: "/";
    color: var(--color-muted);
}

.breadcrumb-link {
    color: var(--color-muted);
    text-decoration: none;
}

.breadcrumb-link:hover {
    color: var(--color-primary);
    text-decoration: none;
}

.breadcrumb-current {
    color: var(--color-text);
    font-weight: 600;
}

/* =========================================================
   17. Responsive global
   Ajustes transversales de layout y componentes base.

   Esta sección concentra adaptaciones mobile y tablet de
   elementos globales del sistema.
   ========================================================= */

@media (max-width: 900px) {
    .app-header-inner {
        grid-template-columns: 1fr;
        justify-items: start;
        padding: var(--space-3) 0;
    }

    .app-nav {
        justify-content: flex-start;
    }

    .app-header-actions {
        justify-content: flex-start;
    }

    .app-company {
        align-items: flex-start;
    }
}
