/* ==========================================================================
   GENERARAPP — UNIFIED DESIGN SYSTEM
   Inspiracion: Emil Kowalski (Sonner / Vaul / Linear)
   - Paleta neutral (zinc/slate) con un solo accent
   - Bordes suaves, sombras sutiles, animaciones spring
   - Tipografia Inter con tracking ajustado
   ========================================================================== */

:root {
    /* === Surface / Neutrals === */
    --bg:             #fafafa;
    --bg-elevated:    #ffffff;
    --bg-subtle:      #f4f4f5;
    --bg-muted:       #f4f4f5;

    /* === Text === */
    --text:           #09090b;
    --text-muted:     #71717a;
    --text-subtle:    #a1a1aa;
    --text-inverse:   #fafafa;

    /* === Borders === */
    --border:         #e4e4e7;
    --border-strong:  #d4d4d8;
    --border-subtle:  #f4f4f5;

    /* === Accent (a single blue) === */
    --accent:         #2563eb;
    --accent-hover:   #1d4ed8;
    --accent-soft:    #eff6ff;
    --accent-ring:    rgba(37, 99, 235, 0.12);

    /* === Semantic === */
    --success:        #10b981;
    --success-soft:   #ecfdf5;
    --warning:        #f59e0b;
    --warning-soft:   #fffbeb;
    --danger:         #ef4444;
    --danger-soft:    #fef2f2;
    --info:           #3b82f6;
    --info-soft:      #eff6ff;

    /* === Radius === */
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 16px;
    --r-2xl: 20px;
    --r-full: 9999px;

    /* === Shadows === */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* === Motion === */
    --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
    --ease-inout: cubic-bezier(0.4, 0, 0.2, 1);
    --d-fast:     120ms;
    --d-med:      200ms;
    --d-slow:     320ms;

    /* === Type === */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;
}

/* =========================================================================
   RESET
   ========================================================================= */

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

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01';
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

h1 { font-size: 1.75rem; letter-spacing: -0.03em; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

p { margin: 0; }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--d-fast) var(--ease-out);
}

a:hover { color: var(--accent-hover); }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.875em;
}

/* =========================================================================
   LAYOUT — App Shell
   ========================================================================= */

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.app-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.01em;
}

.brand:hover { color: var(--text); }

.brand__mark {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: linear-gradient(135deg, #18181b 0%, #3f3f46 100%);
    display: grid;
    place-items: center;
    color: white;
    font-size: 0.95rem;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.app-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--r-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: all var(--d-fast) var(--ease-out);
}

.app-nav__link i {
    font-size: 1.05rem;
    opacity: 0.85;
}

.app-nav__link:hover {
    background: var(--bg-subtle);
    color: var(--text);
}

.app-nav__link.is-active {
    background: var(--bg-subtle);
    color: var(--text);
    font-weight: 600;
}

.app-header__user,
.app-header__right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-nav__link--muted { color: var(--text-subtle); }
.app-nav__link--muted:hover { color: var(--danger); background: var(--danger-soft); }

.app-main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.app-main--wide { max-width: none; padding-left: 32px; padding-right: 32px; }
.app-main--narrow { max-width: 720px; }

/* =========================================================================
   PAGE HEADER
   ========================================================================= */

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.page-header__titles h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.page-header__subtitle {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.page-header__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =========================================================================
   CARDS
   ========================================================================= */

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.card--hover {
    transition: all var(--d-med) var(--ease-out);
}

.card--hover:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.card__header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card__title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card__subtitle {
    font-size: 0.825rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.card__body {
    padding: 24px;
}

.card__footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.card--padded { padding: 24px; }

/* =========================================================================
   BUTTONS
   ========================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: -0.005em;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition:
        background-color var(--d-fast) var(--ease-out),
        border-color var(--d-fast) var(--ease-out),
        color var(--d-fast) var(--ease-out),
        box-shadow var(--d-fast) var(--ease-out),
        transform var(--d-fast) var(--ease-out);
    text-decoration: none;
}

.btn:disabled,
.btn[aria-disabled='true'] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn i {
    font-size: 1rem;
    line-height: 1;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.btn-primary {
    background: #18181b;
    color: white;
    border-color: #18181b;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), var(--shadow-xs);
}

.btn-primary:hover {
    background: #27272a;
    border-color: #27272a;
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), var(--shadow-sm);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border);
    box-shadow: var(--shadow-xs);
}

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

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

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

.btn-accent {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: var(--shadow-xs);
}

.btn-accent:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--bg-elevated);
    color: var(--danger);
    border-color: var(--border);
}

.btn-danger:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
}

.btn-danger-solid {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger-solid:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-sm {
    height: 30px;
    padding: 6px 10px;
    font-size: 0.8125rem;
}

.btn-lg {
    height: 44px;
    padding: 10px 20px;
    font-size: 0.9375rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn-icon.btn-sm { width: 30px; height: 30px; }

/* =========================================================================
   FORMS
   ========================================================================= */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 0;
}

.field-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
    letter-spacing: -0.005em;
}

.field-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.field-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.input,
.textarea,
.select {
    width: 100%;
    padding: 8px 12px;
    height: 36px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text);
    box-shadow: var(--shadow-xs);
    transition:
        border-color var(--d-fast) var(--ease-out),
        box-shadow var(--d-fast) var(--ease-out);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--text-subtle);
}

