/* ============================================================================
   GLOBAL STYLES - MODERN & MOBILE OPTIMIZED
   ============================================================================ */

:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --secondary: #475569;
    --accent: #f97316;
    --success: #059669;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #0284c7;
    --dark: #0f172a;
    --light: #f1f5f9;
    --gray: #64748b;
    --shadow: rgba(0, 0, 0, 0.08);
    --shadow-md: rgba(0, 0, 0, 0.12);
    --shadow-lg: rgba(0, 0, 0, 0.18);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

html,
body {
    min-height: 100vh;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 50%, #cbd5e1 100%);
    background-attachment: fixed;
    color: var(--dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    padding-bottom: 40px;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: max(40px, env(safe-area-inset-bottom));
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px;
}

/* ============================================================================
   HEADER - MODERN GLASSMORPHISM
   ============================================================================ */

.header {
    background: #ffffff;
    padding: 0;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.08);
    margin-bottom: 14px;
    text-align: center;
    border: 1px solid #e2e8f0;
    animation: slideDown 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #f97316 0%, #fb923c 50%, #fdba74 100%);
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.5);
    z-index: 2;
}

/* Dòng chào lễ (theme) nằm dưới banner */
.header::after {
    line-height: 1.35;
    padding: 8px 12px 10px;
    box-sizing: border-box;
}

@keyframes slideDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.header-inner {
    display: block;
    width: 100%;
    line-height: 0;
}

.header-banner {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    aspect-ratio: 2172 / 724;
    object-fit: contain;
    object-position: center center;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Giữ tương thích theme cũ vẫn trỏ .header-title / .header-subtitle */
.header-title,
.header-subtitle {
    display: none;
}

/* ============================================================================
   TABS - MODERN PILL DESIGN
   ============================================================================ */

.tab-container {
    display: flex;
    gap: 6px;
    margin-bottom: 0;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 6px;
    border-radius: var(--radius);
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}

.tab-button {
    flex: 1;
    min-width: 120px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: var(--transition);
    color: var(--gray);
    position: relative;
    overflow: hidden;
}

.tab-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.08) 0%, rgba(59, 130, 246, 0.1) 100%);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s ease;
    z-index: 0;
}

.tab-button:hover::before {
    transform: scaleX(1);
}

.tab-button:hover {
    color: var(--primary);
}

.tab-button:active {
    transform: scale(0.96);
}

.tab-button.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.3);
}

.tab-button.active::before {
    display: none;
}

/* Mobile: 4 tab luôn nằm 1 hàng, menu dính đầu màn hình khi cuộn */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header {
        margin-bottom: 10px;
        border-radius: 10px;
    }

    .header-banner {
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    .tab-container {
        position: sticky;
        top: 0;
        z-index: 1000;
        flex-wrap: nowrap;
        gap: 4px;
        padding: 5px;
        padding-top: max(5px, env(safe-area-inset-top));
        background: rgba(255, 255, 255, 0.88);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        box-shadow: 0 2px 12px rgba(15, 23, 42, 0.12);
    }

    .tab-button {
        min-width: 0;
        padding: 11px 4px;
        font-size: 13px;
        letter-spacing: 0;
        white-space: nowrap;
        border-radius: 9px;
    }

    /* 16px chống iOS tự zoom khi focus input; touch target 44px */
    .form-control {
        font-size: 16px;
        padding: 12px;
    }

    .btn {
        min-height: 44px;
    }

    .dashboard-section {
        padding: 14px;
        margin-bottom: 14px;
    }
}

