/* ==========================================================================
   Sistema de Facturación y Cobranzas — Corporate Modern / Financial SaaS
   Construido sobre tokens.css. Ver docs/DESIGN_SYSTEM.md.
   ========================================================================== */

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-body);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbars follow the active theme too — token-driven (not a fixed
   gray), so this needs no separate dark-mode block: the var(--color-*)
   values already flip under tokens.css's [data-theme="dark"] /
   prefers-color-scheme rules. scrollbar-color covers Firefox; the
   ::-webkit-scrollbar-* pseudo-elements cover Chromium/WebKit. The
   universal selector applies this to every scrolling box in the app
   (page, sidebar, table-wrap, modal bodies, select/date popups), not
   just the page scrollbar. */
* {
    scrollbar-color: var(--color-border-strong) var(--color-bg);
    scrollbar-width: thin;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background-color: var(--color-border-strong);
    border-radius: var(--radius-full);
    border: 2px solid var(--color-bg);
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-text-tertiary);
}

/* The sidebar sits on navy regardless of theme, so its scrollbar (only
   visible if the nav ever overflows a very short viewport) uses a
   translucent-white thumb instead of the light-surface-oriented tokens
   above, matching the other on-navy translucent borders/backgrounds
   already used throughout .sidebar. */
.sidebar {
    scrollbar-color: rgba(248, 250, 252, 0.25) transparent;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(248, 250, 252, 0.25);
    border-color: var(--color-navy);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(248, 250, 252, 0.4);
}

h1, h2, h3, h4 {
    font-family: var(--font-sans);
    color: var(--color-text);
    margin: 0;
}

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

a:hover {
    color: var(--color-blue-hover);
    text-decoration: underline;
}

/* Visible focus ring on every interactive element — never removed without
   a replacement (WCAG). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--color-blue);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--color-navy);
    color: #fff;
    padding: var(--space-2) var(--space-4);
    border-radius: 0 0 var(--radius-sm) 0;
    z-index: 2000;
}

.skip-link:focus {
    left: 0;
}

/* ---------- Type scale utilities ---------- */

.text-h1 { font-size: var(--text-h1); font-weight: 700; letter-spacing: -0.02em; }
.text-h2 { font-size: var(--text-h2); font-weight: 700; letter-spacing: -0.01em; }
.text-h3 { font-size: var(--text-h3); font-weight: 600; }
.text-label { font-size: var(--text-label); font-weight: 500; color: var(--color-text-secondary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-mono-money { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ==========================================================================
   App shell / layout
   ========================================================================== */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-navy);
    color: var(--color-text-on-navy);
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-base), transform var(--transition-base);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-4);
    border-bottom: 1px solid rgba(248, 250, 252, 0.1);
    min-height: var(--topbar-height);
    flex-shrink: 0;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(155deg, var(--color-blue) 0%, var(--color-navy) 65%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.brand-mark .icon { color: #fff; }

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 200px;
    overflow: hidden;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-base), max-width var(--transition-base);
}

.sidebar-brand-text strong {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.sidebar-brand-text span {
    font-size: 0.72rem;
    color: var(--color-text-on-navy-muted);
    line-height: 1.2;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-4) var(--space-3);
    gap: var(--space-1);
    flex: 1;
}

