@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Brand Colors - iHisho Institutional (Deep Navy + Ivory) */
    --brand-primary: #0f172a;
    --brand-primary-light: #1e293b;
    --brand-primary-rgb: 15, 23, 42;
    --brand-accent: #0f172a;
    --brand-accent-hover: #1e293b;

    /* Semantic Colors */
    --color-success: #059669;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --color-info: #2563eb;

    /* Status Colors (prototype palette) */
    --status-urgent-bg: #fee2e2;
    --status-urgent-text: #991b1b;
    --status-pending-bg: #e0f2fe;
    --status-pending-text: #075985;
    --status-new-bg: #dcfce7;
    --status-new-text: #166534;
    --status-ok-bg: #f3f4f6;
    --status-ok-text: #374151;

    /* Light Theme (Institutional - Warm Ivory + Navy) */
    --bg-body: #f8f7f5;
    --bg-surface: #ffffff;
    --bg-surface-glass: rgba(255, 255, 255, 0.85);
    --bg-sidebar: #f0ede6;
    --bg-sidebar-hover: #e5e1d8;

    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-inverse: #ffffff;

    --border-color: #e5e7eb;
    --border-color-glass: rgba(229, 231, 235, 0.8);

    /* Sharp geometry (prototype: minimal rounding) */
    --radius-sm: 2px;
    --radius-md: 3px;
    --radius-lg: 4px;

    /* Subtle shadows, prioritizing solid borders */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    /* Typography & Layout */
    --font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 80px;
    --topbar-height: 70px;
    --transition-speed: 0.3s;
}

/* Dark Theme (Ejecutivo Dark - Onyx & Bronze) */
[data-theme="dark"] {
    --brand-primary: #b45309;
    --brand-primary-light: #d97706;
    --brand-primary-rgb: 180, 83, 9;
    --brand-accent: #b45309;
    --brand-accent-hover: #d97706;

    --color-success: #34d399;
    --color-warning: #fbbf24;
    --color-danger: #fca5a5;
    --color-info: #60a5fa;

    --status-urgent-bg: rgba(153, 27, 27, 0.2);
    --status-urgent-text: #fca5a5;
    --status-pending-bg: rgba(7, 89, 133, 0.2);
    --status-pending-text: #7dd3fc;
    --status-new-bg: rgba(22, 101, 52, 0.2);
    --status-new-text: #86efac;
    --status-ok-bg: rgba(63, 63, 70, 0.3);
    --status-ok-text: #d4d4d8;

    --bg-body: #09090b;
    --bg-surface: #121214;
    --bg-surface-glass: rgba(18, 18, 20, 0.85);
    --bg-sidebar: #18181b;
    --bg-sidebar-hover: #27272a;

    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-inverse: #ffffff;

    --border-color: #27272a;
    --border-color-glass: rgba(39, 39, 42, 0.5);

    --shadow-sm: none;
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --brand-primary: #b45309;
        --brand-primary-light: #d97706;
        --brand-primary-rgb: 180, 83, 9;
        --brand-accent: #b45309;
        --brand-accent-hover: #d97706;

        --status-urgent-bg: rgba(153, 27, 27, 0.2);
        --status-urgent-text: #fca5a5;
        --status-pending-bg: rgba(7, 89, 133, 0.2);
        --status-pending-text: #7dd3fc;
        --status-new-bg: rgba(22, 101, 52, 0.2);
        --status-new-text: #86efac;
        --status-ok-bg: rgba(63, 63, 70, 0.3);
        --status-ok-text: #d4d4d8;

        --bg-body: #09090b;
        --bg-surface: #121214;
        --bg-surface-glass: rgba(18, 18, 20, 0.85);
        --bg-sidebar: #18181b;
        --bg-sidebar-hover: #27272a;

        --text-primary: #f4f4f5;
        --text-secondary: #a1a1aa;
        --text-muted: #71717a;
        --text-inverse: #ffffff;

        --border-color: #27272a;
        --border-color-glass: rgba(39, 39, 42, 0.5);

        --shadow-sm: none;
        --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
    }
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color 0.2s;
}

