/* ==========================================================================
   EPCNI Portal — light theme matching epcni.co.uk
   White + EPCNI green, CRM-style dashboard with dark-teal sidebar
   ========================================================================== */

:root {
    --green: #00a651;
    --green-dark: #008c44;
    --green-light: #e6f7ee;
    --teal-900: #06322b;
    --teal-800: #0a4239;
    --teal-700: #0e5147;
    --teal-600: #116d5c;
    --teal-500: #14907c;
    --amber: #f5a623;
    --red: #e5484d;
    --cyan: #0ea5c6;
    --ink: #12211d;
    --text: #2c3b36;
    --text-muted: #6b7f78;
    --bg: #f2f6f4;
    --card: #ffffff;
    --border: #e3ebe7;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(6, 50, 43, 0.06), 0 8px 24px rgba(6, 50, 43, 0.07);
    --shadow-lg: 0 20px 45px rgba(6, 50, 43, 0.14);
    --sidebar-w: 240px;
}

html { font-size: 15px; }

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

h1, h2, h3, h4, h5, h6 { font-family: 'Poppins', 'Inter', sans-serif; font-weight: 600; color: var(--ink); }

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9d8d2; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--teal-500); }

/* ======================== APP SHELL (sidebar layout) ======================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--teal-900) 0%, var(--teal-800) 100%);
    color: #cfe5de;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand img {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: #fff;
    padding: 3px;
    object-fit: contain;
}

.sidebar-brand .brand-name { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 1.05rem; color: #fff; line-height: 1.2; }
.sidebar-brand .brand-sub { font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: #79a89e; }

.sidebar-nav { padding: 16px 12px; flex: 1; }

.sidebar-nav .nav-section {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #5d8c81;
    padding: 14px 12px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 3px;
    border-radius: 10px;
    color: #b9d6cd;
    font-weight: 500;
    font-size: 0.93rem;
    transition: all 0.2s ease;
}

.sidebar-link svg { width: 19px; height: 19px; flex-shrink: 0; opacity: 0.85; }

.sidebar-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }

.sidebar-link.active {
    background: var(--green);
    color: #fff;
    box-shadow: 0 6px 16px rgba(0, 166, 81, 0.35);
}

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255, 255, 255, 0.08); }

.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }

.sidebar-user .avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green), var(--teal-500));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user .user-name { color: #fff; font-weight: 600; font-size: 0.85rem; line-height: 1.25; }
.sidebar-user .user-org { color: #79a89e; font-size: 0.72rem; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar .page-title { font-size: 1.15rem; font-weight: 600; margin: 0; }

.content { padding: 28px; flex: 1; }

@media (max-width: 767.98px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .sidebar-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 12px; }
    .sidebar-nav .nav-section { display: none; }
    .sidebar-footer { margin-left: auto; border-top: none; }
    .content { padding: 18px; }
}

/* ======================== KPI STAT CARDS (CRM style) ======================== */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 18px; }

.kpi-card {
    position: relative;
    display: block;
    border-radius: var(--radius);
    padding: 20px 22px;
    background: linear-gradient(135deg, var(--teal-700), var(--teal-600));
    color: #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.kpi-card::after {
    content: '';
    position: absolute;
    right: -30px; top: -30px;
    width: 110px; height: 110px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
}

.kpi-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); color: #fff; }

.kpi-card.active { outline: 3px solid rgba(0, 166, 81, 0.55); outline-offset: 2px; }

.kpi-card .kpi-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.14);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    margin-bottom: 12px;
}

.kpi-card .kpi-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #a7d4c9;
}

