/* HDC IT Inventory — minimal, responsive theme matching HDC's actual brand green
   (sampled from the hdc.mv logo mark: #169C50 / #39B34E, and their own CSS
   --primary-600/700 tokens: #16a34a / #15803d) plus their secondary blue accent. */

:root {
    --hdc-green-dark: #14532d;
    --hdc-green: #16a34a;
    --hdc-green-bright: #39b34e;
    --hdc-green-tint: #eafaf1;
    --hdc-blue: #0079c1;
    --hdc-blue-tint: #e2f1fb;
    --hdc-ink: #26312f;
    --hdc-grey: #6b7573;
    --hdc-grey-soft: #8a9391;
    --hdc-bg: #f4f7f5;
    --hdc-white: #ffffff;
    --hdc-success: #16a34a;
    --hdc-warning: #f89927;
    --hdc-danger: #ef4444;
    --radius: .65rem;
    --radius-lg: .9rem;

    --bs-primary: var(--hdc-green);
    --bs-primary-rgb: 22, 163, 74;
    --bs-link-color: var(--hdc-green-dark);
    --bs-link-hover-color: var(--hdc-green);
    --bs-body-font-family: 'Poppins', system-ui, sans-serif;
    --bs-body-color: var(--hdc-ink);
    --bs-body-bg: var(--hdc-bg);
    --bs-border-radius: var(--radius);
    --bs-border-radius-sm: .5rem;
    --bs-border-radius-lg: var(--radius-lg);

    --sidebar-width: 246px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Poppins', system-ui, sans-serif;
    background: var(--hdc-bg);
    color: var(--hdc-ink);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--hdc-green-dark); }
a:hover { color: var(--hdc-green); }

/* ---------------- Form controls: consistent, brand-colored focus ---------------- */

.form-control, .form-select {
    border-radius: .5rem;
    border-color: #dde3e2;
    font-size: .9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--hdc-green);
    box-shadow: 0 0 0 .2rem rgba(22, 163, 74, .14);
}
.form-label { color: var(--hdc-ink); margin-bottom: .35rem; }
.form-text { font-size: .78rem; }

.btn { border-radius: .5rem; font-size: .88rem; font-weight: 500; }

.btn-primary {
    --bs-btn-bg: var(--hdc-green-dark);
    --bs-btn-border-color: var(--hdc-green-dark);
    --bs-btn-hover-bg: #0f3d21;
    --bs-btn-hover-border-color: #0f3d21;
    --bs-btn-active-bg: #0b2f19;
    --bs-btn-focus-shadow-rgb: 20, 83, 45;
}

.btn-outline-primary {
    --bs-btn-color: var(--hdc-green-dark);
    --bs-btn-border-color: var(--hdc-green-dark);
    --bs-btn-hover-bg: var(--hdc-green-dark);
    --bs-btn-hover-border-color: var(--hdc-green-dark);
}

.btn-outline-success {
    --bs-btn-color: #157a47;
    --bs-btn-border-color: #bfe3cd;
    --bs-btn-hover-bg: #157a47;
    --bs-btn-hover-border-color: #157a47;
}

.text-brand { color: var(--hdc-green-dark) !important; }
.bg-brand { background-color: var(--hdc-green-dark) !important; }

