:root {
    --bg: #f6fbf7;
    --panel: #ffffff;
    --stroke: #e3efe6;
    --accent: #1b9a6d;
    --accent-soft: #7cc9a5;
    --text: #0f2d2a;
    --muted: #5f7b76;
    --shadow: 0 12px 40px rgba(15, 45, 42, 0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Manrope", "Segoe UI", Arial, sans-serif;
    background:
        radial-gradient(circle at 20% 20%, rgba(124,201,165,0.14), transparent 32%),
        radial-gradient(circle at 80% 15%, rgba(27,154,109,0.1), transparent 28%),
        linear-gradient(180deg, #f7fbf9 0%, #eef6f2 100%);
    color: var(--text);
}
main { padding: 24px; }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    justify-items: center;
    padding: 32px 16px;
}
.auth-card {
    width: min(560px, 100%);
    margin: 0 auto;
    background: #ffffff;
    border: 1px solid var(--stroke);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 16px 48px rgba(15,45,42,0.1);
    animation: float-in 260ms ease-out;
}
.auth-card .btn { width: 100%; }
.auth-card input { font-size: 18px; height: 52px; }
.auth-header { margin-bottom: 18px; }
.auth-header h1 { margin: 10px 0 4px; font-size: 30px; }
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.loading-overlay.show { display: flex; }
.loading-card {
    background: #0f172a;
    color: #e2e8f0;
    padding: 18px 20px;
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
}
.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #22c55e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loading-text { font-weight: 700; letter-spacing: 0.2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef8f2;
    color: var(--accent);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.2px;
}
.brand-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 14px;
    background: #f3fbf6;
    border: 1px solid var(--stroke);
    box-shadow: 0 6px 18px rgba(27,154,109,0.08);
    animation: pulse-in 400ms ease-out;
}
.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(120deg, var(--accent), #17835d);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; color: var(--text); font-size: 14px; letter-spacing: 0.2px; }
.brand-tag { font-size: 12px; color: var(--muted); }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--stroke);
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { font-weight: 800; letter-spacing: 0.5px; color: var(--text); }
.session { display: flex; gap: 12px; align-items: center; color: var(--muted); }

.panel {
    background: var(--panel);
    border: 1px solid var(--stroke);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--shadow);
}
h1, h2 { margin-top: 0; font-weight: 800; letter-spacing: -0.4px; }

.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
label { color: var(--muted); display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
input, select {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--stroke);
    background: #fdfefe;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(27,154,109,0.12);
}