.kpi-card .kpi-value { font-family: 'Poppins', sans-serif; font-size: 1.9rem; font-weight: 700; line-height: 1.15; color: #fff; }

.kpi-card .kpi-sub { font-size: 0.75rem; color: #8fc4b8; }

.kpi-card.kpi-new { background: linear-gradient(135deg, #0b5a6b, #0e7d94); }
.kpi-card.kpi-progress { background: linear-gradient(135deg, #8a5a06, #c98a13); }
.kpi-card.kpi-completed { background: linear-gradient(135deg, #086b3c, #00a651); }
.kpi-card.kpi-returned { background: linear-gradient(135deg, #8c2f33, #c2444a); }

/* ======================== CARDS ======================== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ink);
    padding: 16px 22px;
}

.card-body { padding: 22px; }

.table-card { padding: 4px 10px; }

/* ======================== CHARTS ======================== */
.chart-grid { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: stretch; }

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

.donut-wrap { display: flex; align-items: center; gap: 22px; }

.donut {
    width: 150px; height: 150px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.donut::after {
    content: '';
    position: absolute;
    inset: 22px;
    border-radius: 50%;
    background: var(--card);
}

.donut .donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.donut .donut-center .donut-total { font-family: 'Poppins', sans-serif; font-size: 1.55rem; font-weight: 700; color: var(--ink); line-height: 1; }
.donut .donut-center .donut-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }

.legend { list-style: none; padding: 0; margin: 0; }
.legend li { display: flex; align-items: center; gap: 9px; font-size: 0.86rem; margin-bottom: 8px; color: var(--text); }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend .legend-count { margin-left: auto; font-weight: 700; color: var(--ink); }

.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-item .bar-top { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 5px; }
.bar-item .bar-top .bar-name { font-weight: 600; color: var(--ink); }
.bar-item .bar-track { height: 9px; border-radius: 6px; background: #e9f1ee; overflow: hidden; }
.bar-item .bar-fill {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--green), var(--teal-500));
    width: 0;
    transition: width 1s cubic-bezier(0.25, 0.8, 0.3, 1);
}

/* ======================== TABLES ======================== */
.table { --bs-table-bg: transparent; color: var(--text); margin-bottom: 0; }

.table thead th {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 13px 14px;
    white-space: nowrap;
}

.table tbody td { border-bottom: 1px solid var(--border); padding: 13px 14px; vertical-align: middle; color: var(--text); }

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

.table-hover tbody tr:hover td { background: #f7fbf9; }

tr.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--red); }

/* ======================== STATUS PILLS ======================== */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 100px;
    white-space: nowrap;
}

.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.status-new { color: #0b7c96; background: #e3f5f9; }
.status-progress { color: #a06c00; background: #fdf3dd; }
.status-completed { color: var(--green-dark); background: var(--green-light); }
.status-returned { color: #c02f34; background: #fdeaea; }

/* ======================== BUTTONS ======================== */
.btn { font-weight: 600; border-radius: 100px; padding: 0.55rem 1.5rem; transition: all 0.22s ease; }

.btn-sm { padding: 0.3rem 1rem; font-size: 0.82rem; }

.btn-primary { background: var(--green); border: none; color: #fff; }
.btn-primary:hover, .btn-primary:focus {
    background: var(--green-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0, 166, 81, 0.3);
}

.btn-success { background: var(--teal-600); border: none; color: #fff; }
.btn-success:hover { background: var(--teal-700); color: #fff; }

.btn-warning { background: var(--amber); border: none; color: #4a3403; }
.btn-warning:hover { background: #de9410; color: #4a3403; }

.btn-outline-secondary { border-color: #cddbd5; color: var(--text-muted); }
.btn-outline-secondary:hover { background: #eef4f1; border-color: #b7cac2; color: var(--ink); }

.btn-outline-danger { border-color: #f3c2c4; color: var(--red); }
.btn-outline-danger:hover { background: #fdeaea; border-color: var(--red); color: var(--red); }

.btn-outline-success { border-color: #bfe6d2; color: var(--green-dark); }
.btn-outline-success:hover { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }

/* ======================== FORMS ======================== */
.form-label { font-weight: 600; font-size: 0.86rem; color: var(--ink); margin-bottom: 0.4rem; }

.form-control, .form-select {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--ink);
    padding: 0.6rem 0.9rem;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 4px rgba(0, 166, 81, 0.12);
}

.form-control::placeholder { color: #9fb2ab; }

.form-check-input:checked { background-color: var(--green); border-color: var(--green); }

.form-text { color: var(--text-muted); }

.text-danger { color: #d33f44 !important; }
.text-muted { color: var(--text-muted) !important; }

/* ======================== ALERTS ======================== */
.alert { border-radius: var(--radius-sm); border: 1px solid; font-weight: 500; }

.alert-success { background: var(--green-light); border-color: #bfe6d2; color: #0b6b3c; }
.alert-danger { background: #fdeaea; border-color: #f3c2c4; color: #b3282d; }

/* ======================== AUTH SCREENS ======================== */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(ellipse 60% 50% at 15% 0%, rgba(0, 166, 81, 0.09), transparent),
        radial-gradient(ellipse 50% 40% at 90% 100%, rgba(14, 109, 92, 0.1), transparent),
        var(--bg);
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    width: 100%;
}

.auth-card .auth-accent { height: 5px; background: linear-gradient(90deg, var(--green), var(--teal-500)); }

.auth-card .card-body { padding: 2.6rem; }

.auth-logo { text-align: center; margin-bottom: 0.75rem; }
.auth-logo img { width: 64px; height: 64px; object-fit: contain; }

/* ======================== DETAIL LISTS / FILES ======================== */
dl.detail-list dt {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-top: 0.35rem;
}

dl.detail-list dd { color: var(--ink); margin-bottom: 0.85rem; }

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f7fbf9;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    margin-bottom: 0.6rem;
}

.file-item .file-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--green-light);
    color: var(--green-dark);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.file-item a { color: var(--ink); font-weight: 600; }
.file-item a:hover { color: var(--green); }

.file-item .file-meta { font-size: 0.78rem; color: var(--text-muted); }

/* ======================== MISC ======================== */
.page-heading { margin-bottom: 22px; }
.page-heading h1 { font-size: 1.35rem; margin-bottom: 2px; }
.page-heading .page-subtitle { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 2.4rem; margin-bottom: 0.75rem; }

hr { border: 0; border-top: 1.5px solid var(--border); opacity: 1; }

/* ======================== ANIMATIONS ======================== */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

.reveal { opacity: 0; }
.reveal.visible { animation: fadeUp 0.55s cubic-bezier(0.25, 0.8, 0.3, 1) forwards; animation-delay: var(--delay, 0s); }

@media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1; }
    .reveal.visible { animation: none; }
    .kpi-card, .btn { transition: none; }
}
