/* Google Fonts loaded via <link> in HTML head for better performance */

:root {
    /* ── Brand Colors ────────────────────────── */
    --primary: #4C12A1;
    --primary-light: #6B3FA0;
    --primary-dark: #3A0D7A;
    --primary-10: rgba(76, 18, 161, 0.10);
    --primary-20: rgba(76, 18, 161, 0.20);
    --accent: #5BC2E7;
    --accent-light: #8AD4EF;
    --accent-10: rgba(91, 194, 231, 0.10);
    --gradient: linear-gradient(135deg, #4C12A1, #5BC2E7);
    --gradient-subtle: linear-gradient(135deg, rgba(76,18,161,0.08), rgba(91,194,231,0.08));
    --navy: #1E1645;
    --navy-light: #2D2260;
    --orange: #E05A29;
    --orange-light: #F4845F;

    /* ── Semantic ─────────────────────────────── */
    --success: #22c55e;
    --success-bg: rgba(34,197,94,0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239,68,68,0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245,158,11,0.1);

    /* ── Surfaces ─────────────────────────────── */
    --bg: #f8f7fc;
    --card: #ffffff;
    --text: #1E1645;
    --text-muted: #6b7280;
    --border: #e9e5f5;
    --border-light: rgba(76, 18, 161, 0.08);

    /* ── Layout ───────────────────────────────── */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* ── Shadows ──────────────────────────────── */
    --shadow-sm: 0 1px 3px rgba(30,22,69,0.06);
    --shadow-md: 0 4px 12px rgba(30,22,69,0.08), 0 1px 3px rgba(30,22,69,0.04);
    --shadow-lg: 0 8px 30px rgba(30,22,69,0.12), 0 2px 8px rgba(30,22,69,0.06);
    --shadow-glow: 0 4px 20px rgba(76,18,161,0.20);

    /* ── Transitions ──────────────────────────── */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 150ms var(--ease);
    --transition-base: 250ms var(--ease);
}

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

html { scroll-behavior: smooth; }
body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
::selection { background: rgba(76,18,161,.15); color: var(--navy); }

/* ── Animations ────────────────────────────────── */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-in {
    animation: fadeSlideUp 0.5s var(--ease) both;
}

/* ── Header ─────────────────────────────────────── */
.header {
    background: linear-gradient(90deg, var(--navy) 0%, #2A1B5E 100%);
    padding: 0 32px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px rgba(30,22,69,.3);
    border-bottom: 1px solid rgba(91,194,231,.08);
}
.header h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.3px;
}
.header a.home-link {
    text-decoration: none;
    color: rgba(255,255,255,.45);
    font-size: 12px;
    transition: all var(--transition-fast);
    display: flex; align-items: center;
}
.header a.home-link:hover { color: var(--accent); }
.header-controls { display: flex; gap: 14px; align-items: center; }

/* ── Controls ───────────────────────────────────── */
select, input[type="text"] {
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: 'Poppins', sans-serif;
    background: var(--card);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
select:hover, input[type="text"]:hover {
    border-color: rgba(76,18,161,.2);
    background: #faf9ff;
}
select:focus, input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-10);
    background: #fff;
}

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-xl);
    font-size: 13px;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-base);
    letter-spacing: .2px;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-primary {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 2px 12px rgba(76,18,161,.25);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(76,18,161,.35); }
.btn-sm { padding: 5px 14px; font-size: 12px; }
.btn-outline {
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.15);
    color: rgba(255,255,255,.8);
    backdrop-filter: blur(4px);
    font-size: 12px;
}
.btn-outline:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.3); color: #fff; }

/* ── Layout ─────────────────────────────────────── */
.container { max-width: 1400px; margin: 0 auto; padding: 24px 32px; }

/* ── KPI Cards ──────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}
.kpi-card {
    background: var(--card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gradient);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .4s var(--ease);
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(76,18,161,.12);
}
.kpi-card:hover::before { transform: scaleX(1); }
.kpi-card .label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 500;
}
.kpi-card .value {
    font-family: 'Montserrat', sans-serif;
    font-size: 32px;
    font-weight: 700;
    margin-top: 4px;
    color: var(--navy);
}
.kpi-card .value.success { color: var(--success); }
.kpi-card .value.danger { color: var(--danger); }

/* ── Chart Grid ─────────────────────────────────── */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.chart-card {
    background: var(--card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 24px 26px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
    position: relative;
}
.chart-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: rgba(76,18,161,.1); }
.chart-card h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 18px;
    color: var(--navy);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}
.chart-card h3::before {
    content: '';
    width: 4px; height: 16px;
    background: var(--gradient);
    border-radius: 2px;
    flex-shrink: 0;
}
/* canvas height controlled by wrapper div, not capped here */