.input:hover,
.textarea:hover,
.select:hover {
    border-color: var(--border-strong);
}

.input:focus,
.textarea:focus,
.select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.textarea {
    height: auto;
    min-height: 88px;
    padding-top: 10px;
    padding-bottom: 10px;
    resize: vertical;
    line-height: 1.5;
}

.select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

/* Input with leading/trailing icon */
.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group .input {
    padding-left: 38px;
    padding-right: 12px;
}

.input-group--trailing .input {
    padding-right: 38px;
}

.input-group__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
    font-size: 1.05rem;
    pointer-events: none;
    transition: color var(--d-fast) var(--ease-out);
}

.input-group__action {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 0;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    color: var(--text-subtle);
    cursor: pointer;
    border-radius: var(--r-sm);
    transition: color var(--d-fast) var(--ease-out), background var(--d-fast) var(--ease-out);
}

.input-group__action:hover {
    color: var(--text);
    background: var(--bg-subtle);
}

.input-group .input:focus ~ .input-group__icon {
    color: var(--accent);
}

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

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

.field-row--3 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 640px) {
    .field-row,
    .field-row--2,
    .field-row--3 { grid-template-columns: 1fr; }
}

/* Switch */
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.switch-row__text { display: flex; flex-direction: column; gap: 2px; }
.switch-row__label { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.switch-row__hint  { font-size: 0.75rem; color: var(--text-muted); }

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    flex: none;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch__slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border-strong);
    border-radius: var(--r-full);
    transition: background-color var(--d-fast) var(--ease-out);
}

.switch__slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    top: 2px;
    background: white;
    border-radius: var(--r-full);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    transition: transform var(--d-med) var(--ease-out);
}

.switch input:checked + .switch__slider { background: #18181b; }
.switch input:checked + .switch__slider::before { transform: translateX(16px); }

/* Checkbox */
.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    cursor: pointer;
    user-select: none;
    transition: background-color var(--d-fast) var(--ease-out);
}

.check-row:hover { background: var(--bg-subtle); }

.check-row input[type='checkbox'] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    flex: none;
    transition: all var(--d-fast) var(--ease-out);
}

.check-row input[type='checkbox']:checked {
    background: #18181b;
    border-color: #18181b;
}

.check-row input[type='checkbox']:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* File input / Dropzone */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--r-lg);
    background: var(--bg-subtle);
    text-align: center;
    cursor: pointer;
    transition: all var(--d-med) var(--ease-out);
}

.dropzone:hover {
    background: var(--bg-muted);
    border-color: var(--text-subtle);
}

.dropzone__icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: var(--r-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    margin-bottom: 12px;
    font-size: 1.25rem;
}

.dropzone__title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.dropzone__hint {
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =========================================================================
   TABLES
   ========================================================================= */

.table-wrap {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

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

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 14px 16px;
    font-size: 0.875rem;
    color: var(--text);
    border-bottom: 1px solid var(--border-subtle);
}

.table tbody tr {
    transition: background-color var(--d-fast) var(--ease-out);
}

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

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

/* =========================================================================
   BADGES / PILLS
   ========================================================================= */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
    border-radius: var(--r-full);
    border: 1px solid transparent;
}

