/* ========================================
   UA-KURTKA DESIGN SYSTEM
   Apple-style, Inter font, Light theme
   ======================================== */

/* === 1. CSS RESET === */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
img, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; }
table { border-collapse: collapse; }
a { color: inherit; }

/* === 2. DESIGN TOKENS === */
:root {
    /* Colors */
    --color-bg: #F5F5F7;
    --color-surface: #FFFFFF;
    --color-text: #1D1D1F;
    --color-text-secondary: #86868B;
    --color-accent: #007AFF;
    --color-success: #34C759;
    --color-error: #FF3B30;
    --color-warning: #FF9500;
    --color-purple: #AF52DE;
    --color-border: #E5E5EA;
    --color-border-light: #F0F0F0;
    --color-row-even: #F8F8F8;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Consolas', monospace;

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.3);

    /* Layout */
    --nav-height: 56px;
    --tab-bar-height: 60px;
}

/* === 3. BASE / TYPOGRAPHY === */
body {
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    font-size: 15px;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

h1 { font-size: 28px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 18px; }
h5 { font-size: 16px; font-weight: 600; }
h6 { font-size: 14px; font-weight: 600; }

small, .small { font-size: 13px; }
hr { border: none; border-top: 1px solid var(--color-border); margin: 16px 0; }

/* === 4. LAYOUT UTILITIES === */

/* Display */
.d-flex { display: flex; }
.d-grid { display: grid; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-none { display: none; }

/* Flex */
.flex-wrap { flex-wrap: wrap; }
.flex-column { flex-direction: column; }
.align-items-center { align-items: center; }
.align-items-start { align-items: start; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-around { justify-content: space-around; }

/* Gap */
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* Margin */
.m-0 { margin: 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.me-2 { margin-right: 8px; }
.me-4 { margin-right: 24px; }
.ms-2 { margin-left: 8px; }
.mx-auto { margin-left: auto; margin-right: auto; }
.my-4 { margin-top: 24px; margin-bottom: 24px; }

/* Padding */
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 16px; }
.px-1 { padding-left: 4px; padding-right: 4px; }
.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 16px; padding-right: 16px; }
.px-4 { padding-left: 24px; padding-right: 24px; }
.px-5 { padding-left: 32px; padding-right: 32px; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 16px; padding-bottom: 16px; }
.ps-2 { padding-left: 8px; }
.ps-4 { padding-left: 24px; }
.pt-2 { padding-top: 8px; }
.pb-2 { padding-bottom: 8px; }

/* Width */
.w-100 { width: 100%; }

/* Text */
.text-center { text-align: center; }
.text-start { text-align: left; }
.text-end { text-align: right; }
.text-muted { color: var(--color-text-secondary); }
.text-dark { color: var(--color-text); }
.text-white { color: #fff; }
.text-secondary { color: var(--color-text-secondary); }
.text-decoration-none { text-decoration: none; }

/* Font Weight */
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.fw-medium { font-weight: 500; }
.fw-normal { font-weight: 400; }
.fs-6 { font-size: 16px; }

/* Border */
.border { border: 1px solid var(--color-border); }
.border-0 { border: 0; }
.border-top { border-top: 1px solid var(--color-border); }
.border-start { border-left: 1px solid var(--color-border); }
.border-end { border-right: 1px solid var(--color-border); }
.border-bottom { border-bottom: 1px solid var(--color-border); }

/* Rounded */
.rounded-1 { border-radius: 4px; }
.rounded-3 { border-radius: var(--radius-sm); }
.rounded-pill { border-radius: var(--radius-full); }
.rounded-circle { border-radius: 50%; }

/* Background */
.bg-white { background: #fff; }
.bg-transparent { background: transparent; }

/* Shadow */
.shadow-sm { box-shadow: var(--shadow-sm); }

/* Position */
.sticky-top { position: sticky; top: 0; z-index: 100; }

/* === 5. GRID SYSTEM === */
.container-fluid {
    width: 100%;
    padding-left: 8px;
    padding-right: 8px;
}

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

.row.g-2 { gap: 8px; }
.row.g-3 { gap: 12px; }

.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }
.col-xl-3, .col-xl-9 { grid-column: span 12; }

/* === 6. NAVIGATION === */

/* Desktop nav */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255,255,255,0.82);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.nav-desktop {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: var(--nav-height);
}

.nav-brand {
    font-weight: 600;
    font-size: 18px;
    letter-spacing: -0.5px;
    text-decoration: none;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 24px;
}

.nav-brand i { color: var(--color-accent); }

.nav-pills {
    display: flex;
    gap: 4px;
    background: #fff;
    padding: 4px;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.nav-pill {
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
    white-space: nowrap;
}

.nav-pill:hover { background: #E5E5EA; color: var(--color-text); }
.nav-pill.active { background: var(--color-text); color: #fff; }

/* Nav dropdown groups */
.nav-group { position: relative; display: flex; align-items: center; }

.nav-group-btn {
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: inherit;
    line-height: 1;
}
.nav-group-btn:hover { background: #E5E5EA; color: var(--color-text); }
.nav-group-btn.active { background: var(--color-accent); color: #fff; }

.nav-group-arrow {
    font-size: 10px;
    opacity: 0.55;
    transition: transform 0.2s ease;
}
.nav-group-btn.active .nav-group-arrow { opacity: 0.85; }
.nav-group:hover .nav-group-arrow,
.nav-group.open .nav-group-arrow { transform: rotate(180deg); }

@keyframes navDropdownIn {
    from { opacity: 0; transform: translateX(-50%) scale(0.96) translateY(-6px); }
    to   { opacity: 1; transform: translateX(-50%) scale(1)    translateY(0); }
}

.nav-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 164px;
    background: rgba(255,255,255,0.94);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 8px 32px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
    padding: 5px;
    z-index: 200;
    flex-direction: column;
}
.nav-group:hover .nav-dropdown,
.nav-group.open .nav-dropdown {
    display: flex;
    animation: navDropdownIn 0.18s cubic-bezier(0.34,1.3,0.64,1) both;
}

/* Bridge the 8px gap so hover is not lost when cursor moves from button to dropdown */
.nav-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
}

.nav-dropdown-item {
    display: block;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}
.nav-dropdown-item:hover {
    background: rgba(0,0,0,0.05);
    color: var(--color-text);
}
.nav-dropdown-item.active {
    background: var(--color-accent);
    color: #fff;
    font-weight: 600;
}

/* Mobile sub-nav: hidden on desktop, shown on mobile via media query */
.nav-mobile-sub { display: none; }

.nav-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-usd-rate {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-accent-green, #34C759);
    background: rgba(52, 199, 89, 0.1);
    padding: 4px 10px;
    border-radius: 8px;
    white-space: nowrap;
}

.nav-sync-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: #fff;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: all 0.2s;
}

.nav-sync-btn:hover { background: #F0F0F0; }

.nav-logout {
    color: var(--color-text-secondary);
    font-size: 13px;
    text-decoration: none;
    font-weight: 500;
}

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

/* Mobile bottom tab bar */
.nav-mobile {
    display: none;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    padding: 4px 0;
}

.tab-item i { font-size: 20px; }
.tab-item.active { color: var(--color-accent); }
.tab-item:hover { color: var(--color-accent); }

/* === 7. CARDS & PANELS === */
.card-panel {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-md);
    border: none;
}

.card-stat {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-md);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-val {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.stat-lbl {
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-sub {
    color: var(--color-text-secondary);
    font-size: 14px;
    font-weight: 500;
    margin-top: 2px;
}

.table-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* === 8. TABLES === */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.table thead th {
    background: var(--color-bg);
    color: var(--color-text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 14px 12px;
    vertical-align: middle;
    white-space: nowrap;
    border: none;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-hover tbody tr:hover { background: #F0F5FF; }

.table tbody tr { border-bottom: 1px solid var(--color-border-light); }
.table tbody tr:nth-child(even) { background: var(--color-row-even); }
.table tbody tr:nth-child(odd) { background: var(--color-surface); }

.table tbody td {
    padding: 14px 12px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.table tbody td:first-child {
    font-weight: 600;
    color: var(--color-text);
}

.table tfoot td {
    padding: 14px 12px;
    font-weight: 700;
    font-size: 14px;
    border-top: 2px solid var(--color-border);
    background: var(--color-bg);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.align-middle { vertical-align: middle; }

/* Color helpers for table cells */
.txt-green { color: var(--color-success); font-weight: 600; }
.txt-purple { color: var(--color-purple); font-weight: 600; }
.txt-danger { color: var(--color-error); font-weight: 600; }
.txt-light { color: #C7C7CC; font-weight: 400; }

.money {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.pct-sub {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-weight: 400;
    margin-left: 3px;
}

/* === 9. FORMS & INPUTS === */
.form-label {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
    font-size: 14px;
    display: block;
}

.form-control {
    display: block;
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    padding: 10px 14px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--color-surface);
    color: var(--color-text);
    outline: none;
}

.form-control:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(0,122,255,0.12);
}

.form-select {
    display: block;
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    padding: 10px 14px;
    font-size: 15px;
    background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2386868B' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
    background-size: 12px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right: 36px;
    color: var(--color-text);
    outline: none;
}

.form-select:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(0,122,255,0.12);
}

.input-group-text {
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    padding: 10px 14px;
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* === 10. BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1.4;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
}

.btn-primary:hover {
    background: #0066D6;
    box-shadow: 0 4px 12px rgba(0,122,255,0.3);
}

.btn-outline-primary {
    background: transparent;
    color: var(--color-accent);
    border: 1.5px solid var(--color-accent);
}

.btn-outline-primary:hover {
    background: var(--color-accent);
    color: #fff;
}

.btn-light {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-light:hover { background: var(--color-bg); }

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

.btn-outline-secondary:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

.btn-group {
    display: flex;
    gap: 4px;
}

.btn-filter {
    border: none;
    background: #E5E5EA;
    color: var(--color-text);
    font-weight: 500;
    border-radius: var(--radius-sm);
    font-size: 14px;
    padding: 8px 16px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
}

.btn-filter.btn-sm { padding: 5px 12px; font-size: 13px; }

.btn-filter:hover, .btn-filter.active {
    background: var(--color-accent);
    color: #fff;
}

.date-range-active {
    background: rgba(0, 122, 255, 0.1);
    border-color: var(--color-accent) !important;
}

/* === 11. ALERTS === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-warning {
    background: #FFF8E1;
    color: #856404;
    border: 1px solid #FFE082;
}

.alert-danger {
    background: #FDECEA;
    color: #C62828;
    border: 1px solid #EF9A9A;
}

.alert a { color: inherit; font-weight: 600; }

/* === 12. FINANCE COMPONENTS === */
.period-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.finance-table tr { border-bottom: 1px solid var(--color-border-light); }

.finance-table td {
    padding: 12px 8px;
    font-size: 14px;
}

.finance-table td:first-child {
    font-weight: 600;
    color: var(--color-text-secondary);
}

.finance-table td:last-child {
    text-align: right;
    font-weight: 600;
    font-family: var(--font-mono);
}

.finance-table .finance-sub-row td {
    font-size: 12px;
    opacity: 0.7;
    padding-top: 6px;
    padding-bottom: 6px;
}

.finance-table .finance-sub-row td:first-child {
    padding-left: 20px;
}

.finance-table .highlight {
    background: linear-gradient(135deg, #E3F2FD 0%, #F0F5FF 100%);
}

.finance-table .highlight td {
    font-weight: 700 !important;
    color: var(--color-accent) !important;
}

.comparison-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 60%, #f093fb 100%);
    color: #fff;
    border-radius: var(--radius-md);
    padding: 30px;
    margin-top: 30px;
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.3);
}

.comparison-item {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.comparison-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.comparison-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.comparison-value {
    font-size: 24px;
    font-weight: 700;
}

/* === 13. PROGRESS / LOADER OVERLAY === */
#loader-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

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

.progress-container {
    background: rgba(255, 255, 255, 0.96);
    border-radius: var(--radius-xl);
    padding: 40px 50px;
    box-shadow: var(--shadow-xl);
    text-align: center;
    min-width: 320px;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.progress-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}

.progress-subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 30px;
}

.progress-ring-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 25px;
}

.progress-ring {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.progress-ring-bg {
    fill: none;
    stroke: var(--color-border);
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--color-accent);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 377;
    stroke-dashoffset: 377;
    transition: stroke-dashoffset 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-percentage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.progress-time {
    font-weight: 500;
    color: var(--color-accent);
}

.progress-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

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

.progress-icon-spin {
    animation: spin 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    font-size: 0;
    display: none;
}

.progress-percentage .progress-icon-spin {
    font-size: 22px;
    display: block;
    margin-bottom: 4px;
    color: var(--color-accent);
}

.progress-percentage .fa-check {
    font-size: 28px;
    color: var(--color-success);
    margin-bottom: 4px;
}

/* === 14. SELECT2 OVERRIDES === */
.select2-container--default .select2-selection--multiple {
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--color-border) !important;
    padding: 6px 12px !important;
    font-size: 15px !important;
    min-height: 44px !important;
    background: var(--color-surface) !important;
}

.select2-container--default .select2-selection--multiple:focus-within {
    border-color: var(--color-accent) !important;
    box-shadow: 0 0 0 3px rgba(0,122,255,0.12) !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: var(--color-accent) !important;
    border: none !important;
    color: #fff !important;
    border-radius: 6px !important;
    padding: 4px 10px !important;
    font-size: 13px !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: rgba(255,255,255,0.8) !important;
    margin-right: 5px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    border: none !important;
    padding: 0 !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #fff !important;
    background: transparent !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--color-accent) !important;
}

.select2-dropdown {
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--color-border) !important;
    box-shadow: var(--shadow-md) !important;
}

.select2-container--default .select2-search--inline .select2-search__field {
    margin-top: 0 !important;
    height: 24px !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 4px !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice + .select2-search--inline .select2-search__field {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    border: none !important;
}

/* === 15. LOGIN PAGE === */
.page-login {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 400px;
}

.login-header { text-align: center; margin-bottom: 30px; }
.login-icon { font-size: 48px; margin-bottom: 20px; }
.login-title { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.login-subtitle { font-size: 14px; color: var(--color-text-secondary); }

.btn-login {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #fff;
    font-weight: 600;
    padding: 14px;
    border-radius: var(--radius-md);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 20px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

/* === 16. UPDATE DB PAGE === */
.page-update-db {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.update-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-xl);
    padding: 50px 60px;
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    text-align: center;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.update-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid var(--color-border);
}

.update-stat { text-align: center; }

.update-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.update-stat-label {
    font-size: 12px;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-update {
    display: inline-block;
    padding: 14px 32px;
    background: #667eea;
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 15px;
    margin-top: 25px;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-update:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-update-secondary {
    background: var(--color-text-secondary);
    margin-left: 10px;
}

.btn-update-secondary:hover { background: #6e6e73; }

.hidden { display: none; }

/* === 17. RESPONSIVE === */

/* SM: 576px+ */
@media (min-width: 576px) {
    .d-sm-inline { display: inline; }
    .col-sm-6 { grid-column: span 6; }
    .container-fluid { padding-left: 16px; padding-right: 16px; }
    .px-sm-3 { padding-left: 16px; padding-right: 16px; }
}

/* MD: 768px+ */
@media (min-width: 768px) {
    .d-md-inline { display: inline; }
    .col-md-3 { grid-column: span 3; }
    .col-md-4 { grid-column: span 4; }
    .col-md-6 { grid-column: span 6; }
    .gap-md-3 { gap: 12px; }
    .w-md-auto { width: auto; }
}

/* LG: 992px+ */
@media (min-width: 992px) {
    .col-lg-3 { grid-column: span 3; }
    .col-lg-4 { grid-column: span 4; }
    .col-lg-6 { grid-column: span 6; }
    .col-lg-8 { grid-column: span 8; }
    .container-fluid { padding-left: 24px; padding-right: 24px; }
    .px-lg-4 { padding-left: 24px; padding-right: 24px; }
    .py-lg-4 { padding-top: 24px; padding-bottom: 24px; }
    .mb-lg-4 { margin-bottom: 24px; }
    .g-lg-3 .row, .row.g-lg-3 { gap: 12px; }
}

/* XL: 1200px+ */
@media (min-width: 1200px) {
    .col-xl-3 { grid-column: span 3; }
    .col-xl-9 { grid-column: span 9; }
}

/* Mobile: responsive table as cards */
@media (max-width: 768px) {
    .responsive-table thead { display: none; }

    .responsive-table tbody tr {
        display: block;
        background: var(--color-surface);
        border-radius: var(--radius-md);
        padding: 16px;
        margin-bottom: 8px;
        box-shadow: var(--shadow-sm);
        border: 1px solid var(--color-border-light);
    }

    .responsive-table tbody tr:nth-child(even) { background: var(--color-surface); }

    .responsive-table tbody td {
        display: flex;
        align-items: baseline;
        padding: 6px 0;
        font-size: 13px;
        border-bottom: 1px solid var(--color-border-light);
        font-variant-numeric: tabular-nums;
        text-align: right;
        white-space: nowrap;
    }

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

    .responsive-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-text-secondary);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        flex-shrink: 0;
        margin-right: auto;
        padding-right: 12px;
        white-space: nowrap;
    }

    .responsive-table tbody td .pct-sub {
        white-space: nowrap;
    }

    .responsive-table tbody td:first-child {
        font-size: 15px;
        font-weight: 700;
        padding-bottom: 10px;
        margin-bottom: 4px;
        border-bottom: 1px solid var(--color-border);
    }

    .responsive-table tbody td:first-child::before { display: none; }

    .responsive-table tfoot { display: none; }
}

/* Mobile: navigation */
@media (max-width: 768px) {
    .nav-desktop { display: none; }

    .nav-mobile {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: var(--tab-bar-height);
        background: rgba(255,255,255,0.95);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border-top: 1px solid rgba(0,0,0,0.06);
        z-index: 100;
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .site-nav {
        position: static;
        background: none;
        backdrop-filter: none;
        border-bottom: none;
    }

    body { padding-bottom: calc(var(--tab-bar-height) + env(safe-area-inset-bottom, 0)); }
    body:has(.nav-mobile-sub) { padding-bottom: calc(var(--tab-bar-height) + 52px + env(safe-area-inset-bottom, 0)); }

    .nav-mobile-sub {
        display: flex;
        position: fixed;
        bottom: var(--tab-bar-height);
        left: 0;
        right: 0;
        z-index: 99;
        background: rgba(242,242,247,0.97);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border-top: 1px solid rgba(0,0,0,0.08);
        justify-content: space-around;
        align-items: center;
        padding: 6px 0;
    }

    .nav-mobile-sub-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        font-size: 10px;
        color: var(--color-text-secondary);
        text-decoration: none;
        font-weight: 500;
        padding: 4px 16px;
        border-radius: var(--radius-sm);
        transition: color 0.15s;
    }

    .nav-mobile-sub-item i { font-size: 17px; }
    .nav-mobile-sub-item.active { color: var(--color-accent); font-weight: 600; }
    .nav-mobile-sub-item:hover { color: var(--color-accent); }

    .stat-val { font-size: 24px; }
    .card-stat { padding: 16px; }
    .card-panel { padding: 12px; }
    .comparison-value { font-size: 20px; }

    .update-card { padding: 40px 24px; }
}

/* Mobile: grid adjustments */
@media (max-width: 768px) {
    .row.g-2, .row.g-3 { gap: 8px; }

    /* Allow grid items to shrink below content minimum width */
    .row > [class*="col-"] {
        min-width: 0;
    }

    /* Stack md-breakpoint columns vertically on mobile */
    .col-md-3,
    .col-md-4,
    .col-md-6 {
        grid-column: span 12;
    }

    /* Smaller inputs on mobile to prevent date overflow */
    .form-control, .form-select {
        font-size: 14px;
        padding: 8px 10px;
    }

    .form-select {
        padding-right: 32px;
        background-position: right 8px center;
    }

    /* Prevent card content from overflowing screen */
    .card-panel {
        overflow: hidden;
    }

    /* Comparison card mobile */
    .comparison-card { padding: 20px; }
    .comparison-card h3 { font-size: 20px !important; }
    .comparison-card .d-flex.justify-content-between {
        flex-direction: column;
        gap: 8px;
    }
    .comparison-card .d-flex.justify-content-between > div:last-child {
        text-align: left !important;
    }

    /* Finance-table compact on mobile (expandable detail rows) */
    .finance-table td {
        padding: 8px 4px;
        font-size: 12px;
    }
    .finance-table td:first-child {
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 11px;
    }
    .finance-table .finance-sub-row td:first-child {
        padding-left: 12px;
        max-width: 130px;
    }
    .finance-table .finance-sub-row td {
        font-size: 10px;
    }
}

/* Zebra striping для таблиць фіолетового блоку */
tr.md-data-row:nth-child(4n+1) {
    background-color: #f8f8fa;
}
tr.md-data-row:nth-child(4n+3) {
    background-color: #ffffff;
}