/* ── Table section ──────────────────────────────── */
.table-section {
    background: var(--card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    animation: fadeSlideUp .5s var(--ease) both;
}
.table-section h3 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    color: var(--navy);
}
.table-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    text-align: left;
    padding: 12px 14px;
    background: rgba(30, 22, 69, 0.04);
    color: var(--navy);
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .6px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
    border-bottom: 2px solid rgba(76, 18, 161, 0.15);
}
thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid rgba(76,18,161,.04);
    transition: background var(--transition-fast);
}
tbody tr:nth-child(even) { background: rgba(76,18,161,0.015); }
tbody tr:hover { background: rgba(76,18,161,0.05); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .2px;
}
.badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.badge-synced { background: rgba(34,197,94,.1); color: #166534; }
.badge-failed { background: rgba(239,68,68,.08); color: #991b1b; }
.badge-draft { background: rgba(107,114,128,.08); color: #374151; }
.badge-submitted { background: rgba(76,18,161,.08); color: #5b21b6; }
.badge-uat { background: rgba(245,158,11,.1); color: #92400e; }
.badge-production { background: rgba(34,197,94,.1); color: #166534; }
.badge-resubmitted { background: rgba(91,194,231,.1); color: #155e75; }

/* ── Pagination ─────────────────────────────────── */
.pagination {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin-top: 16px;
}
.pagination span { font-size: 13px; color: var(--text-muted); font-weight: 400; }
.pagination .btn { background: var(--gradient); color: #fff; font-size: 12px; padding: 6px 16px; box-shadow: 0 2px 8px rgba(76,18,161,.2); }

/* ── Loading ────────────────────────────────────── */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 13px;
}
.loading-skeleton {
    background: linear-gradient(90deg, rgba(76,18,161,.04) 25%, rgba(91,194,231,.06) 50%, rgba(76,18,161,.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s infinite;
    border-radius: var(--radius-sm);
}

/* ── Login Page ─────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy) 0%, var(--primary) 50%, var(--accent) 100%);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: rgba(255,255,255,.04);
    border-radius: 50%;
    top: -200px; right: -200px;
    animation: pulse 6s ease-in-out infinite;
}
.login-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: rgba(255,255,255,.03);
    border-radius: 50%;
    bottom: -100px; left: -100px;
    animation: pulse 8s ease-in-out infinite;
}
.login-card {
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(24px);
    border-radius: var(--radius-xl);
    padding: 52px 44px;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 24px 80px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.1);
    text-align: center;
    position: relative;
    z-index: 1;
}
.login-card img { height: 52px; margin-bottom: 28px; }
.login-card h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 8px;
}
.login-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }
.login-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 32px;
    background: var(--gradient);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(76,18,161,.3);
}
.login-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.login-btn svg { width: 20px; height: 20px; }

/* ── Home Page ──────────────────────────────────── */
.home-container { max-width: 900px; margin: 0 auto; padding: 48px 32px; }
.welcome { margin-bottom: 32px; }
.welcome h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: var(--navy);
}
.welcome p { color: var(--text-muted); margin-top: 4px; font-size: 15px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.report-card {
    background: var(--card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 28px;
    text-decoration: none;
    color: var(--text);
    transition: all var(--transition-base);
    display: block;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid transparent;
    position: relative;
    overflow: hidden;
}
.report-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--gradient-subtle);
    opacity: 0;
    transition: opacity var(--transition-base);
}
.report-card:hover {
    border-left-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.report-card:hover::after { opacity: 1; }
.report-card h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--navy);
    position: relative;
    z-index: 1;
}
.report-card p { font-size: 13px; color: var(--text-muted); position: relative; z-index: 1; }
.admin-card { border-left: 4px solid var(--primary); }

/* ── Access Denied ──────────────────────────────── */
.denied-container {
    max-width: 500px;
    margin: 120px auto;
    text-align: center;
    padding: 48px 32px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.denied-container h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 22px;
    color: var(--navy);
    margin-bottom: 12px;
}
.denied-container p { color: var(--text-muted); margin-bottom: 24px; }

/* ── Focus ──────────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Print ─────────────────────────────────────── */
@media print {
    .header, .sidebar, .btn, .btn-primary, .btn-outline,
    .pagination, .table-controls, .filter-bar, .filter-row { display: none !important; }
    .app-layout { display: block !important; }
    .main-content { padding: 0 !important; overflow: visible !important; }
    .kpi-card, .kpi-box, .chart-card, .table-section { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
    body { background: #fff; color: #000; font-size: 11px; }
    .page-title { font-size: 18px; }
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 1200px) {
    .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .container { padding: 16px; }
    .header { padding: 0 16px; }
    .header h1 { font-size: 15px; }
    .chart-grid { grid-template-columns: 1fr; }
    .table-controls { flex-direction: column; }
    .home-container { padding: 24px 16px; }
    .report-grid { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    /* iOS zoom fix — inputs below 16px trigger auto-zoom */
    select, input[type="text"] { font-size: 16px; }
    /* Touch target minimums */
    .btn { min-height: 44px; }
    .btn-sm { min-height: 44px; padding: 10px 16px; }
    .pagination .btn { min-height: 44px; min-width: 44px; }
}
@media (max-width: 480px) {
    .container { padding: 12px 10px; }
    .header { padding: 0 10px; }
    .header h1 { font-size: 13px; }
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-card .value { font-size: 24px; }
}