.btn {
    background: linear-gradient(120deg, var(--accent), #17835d);
    border: none;
    color: #ffffff;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.2px;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 8px 24px rgba(27,154,109,0.25);
}
.btn.small { padding: 8px 12px; font-size: 13px; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(27,154,109,0.3); }

.alert {
    background: rgba(255,134,115,0.15);
    border: 1px solid rgba(255,134,115,0.4);
    color: #c05b47;
    padding: 12px 14px;
    border-radius: 10px;
}

.table { display: flex; flex-direction: column; gap: 12px; }
.card {
    border: 1px solid var(--stroke);
    border-radius: 12px;
    padding: 14px;
    background: #fdfefe;
    box-shadow: 0 4px 16px rgba(15,45,42,0.06);
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.role-name { font-weight: 700; color: var(--text); }

.permissions { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: #f7fbf9;
    color: var(--muted);
    font-size: 13px;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.chip:hover { border-color: var(--accent-soft); background: #eef8f2; }
.chip input { accent-color: var(--accent); }

table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text);
}
th, td {
    padding: 12px;
    border-bottom: 1px solid var(--stroke);
}
th { text-align: left; color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: 0.2px; }

.inline-form { display: flex; gap: 8px; align-items: center; }

.topnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0 18px;
    position: sticky;
    top: 0;
    background: linear-gradient(180deg, rgba(247,251,249,0.96), rgba(238,246,242,0.96));
    backdrop-filter: blur(10px);
    z-index: 12;
}
.nav-left { display: flex; align-items: center; gap: 10px; }
.topnav .brand-mark { width: 36px; height: 36px; }
.topnav .brand-name { font-size: 16px; }
.topnav .brand-tag { font-size: 12px; color: var(--muted); }
.icon-btn {
    border: 1px solid var(--stroke);
    background: #ffffff;
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 800;
}

.layout {
    display: block;
    position: relative;
}
.sidebar {
    background: #ffffff;
    border: 1px solid var(--stroke);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 14px 36px rgba(15,45,42,0.08);
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    height: 100dvh;
    max-width: 360px;
    width: 85vw;
    transform: translateX(110%);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 20;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; }
.menu { display: flex; flex-direction: column; margin-top: 16px; }
.sidebar nav {
    flex: 1;
    overflow-y: auto;
}
.menu-item {
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}
.menu-item:hover { background: #eef8f2; }
.menu-item.active { background: #e4f3ec; color: var(--accent); }
.menu-item.toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
    background: transparent;
    width: 100%;
    cursor: pointer;
}
.chevron { font-size: 12px; color: var(--muted); transition: transform 0.2s ease; }
.menu-item.toggle.open .chevron { transform: rotate(180deg); }
.submenu {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.2s ease;
    display: flex;
    flex-direction: column;
    padding-left: 8px;
}
.submenu.open { max-height: 400px; }
.menu-subitem {
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    background: #f7fbf9;
}
.menu-subitem:hover { background: #eef8f2; }

.content { display: flex; flex-direction: column; gap: 16px; }
.sidebar-footer {
    margin-top: auto;
    padding: 12px 0 16px 0;
    border-top: 1px solid var(--stroke);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.user-info { color: var(--muted); font-size: 13px; }
.user-name { color: var(--text); font-weight: 700; }
.user-info.inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}
.support-links {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 6px;
}
.support-links a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 13px;
}
.support-links img {
    width: 18px;
    height: 18px;
}
.sidebar-footer .btn {
    width: 100%;
    text-align: center;
}
.license-pill {
    margin-left: auto;
    background: #e6f1ff;
    color: #0f2d2a;
    border: 1px solid #b9d4ff;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
}
.app-footer {
    margin-top: 24px;
    padding: 12px 24px;
    background: rgba(255,255,255,0.8);
    border-top: 1px solid var(--stroke);
}
.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 15;
}
.sidebar-backdrop.show { display: block; }
.two-col {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
}
.grid-form {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.table-responsive { width: 100%; overflow-x: auto; }
.fancy-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text);
}
.fancy-table th, .fancy-table td {
    padding: 12px;
    border-bottom: 1px solid var(--stroke);
}
.fancy-table th { text-align: left; color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: 0.2px; }
.actions { display: flex; gap: 8px; align-items: center; }
.icon-btn.ghost { background: #f7fbf9; border: 1px solid var(--stroke); }
.icon-btn.danger { background: #ffe8e6; border: 1px solid #f4b3ac; color: #c74232; }
.elevate { box-shadow: 0 18px 50px rgba(15,45,42,0.08); }
.muted-note { color: var(--muted); font-size: 13px; margin: 8px 0 16px; }

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.25);
    z-index: 40;
}
.modal-backdrop.show { display: block; }
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    background: #ffffff;
    border: 1px solid var(--stroke);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    z-index: 41;
    width: min(560px, 95vw);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.modal.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    visibility: visible;
    pointer-events: auto;
}
.sidebar {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 0.6px; font-size: 12px; color: var(--muted); }
.soft { background: linear-gradient(180deg, #f8fbf9, #f4f9f6); }

.grid { display: grid; gap: 16px; grid-template-columns: 2fr 1fr; }
.sidebar.open { transform: translateX(0); box-shadow: 0 20px 50px rgba(0,0,0,0.2); }
.sidebar-backdrop { display: block; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
@media (max-width: 1100px) {
    .grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .auth-card { width: 90vw; max-width: 620px; }
}
@media (max-width: 640px) {
    body { background: linear-gradient(180deg, #f7fbf9 0%, #eef6f2 100%); }
    main { padding: 12px; }
    .auth-page { padding: 24px 18px; }
    .auth-card {
        width: 91vw;
        max-width: 540px;
        padding: 28px;
    }
    .auth-header h1 { font-size: 30px; }
    .brand-chip { padding: 14px 16px; gap: 16px; }
    .brand-name { font-size: 18px; }
    .auth-card input { height: 54px; font-size: 19px; }
    .btn { padding: 16px 16px; font-size: 18px; }
    .sidebar {
        width: 100vw;
        max-width: none;
        border-radius: 0;
        left: 0;
        right: 0;
        transform: translateX(110%);
        height: 100vh;
        height: 100dvh;
        padding-bottom: 80px;
    }
    .sidebar.open { transform: translateX(0); }
    .support-links { flex-wrap: wrap; }
}
@media (max-width: 480px) {
    .auth-page { padding: 18px 16px; }
    .auth-card {
        width: 89vw;
        max-width: 500px;
        padding: 26px;
    }
    .auth-header h1 { font-size: 28px; }
    .brand-chip { padding: 12px 14px; gap: 12px; }
    .brand-name { font-size: 16px; }
    .auth-card input { height: 52px; font-size: 18px; }
    .btn { padding: 14px 14px; font-size: 17px; }
}

.kpi-rows { display: block; padding-bottom: 6px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; width: 100%; }
.kpi-card { position: relative; padding: 14px; border: 1px solid rgba(0,0,0,0.04); border-radius: 12px; min-height: 160px; min-width: 150px; background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(244,248,246,0.9)); box-shadow: 0 12px 28px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.03); transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; }
.kpi-card.kpi-ref { min-width: 220px; }
.kpi-card.kpi-bs { min-width: 520px; }
.kpi-card__bg { position:absolute; inset:0; pointer-events:none; background:linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0)); }
.kpi-card__header { display:flex; justify-content:space-between; align-items:center; position:relative; z-index:1; }
.kpi-card__title { display:flex; gap:10px; align-items:center; font-size:15px; }
.kpi-dot { width:10px; height:10px; border-radius:50%; }
.kpi-icon { width:32px; height:32px; border-radius:10px; display:grid; place-items:center; background:linear-gradient(135deg, rgba(27,154,109,0.18), rgba(27,154,109,0.08)); font-size:14px; font-weight:800; color:#0f2d2a; box-shadow: inset 0 1px 2px rgba(0,0,0,0.04); }
.kpi-label { font-weight:700; color:var(--text); letter-spacing:0.2px; }
.kpi-values { margin-top:12px; display:grid; grid-template-columns: repeat(1, 1fr); gap:8px; position:relative; z-index:1; }
.kpi-box { padding:10px; border-radius:12px; text-align:center; }
.kpi-box.ok { background:rgba(15, 157, 88, 0.08); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.kpi-box__label { font-size:12px; color:var(--muted); }
.kpi-box__value { font-weight:800; font-size:17px; }
.kpi-progress { margin-top:10px; position:relative; z-index:1; }
.kpi-progress__bar { height:6px; background:linear-gradient(90deg, #22c55e, #16a34a); border-radius:999px; transition:width 0.4s ease; max-width:100%; }
.kpi-progress__labels { display:flex; justify-content:space-between; font-size:12px; color:var(--muted); margin-top:4px; }
.kpi-footnote { margin-top:4px; font-size:12px; color:var(--muted); text-align:right; position:relative; z-index:1; }

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(27,154,109,0.2);
  box-shadow: 0 16px 32px rgba(0,0,0,0.08), 0 3px 6px rgba(0,0,0,0.04);
}
.charts-grid { margin-top:16px; display:grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap:14px; }
.chart-card { background: linear-gradient(135deg, rgba(255,255,255,0.94), rgba(243,247,245,0.94)); border:1px solid rgba(0,0,0,0.05); border-radius:12px; box-shadow: 0 16px 34px rgba(0,0,0,0.08); padding:14px; min-height: 240px; }
.chart-title { font-weight:700; color:var(--text); margin-bottom:8px; }
.chart-card canvas { width: 100% !important; height: 200px !important; }
.footer {
    text-align: center;
    margin: 16px 0 12px;
    color: var(--muted);
    font-size: 12px;
}
/* Charts removed */

@media (max-width: 900px) {
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .kpi-card,
    .kpi-card.kpi-ref,
    .kpi-card.kpi-bs { min-width: auto !important; width: 100%; }
    .kpi-values { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}
@media (max-width: 640px) {
    .kpi-grid { grid-template-columns: repeat(1, minmax(180px, 1fr)); }
    .kpi-card { padding: 12px; }
    .kpi-card .chip { font-size: 12px; }
    .kpi-values { grid-template-columns: repeat(1, minmax(140px, 1fr)); }
    .kpi-box__value { font-size: 15px; }
    .kpi-card__header { gap: 8px; }
}

@keyframes float-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pulse-in {
    0% { transform: scale(0.96); opacity: 0; }
    60% { transform: scale(1.02); opacity: 1; }
    100% { transform: scale(1); }
}
