:root {
    --orange: #f56600;
    --orange-dark: #d94f00;
    --orange-soft: #fff3e8;
    --green: #16a34a;
    --blue: #3977d5;
    --purple: #7652c7;
    --red: #dc2626;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --surface: #ffffff;
    --background: #f6f8fb;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
    --radius: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--background);
    font-size: 14px;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* Authentication */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background:
        radial-gradient(circle at 15% 15%, rgba(245, 102, 0, .11), transparent 26%),
        radial-gradient(circle at 85% 88%, rgba(22, 163, 74, .08), transparent 22%),
        #fffaf5;
}
.auth-card {
    width: min(100%, 430px);
    padding: 30px;
    border: 1px solid #edf0f4;
    border-top: 4px solid var(--orange);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .12);
    overflow: hidden;
}
.auth-card-wide { width: min(100%, 500px); }
.auth-logo-wrap {
    width: 190px;
    height: 92px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.auth-logo {
    display: block;
    width: 180px;
    max-width: 180px;
    height: 86px;
    max-height: 86px;
    object-fit: contain;
}
.auth-card h1 { margin: 4px 0 8px; text-align: center; font-size: 27px; }
.auth-lead { margin: 0 0 22px; color: var(--muted); text-align: center; line-height: 1.6; }
.auth-footer { margin-top: 18px; text-align: center; color: var(--muted); }
.auth-footer a { color: var(--orange-dark); font-weight: 700; text-decoration: none; }
.auth-footer-muted { margin-top: 8px; font-size: 12px; }

/* Layout */
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: 244px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid var(--line);
    transition: transform .25s ease;
}
.sidebar-brand {
    min-height: 118px;
    padding: 12px 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f1f5f9;
    overflow: hidden;
}
.brand-link {
    width: 100%;
    height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.sidebar-logo {
    display: block;
    width: 176px;
    max-width: 100%;
    height: 84px;
    max-height: 84px;
    object-fit: contain;
}
.sidebar-close { display: none !important; position: absolute; right: 12px; top: 12px; }
.side-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section {
    display: block;
    padding: 12px 12px 8px;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .11em;
    text-transform: uppercase;
}
.nav-link {
    min-height: 46px;
    margin: 4px 0;
    padding: 0 13px;
    display: flex;
    align-items: center;
    gap: 11px;
    border-radius: 11px;
    color: #334155;
    text-decoration: none;
    font-weight: 650;
}
.nav-link:hover { background: #fff7ed; color: var(--orange-dark); }
.nav-link.active {
    background: linear-gradient(135deg, #fb7b18, #ef5d00);
    color: #fff;
    box-shadow: 0 8px 20px rgba(245, 102, 0, .23);
}
.nav-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    font-weight: 900;
}
.sidebar-footer { padding: 14px; border-top: 1px solid var(--line); }
.profile-mini { margin-bottom: 12px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.profile-mini div { min-width: 0; }
.profile-mini strong, .profile-mini small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.profile-mini small { color: var(--muted); margin-top: 2px; }
.user-avatar {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--orange-soft);
    color: var(--orange-dark);
    font-weight: 800;
}
.main-shell { width: calc(100% - 244px); min-width: 0; margin-left: 244px; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 86px;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    gap: 18px;
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.sidebar-toggle { display: none !important; }
.icon-button {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: #f8fafc;
    color: #334155;
    font-size: 22px;
}
.welcome-copy { min-width: 0; flex: 1; }
.welcome-copy strong { display: block; font-size: 20px; }
.welcome-copy span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-user strong, .topbar-user small { display: block; }
.topbar-user small { margin-top: 2px; color: var(--muted); }
.content-area { padding: 24px 26px 42px; }

/* Headings and panels */
.page-heading {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}
.page-heading h1 { margin: 5px 0 5px; font-size: clamp(25px, 2.4vw, 34px); letter-spacing: -.03em; }
.page-heading p { margin: 0; color: var(--muted); line-height: 1.55; }
.eyebrow { color: var(--orange); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.heading-with-actions { align-items: center; }
.panel {
    min-width: 0;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 18px; }
.panel-head {
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head small { display: block; margin-top: 4px; color: var(--muted); }
.form-panel { margin-bottom: 20px; }
.report-panel { margin-top: 20px; }
.dashboard-grid {
    margin-top: 18px;
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 18px;
}
.panel-span-2 { min-width: 0; }

/* KPI cards - designed to keep large amounts inside */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(260px, 1fr));
    gap: 16px;
}
.metric-card {
    min-width: 0;
    min-height: 112px;
    padding: 17px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: #fff;
    box-shadow: var(--shadow);
}
.metric-icon {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    color: #fff;
    font-size: 25px;
    font-weight: 800;
}
.metric-icon.green { background: var(--green); }
.metric-icon.orange { background: #ff6b00; }
.metric-icon.blue { background: var(--blue); }
.metric-icon.purple { background: var(--purple); }
.metric-copy {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    container-type: inline-size;
}
.metric-copy small { display: block; color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-value {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 5px 0 4px;
    color: #169447;
    font-size: clamp(14px, 7cqi, 24px);
    line-height: 1.1;
    letter-spacing: -.045em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    font-variant-numeric: tabular-nums;
}
.metric-card:nth-child(2) .metric-value { color: #e85d04; }
.metric-card:nth-child(3) .metric-value { color: var(--blue); }
.metric-card:nth-child(4) .metric-value { color: var(--purple); }
.metric-copy > span { display: block; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Forms */
.stack-form { display: grid; gap: 14px; }
.form-grid { display: grid; gap: 16px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-column { grid-column: 1 / -1; }
label { color: #334155; font-size: 12px; font-weight: 700; }
label small { display: block; margin-top: 6px; color: var(--muted); font-weight: 400; line-height: 1.45; }
input, select, textarea {
    width: 100%;
    min-height: 43px;
    margin-top: 7px;
    padding: 10px 12px;
    border: 1px solid #cfd8e3;
    border-radius: 9px;
    outline: none;
    background: #fff;
    color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(245, 102, 0, .11);
}
input[readonly] { background: #f8fafc; color: #475569; }
.required { color: var(--red); }
.form-actions { display: flex; justify-content: flex-end; }
.date-filter {
    padding: 10px;
    display: flex;
    align-items: end;
    gap: 9px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}
.date-filter label { min-width: 135px; }
.date-filter input { min-height: 37px; margin-top: 4px; padding: 7px 9px; }

/* Buttons */
.btn {
    min-height: 40px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: 9px;
    text-decoration: none;
    font-weight: 750;
    white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, #fb7b18, #ef5d00); color: #fff; box-shadow: 0 7px 17px rgba(245, 102, 0, .18); }
.btn-primary:hover { background: var(--orange-dark); }
.btn-light { border-color: #d8e0ea; background: #fff; color: #334155; }
.btn-light:hover { background: #f8fafc; }
.btn-danger { background: #fff1f2; border-color: #fecdd3; color: #be123c; }
.btn-small { min-height: 32px; padding: 6px 9px; font-size: 11px; }
.btn-block { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 9px; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; }
table { width: 100%; min-width: 860px; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { background: #f8fafc; color: #52627a; font-size: 10px; letter-spacing: .03em; text-transform: uppercase; }
tbody tr:hover { background: #fffaf5; }
tbody tr:last-child td { border-bottom: 0; }
.empty-cell { padding: 28px; color: var(--muted); text-align: center; }
.actions-cell { display: flex; align-items: center; gap: 7px; }
.actions-cell form { margin: 0; }
code { max-width: 420px; display: inline-block; overflow: hidden; text-overflow: ellipsis; color: #475569; }

/* Charts / data visuals */
.bar-chart {
    min-height: 245px;
    padding: 20px 10px 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    gap: 16px;
    border-bottom: 1px solid #cbd5e1;
}
.bar-column { position: relative; min-width: 72px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bar-fill { width: 42px; border-radius: 8px 8px 2px 2px; }
.orange-bar { background: linear-gradient(180deg, #ff8a2c, #f56600); box-shadow: 0 7px 18px rgba(245, 102, 0, .17); }
.bar-column strong { font-size: 12px; }
.bar-column small { max-width: 95px; color: var(--muted); font-size: 9px; text-align: center; }
.bar-tooltip { position: absolute; bottom: calc(100% + 7px); display: none; padding: 6px 8px; border-radius: 7px; background: #0f172a; color: #fff; font-size: 10px; white-space: nowrap; }
.bar-column:hover .bar-tooltip { display: block; }
.horizontal-scroll { overflow-x: auto; }
.category-list { display: grid; gap: 17px; }
.category-label { margin-bottom: 7px; display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.category-label strong { font-size: 11px; }
.progress-track { height: 8px; overflow: hidden; border-radius: 99px; background: #edf2f7; }
.progress-track span { height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, #22c55e, #16a34a); }
.category-bars { min-height: 245px; display: flex; align-items: end; justify-content: space-around; gap: 12px; overflow-x: auto; }
.category-bar-item { min-width: 100px; display: flex; flex-direction: column; align-items: center; gap: 7px; text-align: center; }
.category-bar { width: 38px; min-height: 4px; border-radius: 7px 7px 2px 2px; background: linear-gradient(180deg, #35b45b, #179043); }
.category-bar-item strong { font-size: 11px; }
.category-bar-item small { color: var(--muted); font-size: 9px; }
.ranking-list { margin: 0; padding: 0; display: grid; gap: 9px; list-style: none; }
.ranking-list li { padding: 10px 0; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 9px; border-bottom: 1px solid #f1f5f9; }
.ranking-list li:last-child { border-bottom: 0; }
.ranking-list li span:nth-child(2) { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ranking-list strong { font-size: 11px; }
.rank-number { width: 25px; height: 25px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--orange-soft); color: var(--orange-dark); font-weight: 800; }
.empty-state { padding: 26px; color: var(--muted); text-align: center; }

/* Alerts, badges and extras */
.alert { margin-bottom: 14px; padding: 12px 14px; border: 1px solid transparent; border-radius: 10px; line-height: 1.5; }
.alert-success { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.alert-danger { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.alert-warning { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.alert-info { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }
.badge { padding: 4px 8px; display: inline-flex; border-radius: 99px; font-size: 10px; font-weight: 750; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #e2e8f0; color: #475569; }
.info-box { padding: 14px 16px; border: 1px solid #fed7aa; border-radius: 11px; background: #fff7ed; color: #9a3412; }
.info-box ul { margin: 8px 0 0 18px; padding: 0; line-height: 1.7; }
.compact-list p { margin: 7px 0 18px; color: var(--muted); line-height: 1.6; }
.detail-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-banner strong, .detail-banner small { display: block; }
.detail-banner small { margin-top: 4px; color: var(--muted); }
.user-actions { min-width: 220px; }
.user-actions summary { cursor: pointer; color: var(--orange-dark); font-weight: 750; }
.user-actions[open] { padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.user-actions form + form { margin-top: 10px; }
.compact-form { gap: 8px; }
.compact-form input, .compact-form select { min-height: 35px; padding: 6px 8px; }
.sidebar-overlay { display: none; }

/* Responsive */
@media (max-width: 1380px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(280px, 1fr)); }
}

@media (max-width: 980px) {
    .sidebar { transform: translateX(-100%); box-shadow: 14px 0 40px rgba(15, 23, 42, .17); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: inline-flex !important; align-items: center; justify-content: center; }
    .sidebar-toggle { display: inline-flex !important; align-items: center; justify-content: center; }
    .sidebar-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .42); }
    .sidebar-overlay.show { display: block; }
    .main-shell { width: 100%; margin-left: 0; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .topbar-user { display: none; }
}

@media (max-width: 720px) {
    .content-area { padding: 18px 14px 34px; }
    .topbar { min-height: 72px; padding: 10px 14px; }
    .welcome-copy strong { font-size: 16px; }
    .welcome-copy span { display: none; }
    .page-heading, .heading-with-actions { align-items: stretch; flex-direction: column; }
    .date-filter { width: 100%; align-items: stretch; flex-direction: column; }
    .date-filter label { min-width: 0; }
    .metric-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 104px; }
    .two-columns { grid-template-columns: 1fr; }
    .full-column { grid-column: auto; }
    .panel { padding: 16px; border-radius: 13px; }
    .panel-head { align-items: flex-start; flex-direction: column; }
    .panel-head .btn { width: 100%; }
    .button-row { flex-direction: column; }
    .button-row .btn { width: 100%; }
    .form-actions .btn { width: 100%; }
    .auth-card { padding: 23px 18px; }
    .auth-logo-wrap { width: 160px; height: 82px; }
    .auth-logo { width: 152px; max-width: 152px; height: 75px; max-height: 75px; }
}