.sidebar-nav .nav-link {
    color: rgba(248, 250, 252, 0.72);
    padding: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    position: relative;
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav .nav-link .icon {
    flex-shrink: 0;
}

.sidebar-nav .nav-link span {
    opacity: 1;
    max-width: 200px;
    transition: opacity var(--transition-base), max-width var(--transition-base);
}

.sidebar-nav .nav-link:hover {
    background: rgba(248, 250, 252, 0.08);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav .nav-link.active {
    background: rgba(37, 99, 235, 0.22);
    color: #fff;
    font-weight: 600;
}

.sidebar-nav .nav-link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: var(--radius-full);
    background: var(--color-teal);
    transition: left var(--transition-base);
}

.sidebar-nav .nav-link.active .icon {
    color: var(--color-teal);
}

.sidebar-collapse-toggle {
    margin-top: auto;
    border-top: 1px solid rgba(248, 250, 252, 0.1);
    padding: var(--space-3);
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

.sidebar-collapse-toggle button {
    background: transparent;
    border: none;
    color: rgba(248, 250, 252, 0.6);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-collapse-toggle button:hover {
    background: rgba(248, 250, 252, 0.08);
    color: #fff;
}

.sidebar-collapse-toggle .icon-collapse {
    transition: transform var(--transition-base);
}

/* Collapsed state (desktop only, toggled via JS with a body/shell class).
   The nav-link's own justify-content/padding stay constant on purpose —
   those properties can't be interpolated, so changing them on collapse
   made the icon visibly jump; only opacity/max-width (both animatable)
   change here, which the sidebar's own width transition already smooths
   out. The collapse-toggle button itself (and its icon) is never touched
   by this rule, so it can't disappear when the sidebar collapses. */
html.sidebar-collapsed .app-shell .sidebar {
    width: var(--sidebar-width-collapsed);
}

html.sidebar-collapsed .app-shell .sidebar-brand-text,
html.sidebar-collapsed .app-shell .sidebar-nav .nav-link span {
    opacity: 0;
    max-width: 0;
}

html.sidebar-collapsed .app-shell .sidebar-nav .nav-link.active::before {
    left: 0;
}

html.sidebar-collapsed .app-shell .sidebar-collapse-toggle .icon-collapse {
    transform: rotate(180deg);
}

html.sidebar-collapsed .app-shell .app-main {
    margin-left: var(--sidebar-width-collapsed);
}

/* Tooltip shown on hover when collapsed (title attribute fallback covers
   no-JS/keyboard access; this is the visual affordance on top of it) */
html.sidebar-collapsed .app-shell .sidebar-nav .nav-link {
    position: relative;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left var(--transition-base);
}

.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 var(--space-6);
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-breadcrumb {
    font-size: var(--text-body);
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1;
    min-width: 0;
}

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

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--color-bg);
    border-color: var(--color-border-strong);
    color: var(--color-text);
}

.theme-toggle .icon-moon {
    display: flex;
}

.theme-toggle .icon-sun {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
    display: flex;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-moon {
        display: none;
    }

    :root:not([data-theme="light"]) .theme-toggle .icon-sun {
        display: flex;
    }
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
    background: var(--color-surface);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.topbar-user:hover {
    border-color: var(--color-border-strong);
    background: var(--color-bg);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--color-blue-subtle);
    color: var(--color-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.avatar-photo {
    object-fit: cover;
    border: 1px solid var(--color-border);
}

.topbar-user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    text-align: left;
}

.topbar-user-meta strong {
    font-size: 0.82rem;
    color: var(--color-text);
}

.topbar-user-meta span {
    font-size: 0.72rem;
    color: var(--color-text-secondary);
}

.content {
    padding: var(--space-6);
    flex: 1;
    animation: page-fade-in var(--transition-base) both;
}

@keyframes page-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: var(--text-h2);
    font-weight: 700;
    color: var(--color-text);
}

.page-header p {
    color: var(--color-text-secondary);
    margin-top: var(--space-1);
    font-size: var(--text-body);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
    line-height: 1.4;
    white-space: nowrap;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled,
.btn.is-loading {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: 0.8125rem;
}

.btn-primary {
    background: var(--color-navy);
    border-color: var(--color-navy);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-navy-hover);
    border-color: var(--color-navy-hover);
    color: #fff;
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--color-text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #B91C1C;
    border-color: #B91C1C;
}

.btn-link {
    background: transparent;
    border-color: transparent;
    color: var(--color-blue);
    font-weight: 500;
    padding: var(--space-1) var(--space-2);
}

.btn-link:hover:not(:disabled) {
    text-decoration: underline;
}

.btn .spinner {
    display: none;
}

.btn.is-loading .spinner {
    display: inline-flex;
}

.btn.is-loading .btn-label-idle {
    display: none;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn-secondary .spinner,
.btn-ghost .spinner {
    border-color: rgba(15, 23, 42, 0.2);
    border-top-color: var(--color-text);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Forms
   ========================================================================== */

.field {
    margin-bottom: var(--space-4);
}

.field-label {
    display: block;
    font-size: var(--text-label);
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: var(--space-2);
}

.field-label .required {
    color: var(--color-danger);
}

.field-help {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin-top: var(--space-1);
}

.field-error {
    font-size: var(--text-xs);
    color: var(--color-danger);
    margin-top: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.form-control,
.form-select {
    width: 100%;
    font-family: var(--font-sans);
    font-size: var(--text-body);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control::placeholder {
    color: var(--color-text-tertiary);
}

.form-control[readonly] {
    background: var(--color-bg);
    color: var(--color-text-secondary);
    cursor: not-allowed;
}

.form-control:focus,
.form-select:focus {
    background: var(--color-surface);
    color: var(--color-text);
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px var(--color-blue-subtle);
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--color-danger);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px var(--color-danger-subtle);
}

.form-control:disabled {
    background: var(--color-bg);
    color: var(--color-text-tertiary);
    cursor: not-allowed;
}

.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.form-check-input {
    width: 18px;
    height: 18px;
    accent-color: var(--color-navy);
}

.input-money {
    position: relative;
}

.input-money .currency-prefix {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    pointer-events: none;
}

.input-money input {
    padding-left: calc(var(--space-3) * 2 + 22px);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: calc(var(--space-3) * 2 + 18px);
}

.password-toggle {
    position: absolute;
    right: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-1);
    background: none;
    border: none;
    color: var(--color-text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    line-height: 0;
}

.password-toggle:hover {
    color: var(--color-text-secondary);
}

.password-toggle .icon-hide {
    display: none;
}

.password-toggle.is-visible .icon-show {
    display: none;
}

.password-toggle.is-visible .icon-hide {
    display: flex;
}

/* ==========================================================================
   Custom select — progressively enhances every <select class="form-select">
   (app.js) into a styled trigger + listbox. The native <select> stays in the
   DOM (visually hidden) so form submission and any onchange="" wiring on
   filter selects keep working unmodified.
   ========================================================================== */

.select-field {
    position: relative;
}

.select-field .form-select.is-enhanced {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

.select-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    font-family: var(--font-sans);
    font-size: var(--text-body);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.select-trigger-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.select-trigger .icon {
    flex-shrink: 0;
    color: var(--color-text-tertiary);
    transition: transform var(--transition-fast);
}

.select-field.is-open .select-trigger .icon {
    transform: rotate(180deg);
}

.select-trigger:focus-visible,
.select-field.is-open .select-trigger {
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px var(--color-blue-subtle);
}

.select-trigger:disabled {
    background: var(--color-bg);
    color: var(--color-text-tertiary);
    cursor: not-allowed;
}

.select-popup {
    /* position: fixed, positioned via JS (positionFixedPopup() in app.js)
       rather than CSS top/left relative to .select-field — this is what
       lets the popup escape a scrolling ancestor (e.g. the form modal's
       .modal-form-body) instead of being clipped by its overflow. top/
       left/right/bottom below are placeholder-only; JS always overrides
       them at open time. Kept off-screen by default so a closed popup
       (still opacity:0, not display:none, so its own open/close
       transition can animate) never has stray fixed-position geometry
       that could contribute to the viewport's own scrollable area. */
    position: fixed;
    top: -9999px;
    left: -9999px;
    max-height: 260px;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: var(--space-1);
    margin: 0;
    list-style: none;
    z-index: 1950;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.select-popup.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    font-size: var(--text-body);
    color: var(--color-text);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.select-option .icon {
    flex-shrink: 0;
    color: var(--color-blue);
    opacity: 0;
}

.select-option.is-selected {
    color: var(--color-navy);
    font-weight: 600;
}

.select-option.is-selected .icon {
    opacity: 1;
}

.select-option.is-active {
    background: var(--color-bg);
}

/* ==========================================================================
   Custom date/month picker — progressively enhances input[type="date"] and
   input[type="month"] (app.js). Same pattern as the custom select: the
   native input stays in the DOM to hold the real ISO value.
   ========================================================================== */

.datepicker-field {
    position: relative;
}

.datepicker-field input[type="date"].is-enhanced,
.datepicker-field input[type="month"].is-enhanced {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

.datepicker-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    font-family: var(--font-sans);
    font-size: var(--text-body);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.datepicker-trigger-label.is-placeholder {
    color: var(--color-text-tertiary);
}

.datepicker-trigger .icon {
    flex-shrink: 0;
    color: var(--color-text-tertiary);
}

.datepicker-trigger:focus-visible,
.datepicker-field.is-open .datepicker-trigger {
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px var(--color-blue-subtle);
}

.datepicker-popup {
    /* position: fixed, positioned via JS — see the comment on .select-popup
       above, same reasoning (and the same portal-to-<body> handling in
       app.js, since a transformed ancestor like .modal-panel would
       otherwise still hijack position:fixed's containing block). */
    position: fixed;
    top: -9999px;
    left: -9999px;
    width: 272px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--space-3);
    z-index: 1950;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.datepicker-popup.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

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

.datepicker-title {
    font-size: var(--text-label);
    font-weight: 600;
    color: var(--color-text);
    text-transform: capitalize;
}

.datepicker-nav {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.datepicker-nav:hover {
    background: var(--color-bg);
    color: var(--color-navy);
}

.datepicker-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text-tertiary);
    margin-bottom: var(--space-1);
}

.datepicker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.datepicker-day {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.datepicker-day:hover,
.datepicker-day.is-active {
    background: var(--color-bg);
}

.datepicker-day.is-outside {
    color: var(--color-text-tertiary);
}

.datepicker-day.is-today {
    box-shadow: inset 0 0 0 1px var(--color-blue);
}

.datepicker-day.is-selected {
    background: var(--color-navy);
    color: var(--color-text-on-navy);
}

.datepicker-months-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
}

.datepicker-month-cell {
    padding: var(--space-3) var(--space-2);
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: var(--text-body);
    color: var(--color-text);
    cursor: pointer;
    text-transform: capitalize;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.datepicker-month-cell:hover,
.datepicker-month-cell.is-active {
    background: var(--color-bg);
}

.datepicker-month-cell.is-selected {
    background: var(--color-navy);
    color: var(--color-text-on-navy);
}

/* ==========================================================================
   Surfaces / cards
   ========================================================================== */

.card-surface {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.kpi-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.kpi-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-border-strong);
}

.kpi-card.is-critical {
    border-color: rgba(220, 38, 38, 0.35);
    background: linear-gradient(180deg, var(--color-danger-subtle) 0%, var(--color-surface) 42%);
}

.kpi-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-blue-subtle);
    color: var(--color-blue);
    flex-shrink: 0;
}

.kpi-icon.icon-teal { background: var(--color-teal-subtle); color: var(--color-teal); }
.kpi-icon.icon-navy { background: rgba(15, 39, 71, 0.08); color: var(--color-navy); }
.kpi-icon.icon-danger { background: var(--color-danger-subtle); color: var(--color-danger); }

.kpi-label {
    color: var(--color-text-secondary);
    font-size: var(--text-label);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.kpi-card.is-critical .kpi-value {
    color: var(--color-danger);
}

.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-xs);
    font-weight: 600;
}

.kpi-trend.is-up { color: var(--color-success); }
.kpi-trend.is-down { color: var(--color-danger); }
.kpi-trend-context { color: var(--color-text-tertiary); font-weight: 400; }

.chart-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
    height: 100%;
}

.chart-card h2 {
    font-size: var(--text-h3);
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.chart-legend {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-top: var(--space-4);
    font-size: var(--text-xs);
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text-secondary);
}

.chart-legend .dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
}

.table-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-body);
}

