/* ==========================================================================
   Cancellation Compensator Console - Design System & Styling (Apple Liquid Glass)
   ========================================================================== */

:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(22, 31, 48, 0.75);
    --card-border: rgba(255, 255, 255, 0.1);
    --card-hover-border: rgba(59, 130, 246, 0.4);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --accent-blue: #2563eb;
    --accent-blue-hover: #1d4ed8;
    --accent-blue-light: rgba(37, 99, 235, 0.15);
    
    --accent-green: #059669;
    --accent-green-light: rgba(5, 150, 105, 0.15);
    
    --accent-amber: #d97706;
    --accent-amber-light: rgba(217, 119, 6, 0.15);
    
    --accent-purple: #7c3aed;
    --accent-purple-light: rgba(124, 58, 237, 0.15);
    
    --accent-red: #dc2626;
    --accent-red-light: rgba(220, 38, 38, 0.15);
    
    --input-bg: #1e293b;
    --input-border: #334155;
    --input-focus-border: #3b82f6;
    
    --table-header-bg: #111827;
    --table-hover: rgba(255, 255, 255, 0.03);
    
    --shadow-subtle: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

[data-theme="light"] {
    --bg-color: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-border: rgba(0, 0, 0, 0.08);
    --card-hover-border: rgba(37, 99, 235, 0.4);
    
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #94a3b8;
    
    --accent-blue: #2563eb;
    --accent-blue-hover: #1d4ed8;
    --accent-blue-light: rgba(37, 99, 235, 0.1);
    
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --input-focus-border: #2563eb;
    
    --table-header-bg: #f8fafc;
    --table-hover: rgba(0, 0, 0, 0.02);
    --shadow-subtle: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   Login Page Styling
   ========================================================================== */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

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

.login-card {
    background: var(--card-bg);
    backdrop-filter: blur(25px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    box-shadow: var(--shadow-subtle);
    text-align: center;
}

.login-header .brand-icon {
    width: 64px;
    height: 64px;
    background-color: var(--accent-blue);
    color: #ffffff;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 20px auto;
}

.login-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.login-header p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 28px;
}

.login-form .form-group {
    text-align: left;
    margin-bottom: 20px;
}

.login-footer {
    margin-top: 30px;
    font-size: 12px;
    color: var(--text-dim);
}

/* ==========================================================================
   App Header & Navigation
   ========================================================================== */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 40px;
    background: var(--card-bg);
    backdrop-filter: blur(25px);
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    width: 44px;
    height: 44px;
    background-color: var(--accent-blue);
    color: #ffffff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.brand-title h1 {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.2;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.badge-dev { background-color: var(--accent-blue); color: #ffffff; }
.badge-purple { background-color: var(--accent-purple); color: #ffffff; }
.badge-green { background-color: var(--accent-green); color: #ffffff; }

.nav-controls {
    display: flex;
    align-items: center;
    gap: 14px;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.status-dot.online { background-color: #10b981; }

/* Main App Shell Layout */
.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 32px 40px;
}

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

/* Tab Buttons Navigation Bar */
.tabs-nav {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 14px;
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 12px 22px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-main);
    background-color: var(--table-hover);
    border-color: var(--card-border);
}

.tab-btn.active {
    color: #ffffff;
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.25s ease-in-out;
}

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

/* ==========================================================================
   Cards & Layout Grid System
   ========================================================================== */

.card {
    background: var(--card-bg);
    backdrop-filter: blur(25px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-subtle);
    margin-bottom: 28px;
    transition: border-color 0.2s ease;
}

.card:last-child {
    margin-bottom: 0;
}

.card-header {
    margin-bottom: 22px;
}

.card-header h3 {
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section-title {
    margin-bottom: 28px;
}

.section-title h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title p {
    font-size: 14px;
    color: var(--text-muted);
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 28px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

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

/* KPI Summary Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(25px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow-subtle);
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.icon-blue { background-color: var(--accent-blue-light); color: #3b82f6; }
.icon-purple { background-color: var(--accent-purple-light); color: #8b5cf6; }
.icon-green { background-color: var(--accent-green-light); color: #10b981; }
.icon-amber { background-color: var(--accent-amber-light); color: #f59e0b; }

.stat-value {
    display: block;
    font-size: 26px;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 28px;
    margin-bottom: 32px;
}

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

.chart-card {
    background: var(--card-bg);
    backdrop-filter: blur(25px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-subtle);
}

.chart-header h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-body {
    position: relative;
    height: 300px;
}

/* ==========================================================================
   Form Controls, Inputs & Selects
   ========================================================================== */

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

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-control, .form-select {
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.form-input-inline {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-main);
    font-size: 17px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
}

.form-input-inline:focus {
    background-color: var(--input-bg);
    border-color: var(--input-border);
}

/* Toolbar & Filter Rows */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

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

.filter-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.filter-group select, .filter-group input {
    min-width: 240px;
}

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

/* Dynamic Filter Rules Builder */
.rules-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.rule-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 2fr 48px;
    gap: 12px;
    align-items: center;
}

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

.rule-row select, .rule-row input {
    min-height: 44px;
}

/* ==========================================================================
   Buttons & Actions
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary { 
    background-color: var(--accent-blue); 
    color: #ffffff; 
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover { 
    background-color: var(--accent-blue-hover); 
    transform: translateY(-1px);
}

.btn-secondary { 
    background-color: var(--input-bg); 
    border: 1px solid var(--input-border); 
    color: var(--text-main); 
}
.btn-secondary:hover { 
    background-color: var(--table-hover); 
    border-color: var(--text-muted);
}

.btn-warning { background-color: var(--accent-amber); color: #ffffff; }
.btn-warning:hover { background-color: #b45309; }

.btn-danger { background-color: var(--accent-red); color: #ffffff; }

.btn-sm { 
    min-height: 40px; 
    padding: 0 16px; 
    font-size: 13px; 
    border-radius: var(--radius-sm);
}

.btn-block { width: 100%; }

.btn-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* ==========================================================================
   Data Tables & Badges
   ========================================================================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
}

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

.data-table th, .data-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--card-border);
    vertical-align: middle;
}

.data-table th {
    color: var(--text-muted);
    font-weight: 700;
    background-color: var(--table-header-bg);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

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

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

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #475569;
    transition: .3s;
}

.slider.round { border-radius: 26px; }
.slider.round:before { border-radius: 50%; }

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
}

input:checked + .slider { background-color: var(--accent-blue); }
input:checked + .slider:before { transform: translateX(22px); }

/* Dividers & Utilities */
.divider { 
    border: 0; 
    height: 1px; 
    background: var(--card-border); 
    margin: 24px 0; 
}

.flex-between { display: flex; align-items: center; justify-content: space-between; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 20px; }
.mb-3 { margin-bottom: 14px; }
.mb-4 { margin-bottom: 24px; }
.mr-1 { margin-right: 6px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: #10b981; }
.text-danger { color: #ef4444; }
.py-4 { padding-top: 24px; padding-bottom: 24px; }

.code-block {
    background: #090d16;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: SFMono-Regular, Consolas, monospace;
    font-size: 13px;
    color: #38bdf8;
    line-height: 1.6;
}

.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.alert-danger { background-color: var(--accent-red-light); border: 1px solid var(--accent-red); color: #fca5a5; }

.upload-box {
    border: 2px dashed var(--input-border);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.upload-box:hover {
    border-color: var(--accent-blue);
}

.upload-icon {
    font-size: 44px;
    color: var(--accent-blue);
    margin-bottom: 14px;
}

/* Modal Window */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}
