/* ============================================================
   kzFacturador Design System
   ============================================================ */

/* --- Tokens / Variables --- */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --bg-hover: rgba(255,255,255,0.04);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border-color: #334155;
    --border-light: rgba(255,255,255,0.08);

    /* Semantic Colors */
    --color-success: #22c55e;
    --color-success-bg: rgba(34, 197, 94, 0.12);
    --color-warning: #f59e0b;
    --color-warning-bg: rgba(245, 158, 11, 0.12);
    --color-danger: #ef4444;
    --color-danger-bg: rgba(239, 68, 68, 0.12);
    --color-info: #3b82f6;
    --color-info-bg: rgba(59, 130, 246, 0.12);
    --color-primary: #6366f1;
    --color-primary-bg: rgba(99, 102, 241, 0.12);
    --color-accent: #8b5cf6;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.3);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Typography */
    --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Cascadia Code', 'JetBrains Mono', 'Fira Code', monospace;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Legacy vars (backward compat) */
    --bg-color: var(--bg-primary);
    --card-bg: var(--bg-card);
    --text-color: var(--text-primary);
    --primary-color: var(--color-primary);
    --primary-hover: #5558e6;
    --danger-color: var(--color-danger);
    --success-color: var(--color-success);
    --info-color: var(--color-info);
    --progress-bg: #1e293b;
    --table-stripe: rgba(255,255,255,0.02);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

/* --- Layout --- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 32px;
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
}

/* --- Grid System --- */
.grid { display: grid; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }

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

/* --- Navbar --- */
header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.header-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    height: 64px;
}

.brand-logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.02em;
}

.logo-icon {
    font-size: 1.4rem;
}

.main-nav {
    display: flex;
    gap: 2px;
}

.nav-link {
    color: var(--text-muted);
    font-weight: 500;
    padding: 0 20px;
    display: flex;
    align-items: center;
    border-bottom: 2px solid transparent;
    font-size: 0.875rem;
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

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

.nav-link.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 0 8px;
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: transform var(--transition-fast);
}

@media (max-width: 768px) {
    .header-container { padding: 0 16px; }
    .mobile-menu-btn { display: flex; }
    .main-nav {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        flex-direction: column;
        border-bottom: 1px solid var(--border-color);
        box-shadow: var(--shadow-lg);
    }
    .main-nav.open { display: flex; }
    .nav-link { padding: 14px 20px; border-bottom: none; border-left: 3px solid transparent; }
    .nav-link.active { border-left-color: var(--color-primary); border-bottom: none; }
}

/* ============================================================
   COMPONENTES BASE
   ============================================================ */

/* --- KPI Card --- */
.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    border-color: rgba(255,255,255,0.12);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.kpi-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.kpi-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.kpi-card-icon.success { background: var(--color-success-bg); color: var(--color-success); }
.kpi-card-icon.warning { background: var(--color-warning-bg); color: var(--color-warning); }
.kpi-card-icon.danger { background: var(--color-danger-bg); color: var(--color-danger); }
.kpi-card-icon.info { background: var(--color-info-bg); color: var(--color-info); }
.kpi-card-icon.primary { background: var(--color-primary-bg); color: var(--color-primary); }

.kpi-card-trend {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.kpi-card-trend.up { background: var(--color-success-bg); color: var(--color-success); }
.kpi-card-trend.down { background: var(--color-danger-bg); color: var(--color-danger); }
.kpi-card-trend.neutral { background: rgba(148, 163, 184, 0.12); color: var(--text-secondary); }

.kpi-card-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    margin-bottom: 4px;
}

.kpi-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-card-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* --- Progress Bar --- */
.progress-block {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    border: 1px solid var(--border-color);
}

.progress-block-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.progress-block-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-block-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.progress-track {
    height: 20px;
    background: var(--bg-primary);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08));
    border-radius: 10px;
}

.progress-fill.success { background: linear-gradient(90deg, #22c55e, #16a34a); }
.progress-fill.warning { background: linear-gradient(90deg, #f59e0b, #d97706); }
.progress-fill.danger { background: linear-gradient(90deg, #ef4444, #dc2626); }
.progress-fill.primary { background: linear-gradient(90deg, var(--color-primary), var(--color-accent)); }

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    flex-wrap: wrap;
    gap: 8px;
}

.progress-stat {
    color: var(--text-secondary);
}

.progress-stat strong {
    color: var(--text-primary);
    font-weight: 600;
}

.progress-stat.highlight {
    color: var(--color-warning);
}

.progress-stat.danger {
    color: var(--color-danger);
}

/* Threshold marker */
.progress-threshold {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-warning);
    z-index: 2;
    opacity: 0.7;
}

.progress-threshold::before {
    content: '⚠ Umbral';
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: var(--color-warning);
    white-space: nowrap;
    font-weight: 600;
}

/* === Bar Chart === */
.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-card-title {
    font-size: 1rem;
    font-weight: 600;
}

.chart-container {
    width: 100%;
    height: 280px;
    position: relative;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* === Alert Banner === */
.alert-banner {
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border: 1px solid transparent;
    animation: alertSlideIn 0.3s ease-out;
}

.alert-banner.success {
    background: var(--color-success-bg);
    border-color: rgba(34, 197, 94, 0.2);
    color: var(--color-success);
}

.alert-banner.warning {
    background: var(--color-warning-bg);
    border-color: rgba(245, 158, 11, 0.2);
    color: var(--color-warning);
}

.alert-banner.danger {
    background: var(--color-danger-bg);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--color-danger);
}

.alert-banner.info {
    background: var(--color-info-bg);
    border-color: rgba(59, 130, 246, 0.2);
    color: var(--color-info);
}

.alert-banner-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-banner-content {
    flex: 1;
}

.alert-banner-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.alert-banner-text {
    font-size: 0.85rem;
    opacity: 0.9;
}

.alert-banner-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.5;
    font-size: 1.1rem;
    transition: opacity var(--transition-fast);
    padding: 2px;
}

.alert-banner-close:hover {
    opacity: 1;
}

@keyframes alertSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Stat Card (comparativa) === */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
}

.stat-card:hover {
    border-color: rgba(255,255,255,0.1);
}

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-card-icon.success { background: var(--color-success-bg); color: var(--color-success); }
.stat-card-icon.warning { background: var(--color-warning-bg); color: var(--color-warning); }
.stat-card-icon.danger { background: var(--color-danger-bg); color: var(--color-danger); }
.stat-card-icon.info { background: var(--color-info-bg); color: var(--color-info); }

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

.stat-card-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}

.stat-card-main {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card-compare {
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.stat-card-compare.up { color: var(--color-success); }
.stat-card-compare.down { color: var(--color-danger); }
.stat-card-compare.neutral { color: var(--text-muted); }

/* === Period Selector === */
.period-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 3px;
    border: 1px solid var(--border-color);
}

.period-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
    opacity: 0.45;
}

.period-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    opacity: 1;
}