@media (max-width: 380px) {
    .tab-button {
        font-size: 12px;
        padding: 10px 2px;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.tab-content {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.tab-content.active {
    display: block;
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 5px;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   FORM - MODERN CARD DESIGN
   ============================================================================ */


.view-frame,
.summary-frame {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 2px solid #f97316;
}

.view-frame h2,
.summary-frame h2 {
    margin-bottom: 16px;
    color: #ea580c;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.form-section {
    margin-bottom: 0;
    padding: 14px;
    background: #ffffff;
    border-radius: var(--radius);
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--accent);
    transition: var(--transition);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
}

.form-section:focus-within,
.form-section:hover {
    border-color: rgba(249, 115, 22, 0.45);
    border-left-color: var(--accent);
    box-shadow: 0 4px 14px rgba(249, 115, 22, 0.12);
}

.form-section:last-child {
    margin-bottom: 0;
}

.form-section h3 {
    font-size: 15px;
    color: var(--primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #475569;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.01em;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-size: 15px;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
    background-color: #f8fafc;
    color: #0f172a;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.form-control:hover {
    border-color: rgba(249, 115, 22, 0.5);
    background-color: #ffffff;
    box-shadow: 0 2px 6px rgba(249, 115, 22, 0.1);
}

.form-control:focus {
    outline: none;
    border-color: #f97316;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
    background-color: #ffffff;
}

/* Placeholder styling - má» vÃ  má»ng hÆ¡n */
.form-control::placeholder,
input::placeholder,
textarea::placeholder,
select::placeholder {
    color: #94a3b8;
    opacity: 0.5;
    font-weight: 400;
}

.form-control::-webkit-input-placeholder {
    color: #94a3b8;
    opacity: 0.5;
    font-weight: 400;
}

.form-control::-moz-placeholder {
    color: #94a3b8;
    opacity: 0.5;
    font-weight: 400;
}

.form-control:-ms-input-placeholder {
    color: #94a3b8;
    opacity: 0.5;
    font-weight: 400;
}

/* Date input styling */
input[type="date"] {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

input[type="date"]::-webkit-datetime-edit {
    font-size: 15px;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    background: rgba(30, 64, 175, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 4px;
}

.form-row .form-group {
    margin-bottom: 0;
}

/* ============================================================================
   BUTTONS - MODERN GRADIENT & EFFECTS
   ============================================================================ */

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-height: 42px;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.2px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

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

.btn-primary {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.4), 0 0 0 1px rgba(59, 130, 246, 0.3);
    border: 1px solid rgba(59, 130, 246, 0.5);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    box-shadow: 0 2px 12px rgba(108, 117, 125, 0.25);
}

.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(108, 117, 125, 0.35);
}

.btn-success {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.4), 0 0 12px rgba(249, 115, 22, 0.3);
    border: 1px solid rgba(251, 146, 60, 0.5);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    color: #ffffff;
    box-shadow: 0 2px 12px rgba(245, 158, 11, 0.3);
    border: none;
}

.btn-warning:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
}

.btn-theme {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    border: none;
}

.btn-theme:hover {
    transform: translateY(-1px);
}

.btn-info {
    background: linear-gradient(135deg, var(--info) 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.25);
}

.btn-info:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
}

.btn-small {
    padding: 8px 16px;
    font-size: 12px;
    min-height: 36px;
}

/* ============================================================================
   MESSAGE - MODERN TOAST STYLE
   ============================================================================ */

.message {
    position: fixed;
    top: 16px;
    right: 16px;
    left: auto;
    max-width: min(420px, calc(100vw - 32px));
    margin: 0;
    padding: 12px 16px;
    border-radius: 8px;
    display: none;
    font-size: 14px;
    font-weight: 600;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-left: 3px solid;
    animation: slideInRight 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    background: #ffffff;
}

@keyframes slideInRight {
    from {
        transform: translateX(100px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.message.show {
    display: flex !important;
    align-items: center;
    gap: 12px;
}

.message.success {
    background: rgba(74, 222, 128, 0.15);
    color: #16a34a;
    border-left-color: var(--success);
}

.message.error {
    background: rgba(248, 113, 113, 0.15);
    color: #dc2626;
    border-left-color: var(--danger);
}

.message.info {
    background: rgba(96, 165, 250, 0.15);
    color: #2563eb;
    border-left-color: var(--info);
}

.message.warning {
    background: rgba(251, 191, 36, 0.15);
    color: #d97706;
    border-left-color: var(--warning);
}

/* ============================================================================
   TABLE - MODERN DESIGN
   ============================================================================ */

.table-wrapper {
    overflow-x: auto;
    margin-top: 16px;
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    background: #ffffff;
}

.data-table thead {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    font-weight: 700;
    border-bottom: 3px solid #f97316;
}

.data-table th {
    padding: 12px 10px;
    text-align: center;
    color: white;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.3px;
    border: none;
}

.data-table thead tr th:first-child {
    border-top-left-radius: var(--radius-sm);
}

.data-table thead tr th:last-child {
    border-top-right-radius: var(--radius-sm);
}

.data-table td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(203, 213, 225, 0.5);
    text-align: center;
    color: #0f172a;
    font-weight: 600;
    font-size: 13px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: #fef3c7;
    transform: scale(1.01);
    box-shadow: 0 2px 4px rgba(249, 115, 22, 0.2);
}

.data-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.data-table tbody tr:nth-child(even):hover {
    background: #fef3c7;
}

.data-table input[type="checkbox"] {
    cursor: pointer;
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

.data-table .btn-small {
    margin: 0;
    padding: 6px 12px;
    font-size: 12px;
}

/* ============================================================================
   SUMMARY - MODERN CARDS
   ============================================================================ */

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

.summary-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    color: #0f172a;
    padding: 18px;
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 0 0 2px rgba(249, 115, 22, 0.3);
    border: 2px solid rgba(249, 115, 22, 0.3);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.summary-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.summary-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.4);
}

.summary-card h3 {
    font-size: 16px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.summary-card .stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.summary-card .stat:last-child {
    border-bottom: none;
}

.summary-card .stat-label {
    font-size: 14px;
    opacity: 0.9;
    font-weight: 500;
}

.summary-card .stat-value {
    font-size: 18px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ============================================================================
   RANGE SUMMARY
   ============================================================================ */

.range-summary-grid {
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.range-summary-grid .summary-card {
    background: white;
    color: #333;
    border: 2px solid var(--primary);
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.12);
}

.range-summary-grid .summary-card h3 {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.range-summary-grid .stat {
    border-color: #ddd;
}

.range-summary-grid .stat-label {
    color: #666;
    font-weight: 500;
}

.range-summary-grid .stat-value {
    color: #333;
    font-weight: 700;
}

/* ============================================================================
   DASHBOARD / HOME PAGE STYLES
   ============================================================================ */

.dashboard-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 20px;
}

/* ============================================================================
   DASHBOARD DESIGN (USER PREFERRED: 1-1-3, 4 COLORS, INDEPENDENT SECTIONS)
   ============================================================================ */

/* 1. Dashboard Container (SPECIFIC TO HOME) */
#home-tab .dashboard-container {
    background: #ffffff;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 2. Section Containers (Base Style - Desktop) */
.quick-stats-section,
.daily-summary-section,
.weekly-summary-section,
.monthly-summary-section {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #f1f5f9;
}

/* 3. Grid Layout (Desktop Default) */
.quick-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 0;
}

/* 4. Calm Scientific KPI Tiles */
.stat-card {
    background: #f8fafc;
    border-radius: 10px;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-top: 2px solid var(--primary);
    box-shadow: none;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    position: relative;
    min-height: 74px;
}

.stat-card:hover {
    background: #ffffff;
    border-color: #cbd5e1;
}

.stat-card-icon {
    display: none;
}

.stat-card-label {
    font-size: 12.5px;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.01em;
    margin-bottom: 4px;
}

.stat-card-value {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

/* 5. Subtle Section Top Accent (Neutral Surface, Semantic Hairline) */
#quick-stats-grid .stat-card {
    border-top-color: var(--accent, #f97316);
}

#daily-summary-content .stat-card {
    border-top-color: var(--info, #0284c7);
}

#weekly-summary-content .stat-card {
    border-top-color: var(--primary, #1e40af);
}

#monthly-summary-content .stat-card {
    border-top-color: var(--success, #059669);
}

@media (max-width: 768px) {
    #home-tab .dashboard-container {
        padding: 12px;
        background: #f8fafc;
    }

    .dashboard-container h2 {
        font-size: 14.5px;
        margin-bottom: 0;
        font-weight: 700;
    }

    .stat-card-label {
        font-size: 12px;
    }

    .stat-card-value {
        font-size: 19px;
    }
}

/* ============================================================================
   MOBILE OPTIMIZATIONS (ADDED 2026-02-09)
   ============================================================================ */

/* 1. Statistics Tab - Horizontal Scroll on Mobile */
.summary-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}

/* 2. Management Tab - Quick Search Row */
.quick-search-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* 3. Mobile Overrides */
@media (max-width: 768px) {

    /* Input Tab: Force 2 Columns for Form Rows */
    .form-row {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    /* Statistics Tab: Horizontal Scroll for Summary Cards ("Hàng ngang") */
    .summary-stat-grid {
        display: flex !important;
        overflow-x: auto !important;
        padding-bottom: 12px !important;
        scroll-snap-type: x mandatory;
        /* Hide scrollbar for cleaner look */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .summary-stat-grid::-webkit-scrollbar {
        display: none;
    }

    .summary-stat-grid>div {
        min-width: 140px;
        scroll-snap-align: start;
        flex-shrink: 0;
    }

    /* Management Tab: Quick Search Horizontal Scroll */
    .quick-search-row {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        padding-bottom: 8px !important;
    }

    .quick-search-row>* {
        flex-shrink: 0;
    }

    .quick-search-row .form-group {
        min-width: 150px !important;
        /* Smaller than desktop 180px */
    }

    /* Make buttons in search row smaller/compact */
    .quick-search-row .btn {
        padding: 8px 12px !important;
        font-size: 13px !important;
        white-space: nowrap;
    }
}

/* ============================================================================
   MODAL STYLES - OVERLAY POPUP
   ============================================================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: #ffffff;
    margin: auto;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideDown 0.3s ease;
    position: relative;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 3px solid var(--accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

.modal-close {
    color: rgba(255, 255, 255, 0.9);
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: var(--transition);
    opacity: 0.9;
}

.modal-close:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background-color: #f8fafc;
}

.modal-sm {
    max-width: 400px;
    width: 100%;
}

.modal-md {
    max-width: 550px;
    width: 100%;
}

.modal-lg {
    max-width: 700px;
    width: 100%;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .modal-content {
        max-width: 95%;
        margin: 20px auto;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }
}

/* ============================================================================
   MODAL STYLES (LAYOUT FIX - MERGED INTO MAIN MODAL ABOVE)
   ============================================================================ */

@keyframes modalSlideDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================================================
   MOBILE RESPONSIVE TWEAKS (ADDED FOR LAYOUT FIX)
   ============================================================================ */

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

    .quick-search-section .form-group {
        width: 100%;
        min-width: 100% !important;
        margin-bottom: 10px;
    }

    .quick-search-section {
        padding: 12px;
    }

    .button-group .btn {
        flex: 1;
        justify-content: center;
    }

    .modal-content {
        margin: 20% auto;
        width: 95%;
    }
}


/* ============================================================================
   MAIN CARD STYLES (STANDARDIZED LAYOUT) - ADDED FOR LAYOUT FIX 2
   ============================================================================ */
.main-card {
    background-color: #ffffff;
    border-radius: var(--radius);
    overflow: clip;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.08);
    border: 1px solid #e2e8f0;
    margin-bottom: 16px;
}

.main-card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 15px 20px;
    text-align: left;
    border-bottom: 3px solid var(--accent);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.main-card-header h2 {
    margin: 0;
    font-size: 18px;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.main-card-header p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    opacity: 0.95;
    color: rgba(255, 255, 255, 0.9);
}

.main-card-body {
    padding: 16px;
}

@media (max-width: 480px) {
    .main-card-body {
        padding: 12px;
    }

    .main-card-header {
        padding: 15px;
    }
}

/* Added Sections */
.quick-search-section {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    padding: 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(30, 64, 175, 0.25);
    border: none;
}

.custom-range-section {
    background: #f8fafc;
    border: 1px solid #ddd;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.custom-range-section h3 {
    color: #ea580c;
    font-size: 14px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ============================================================================
   SUMMARY TAB - REDESIGNED STYLES
   ============================================================================ */

/* ============================================================================
   SUMMARY TAB - REDESIGNED STYLES (Refactored to use Main Card)
   ============================================================================ */

.summary-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #64748b;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f1f5f9;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.loading-indicator {
    display: none;
    text-align: center;
    padding: 30px;
    color: var(--primary);
}

.loading-indicator.is-visible {
    display: block;
}

.loading-indicator .loading-spinner {
    display: inline-block;
    margin-bottom: 12px;
}

.loading-indicator p {
    margin: 0;
    font-weight: 600;
    color: var(--gray);
}

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

/* Summary Stats Grid - Adjusted for Main Card Body */
.summary-stats-grid {
    display: grid;
    grid-template-columns: repeat(var(--summary-cols, 5), minmax(0, 1fr));
    gap: 0;
    border-bottom: 1px solid #e2e8f0;
}

.summary-stat-item {
    padding: 16px 14px;
    text-align: left;
    border-right: 1px solid #e2e8f0;
    background: #ffffff;
    transition: background 0.15s;
}

.summary-stat-item:last-child {
    border-right: none;
}

.summary-stat-item:hover {
    background: #f8fafc;
}

.summary-stat-icon {
    display: none;
}

.summary-stat-label {
    font-size: 12.5px;
    color: #64748b;
    font-weight: 600;
    letter-spacing: 0.01em;
    margin-bottom: 4px;
}

.summary-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
}

.summary-stat-value.orange {
    color: #0f172a;
}

.summary-stat-value.blue {
    color: var(--primary-dark, #1e3a8a);
}

/* Summary Actions */
.summary-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

/* OLD CSS CLASSES REMOVED: 
   .summary-main-card, .summary-options-card
   .summary-header, .summary-options-header 
   (Replaced by .main-card structure) 
*/

/* Quick Range Buttons */
.quick-range-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    justify-content: center;
}

.range-btn {
    flex: 1;
    max-width: 180px;
    padding: 16px 20px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.range-btn:hover {
    border-color: #f97316;
    background: #fff7ed;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.15);
}

.range-btn .range-icon {
    font-size: 24px;
}

.range-btn span:last-child {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Custom Range Box */
.custom-range-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
}

.custom-range-title {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    text-align: center;
}

.custom-range-inputs {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.date-input-group {
    flex: 1;
    min-width: 140px;
}

.date-input-group label {
    display: block;
    font-size: 12px;
    color: #475569;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.custom-range-btn {
    min-width: 160px;
}

/* Range Summary Result Card */
.range-summary-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 2px solid #10b981;
    margin-top: 20px;
}

.range-summary-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 20px 24px;
    text-align: center;
}

.range-summary-header h3 {
    margin: 0 0 6px 0;
    font-size: 18px;
    font-weight: 700;
}

.range-summary-header p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.range-summary-body {
    padding: 24px;
}

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

.range-stat-card {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    transition: all 0.2s;
}

.range-stat-card:hover {
    border-color: #10b981;
    background: #f0fdf4;
}

.range-stat-card .stat-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.range-stat-card .stat-label {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.range-stat-card .stat-value {
    font-size: 24px;
    font-weight: 800;
    color: #059669;
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .summary-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .summary-stats-grid[data-cols="2"] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-stats-grid[data-cols="2"] .summary-stat-item:nth-child(2) {
        border-right: none;
    }

    .summary-stats-grid[data-cols="3"] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .summary-stats-grid[data-cols="4"] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(3) {
        border-right: none;
    }

    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(4),
    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(5) {
        border-top: 1px solid #e2e8f0;
    }

    .summary-stat-value {
        font-size: 18px;
    }

    .quick-range-buttons {
        flex-direction: column;
    }

    .range-btn {
        max-width: 100%;
        flex-direction: row;
        justify-content: center;
    }

    .custom-range-inputs {
        flex-direction: column;
    }

    .date-input-group {
        width: 100%;
    }

    .custom-range-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) {
        grid-template-columns: repeat(6, 1fr);
    }

    .summary-stats-grid[data-cols="2"] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-stats-grid[data-cols="2"] .summary-stat-item {
        grid-column: span 1;
        border-bottom: none;
    }

    /* Row 1: 2 items (50% each) */
    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(1),
    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(2) {
        grid-column: span 3;
        border-bottom: 1px solid #e2e8f0;
    }

    /* Row 2: 3 items (33.3% each) */
    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(3),
    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(4),
    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(5) {
        grid-column: span 2;
        border-top: none;
        /* Already has bottom border from row 1 */
    }

    /* Borders handling */
    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(1) {
        border-right: 1px solid #e2e8f0;
    }

    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(2) {
        border-right: none;
    }

    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(3),
    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(4) {
        border-right: 1px solid #e2e8f0;
    }

    .summary-stats-grid:not([data-cols="2"]):not([data-cols="3"]):not([data-cols="4"]) .summary-stat-item:nth-child(5) {
        border-right: none;
    }

    .summary-header {
        padding: 20px 16px;
    }

    .summary-actions {
        flex-wrap: wrap;
    }

    .summary-actions .btn {
        flex: 1;
        min-width: 120px;
    }
}

/* ============================================================================
   UI UTILITIES — professional cleanup
   ============================================================================ */

.hint-banner {
    display: none;
    background-color: #fffbf0;
    border-left: 3px solid var(--warning);
    padding: 10px 12px;
    border-radius: 4px;
    margin-bottom: 20px;
    color: #92400e;
    font-size: 13px;
    line-height: 1.6;
}

.hint-banner.is-visible {
    display: block;
}

.form-group-spaced {
    margin-bottom: 25px;
}

.button-group-center {
    justify-content: center;
    margin-bottom: 20px;
    margin-top: 10px;
}

.btn-wide {
    min-width: 160px;
}

.summary-today {
    display: none;
    margin-top: 20px;
}

.summary-today.is-visible {
    display: block;
}

.toolbar-primary,
.toolbar-secondary {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar-secondary {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #e2e8f0;
}

.toolbar-danger {
    margin-left: auto;
}

.quick-search-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.quick-search-field {
    flex: 1;
    min-width: 180px;
    margin: 0;
}

.quick-search-label {
    color: #ffffff;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
    font-size: 13px;
}

.quick-search-actions {
    display: flex;
    gap: 8px;
}

.btn-search-on-dark {
    background: var(--accent);
    color: #ffffff;
    font-weight: 600;
    border: 1px solid rgba(251, 146, 60, 0.6);
}

.btn-ghost-on-dark {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    font-weight: 600;
}

.data-meta-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--accent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
    gap: 10px;
}

.data-meta-left {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.data-info-text {
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
}

.date-range-text {
    color: var(--success);
    font-size: 13px;
    font-weight: 600;
}

.pagination-controls {
    display: flex;
    gap: 5px;
    align-items: center;
}

.load-more-section {
    display: none;
    text-align: center;
    margin: 15px 0;
}

.load-more-section.is-visible {
    display: block;
}

.sortable-th {
    cursor: pointer;
}

.admin-login-hint {
    color: #666;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.6;
}

.alert-box {
    padding: 12px 15px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.7;
}

.alert-box ul {
    margin: 8px 0 0 20px;
}

.alert-warning {
    background: #fef3c7;
    border-left: 4px solid var(--warning);
    color: #92400e;
}

.alert-info {
    background: #e0f2fe;
    border-left: 4px solid var(--info);
    color: #075985;
}

.alert-success {
    background: #f0fdf4;
    border-left: 4px solid var(--success);
    color: #065f46;
}

.alert-danger {
    background: #fef2f2;
    border-left: 4px solid var(--danger);
    color: #991b1b;
}

.alert-primary {
    background: #dbeafe;
    border-left: 4px solid var(--primary);
    color: #1e3a8a;
}

.help-section-title {
    color: var(--primary);
    margin-top: 20px;
    margin-bottom: 12px;
    font-size: 16px;
}

.help-list {
    color: #444;
    line-height: 1.8;
    margin-left: 20px;
}

.import-file-input {
    padding: 10px;
    border: 2px dashed #d1d5db;
    background: #f9fafb;
}

.import-preview {
    display: none;
    margin-top: 16px;
    padding: 15px;
    background: #f0f9ff;
    border-radius: 6px;
    border-left: 4px solid var(--primary);
}

.import-preview.is-visible {
    display: block;
}

.import-preview-title {
    color: var(--primary);
    font-weight: 700;
}

.import-preview-content {
    margin-top: 10px;
    color: var(--primary-dark);
    font-size: 14px;
}

.import-progress {
    display: none;
    margin-top: 16px;
}

.import-progress.is-visible {
    display: block;
}

.import-progress-track {
    background: #e5e7eb;
    border-radius: 8px;
    height: 24px;
    overflow: hidden;
}

.import-progress-bar {
    background: linear-gradient(90deg, var(--success) 0%, #047857 100%);
    height: 100%;
    width: 0%;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.import-status {
    margin-top: 10px;
    color: #666;
    font-size: 14px;
    text-align: center;
}

.theme-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.theme-card {
    cursor: pointer;
    padding: 14px 16px;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: var(--transition);
}

.theme-card:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.12);
}

.theme-card.is-active {
    outline: 3px solid var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.2);
}

.theme-card-swatch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.theme-card-title {
    font-weight: 700;
    color: var(--dark);
    font-size: 15px;
}

.theme-card-desc {
    color: var(--gray);
    font-size: 13px;
    margin-top: 2px;
}

.theme-card-check {
    margin-left: auto;
    font-size: 16px;
    color: var(--success);
    font-weight: 700;
    display: none;
}

.theme-card.is-active .theme-card-check {
    display: block;
}

.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.confirm-dialog {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 100%;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.confirm-dialog h3 {
    margin: 0 0 16px 0;
    color: #1f2937;
    font-size: 18px;
}

.confirm-dialog-body {
    margin-bottom: 24px;
    color: #4b5563;
    font-size: 15px;
    line-height: 1.6;
}

.confirm-dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.detail-block {
    margin-bottom: 0;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

.detail-block-header {
    background: #f1f5f9;
    padding: 6px 12px;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 700;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.detail-table th {
    padding: 5px 8px;
    text-align: left;
    color: #64748b;
    font-weight: 600;
    background: #ffffff;
    border-bottom: 2px solid #f1f5f9;
}

.detail-table th.num,
.detail-table td.num {
    text-align: right;
}

.detail-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #e5e7eb;
    color: #2c3e50;
    white-space: nowrap;
}

.detail-table td.muted {
    color: #666;
}

.detail-table td.delta-pos {
    background-color: #f0fdf4;
    color: #059669;
    font-weight: 700;
}

.detail-table td.delta-neg {
    background-color: #fef2f2;
    color: #dc2626;
    font-weight: 700;
}

.detailed-sections {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.summary-subheading {
    text-align: left;
    color: var(--primary-dark);
    margin: 0 0 10px 0;
    font-size: 13.5px;
    font-weight: 700;
    border-top: 1px solid #e2e8f0;
    padding-top: 16px;
}

.main-card-header.has-close {
    position: relative;
    padding-right: 52px;
}

.card-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.card-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.main-card-body.no-pad {
    padding: 0;
}

.main-card-body.centered-empty {
    text-align: center;
    color: #666;
    padding: 40px;
}

.summary-period-bar {
    text-align: center;
    padding: 10px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
    color: #64748b;
}

.table-empty-cell {
    text-align: center;
    padding: 40px;
    color: #666;
}

.theme-card-swatch[data-theme="tet"] {
    background: linear-gradient(135deg, #b71c1c, #ffd700);
}
.theme-card-swatch[data-theme="party-day"] {
    background: linear-gradient(135deg, #c8001e, #ffd700);
}
.theme-card-swatch[data-theme="canh-ve-cand"] {
    background: linear-gradient(135deg, #0a1628, #c8a84b);
}
.theme-card-swatch[data-theme="women-0803"] {
    background: linear-gradient(135deg, #c2185b, #e040fb);
}
.theme-card-swatch[data-theme="liberation"] {
    background: linear-gradient(135deg, #c62828, #ffb300);
}
.theme-card-swatch[data-theme="aug-revolution"] {
    background: linear-gradient(135deg, #b71c1c, #ffa000);
}
.theme-card-swatch[data-theme="national-day"] {
    background: linear-gradient(135deg, #d50000, #ffd600);
}
.theme-card-swatch[data-theme="women-2010"] {
    background: linear-gradient(135deg, #880e4f, #e040fb);
}

.is-hidden {
    display: none !important;
}

.admin-only {
    display: none;
}

.admin-only.is-visible {
    display: inline-flex;
}

/* Small layout refinements shared by the existing tabs. */
.tab-content.active {
    margin-top: 12px;
}

.main-card-header {
    padding: 14px 18px;
    gap: 5px;
}

.form-control {
    min-width: 0;
    min-height: 44px;
    padding: 8px 10px;
    font-size: 16px;
}

select.form-control {
    appearance: auto;
    font-family: inherit;
}

.btn,
.range-btn,
.tab-button {
    min-height: 44px;
    line-height: 1.4;
}

:is(.btn, .range-btn, .tab-button, .modal-close, .card-close-btn):focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 3px;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.input-layout > :not(.form-section),
.input-layout > .form-section-other {
    grid-column: 1 / -1;
}

.input-layout > .form-group-spaced,
.input-layout > .hint-banner,
.input-layout > .button-group {
    margin: 0;
}

.input-layout .form-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 0;
}

.input-layout .form-section-other .form-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.input-layout .form-section h3 {
    margin-bottom: 10px;
}

.form-row > .form-group {
    min-width: 0;
}

.form-group label {
    margin-bottom: 6px;
    line-height: 1.4;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-row.reset-controls {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    align-items: end;
    gap: 12px;
}

.reset-controls > .form-group {
    grid-column: span 2;
}

.reset-controls > .reset-action {
    grid-column: span 3;
}

.reset-action .btn {
    width: 100%;
    height: auto;
    white-space: normal;
}

.summary-stat-item {
    min-width: 0;
    padding: 16px 10px;
}

.summary-stat-value {
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.quick-range-buttons {
    gap: 8px;
    margin-bottom: 16px;
}

.range-btn {
    padding: 10px 12px;
}

.custom-range-box {
    padding: 14px;
}

.table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

.detail-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    font-size: 13px;
}

.detail-block {
    min-width: 0;
    max-width: 100%;
}

.detail-table th {
    padding: 8px 10px;
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    border-bottom: 1px solid #e2e8f0;
}

.detail-table :is(th, td) {
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
    padding: 8px 10px;
}

.detail-table td.station-cell {
    font-weight: 700;
    color: var(--primary-dark);
    background: #f8fafc;
    vertical-align: middle;
    border-right: 1px solid #e2e8f0;
    width: 24%;
}

.detail-table tr.station-group-start td {
    border-top: 1px solid #cbd5e1;
}

.detail-table tbody tr:first-child td {
    border-top: none;
}

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

.data-table td {
    white-space: nowrap;
}

.data-table tbody tr:hover {
    transform: none;
}

@media (max-width: 768px) {
    .detail-table {
        font-size: 12px;
    }

    .detail-table :is(th, td) {
        padding: 7px 6px;
    }

    .input-layout,
    .admin-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .input-layout .form-row {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .input-layout .form-section-other .form-group:last-child {
        grid-column: 1 / -1;
    }

    .tab-container {
        overflow-x: auto;
    }

    .tab-button {
        flex: 1 0 auto;
        padding: 10px 8px;
        font-size: 13px;
    }

    .quick-range-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .range-btn {
        flex: 1 1 80px;
        min-width: 0;
    }

    .custom-range-inputs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .date-input-group {
        min-width: 0;
    }

    .custom-range-btn {
        grid-column: 1 / -1;
        min-width: 0;
    }

    .button-group .btn {
        min-width: 0;
        flex: 1 1 140px;
    }
}

@media (max-width: 600px) {
    .form-row.reset-controls {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .reset-controls > .form-group {
        grid-column: 1;
    }
}

@media (max-width: 360px) {
    .custom-range-inputs {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 768px) {
    .message {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
    }

    .toolbar-danger {
        margin-left: 0;
        width: 100%;
    }

    .toolbar-danger .btn {
        width: 100%;
    }
}

/* ============================================================================
   UNIFIED MULTI-TARGET VISUAL SYSTEM & MOBILE-FIRST OPTIMIZATION
   ============================================================================ */

:root {
    --viz-may-soi: #257de0;
    --viz-cong-tu: #f47230;
    --viz-track: #eef2f6;
    --viz-grid: #e2e8f0;
    --viz-ink: #0f172a;
    --viz-muted: #64748b;
}

.segmented-control {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px;
    background: #eef2f6;
    border: 1px solid #dce3ec;
    border-radius: 9px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.segmented-control::-webkit-scrollbar {
    display: none;
}

.seg-pill {
    min-height: 36px;
    padding: 6px 13px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.seg-pill:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.78);
}

.seg-pill:active {
    transform: scale(0.98);
}

.seg-pill.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.16);
}

.seg-pill:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 2px;
}

/* Home section headers & breakdown */
.section-header-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

#home-tab .section-header-row .dashboard-section-title,
.section-header-row .dashboard-section-title {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    margin-bottom: 0;
}

.section-period-meta {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--viz-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.home-breakdown-wrap:empty {
    display: none;
}

.home-breakdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin: 14px 0 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: #475569;
}

.home-breakdown-hint {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--viz-muted);
}

/* DataViz: Legend, Meter List & Grouped Horizontal Bars */
.viz-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
}

.viz-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.viz-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.viz-swatch.may-soi {
    background: var(--viz-may-soi);
}

.viz-swatch.cong-tu {
    background: var(--viz-cong-tu);
}

.viz-meter-list {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    overflow: hidden;
}

.viz-meter-item + .viz-meter-item {
    border-top: 1px solid #f1f5f9;
}

.viz-meter-toggle {
    width: 100%;
    border: none;
    background: transparent;
    padding: 11px 13px;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 7px;
    transition: background-color 0.15s ease;
}

.viz-meter-toggle:hover {
    background: #f8fafc;
}

.viz-meter-toggle:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: -2px;
}

.viz-meter-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.viz-meter-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--primary-dark);
}

.viz-meter-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    line-height: 1;
    font-size: 13px;
    color: var(--primary-light);
    transition: transform 0.18s ease;
    flex-shrink: 0;
}

.viz-meter-item.is-open .viz-meter-chevron {
    transform: rotate(90deg);
}

.viz-meter-nums {
    display: inline-flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    color: var(--viz-ink);
}

.viz-num-pair {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.viz-num-label {
    font-size: 11.5px;
    color: var(--viz-muted);
    font-weight: 500;
}

.viz-num-val {
    font-weight: 700;
    color: var(--viz-ink);
}

.viz-empty-pill {
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    font-style: italic;
}

.viz-bar-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    border-left: 1px solid #cbd5e1;
    padding-left: 0;
}

.viz-bar-track {
    width: 100%;
    height: 7px;
    background: var(--viz-track);
    border-radius: 0 4px 4px 0;
    overflow: hidden;
}

.viz-bar-fill {
    height: 100%;
    border-radius: 0 4px 4px 0;
    transition: width 0.3s ease;
}

.viz-bar-fill.may-soi {
    background: var(--viz-may-soi);
}

.viz-bar-fill.cong-tu {
    background: var(--viz-cong-tu);
}

.viz-meter-sub {
    font-size: 11.5px;
    color: var(--viz-muted);
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
}

.viz-station-panel {
    display: none;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 10px 13px 12px;
}

.viz-meter-item.is-open .viz-station-panel {
    display: block;
}

.viz-station-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.viz-station-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.viz-station-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 12.5px;
}

.viz-station-name {
    font-weight: 600;
    color: #334155;
}

.viz-station-vals {
    font-variant-numeric: tabular-nums;
    color: var(--viz-ink);
    font-weight: 600;
    display: inline-flex;
    gap: 10px;
}

.viz-station-bars {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-left: 1px solid #cbd5e1;
}

.viz-station-bars .viz-bar-track {
    height: 5px;
}

/* Report Chart & Collapsible Target Accordions in Summary Tab */
.viz-chart-card {
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 16px;
}

.viz-chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.viz-chart-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-dark);
}

.viz-grouped-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.viz-grouped-row {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.viz-grouped-label {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
}

.viz-grouped-sub {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--viz-muted);
}

.viz-grouped-tracks {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-left: 1px solid #cbd5e1;
    padding: 2px 0;
}

.viz-track-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.viz-track-line .viz-bar-track {
    height: 11px;
}

.viz-bar-readout {
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--viz-ink);
    min-width: 56px;
    text-align: right;
}

.report-accordions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.report-target-accordion {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    overflow: hidden;
}

.report-target-toggle {
    width: 100%;
    border: none;
    background: #f8fafc;
    padding: 12px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    text-align: left;
    transition: background-color 0.15s ease;
}

.report-target-toggle:hover {
    background: #f1f5f9;
}

.report-target-left {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--primary-dark);
}

.report-target-summary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    color: #334155;
    font-weight: 600;
}