.data-table thead th {
    text-align: left;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    padding: var(--space-3) var(--space-3);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.data-table thead th.is-numeric,
.data-table td.is-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table tbody td {
    padding: var(--space-3) var(--space-3);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--color-bg);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr.row-danger {
    background: var(--color-danger-subtle);
}

.data-table tbody tr.row-danger:hover {
    background: var(--color-danger-subtle);
    filter: brightness(0.97);
}

.data-table .cell-money {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.data-table .cell-primary {
    font-weight: 600;
    color: var(--color-text);
}

.data-table .cell-muted {
    color: var(--color-text-secondary);
}

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

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

.filter-bar .form-control,
.filter-bar .form-select {
    width: auto;
}

.search-input {
    position: relative;
}

.search-input .icon {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-tertiary);
    pointer-events: none;
}

.search-input input {
    padding-left: calc(var(--space-3) * 2 + 18px);
    min-width: 260px;
}

.table-pagination-meta {
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
}

.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
}

.pagination {
    display: flex;
    gap: var(--space-1);
    list-style: none;
    margin: 0;
    padding: 0;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    font-weight: 500;
    background: var(--color-surface);
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.page-link:hover {
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
}

.page-item.active .page-link {
    background: var(--color-navy);
    border-color: var(--color-navy);
    color: #fff;
}

.page-item.disabled .page-link {
    color: var(--color-text-tertiary);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0.2rem var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-status-PENDIENTE { background: var(--color-info-subtle); color: var(--color-info); }
.badge-status-PARCIAL { background: var(--color-warning-subtle); color: #92620A; }
.badge-status-PAGADA { background: var(--color-success-subtle); color: var(--color-success); }
.badge-status-VENCIDA { background: var(--color-danger-subtle); color: var(--color-danger); }

.badge-neutral { background: var(--color-bg); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.badge-success { background: var(--color-success-subtle); color: var(--color-success); }
.badge-danger { background: var(--color-danger-subtle); color: var(--color-danger); }
.badge-info { background: var(--color-blue-subtle); color: var(--color-blue); }

/* ==========================================================================
   Empty / error states
   ========================================================================== */

.empty-state,
.error-state {
    text-align: center;
    padding: var(--space-12) var(--space-4);
    color: var(--color-text-secondary);
}

.empty-state .state-icon,
.error-state .state-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-4);
    color: var(--color-text-tertiary);
}

.error-state .state-icon {
    background: var(--color-danger-subtle);
    color: var(--color-danger);
}

.empty-state h3,
.error-state h3 {
    font-size: var(--text-h3);
    color: var(--color-text);
    margin-bottom: var(--space-1);
}

.empty-state p,
.error-state p {
    font-size: var(--text-body);
    max-width: 360px;
    margin: 0 auto var(--space-4);
}

/* ==========================================================================
   Modal (confirmation dialogs — replaces window.confirm())
   ========================================================================== */

.modal-backdrop-custom {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1900;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-modal);
}

.modal-backdrop-custom.is-open {
    opacity: 1;
    pointer-events: auto;
}

.modal-dialog-custom {
    position: fixed;
    inset: 0;
    z-index: 1901;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    pointer-events: none;
}

/* The confirmation dialog can be triggered from inside an already-open
   form modal (e.g. "¿Generar facturas?" over the invoice wizard) — it
   must always stack above it. Both share .modal-backdrop-custom/
   .modal-dialog-custom, so without this override they'd tie at the same
   z-index and DOM order (form modal markup comes after confirm modal
   markup in the layout) would silently paint the form modal on top,
   leaving the confirm dialog open but invisible underneath it. */
#confirmModalBackdrop {
    z-index: 1950;
}