/* =========================================
   Typography Utilities (prototype classes)
   ========================================= */
.text-micro-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--text-muted);
}

.text-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* =========================================
   Layout Shell
   ========================================= */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Auth Layout */
.auth-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-body);
}

/* =========================================
   Sidebar (Institutional Light)
   ========================================= */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: var(--text-primary);
    transition: width var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    z-index: 100;
    border-right: 1px solid var(--border-color);
}

.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
}

.brand-logo {
    font-weight: 700;
    font-size: 1.25rem;
    white-space: nowrap;
    overflow: hidden;
    color: var(--text-primary);
}

.sidebar.collapsed .brand-logo {
    display: none;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Sidebar Menu Group (prototype structure) */
.menu-group {
    margin-bottom: 20px;
}

.menu-title {
    padding: 0 20px;
    margin-bottom: 8px;
}

/* Nav Items (sidebar links) */
.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.2s;
    cursor: pointer;
    border-left: 3px solid transparent;
    margin: 0;
    border-radius: 0;
}

.nav-item:hover {
    background-color: var(--bg-sidebar-hover);
}

.nav-item.active {
    background-color: var(--brand-primary);
    color: var(--text-inverse);
    font-weight: 500;
}

.nav-icon {
    font-size: 1rem;
    min-width: 24px;
    margin-right: 10px;
    text-align: center;
}

.nav-text {
    white-space: nowrap;
}

.sidebar.collapsed .nav-text {
    display: none;
}
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px;
    border-left: none;
}
.sidebar.collapsed .nav-icon {
    margin-right: 0;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 20px 0;
    border-top: 1px solid var(--border-color);
}

/* =========================================
   Main Content Area
   ========================================= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-body);
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.toggle-sidebar-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s, color 0.2s;
}
.toggle-sidebar-btn:hover {
    background-color: var(--bg-body);
    color: var(--text-primary);
}

.page-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin: 0;
}

/* Page Body */
.page-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

/* =========================================
   Page Structure (prototype)
   ========================================= */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
    font-weight: 600;
    color: var(--text-primary);
}

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

/* =========================================
   Metric Cards (prototype)
   ========================================= */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 8px 0;
    letter-spacing: -1px;
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.metric-trend {
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend-up { color: var(--color-success); }
.trend-down { color: var(--color-danger); }

/* KPI Cards (interactive metrics, existing compat) */
.kpi-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.kpi-card.active {
    box-shadow: 0 0 0 2px var(--brand-primary);
}

/* =========================================
   Content Grid (2fr 1fr layout)
   ========================================= */
.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

/* =========================================
   Panel (prototype card alternative)
   ========================================= */
.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.panel-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* =========================================
   Cards (existing, updated to match geometry)
   ========================================= */
.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

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

/* =========================================
   Buttons (sharp geometry, prototype)
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    gap: 8px;
    font-family: var(--font-family);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background-color: var(--brand-primary);
    color: var(--text-inverse);
    border-color: var(--brand-primary);
}
.btn-primary:hover {
    background-color: var(--brand-primary-light);
    border-color: var(--brand-primary-light);
}

.btn-accent {
    background-color: var(--brand-accent);
    color: var(--text-inverse);
}
.btn-accent:hover {
    background-color: var(--brand-accent-hover);
}

.btn-success {
    background-color: var(--color-success);
    color: var(--text-inverse);
}
.btn-success:hover {
    background-color: #047857;
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
    box-shadow: none;
}
.btn-outline:hover {
    background-color: var(--bg-body);
    border-color: var(--text-secondary);
}

/* =========================================
   Badges (sharp geometry, prototype)
   ========================================= */
.badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-sm);
}