.report-target-body {
    display: none;
    padding: 12px 14px 14px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
}

.report-target-accordion.is-open .report-target-body {
    display: block;
}

.report-target-accordion.is-open .viz-meter-chevron {
    transform: rotate(90deg);
}

/* Unified Table Scroll */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
}

/* Unified Input Tab (All Targets on One Flow, No Target Tabs) */
.input-unified-bar {
    grid-column: 1 / -1;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.input-date-group {
    flex: 1 1 280px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-date-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.input-date-row .form-control {
    flex: 1 1 160px;
    min-width: 0;
}

.input-quick-dates {
    display: inline-flex;
    gap: 6px;
    flex-shrink: 0;
}

.quick-date-btn {
    min-height: 40px;
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.quick-date-btn:hover {
    background: #eff6ff;
    border-color: var(--primary-light);
}

.input-coverage-wrap {
    display: flex;
    align-items: center;
}

.input-coverage-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 11px;
    border-radius: 999px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: var(--primary-dark);
    font-size: 12.5px;
    font-weight: 700;
}

.context-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    margin: 0;
}

.inline-hint {
    grid-column: 1 / -1;
    margin: 0;
    padding: 9px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid var(--warning);
    border-radius: 6px;
    color: #475569;
    font-size: 13px;
    line-height: 1.45;
}

.input-targets-stack {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-target-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.input-target-card.is-dirty {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

.input-target-head {
    width: 100%;
    border: none;
    background: #f8fafc;
    padding: 12px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-align: left;
}

.input-target-head:hover {
    background: #f1f5f9;
}

.input-target-head-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.input-target-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-dark);
}

.input-target-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.input-target-badge.is-saved {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.input-target-badge.is-edited {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

.accordion-chevron {
    font-size: 14px;
    color: #64748b;
    transition: transform 0.18s ease;
}

.input-target-card:not(.is-open) .input-target-body {
    display: none;
}

.input-target-card:not(.is-open) .accordion-chevron {
    transform: rotate(-90deg);
}

.input-target-body {
    padding: 14px;
    border-top: 1px solid #e2e8f0;
}

.input-stations-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.input-stations-grid > .form-section-other,
.input-stations-grid > .form-section.is-single-station {
    grid-column: 1 / -1;
}

.input-stations-grid > .form-section {
    margin: 0;
}

.field-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 5px;
}

.field-label-row label {
    margin-bottom: 0;
}

.field-delta-badge {
    font-size: 11.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #059669;
    white-space: nowrap;
}

.field-delta-badge.is-warn {
    color: #dc2626;
}

.field-delta-badge.is-neutral {
    color: #64748b;
    font-weight: 600;
}

/* Summary Tab: Single Period Toolbar & Report Stage */
.report-toolbar {
    padding: 12px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.custom-range-bar {
    padding-top: 10px;
    border-top: 1px dashed #cbd5e1;
}

.report-stage {
    background: #ffffff;
}

.report-stage > .main-card-body > .dashboard-empty {
    margin: 18px 20px;
}

.summary-meta-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 20px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
    color: #475569;
}

.summary-meta-strip strong {
    color: var(--viz-ink);
}

.report-section-pad {
    padding: 16px 20px 20px;
}

.report-section-pad .summary-subheading:first-child {
    border-top: none;
    padding-top: 0;
}

/* Admin tab: flat hairline-divided layout + per-target rows */
.admin-system-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    padding: 0;
}

.admin-split-col {
    padding: 18px 20px;
}

.admin-split-col + .admin-split-col {
    border-left: 1px solid #e2e8f0;
}

.admin-target-body {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.admin-section {
    padding: 18px 20px;
}

.admin-section + .admin-section {
    border-top: 1px solid #e2e8f0;
}

.admin-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.admin-section-title {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-dark);
}

.admin-section-desc {
    margin: 0 0 12px 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
}

.admin-section-head .admin-section-desc {
    margin-bottom: 0;
}

.admin-sheet-note {
    font-size: 11.5px;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 2px 8px;
    border-radius: 6px;
}

.admin-target-list {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #ffffff;
}

.admin-target-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
}