#confirmModalDialog {
    z-index: 1951;
}

.modal-panel {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-width: 440px;
    width: 100%;
    padding: var(--space-6);
    opacity: 0;
    transform: scale(0.96) translateY(4px);
    transition: opacity var(--transition-modal), transform var(--transition-modal);
    pointer-events: none;
}

.modal-backdrop-custom.is-open + .modal-dialog-custom .modal-panel,
.modal-dialog-custom.is-open .modal-panel {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
}

.modal-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--color-warning-subtle);
    color: var(--color-warning);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
}

.modal-icon.is-danger { background: var(--color-danger-subtle); color: var(--color-danger); }

.modal-panel h3 {
    font-size: var(--text-h3);
    margin-bottom: var(--space-2);
}

.modal-panel p {
    color: var(--color-text-secondary);
    font-size: var(--text-body);
    margin-bottom: var(--space-5);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* ==========================================================================
   Form modal — overlays small create/edit forms on top of their list page
   instead of navigating to a dedicated screen (app.js: openFormModal()).
   Reuses .modal-backdrop-custom / .modal-dialog-custom, with a wider,
   left-aligned panel variant.
   ========================================================================== */

.modal-panel-form {
    text-align: left;
    max-width: 520px;
    padding: 0;
}

.modal-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--color-border);
}