.badge--success { background: var(--success-soft); color: #047857; border-color: rgba(16, 185, 129, 0.2); }
.badge--warning { background: var(--warning-soft); color: #b45309; border-color: rgba(245, 158, 11, 0.25); }
.badge--danger  { background: var(--danger-soft);  color: #b91c1c; border-color: rgba(239, 68, 68, 0.2); }
.badge--info    { background: var(--info-soft);    color: #1d4ed8; border-color: rgba(37, 99, 235, 0.2); }
.badge--muted   { background: var(--bg-subtle);    color: var(--text-muted); border-color: var(--border); }
.badge--dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: var(--r-full);
    background: currentColor;
}

/* =========================================================================
   AVATAR
   ========================================================================= */

.avatar {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--r-full);
    background: linear-gradient(135deg, #27272a 0%, #52525b 100%);
    color: white;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    flex: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.avatar--sm { width: 24px; height: 24px; font-size: 0.7rem; }
.avatar--lg { width: 40px; height: 40px; font-size: 0.95rem; }
.avatar--xl { width: 56px; height: 56px; font-size: 1.2rem; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    border-radius: var(--r-full);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    transition: all var(--d-fast) var(--ease-out);
}

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

.user-chip__body { display: flex; flex-direction: column; }
.user-chip__name { font-size: 0.8125rem; font-weight: 500; line-height: 1.1; }
.user-chip__meta { font-size: 0.7rem; color: var(--text-muted); line-height: 1.1; margin-top: 2px; }

/* =========================================================================
   STAT CARDS
   ========================================================================= */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.stat {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    transition: all var(--d-med) var(--ease-out);
}

.stat:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.stat__label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat__label i { font-size: 0.9rem; opacity: 0.8; }

.stat__value {
    margin-top: 8px;
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text);
    line-height: 1.1;
}

.stat__meta {
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* =========================================================================
   FLASH / ALERTS
   ========================================================================= */

.flash-stack {
    max-width: 1200px;
    margin: 16px auto 0;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--text);
    box-shadow: var(--shadow-xs);
}

.flash i { font-size: 1.1rem; flex: none; margin-top: 1px; }
.flash--success { background: var(--success-soft); border-color: rgba(16, 185, 129, 0.25); color: #065f46; }
.flash--error   { background: var(--danger-soft);  border-color: rgba(239, 68, 68, 0.25);  color: #991b1b; }
.flash--warning { background: var(--warning-soft); border-color: rgba(245, 158, 11, 0.3);  color: #92400e; }
.flash--info    { background: var(--info-soft);    border-color: rgba(37, 99, 235, 0.2);   color: #1e3a8a; }

/* =========================================================================
   TOAST (opcional, mismo estilo que admin panel)
   ========================================================================= */

.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    min-width: 280px;
    max-width: 380px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    color: var(--text);
    pointer-events: auto;
    animation: toastIn var(--d-med) var(--ease-out);
}

.toast i { font-size: 1.1rem; flex: none; }
.toast-success i { color: var(--success); }
.toast-error i   { color: var(--danger); }
.toast-warning i { color: var(--warning); }
.toast-info i    { color: var(--info); }

.toast.removing { animation: toastOut 220ms var(--ease-inout) forwards; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateY(-6px) scale(0.98); }
}

/* =========================================================================
   MODAL
   ========================================================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: grid;
    place-items: center;
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--d-med) var(--ease-out);
}

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

.modal {
    width: 92%;
    max-width: 480px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    transform: translateY(8px) scale(0.98);
    transition: transform var(--d-slow) var(--ease-out);
}

.modal-overlay.is-open .modal {
    transform: translateY(0) scale(1);
}

.modal__header {
    padding: 20px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal__title { font-size: 1.05rem; font-weight: 600; }

.modal__close {
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all var(--d-fast) var(--ease-out);
}

.modal__close:hover {
    background: var(--bg-subtle);
    color: var(--text);
}

.modal__body { padding: 16px 24px 20px; }

.modal__footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* =========================================================================
   TABS (horizontales)
   ========================================================================= */

.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
}

.tab {
    padding: 10px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: all var(--d-fast) var(--ease-out);
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

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

/* =========================================================================
   EMPTY STATE
   ========================================================================= */

.empty {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
}

.empty__icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: var(--r-lg);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--text-subtle);
    font-size: 1.75rem;
    margin: 0 auto 16px;
}

.empty__title {
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.empty__desc { font-size: 0.875rem; }

.empty__actions { margin-top: 16px; }

/* =========================================================================
   PROGRESS BAR
   ========================================================================= */

.progress {
    width: 100%;
    height: 6px;
    background: var(--bg-muted);
    border-radius: var(--r-full);
    overflow: hidden;
}

.progress__bar {
    height: 100%;
    background: #18181b;
    border-radius: var(--r-full);
    transition: width 400ms var(--ease-out);
}

.progress--accent .progress__bar { background: var(--accent); }

/* =========================================================================
   SPINNER / LOADER
   ========================================================================= */

.spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    border-top-color: var(--text);
    animation: spin 720ms linear infinite;
    display: inline-block;
    vertical-align: -3px;
}

.spinner-lg { width: 28px; height: 28px; border-width: 3px; }

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

/* =========================================================================
   KBD / CODE
   ========================================================================= */

kbd,
.kbd {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--text-muted);
    box-shadow: 0 1px 0 var(--border);
}

.code-inline {
    font-family: var(--font-mono);
    font-size: 0.8125em;
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--text);
}

/* =========================================================================
   AUTH LAYOUT (login / register)
   ========================================================================= */

.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1000px 500px at 10% -10%, rgba(59, 130, 246, 0.06), transparent 50%),
        radial-gradient(800px 400px at 110% 110%, rgba(168, 85, 247, 0.06), transparent 50%),
        var(--bg);
}