.admin-target-row + .admin-target-row {
    border-top: 1px solid #f1f5f9;
}

.admin-target-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.admin-target-title-line {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-target-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-dark);
}

.admin-target-range {
    font-size: 12.5px;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}

.admin-target-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-sm {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 13px;
}

.reset-note {
    margin: 0;
    padding: 9px 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 3px solid var(--danger);
    border-radius: 6px;
    color: #991b1b;
    font-size: 13px;
    line-height: 1.5;
}

.admin-btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.target-group-heading {
    margin: 14px 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-dark);
}

.target-group-heading:first-child {
    margin-top: 0;
}

@media (max-width: 768px) {
    .input-stations-grid,
    .admin-system-split {
        grid-template-columns: minmax(0, 1fr);
    }

    .input-target-body {
        padding: 12px;
    }

    .admin-split-col {
        padding: 14px;
    }

    .admin-split-col + .admin-split-col {
        border-left: none;
        border-top: 1px solid #e2e8f0;
    }

    .admin-section {
        padding: 14px;
    }

    .report-toolbar {
        padding: 10px 14px;
    }

    .summary-meta-strip {
        padding: 10px 14px;
    }

    .report-section-pad {
        padding: 12px 14px 16px;
    }

    .report-stage > .main-card-body > .dashboard-empty {
        margin: 12px 14px;
    }

    .viz-grouped-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
    }

    .viz-grouped-label {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 8px;
    }
}

@media (max-width: 640px) {
    .report-period-scroll {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        width: 100%;
        overflow: visible;
    }

    .report-period-scroll .seg-pill {
        width: 100%;
        padding: 7px 6px;
        font-size: 12.5px;
        text-align: center;
    }

    .report-period-scroll .seg-pill:nth-child(-n+3) {
        grid-column: span 2;
    }

    .report-period-scroll .seg-pill:nth-child(n+4) {
        grid-column: span 3;
    }

    .input-action-bar {
        position: sticky;
        bottom: 8px;
        z-index: 40;
        padding: 8px;
        background: rgba(255, 255, 255, 0.94);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
        margin-top: 4px;
    }

    .admin-target-row {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-target-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .viz-meter-toggle {
        padding: 10px 11px;
    }

    .viz-meter-nums {
        gap: 8px;
        font-size: 12.5px;
    }
}