.modal-form-header h3 {
    margin: 0;
    font-size: var(--text-h3);
}

.modal-form-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-form-close:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.modal-form-body {
    padding: var(--space-6);
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}

.modal-form-body .field:last-of-type {
    margin-bottom: 0;
}

.modal-form-body form > .d-flex:last-child {
    margin-top: var(--space-6);
}

.modal-form-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) 0;
    color: var(--color-text-secondary);
}

.spinner-lg {
    width: 24px;
    height: 24px;
    border-width: 3px;
    border-color: var(--color-border-strong);
    border-top-color: var(--color-navy);
}

.select-field:has(.form-select.is-invalid) .select-trigger,
.datepicker-field:has(input.is-invalid) .datepicker-trigger {
    border-color: var(--color-danger);
}

.select-field:has(.form-select.is-invalid) .select-trigger:focus-visible,
.datepicker-field:has(input.is-invalid) .datepicker-trigger:focus-visible {
    box-shadow: 0 0 0 3px var(--color-danger-subtle);
}

/* ==========================================================================
   Toasts
   ========================================================================== */

.toast-stack {
    position: fixed;
    top: calc(var(--topbar-height) + var(--space-4));
    right: var(--space-5);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 360px;
}

.toast-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-info);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    animation: toast-in var(--transition-base) both;
}