/* Semantic badges (prototype naming) */
.badge-urgent { background: var(--status-urgent-bg); color: var(--status-urgent-text); }
.badge-pending { background: var(--status-pending-bg); color: var(--status-pending-text); }
.badge-new { background: var(--status-new-bg); color: var(--status-new-text); }
.badge-ok { background: var(--status-ok-bg); color: var(--status-ok-text); }

/* Legacy badge names (backward compat) */
.badge-warning { background: var(--status-urgent-bg); color: var(--status-urgent-text); }
.badge-success { background: var(--status-new-bg); color: var(--status-new-text); }
.badge-info { background: var(--status-pending-bg); color: var(--status-pending-text); }
.badge-primary { background: rgba(var(--brand-primary-rgb), 0.15); color: var(--brand-primary); }
.badge-danger { background: var(--status-urgent-bg); color: var(--status-urgent-text); }
.badge-secondary { background: var(--status-ok-bg); color: var(--status-ok-text); }
.badge-purple-soft { background: var(--status-new-bg); color: var(--status-new-text); }

[data-theme="dark"] .badge-primary { background: rgba(var(--brand-primary-rgb), 0.2); color: var(--brand-primary-light); }

/* =========================================
   Grid System
   ========================================= */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

/* =========================================
   Detail Page Components (Single Column)
   ========================================= */
.detail-fields-row {
    display: flex;
    flex-wrap: wrap;
}

.detail-field {
    flex: 1;
    min-width: 200px;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.detail-field:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

@media (max-width: 768px) {
    .detail-field {
        border-right: none !important;
    }
}

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

.detail-section {
    margin-bottom: 24px;
}

/* =========================================
   Financial Highlight Row
   ========================================= */
.financial-highlight {
    background-color: rgba(var(--brand-primary-rgb), 0.08);
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--brand-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.financial-highlight .label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.financial-highlight .value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--brand-primary);
    font-family: monospace;
}

.financial-sub {
    background-color: rgba(var(--brand-primary-rgb), 0.05);
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--brand-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

/* =========================================
   Chart / Gradient Card
   ========================================= */
.chart-card-gradient {
    background: linear-gradient(135deg, var(--brand-primary), #0f172a);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
}

/* =========================================
   Table Styling
   ========================================= */
.table-container {
    width: 100%;
    border-collapse: collapse;
}

.table-header th {
    padding: 12px 20px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    background-color: var(--bg-body);
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.table-row td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.table-row:hover {
    background-color: rgba(var(--brand-primary-rgb), 0.04);
}

.table-row-clickable {
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}
.table-row-clickable:hover {
    background-color: rgba(var(--brand-primary-rgb), 0.08) !important;
}
.table-row-clickable td {
    transition: background-color 0.15s ease-in-out;
}
.table-row-clickable:hover td {
    background-color: rgba(var(--brand-primary-rgb), 0.08) !important;
}

/* =========================================
   Inputs
   ========================================= */
input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="date"], select, textarea, .form-control {
    background-color: var(--bg-body);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-family: var(--font-family);
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
    display: block;
    font-size: 0.9rem;
}
input[type="text"]:focus, input[type="number"]:focus, input[type="email"]:focus, input[type="password"]:focus, input[type="date"]:focus, select:focus, textarea:focus, .form-control:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(var(--brand-primary-rgb), 0.15);
}

input[disabled], select[disabled], textarea[disabled] {
    background-color: var(--bg-body);
    opacity: 0.6;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.6);
}

.validation-message {
    color: var(--color-danger);
    font-size: 0.8rem;
    margin-top: 4px;
    font-weight: 500;
}

/* =========================================
   Info Box
   ========================================= */
.info-box {
    background-color: rgba(var(--brand-primary-rgb), 0.04);
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--brand-primary);
    margin-bottom: 16px;
}

/* =========================================
   Detail Sidebar
   ========================================= */
.detail-sidebar {
    margin-top: 24px;
}

/* =========================================
   Loading & Empty States
   ========================================= */
.loading-container {
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
}