.auth__card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 32px;
    box-shadow: var(--shadow-lg);
}

.auth__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    margin-bottom: 20px;
}

.auth__title {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.auth__subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 24px;
}

.auth__form { display: flex; flex-direction: column; gap: 14px; }

.auth__divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-subtle);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.auth__divider::before,
.auth__divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth__footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.825rem;
    color: var(--text-muted);
    text-align: center;
}

.auth__footer a { font-weight: 500; }

/* =========================================================================
   UTILITIES
   ========================================================================= */

.stack    { display: flex; flex-direction: column; }
.stack-xs { gap: 4px; }
.stack-sm { gap: 8px; }
.stack-md { gap: 16px; }
.stack-lg { gap: 24px; }
.stack-xl { gap: 32px; }

.row      { display: flex; align-items: center; }
.row-sm   { gap: 8px; }
.row-md   { gap: 16px; }
.row-gap  { justify-content: space-between; }
.row-wrap { flex-wrap: wrap; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.text-muted  { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm     { font-size: 0.8125rem; }
.text-xs     { font-size: 0.75rem; }
.text-lg     { font-size: 1rem; }
.font-mono   { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }

.w-full { width: 100%; }
.hide   { display: none !important; }

@media (max-width: 640px) {
    .hide-on-mobile { display: none !important; }
}

.divider {
    border: 0;
    border-top: 1px solid var(--border-subtle);
    margin: 20px 0;
}

.fade-in { animation: fadeIn var(--d-slow) var(--ease-out); }

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

/* =========================================================================
   RESPONSIVE HEADER
   ========================================================================= */

@media (max-width: 768px) {
    .app-header__inner { padding: 0 16px; gap: 12px; }
    .app-nav { display: none; }
    .app-main { padding: 20px 16px 48px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .user-chip__meta { display: none; }
    .card__header { padding: 16px; }
    .card__body { padding: 16px; }
    .auth__card { padding: 24px; }
}

/* =========================================================================
   SCROLLBAR (webkit, subtle)
   ========================================================================= */

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--r-full);
    border: 3px solid var(--bg);
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* Selection */
::selection {
    background: rgba(37, 99, 235, 0.15);
    color: var(--text);
}