.toast-item.is-leaving {
    animation: toast-out var(--transition-fast) both;
}

.toast-item.toast-success { border-left-color: var(--color-success); }
.toast-item.toast-warning { border-left-color: var(--color-warning); }
.toast-item.toast-danger { border-left-color: var(--color-danger); }

.toast-item .icon-wrap {
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-success .icon-wrap { color: var(--color-success); }
.toast-warning .icon-wrap { color: var(--color-warning); }
.toast-danger .icon-wrap { color: var(--color-danger); }
.toast-info .icon-wrap { color: var(--color-info); }

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

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-text);
}

.toast-message {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.toast-close {
    background: none;
    border: none;
    color: var(--color-text-tertiary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(16px); }
}

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs {
    display: flex;
    gap: var(--space-1);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-6);
}

.tab-link {
    padding: var(--space-3) var(--space-4);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

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

.tab-link.is-active {
    color: var(--color-navy);
    border-bottom-color: var(--color-navy);
    font-weight: 600;
}

/* ==========================================================================
   Wizard / stepper (invoice generation)
   ========================================================================== */

.wizard-steps {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-6);
    list-style: none;
    padding: 0;
}

.wizard-steps li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text-tertiary);
    font-size: var(--text-xs);
    font-weight: 600;
}

.wizard-steps li .step-dot {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--color-surface);
    transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.wizard-steps li.is-active .step-dot {
    border-color: var(--color-navy);
    background: var(--color-navy);
    color: #fff;
}

.wizard-steps li.is-done .step-dot {
    border-color: var(--color-success);
    background: var(--color-success);
    color: #fff;
}

.wizard-steps li.is-active,
.wizard-steps li.is-done {
    color: var(--color-text);
}

.wizard-steps .step-connector {
    flex: 1;
    height: 2px;
    background: var(--color-border);
    margin: 0 var(--space-2);
}

.wizard-panel {
    display: none;
    animation: page-fade-in var(--transition-base) both;
}

.wizard-panel.is-active {
    display: block;
}

.wizard-summary-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}

.wizard-summary-row:last-child {
    border-bottom: none;
}

.wizard-summary-row dt {
    color: var(--color-text-secondary);
}

.wizard-summary-row dd {
    margin: 0;
    font-weight: 600;
    color: var(--color-text);
}

/* ==========================================================================
   Progress (batch invoice generation feedback)
   ========================================================================== */

.progress-track {
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--color-border);
    overflow: hidden;
}

.progress-track .progress-fill {
    height: 100%;
    background: var(--color-blue);
    border-radius: var(--radius-full);
    animation: progress-indeterminate 1.2s ease-in-out infinite;
    width: 40%;
}

@keyframes progress-indeterminate {
    0% { margin-left: -40%; }
    100% { margin-left: 100%; }
}

/* ==========================================================================
   Guest layout (login / password reset)
   ========================================================================== */

.guest-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.guest-branding {
    background: linear-gradient(160deg, var(--color-navy) 0%, #0B1D38 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-16);
    position: relative;
    overflow: hidden;
    animation: guest-fade-left 450ms ease-out both;
}

.guest-branding::before {
    content: "";
    position: absolute;
    width: 480px;
    height: 480px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.25) 0%, transparent 70%);
    top: -120px;
    right: -160px;
}