.loading-spinner {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
}

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

/* =========================================
   Follow-up Timeline
   ========================================= */
.follow-up-new {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface);
}

.follow-up-textarea {
    width: 100%;
    min-height: 80px;
    margin-bottom: 12px;
}

.follow-up-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.follow-up-timeline {
    max-height: 500px;
    overflow-y: auto;
}

.follow-up-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.follow-up-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--brand-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.follow-up-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.follow-up-user {
    font-weight: 600;
    color: var(--text-primary);
}

.follow-up-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.follow-up-delete {
    padding: 4px;
    border: none;
    color: var(--color-danger);
}

.follow-up-comment {
    color: var(--text-primary);
    white-space: pre-wrap;
    margin-bottom: 12px;
}

.follow-up-docs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.follow-up-doc-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background-color: var(--bg-body);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.follow-up-attach {
    margin-top: 8px;
}

.attach-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* =========================================
   Page Header (gradient brand header)
   ========================================= */
.page-header-custom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 2rem;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-light) 100%);
    color: white;
    box-shadow: var(--shadow-sm);
}

.page-header-custom .page-title {
    margin: 0 0 0.5rem 0;
    font-weight: 700;
    font-size: 1.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
}

.page-header-custom .page-subtitle {
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    font-size: 1rem;
}

.btn-surface {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
}

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

/* =========================================
   Loader & Empty State
   ========================================= */
.loader-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.empty-state {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    background-color: var(--bg-surface);
}

.empty-icon {
    width: 60px; height: 60px;
    border-radius: 50%;
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--color-info);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
}

/* =========================================
   Table (ihisho-table)
   ========================================= */
.table-wrapper { overflow-x: auto; }

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

.ihisho-table th {
    text-align: left;
    padding: 1.25rem 1.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(0,0,0,0.01);
}

[data-theme="dark"] .ihisho-table th { background-color: rgba(255,255,255,0.02); }

.ihisho-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color-glass);
    vertical-align: middle;
}

.ihisho-table tr:last-child td { border-bottom: none; }
.ihisho-table tr:hover td { background-color: rgba(0, 0, 0, 0.02); }
[data-theme="dark"] .ihisho-table tr:hover td { background-color: rgba(255, 255, 255, 0.02); }

/* =========================================
   Avatar Circle (gradient initials)
   ========================================= */
.avatar-circle {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-accent) 0%, var(--brand-accent-hover) 100%);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.3);
}

/* =========================================
   Icon Button
   ========================================= */
.btn-icon {
    background: none; border: none;
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background-color: var(--bg-body);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.btn-icon.text-warning:hover { color: var(--color-warning); }
.btn-icon.text-danger:hover { color: var(--color-danger); }
.btn-icon.text-primary:hover { color: var(--brand-primary); }

/* =========================================
   Badge variants (extended)
   ========================================= */
.badge-success { background-color: rgba(5, 150, 105, 0.15); color: var(--color-success); }
[data-theme="dark"] .badge-success { background-color: rgba(52, 211, 153, 0.15); color: var(--color-success); }

.badge-warning { background-color: rgba(217, 119, 6, 0.15); color: var(--color-warning); }
[data-theme="dark"] .badge-warning { background-color: rgba(251, 191, 36, 0.15); color: var(--color-warning); }

.badge-info { background-color: rgba(37, 99, 235, 0.15); color: var(--color-info); }
[data-theme="dark"] .badge-info { background-color: rgba(96, 165, 250, 0.15); color: var(--color-info); }

.badge-danger { background-color: rgba(220, 38, 38, 0.15); color: var(--color-danger); }
[data-theme="dark"] .badge-danger { background-color: rgba(252, 165, 165, 0.15); color: var(--color-danger); }

/* =========================================
   Modal (custom-blazor override)
   ========================================= */
.custom-modal-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.custom-modal {
    background-color: var(--bg-surface);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
    overflow: hidden;
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.custom-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(0,0,0,0.02);
}

[data-theme="dark"] .custom-modal-header { background-color: rgba(255,255,255,0.02); }

.custom-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.close-btn {
    background: none; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: color 0.2s;
}

.close-btn:hover { color: var(--color-danger); }

.custom-modal-body { padding: 1.5rem; }

.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 0.5rem; font-weight: 500; font-size: 0.875rem; color: var(--text-secondary);
}