.badge { font-weight: 500; font-size: .74rem; padding: .38em .65em; border-radius: .4rem; }
.badge-fixed-asset { background: var(--hdc-blue-tint); color: var(--hdc-blue); }
.badge-consumable { background: var(--hdc-green-tint); color: var(--hdc-green-dark); }
.badge-other { background: #eef1f0; color: var(--hdc-grey); }
.badge-low-stock { background: #fff3e6; color: var(--hdc-warning); }
.badge-out-stock { background: #fdeaea; color: var(--hdc-danger); }
.badge-in-stock { background: #eaf7ee; color: var(--hdc-success); }
.badge-role { background: var(--hdc-blue-tint); color: var(--hdc-blue); font-weight: 500; }

/* ---------------- App shell ---------------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(10, 20, 19, .45);
    z-index: 1025;
}
.sidebar-backdrop.show { display: block; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(185deg, var(--hdc-green-dark) 0%, #0a2e18 100%);
    color: #fff;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    overflow-y: auto;
    z-index: 1030;
    transition: transform .25s ease;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.15rem 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar .brand img { height: 34px; }
.sidebar .brand-text { font-weight: 600; font-size: .93rem; line-height: 1.2; }
.sidebar .brand-text small { display: block; font-weight: 400; opacity: .65; font-size: .68rem; }

.sidebar nav { padding: .6rem 0 1.5rem; }
.sidebar .nav-section-label {
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    opacity: .5;
    padding: 1rem 1.2rem .3rem;
}
.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    color: rgba(255,255,255,.82);
    padding: .5rem 1.2rem;
    font-size: .87rem;
    border-left: 3px solid transparent;
    transition: background .15s ease, color .15s ease;
}
.sidebar .nav-link i { width: 18px; text-align: center; opacity: .9; font-size: .95rem; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link.active {
    background: rgba(255,255,255,.13);
    border-left-color: var(--hdc-green-bright);
    color: #fff;
    font-weight: 500;
}

.main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #e9edec;
    padding: .65rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.topbar h1 { font-size: 1.02rem; font-weight: 600; margin: 0; color: var(--hdc-ink); }

.content { padding: 1.4rem; flex: 1; min-width: 0; }

.card {
    border: 1px solid #e9edec;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(2, 40, 40, .04);
}
.card-header { background: #fff; border-bottom: 1px solid #eef1f0; font-weight: 600; font-size: .92rem; border-top-left-radius: var(--radius) !important; border-top-right-radius: var(--radius) !important; }
.card-body { padding: 1.15rem; }

.kpi-card { border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; background: #fff; border: 1px solid #e9edec; transition: box-shadow .15s ease; overflow: hidden; }
.kpi-card > div { min-width: 0; }
.kpi-card .kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--hdc-ink); line-height: 1.2; overflow-wrap: break-word; }
.kpi-card .kpi-label { font-size: .74rem; color: var(--hdc-grey); text-transform: uppercase; letter-spacing: .04em; }
.kpi-card .kpi-icon {
    width: 40px; height: 40px; min-width: 40px; flex-shrink: 0; border-radius: .6rem;
    display: flex; align-items: center; justify-content: center;
    background: var(--hdc-green-tint); color: var(--hdc-green-dark); font-size: 1.05rem;
}

a .card:hover, a:hover .card { box-shadow: 0 6px 16px rgba(10, 46, 24, .09); border-color: #d9e6de; }

/* Chart.js canvases default to 300px wide before their responsive resize
   observer fires; without this they can flash-overflow narrow columns. */
canvas { max-width: 100%; }

.table { font-size: .87rem; }
.table thead th {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--hdc-grey);
    border-bottom-width: 1px;
    background: #fafcfb;
    white-space: nowrap;
}
.table td, .table th { vertical-align: middle; }

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--hdc-green-dark) 0%, #0f3d21 55%, #0a2e18 100%);
    padding: 1.25rem;
}
.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 2.2rem 2.2rem 1.8rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card .brand-logo { height: 46px; margin-bottom: .6rem; }

.scan-input { font-family: 'Courier New', monospace; letter-spacing: .04em; background: #fcfefe; }

.print-label { border: 1px dashed #b7c3c1; padding: .6rem; border-radius: .5rem; display: inline-block; text-align: center; }

/* ---------------- Responsive ---------------- */

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); box-shadow: 0 0 30px rgba(0,0,0,.25); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .content { padding: 1rem; }
    .topbar { padding: .6rem 1rem; }
}

@media (max-width: 575px) {
    .content { padding: .75rem; }
    .card-body { padding: .9rem; }
    .kpi-card { padding: .9rem 1rem; }
    .kpi-card .kpi-value { font-size: 1.2rem; }
    .topbar h1 { font-size: .95rem; }
}

body { overflow-x: hidden; }

@media print {
    .no-print { display: none !important; }
    .main { margin-left: 0 !important; }
}