.guest-branding::after {
    content: "";
    position: absolute;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(20, 184, 166, 0.18) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
}

.guest-branding-content {
    position: relative;
    z-index: 1;
    max-width: 420px;
}

.guest-branding .brand-mark {
    width: 52px;
    height: 52px;
    margin-bottom: var(--space-6);
}

.guest-branding h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: var(--space-2);
}

.guest-branding p {
    color: var(--color-text-on-navy-muted);
    font-size: var(--text-body-lg);
    line-height: 1.6;
}

.guest-branding-features {
    margin-top: var(--space-10);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.guest-branding-features .feature {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: rgba(248, 250, 252, 0.85);
    font-size: 0.875rem;
}

.guest-branding-features .feature .icon-wrap {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-teal);
}

.guest-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    background: var(--color-bg);
    animation: guest-fade-up 500ms ease-out both;
    animation-delay: 80ms;
}

.guest-form-card {
    width: 100%;
    max-width: 380px;
}

.guest-form-card .form-title {
    font-size: var(--text-h2);
    font-weight: 700;
    margin-bottom: var(--space-1);
}

.guest-form-card .form-subtitle {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-6);
    font-size: var(--text-body);
}

@keyframes guest-fade-left {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes guest-fade-up {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Misc: dropdown menu restyle (used with bootstrap.bundle popper)
   ========================================================================== */

.dropdown-menu {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: var(--space-2);
    font-size: 0.875rem;
    animation: dropdown-in var(--transition-fast) both;
}

@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Notification bell (topbar)
   ========================================================================== */

.notification-bell {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.notification-panel {
    width: 380px;
    max-width: calc(100vw - 32px);
    padding: 0;
    overflow: hidden;
}

.notification-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.notification-panel-header strong {
    font-size: 0.9375rem;
}

.notification-mark-all {
    background: none;
    border: none;
    color: var(--color-blue);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.notification-mark-all:hover {
    text-decoration: underline;
}

.notification-tabs {
    display: flex;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
}

.notification-tab {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    padding: var(--space-1) var(--space-2);
    color: var(--color-text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.notification-tab span {
    color: var(--color-text-tertiary);
    font-weight: 500;
}

.notification-tab:hover {
    background: var(--color-bg);
}

.notification-tab.is-active {
    background: var(--color-bg);
    color: var(--color-text);
}

.notification-list {
    max-height: 360px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    text-decoration: none;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.notification-dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    margin-top: 6px;
    border-radius: 999px;
    background: var(--color-warning);
}

.notification-dot.is-read {
    background: transparent;
}

.notification-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.8125rem;
    min-width: 0;
}

.notification-body strong {
    font-size: 0.8125rem;
    font-weight: 600;
}

.notification-message {
    color: var(--color-text-secondary);
}

.notification-time {
    color: var(--color-text-tertiary);
    font-size: 0.75rem;
}

.notification-empty {
    padding: var(--space-6) var(--space-4);
    text-align: center;
    color: var(--color-text-tertiary);
    font-size: 0.8125rem;
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text);
}

.dropdown-item:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.dropdown-item-text {
    padding: var(--space-2) var(--space-3);
}

.dropdown-divider {
    border-color: var(--color-border);
    margin: var(--space-2) 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: var(--shadow-md);
    }

    .app-main,
    html.sidebar-collapsed .app-shell .app-main {
        margin-left: 0;
    }

    .sidebar-collapse-toggle {
        display: none;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .search-input input {
        min-width: 0;
        width: 100%;
    }

    .guest-shell {
        grid-template-columns: 1fr;
    }

    .guest-branding {
        display: none;
    }

    .guest-form-side {
        padding: var(--space-4);
    }
}

@media (max-width: 575.98px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: var(--space-4);
    }

    .topbar {
        padding: 0 var(--space-4);
    }

    .topbar-user-meta {
        display: none;
    }

    .wizard-steps li span.step-label {
        display: none;
    }

    .wizard-steps li.is-active span.step-label {
        display: inline;
        white-space: nowrap;
    }

    .wizard-steps .step-connector {
        margin: 0 var(--space-1);
    }
}
