:root {
    --bg: #eef3f8;
    --panel: #ffffff;
    --text: #172033;
    --muted: #697586;
    --line: #dde5f0;
    --primary: #1565c0;
    --primary-dark: #0f4f97;
    --green: #15803d;
    --red: #b42318;
    --shadow: 0 10px 30px rgba(28, 39, 64, 0.07);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
    width: min(1500px, calc(100% - 32px));
    margin: 0 auto;
    padding: 18px 0 32px;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 8px 0 16px;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.unidu-logo {
    width: clamp(190px, 24vw, 330px);
    height: auto;
    flex: 0 0 auto;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(1.45rem, 2.2vw, 2.1rem);
    font-weight: 820;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 0;
    font-size: 1.05rem;
    font-weight: 800;
}

.refresh-pill {
    flex: 0 0 auto;
    padding: 8px 12px;
    color: var(--primary-dark);
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(21, 101, 192, 0.16);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logout-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 0.82rem;
}

.period-notice {
    margin-bottom: 14px;
    padding: 10px 12px;
    color: #164e63;
    background: #ecfeff;
    border: 1px solid #a5f3fc;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 750;
}

.period-notice-warning {
    color: #854d0e;
    background: #fffbeb;
    border-color: #fde68a;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.metric-card,
.panel {
    background: var(--panel);
    border: 1px solid rgba(221, 229, 240, 0.82);
    box-shadow: var(--shadow);
}

.metric-card {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 8px;
}

.metric-icon {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    background: #eef5ff;
    border-radius: 8px;
    color: var(--primary);
    font-size: 1rem;
}

.metric-card p {
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 750;
}

.metric-card strong {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 0.92rem;
}

.panel {
    border-radius: 8px;
    padding: 16px;
}

.filters.panel,
.panel:has(.filters) {
    box-shadow: 0 8px 24px rgba(28, 39, 64, 0.06);
}

.filters {
    display: grid;
    grid-template-columns: 1fr 180px 180px minmax(180px, 240px) auto;
    gap: 14px;
    align-items: end;
}

.filters label {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.range-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn {
    border-radius: 8px;
    font-weight: 760;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.refresh-button {
    min-height: 38px;
}

.form-control,
.form-select {
    border-radius: 8px;
}

.form-control:disabled {
    background: #f1f5f9;
    color: #94a3b8;
}

.chart-grid,
.table-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.wide {
    grid-column: 1 / -1;
}

.chart-panel {
    min-height: 270px;
}

.panel-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.subtle {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 650;
}

.empty-state {
    display: grid;
    min-height: 170px;
    place-items: center;
    color: var(--muted);
    background: #f8fafc;
    border: 1px dashed var(--line);
    border-radius: 8px;
    font-weight: 700;
}

.table {
    margin-bottom: 0;
    min-width: 720px;
}

.table thead th {
    color: var(--muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.table tbody td {
    font-size: 0.92rem;
}

.badge-ok {
    color: var(--green);
    background: rgba(21, 128, 61, 0.1);
}

.badge-error {
    color: var(--red);
    background: rgba(180, 35, 24, 0.1);
}

@media (max-width: 1280px) {
    .status-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .range-buttons {
        grid-column: 1 / -1;
    }
}

@media (max-width: 840px) {
    .app-shell {
        width: min(100% - 20px, 1480px);
        padding-top: 14px;
    }

    .hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .brand-block {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .unidu-logo {
        width: min(100%, 280px);
    }

    .top-actions {
        width: 100%;
        justify-content: space-between;
    }

    .status-grid,
    .chart-grid,
    .table-grid,
    .filters {
        grid-template-columns: 1fr;
    }

    .range-buttons {
        grid-column: auto;
    }

    .panel {
        padding: 14px;
    }
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    background:
        radial-gradient(circle at 20% 10%, rgba(21, 101, 192, 0.12), transparent 28%),
        radial-gradient(circle at 90% 90%, rgba(21, 128, 61, 0.12), transparent 28%),
        var(--bg);
}

.login-shell {
    width: min(100% - 32px, 430px);
}

.login-panel {
    padding: 28px;
    background: var(--panel);
    border: 1px solid rgba(221, 229, 240, 0.9);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-brand {
    display: grid;
    gap: 16px;
    margin-bottom: 22px;
}

.login-brand h1 {
    font-size: 1.6rem;
}

.login-logo {
    width: min(100%, 320px);
    height: auto;
}

.login-form {
    display: grid;
    gap: 14px;
}

.login-form label {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 800;
}

.login-form .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
}

.secret-input {
    -webkit-text-security: disc;
}
