:root {
    --bg-body: #f4f5f7;
    --bg-surface: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-hover: #fff5f0;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    --accent: #FF6800;
    --accent-hover: #e55d00;
    --accent-light: #fff3eb;
    --success: #10b981;
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --radius: 8px;
    --radius-lg: 12px;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
}

[data-theme="dark"] {
    --bg-body: #0a0c10;
    --bg-surface: #14171c;
    --bg-sidebar: #0d0f13;
    --bg-hover: #1f1a16;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border-color: #1f232b;
    --border-light: #181a20;
    --accent: #FF6800;
    --accent-hover: #ff8534;
    --accent-light: #261d1a;
    --success: #22c55e;
    --success-bg: #0d2a19;
    --success-text: #86efac;
    --warning: #fbbf24;
    --warning-bg: #2a2415;
    --warning-text: #fde68a;
    --danger: #f87171;
    --danger-bg: #261515;
    --danger-text: #fca5a5;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    line-height: 1.5;
    transition: background 0.3s ease, color 0.3s ease;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

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

.table a {
    color: var(--text-primary);
}

[data-theme="dark"] .table a {
    color: #f9fafb;
}

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

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

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    transition: background 0.3s ease, border-color 0.3s ease, left 0.3s ease;
}

.sidebar-content {
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-brand {
    padding: 0 12px 32px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(255, 104, 0, 0.3);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.15s ease;
}

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

.nav-link.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.nav-link svg {
    color: var(--text-secondary);
}

.nav-link:hover svg,
.nav-link.active svg {
    color: var(--accent);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    background: none;
    width: 100%;
    font-size: 14px;
    font-weight: 500;
}

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

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.main-content {
    flex: 1;
    min-width: 0;
}

.header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.header-content {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.search-wrapper {
    position: relative;
    width: 300px;
}

.search-wrapper input {
    width: 100%;
    padding-right: 40px;
}

.search-wrapper svg {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
}

.search-results-section {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-hover);
}

.search-results-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.1s ease;
}

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

.search-results-item:hover {
    background: var(--bg-hover);
}

.search-results-item-title {
    font-weight: 600;
    color: var(--text-primary);
}

.search-results-item-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.search-results-item-type {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-right: 8px;
}

.search-results-item-type.cliente {
    background: var(--accent-light);
    color: var(--accent);
}

.search-results-item-type.activacion {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.search-results-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

@media (max-width: 768px) {
    .search-wrapper {
        width: 200px;
    }
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.meta {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 40px 48px 64px;
}

.page-header {
    margin-bottom: 32px;
}

.page-header .actions {
    display: flex;
    gap: 12px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 40px 0 20px;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.cards .card {
    padding: 20px;
}

.cards .card .meta {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.cards .card .page-title {
    font-size: 32px;
    color: var(--accent);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

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

.chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 16px;
}

.chart-container {
    height: 300px;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    box-shadow: var(--shadow);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.table th {
    background: var(--bg-hover);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

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

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

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-cobrado {
    background: var(--success-bg);
    color: var(--success-text);
}

[data-theme="dark"] .status-cobrado {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.status-pendiente {
    background: var(--warning-bg);
    color: var(--warning-text);
}

[data-theme="dark"] .status-pendiente {
    background: rgba(251, 191, 36, 0.2);
    color: #fcd34d;
}

.status-cortesia {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.type-badge.marca {
    background: #dbeafe;
    color: #1e40af;
}

.type-badge.agencia {
    background: #fce7f3;
    color: #9d174d;
}

.type-badge.social {
    background: #d1fae5;
    color: #065f46;
}

.type-badge.rolato {
    background: #fef3c7;
    color: #92400e;
}

[data-theme="dark"] .type-badge.marca {
    background: #1e3a5f;
    color: #93c5fd;
}

[data-theme="dark"] .type-badge.agencia {
    background: #4a1f3a;
    color: #f9a8d4;
}

[data-theme="dark"] .type-badge.social {
    background: #1a3d2e;
    color: #6ee7b7;
}

[data-theme="dark"] .type-badge.rolato {
    background: #3d3320;
    color: #fde68a;
}

.filters {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    align-items: end;
}

.form {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
    max-width: 640px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

input,
select,
textarea {
    font: inherit;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 104, 0, 0.15);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 12px;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: 0 2px 4px rgba(255, 104, 0, 0.2);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 104, 0, 0.3);
}

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

.btn-ghost:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.btn-link {
    background: transparent;
    border: none;
    color: var(--accent);
    padding: 0;
    font-weight: 500;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
}

.alert {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.empty {
    padding: 56px 32px;
    text-align: center;
    background: var(--bg-surface);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
}

.empty::before {
    content: "📭";
    display: block;
    font-size: 40px;
    margin-bottom: 16px;
}

.inline-actions {
    display: flex;
    gap: 12px;
}

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

.detail-item {
    background: var(--bg-hover);
    padding: 20px;
    border-radius: var(--radius);
}

.detail-item strong {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
}

.detail-item div {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-body);
    padding: 32px;
    transition: background 0.3s ease;
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
}

.login-card h1 {
    text-align: center;
    font-size: 24px;
    margin-bottom: 8px;
}

.login-card .meta {
    text-align: center;
    margin-bottom: 32px;
}

footer {
    text-align: center;
    padding: 40px 24px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border-color);
    margin-top: 64px;
}

@media (max-width: 1024px) {
    .header {
        padding: 16px 32px;
    }

    .container {
        padding: 32px 32px 48px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        z-index: 100;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .header {
        padding: 12px 20px;
    }

    .header-content {
        flex-wrap: wrap;
        gap: 12px;
    }

    .container {
        padding: 24px 20px 40px;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .form {
        max-width: 100%;
    }

    .mobile-menu-toggle {
        display: block;
    }
}

@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none;
    }
}