.form-control {
    width: 100%; padding: 0.75rem 1rem; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 1rem;
}

.form-text { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.35rem; }
.validation-error { color: var(--color-danger); font-size: 0.75rem; display: block; margin-top: 0.25rem; }

.modal-actions {
    display: flex; justify-content: flex-end; gap: 1rem; margin-top: 2rem;
}

/* =========================================
   Plans Grid
   ========================================= */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.plan-card { padding: 1.5rem; transition: transform 0.2s, box-shadow 0.2s; }
.plan-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* =========================================
   Flex utilities (scoped overrides)
   ========================================= */
.flex-center-gap { display: flex; align-items: center; gap: 0.75rem; }

/* =========================================
   Action List (prototype)
   ========================================= */
.action-list {
    list-style: none;
}

.action-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.action-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.action-info h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-primary);
}

/* =========================================
   Chart Mockup (prototype bars)
   ========================================= */
.chart-mockup {
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 8%;
    padding-top: 20px;
}

.chart-bar {
    flex: 1;
    background-color: var(--brand-primary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    opacity: 0.8;
}

/* =========================================
   List Page Utilities (indicator cards, filter bar)
   ========================================= */
.indicator-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.indicator-card {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid var(--brand-primary);
}

.indicator-icon {
    padding: 12px;
    border-radius: 50%;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.indicator-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}

.indicator-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* =========================================
   Filter Toolbar (Reusable across all list pages)
   ========================================= */
.filter-toolbar {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface);
}

.filter-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
}

.filter-row + .filter-row {
    margin-top: 10px;
}

.filter-search {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.filter-search i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

.filter-search input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.85rem;
    background-color: var(--bg-body);
    color: var(--text-primary);
}

.filter-search input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(var(--brand-primary-rgb), 0.15);
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    flex: 1;
    min-width: 100px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(var(--brand-primary-rgb), 0.15);
}

/* Legacy filter-bar kept for backward compat */
.filter-bar {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 16px;
    background-color: var(--bg-surface);
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--brand-primary);
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 10px;
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* =========================================
   Filter Toolbar - Single row variant (simple pages)
   ========================================= */
.filter-toolbar-single {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: nowrap;
}

.filter-toolbar-single .filter-search {
    flex: 1;
    min-width: 200px;
    max-width: 450px;
}

/* =========================================
   Dashboard panel table compact variant
   ========================================= */
.panel .ihisho-table th {
    padding: 0.75rem 1rem;
}
.panel .ihisho-table td {
    padding: 0.6rem 1rem;
}

/* =========================================
   Flex & Spacing Utilities
   ========================================= */
.flex-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

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

.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mt-2 { margin-top: 10px; }

/* =========================================
   Sidebar Helpers
   ========================================= */
.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: color 0.2s;
}
.sidebar-toggle-btn:hover {
    color: var(--text-primary);
}
.sidebar-toggle-btn i {
    font-size: 1.25rem;
}

.nav-item-danger {
    color: #f87171 !important;
}
.nav-item-danger:hover {
    background-color: rgba(248, 113, 113, 0.1) !important;
}

.menu-title.collapsed {
    display: none;
}

/* =========================================
   Button Variants
   ========================================= */