.period-btn.active {
    background: var(--color-primary);
    color: white;
    opacity: 1;
}

.period-btn.active.has-data::after {
    display: none;
}

.period-btn.has-data {
    color: var(--text-primary);
    opacity: 1;
    font-weight: 600;
}

.period-btn.has-data::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-success);
    margin-left: 4px;
    vertical-align: middle;
}

.period-year-select {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

/* === Filter Bar === */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
}

.filter-bar .filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-bar label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.filter-select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.filter-select:focus {
    border-color: var(--color-primary);
}

.filter-input {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    outline: none;
}

.filter-input:focus {
    border-color: var(--color-primary);
}

/* === Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.badge-info {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.badge-neutral {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-secondary);
}

/* === Tables === */
.table-container {
    overflow-x: auto;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

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

.table-container th {
    padding: 14px 16px;
    text-align: left;
    background: rgba(0,0,0,0.25);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    -webkit-user-select: none;
    user-select: none;
}

.table-container th.sortable {
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.table-container th.sortable:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.08);
}

.table-container th .sort-indicator {
    font-size: 0.65rem;
    margin-left: 4px;
    color: var(--color-primary);
}

.table-container td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.875rem;
    vertical-align: middle;
}

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

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

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

/* Highlight current row in tables */
tr.current-row td {
    background: var(--color-primary-bg);
}

tr.current-row td:first-child {
    border-left: 3px solid var(--color-primary);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state-text {
    font-size: 1rem;
    margin-bottom: 8px;
}

.empty-state-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* === Loading === */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.loading-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* === Dashboard Section === */
.dashboard-section {
    margin-bottom: 28px;
}

.section-header {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-header-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    text-align: center;
    line-height: 1.4;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5558e6;
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #16a34a;
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

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

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

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-dialog {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    animation: modalSlideUp 0.25s ease-out;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

/* === Detail Grid (for invoice detail, etc) === */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-item {
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.detail-item.full {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}

.detail-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

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

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast);
    outline: none;
}

.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

select.form-control {
    cursor: pointer;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

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

/* === Tabs === */
.tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-primary);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 18px;
    font-size: 0.85rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
}

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

.tab.active {
    background: var(--color-primary);
    color: white;
}

/* === Utility Classes === */
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.justify-content-end { justify-content: flex-end; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }

.m-0 { margin: 0 !important; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--color-success) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-primary { color: var(--color-primary) !important; }
.text-info { color: var(--color-info) !important; }
.text-white { color: white !important; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.15rem; }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.fw-medium { font-weight: 500; }

.w-full { width: 100%; }
.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mono font utility */
.font-mono {
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
}

/* Backward compatibility aliases */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
}

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

.mini-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

/* ================================
   Modal
   ================================ */
.custom-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    padding: 20px;
}

.custom-modal-content {
    background: var(--bg-card, #1e293b);
    border-radius: var(--radius-lg, 12px);
    border: 1px solid var(--border-color, #334155);
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.custom-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color, #334155);
    flex-shrink: 0;
}

.custom-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #f1f5f9);
}

.custom-modal-close {
    background: none;
    border: none;
    color: var(--text-muted, #64748b);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.custom-modal-close:hover {
    background: var(--bg-hover, #1e293b);
    color: var(--text-primary, #f1f5f9);
}

.custom-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.custom-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color, #334155);
    flex-shrink: 0;
}

/* Detail grid inside modal */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-grid .detail-item.full {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted, #64748b);
    margin-bottom: 2px;
}

.detail-value {
    font-size: 0.95rem;
    color: var(--text-primary, #f1f5f9);
}

/* ================================
   Toast Notifications
   ================================ */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    color: white;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.toast-notification.toast-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toast-success {
    background: var(--color-success);
}

.toast-error {
    background: var(--color-danger);
}

.toast-warning {
    background: var(--color-warning);
    color: #1e293b;
}

.toast-info {
    background: var(--color-info);
}

@media (max-width: 480px) {
    .toast-notification {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}