.btn-pill {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-icon-only {
    background: none;
    border: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    color: var(--text-muted);
}
.btn-icon-only:hover {
    background-color: var(--bg-body);
    color: var(--text-primary);
}
.btn-icon-only i {
    font-size: 1.5rem;
}

.btn-full {
    width: 100%;
    margin-top: 16px;
    font-weight: 600;
}

/* =========================================
   Header Icons & Avatar
   ========================================= */
.icon-header {
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}
.icon-header:hover {
    color: var(--text-primary);
}

.avatar-header-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.avatar-header-wrapper:hover {
    transform: scale(1.05);
}
.avatar-header-wrapper:hover .avatar-edit-badge {
    background-color: var(--brand-accent-hover, #7c3aed);
    color: white;
    border-color: var(--brand-accent-hover, #7c3aed);
    transform: scale(1.15);
}

.avatar-header {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
    object-fit: cover;
    transition: box-shadow 0.2s;
}
.avatar-header-wrapper:hover .avatar-header {
    box-shadow: 0 0 0 2px var(--brand-accent, #6366f1);
}

.avatar-header-initials {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-accent, #6366f1) 0%, #8b5cf6 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    border: 2px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
    transition: all 0.2s;
}
.avatar-header-wrapper:hover .avatar-header-initials {
    box-shadow: 0 0 0 2px var(--brand-accent, #6366f1), 0 4px 12px rgba(99, 102, 241, 0.4);
}

.avatar-edit-badge {
    position: absolute;
    bottom: -2px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--bg-surface, #ffffff);
    color: var(--text-secondary, #475569);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 2;
}
[data-theme="dark"] .avatar-edit-badge {
    background-color: #1e1b4b;
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

/* =========================================
   Metric Card Variants
   ========================================= */
.metric-card-warning {
    border-left: 3px solid var(--color-warning);
}

.icon-metric {
    color: var(--text-muted);
    font-size: 1.25rem;
}

.icon-metric-warning {
    color: var(--color-warning);
    font-size: 1.25rem;
}

/* =========================================
   Panel Variants
   ========================================= */
.panel-title-danger {
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-title-danger i {
    color: var(--color-danger);
}

/* =========================================
   Login Page
   ========================================= */
.login-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100vw;
    height: 100vh;
}

.login-form-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    background-color: var(--bg-surface);
}

.login-form-container {
    width: 100%;
    max-width: 400px;
}

.login-brand-header {
    margin-bottom: 40px;
    text-align: center;
}

.login-brand-title {
    font-size: 2rem;
    color: var(--brand-primary);
    font-weight: 700;
    margin-bottom: 4px;
}

.login-error {
    background-color: var(--status-urgent-bg);
    color: var(--status-urgent-text);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.login-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.link-forgot {
    font-size: 0.875rem;
    font-weight: 500;
}

.login-brand-side {
    background-color: var(--brand-primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: white;
}

.login-brand-icon {
    font-size: 6rem;
    margin-bottom: 20px;
}

.login-brand-headline {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 16px;
    text-align: center;
}

.login-brand-subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    max-width: 400px;
}

/* =========================================
   App.razor utilities
   ========================================= */
.app-loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    text-align: center;
}

.app-loading-icon {
    font-size: 4rem;
    color: var(--color-warning);
    margin-bottom: 20px;
}

.app-loading-text {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* =========================================
   Dark theme overrides
   ========================================= */
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

[data-theme="dark"] .sidebar {
    border-right-color: var(--border-color);
}

[data-theme="dark"] .sidebar-header {
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .sidebar-footer {
    border-top-color: var(--border-color);
}

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        height: 100%;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open {
        left: 0;
    }
    .grid-cols-3, .grid-cols-4 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .content-grid {
        grid-template-columns: 1fr;
    }
    .topbar {
        padding: 0 16px;
    }
}

/* =========================================
   Custom Scrollbar (Global)
   ========================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.6);
}

/* =========================================
   Blazor Framework Elements
   ========================================= */
#blazor-error-ui {
    background: var(--status-urgent-bg);
    color: var(--status-urgent-text);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}
.loading-progress circle {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: var(--brand-primary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: var(--brand-primary);
}
.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Iniciando iHisho...");
}
