/* ===========================================================
   Eeleins Material Tracking — UI theme
   Large, touch-friendly widgets for store / shop-floor use.
   =========================================================== */
:root {
    --brand-900: #0d1f3c;
    --brand-800: #13294f;
    --brand-700: #1b3a6b;
    --brand-500: #257de0;
    --brand-100: #e6f0fc;
    --surface: #ffffff;
    --bg: #f2f5fa;
    --text: #1a2233;
    --text-2: #5d6779;
    --border: #e1e6ef;
    --ok: #0a8a1f;
    --warn: #b97800;
    --err: #c62f30;
    --radius: 16px;
    --shadow: 0 1px 2px rgba(16, 30, 60, .06), 0 6px 20px rgba(16, 30, 60, .06);
    --sidebar-w: 268px;

    --bs-primary: #1f63c4;
    --bs-primary-rgb: 31, 99, 196;
    --bs-body-font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-color: var(--text);
    --bs-body-bg: var(--bg);
}

html { font-size: 16px; }
body { background: var(--bg); color: var(--text); min-height: 100vh; }

/* ---------- Buttons ---------- */
.btn { border-radius: 12px; font-weight: 600; }
.btn-primary { --bs-btn-bg: #1f63c4; --bs-btn-border-color: #1f63c4; --bs-btn-hover-bg: #1a54a8; --bs-btn-hover-border-color: #1a54a8; --bs-btn-active-bg: #164890; }
.btn-success { --bs-btn-bg: #0a8a1f; --bs-btn-border-color: #0a8a1f; --bs-btn-hover-bg: #08731a; --bs-btn-hover-border-color: #08731a; }
.btn-xl { padding: 1rem 2rem; font-size: 1.25rem; border-radius: 14px; }
.btn-icon { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }

/* ---------- Forms (large) ---------- */
.form-control, .form-select { border-radius: 12px; border-color: #cfd6e3; }
.form-control-lg, .form-select-lg { min-height: 56px; font-size: 1.1rem; }
.form-label { font-weight: 600; color: var(--text-2); margin-bottom: .35rem; }
.form-control:focus, .form-select:focus { border-color: var(--brand-500); box-shadow: 0 0 0 .25rem rgba(37, 125, 224, .18); }
.required::after { content: " *"; color: var(--err); }

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

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--brand-900), var(--brand-800));
    color: #cdd8ea;
    display: flex; flex-direction: column;
}
@media (min-width: 992px) {
    .sidebar { position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
}
@media (max-width: 991.98px) {
    .sidebar.offcanvas-lg { --bs-offcanvas-width: var(--sidebar-w); --bs-offcanvas-bg: var(--brand-900); }
}

.sidebar-brand { display: flex; align-items: center; gap: .85rem; padding: 1.5rem 1.25rem 1.25rem; }
.brand-mark {
    width: 48px; height: 48px; border-radius: 14px;
    background: linear-gradient(135deg, #3b8cf0, #1f63c4);
    display: grid; place-items: center; color: #fff; font-size: 1.5rem;
    box-shadow: 0 6px 16px rgba(31, 99, 196, .45);
}
.brand-name { color: #fff; font-weight: 800; letter-spacing: .14em; font-size: 1.15rem; }
.brand-sub { font-size: .82rem; color: #93a6c6; }

.sidebar-nav { padding: .5rem .85rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.nav-section { text-transform: uppercase; font-size: .72rem; letter-spacing: .12em; color: #7488aa; padding: 1.1rem .9rem .35rem; }
.nav-item-link {
    display: flex; align-items: center; gap: .9rem;
    padding: .9rem 1rem; border-radius: 12px;
    color: #cdd8ea; text-decoration: none; font-size: 1.05rem; font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-item-link i { font-size: 1.3rem; width: 1.5rem; text-align: center; }
.nav-item-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item-link.active { background: #1f63c4; color: #fff; box-shadow: 0 6px 16px rgba(31, 99, 196, .35); }
.sidebar-foot { padding: 1rem 1.5rem 1.4rem; font-size: .85rem; border-top: 1px solid rgba(255, 255, 255, .08); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: 1.1rem 2rem; background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1020;
}
.page-title { font-size: 1.6rem; font-weight: 700; margin: 0; }
.page-sub { color: var(--text-2); font-size: .95rem; }
.topbar-clock { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.content { padding: 1.75rem 2rem 3rem; }
@media (max-width: 767.98px) {
    .topbar { padding: .85rem 1rem; }
    .page-title { font-size: 1.3rem; }
    .content { padding: 1rem; }
}

/* ---------- Cards / panels ---------- */
.panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); }
.panel-head h2, .panel-head h3 { font-size: 1.15rem; font-weight: 700; margin: 0; }
.panel-head .sub { color: var(--text-2); font-size: .88rem; }
.panel-body { padding: 1.4rem; }

/* KPI tiles */
.kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.4rem 1.5rem; display: flex; align-items: center; gap: 1.1rem; height: 100%;
    text-decoration: none; color: inherit; transition: transform .12s, box-shadow .12s;
}
a.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(16, 30, 60, .12); color: inherit; }
.kpi-icon { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; font-size: 1.7rem; flex-shrink: 0; }
.kpi-value { font-size: 2.3rem; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--text-2); font-weight: 600; font-size: .95rem; }
.tone-blue   { background: #e3eefc; color: #1f63c4; }
.tone-green  { background: #e2f5e6; color: #0a7a1c; }
.tone-orange { background: #fdeee4; color: #c4541a; }
.tone-violet { background: #ece8fc; color: #5a3fcf; }
.tone-aqua   { background: #dff6f0; color: #00876b; }

/* ---------- Tables ---------- */
.table-app { margin: 0; --bs-table-bg: transparent; }
.table-app thead th {
    background: #f6f8fc; color: var(--text-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
    font-weight: 700; border-bottom: 1px solid var(--border); padding: .9rem 1rem; white-space: nowrap;
}
.table-app tbody td { padding: .95rem 1rem; vertical-align: middle; border-color: #eef1f6; }
.table-app tbody tr:hover { background: #f8fafe; }
.serial { font-family: Consolas, "Cascadia Mono", monospace; font-weight: 700; color: var(--brand-700); letter-spacing: .02em; }
a.serial { text-decoration: none; }
a.serial:hover { text-decoration: underline; }
.muted { color: var(--text-2); }
.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--text-2); }
.empty-state i { font-size: 3rem; display: block; margin-bottom: .75rem; color: #b5c0d3; }

/* ---------- Status badges (icon + label, never colour alone) ---------- */
.status { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .75rem; border-radius: 999px; font-weight: 600; font-size: .85rem; white-space: nowrap; }
.status-received  { background: #e3eefc; color: #1a55a8; }
.status-issued    { background: #fdeee4; color: #a8460f; }
.status-installed { background: #e2f5e6; color: #0a6e19; }
.status-returned  { background: #ece8fc; color: #4b33b5; }
.status-rejected  { background: #fde6e6; color: #b02425; }
.status-correction { background: #eceff4; color: #4a5568; }

/* ---------- Scan station ---------- */
.scan-hero {
    background: radial-gradient(1200px 400px at 10% -10%, #2f7be0 0%, transparent 60%), linear-gradient(135deg, #13294f, #1b3a6b);
    color: #fff; border-radius: 22px; padding: 2.25rem; box-shadow: 0 16px 40px rgba(19, 41, 79, .3);
}
.scan-hero h2 { font-weight: 800; font-size: 1.8rem; }
.scan-hero p { color: #c8d6ee; font-size: 1.05rem; }
.scan-input-wrap { position: relative; }
.scan-input-wrap i { position: absolute; left: 1.4rem; top: 50%; transform: translateY(-50%); font-size: 2rem; color: #1f63c4; }
.scan-input {
    height: 92px; font-size: 2rem; font-weight: 700; letter-spacing: .06em;
    padding-left: 4.4rem; border-radius: 18px; border: 3px solid transparent;
    font-family: Consolas, "Cascadia Mono", monospace;
}
.scan-input:focus { border-color: #7fb4f5; box-shadow: 0 0 0 .4rem rgba(127, 180, 245, .35); }
.scanner-state { display: inline-flex; align-items: center; gap: .6rem; font-weight: 600; padding: .5rem 1rem; border-radius: 999px; background: rgba(255, 255, 255, .12); }
.scanner-state .dot { width: 12px; height: 12px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74, 222, 128, .7); animation: pulse 1.6s infinite; }
.scanner-state.idle .dot { background: #fbbf24; animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .7); } 70% { box-shadow: 0 0 0 12px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }
.today-counter { text-align: center; background: rgba(255, 255, 255, .1); border-radius: 18px; padding: 1.1rem 1.6rem; }
.today-counter .num { font-size: 3rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.today-counter .lbl { color: #c8d6ee; font-weight: 600; }

/* Scan modal */
.modal-content { border-radius: 22px; border: none; }
.modal-header { border-bottom: 1px solid var(--border); padding: 1.3rem 1.75rem; }
.modal-body { padding: 1.5rem 1.75rem; }
.modal-footer { border-top: 1px solid var(--border); padding: 1.1rem 1.75rem; }
.modal-serial {
    background: var(--brand-100); border: 2px dashed #9cc2f2; border-radius: 16px; padding: 1rem 1.25rem;
    display: flex; align-items: center; gap: 1rem;
}
.modal-serial .code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 1.7rem; font-weight: 800; color: var(--brand-700); word-break: break-all; }
.dup-box { background: #fff6e5; border: 2px solid #f5c26b; border-radius: 16px; padding: 1.25rem; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: .45rem 1rem; }
.kv dt { color: var(--text-2); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }

/* ---------- Tracking ---------- */
.track-search .form-control { min-height: 68px; font-size: 1.5rem; font-family: Consolas, "Cascadia Mono", monospace; font-weight: 700; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.detail-item { background: #f6f8fc; border-radius: 14px; padding: 1rem 1.15rem; }
.detail-item .lbl { color: var(--text-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.detail-item .val { font-size: 1.15rem; font-weight: 700; margin-top: .2rem; word-break: break-word; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 23px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline li { position: relative; display: flex; gap: 1rem; padding-bottom: 1.35rem; }
.timeline li:last-child { padding-bottom: 0; }
.tl-dot { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 1.25rem; flex-shrink: 0; z-index: 1; border: 3px solid var(--surface); }
.tl-body { flex: 1; padding-top: .2rem; }
.tl-title { font-weight: 700; font-size: 1.05rem; }
.tl-meta { color: var(--text-2); font-size: .88rem; }
.tl-notes { margin-top: .35rem; background: #f6f8fc; border-radius: 10px; padding: .6rem .85rem; font-size: .95rem; }

/* Status picker (large tiles) */
.status-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.status-picker input { position: absolute; opacity: 0; pointer-events: none; }
.status-picker label {
    display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 1rem .5rem;
    border: 2px solid var(--border); border-radius: 14px; cursor: pointer; font-weight: 600; text-align: center;
    transition: border-color .12s, background .12s;
}
.status-picker label i { font-size: 1.6rem; }
.status-picker input:checked + label { border-color: #1f63c4; background: var(--brand-100); }
.status-picker input:focus-visible + label { outline: 3px solid rgba(37, 125, 224, .4); }

/* ---------- Dashboard charts ---------- */
.chart-box { position: relative; height: 300px; }
.status-row { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; align-items: center; margin-bottom: 1rem; }
.status-row .status { justify-self: start; }
.status-row .bar { grid-column: 1 / -1; height: 10px; border-radius: 6px; background: #eef1f6; overflow: hidden; }
.status-row .bar span { display: block; height: 100%; border-radius: 6px; }
.status-row .count { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

/* ---------- Filters ---------- */
.filter-bar .form-control, .filter-bar .form-select { min-height: 50px; }

.pagination .page-link { min-width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 10px !important; margin: 0 .15rem; font-weight: 600; }

/* ---------- Validation summary: hide when there are no errors ---------- */
.validation-summary-valid { display: none; }
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }
.min-w-0 { min-width: 0; }

/* ---------- Signed-in user (sidebar) ---------- */
.sidebar-user { padding: 1.1rem 1.25rem 1.4rem; border-top: 1px solid rgba(255, 255, 255, .08); }
.user-name { color: #fff; font-weight: 700; }
.user-role { color: #93a6c6; font-size: .85rem; }
.btn-sidebar {
    background: rgba(255, 255, 255, .08); color: #dbe5f5; border: 1px solid rgba(255, 255, 255, .1);
    font-weight: 600; font-size: .9rem; padding: .55rem .5rem; border-radius: 10px;
}
.btn-sidebar:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.avatar {
    width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center; font-weight: 800; letter-spacing: .03em;
    background: #e3eefc; color: #1a55a8;
}
.avatar-dark { background: linear-gradient(135deg, #3b8cf0, #1f63c4); color: #fff; }

.role-badge { display: inline-block; padding: .3rem .8rem; border-radius: 999px; font-weight: 700; font-size: .82rem; }
.role-admin { background: #ece8fc; color: #4b33b5; }
.role-operator { background: #e3eefc; color: #1a55a8; }
.role-viewer { background: #dff6f0; color: #00745c; }
.role-picker { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.role-picker label small { font-size: .8rem; line-height: 1.3; }

/* ---------- Login page ---------- */
.auth-body { background: var(--bg); }
.auth-shell { display: flex; min-height: 100vh; }
.auth-brand {
    flex: 0 0 46%; flex-direction: column; justify-content: space-between; padding: 3rem 3.5rem;
    color: #cdd8ea;
    background: radial-gradient(900px 500px at 0% 0%, #2f7be0 0%, transparent 55%),
                radial-gradient(700px 500px at 100% 100%, #1f4f9a 0%, transparent 60%),
                linear-gradient(160deg, #0d1f3c, #13294f);
}
.auth-headline { color: #fff; font-weight: 800; font-size: 2.9rem; line-height: 1.12; margin-bottom: 2rem; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; font-size: 1.1rem; }
.auth-points i {
    width: 42px; height: 42px; border-radius: 12px; display: inline-grid; place-items: center; margin-right: .9rem;
    background: rgba(255, 255, 255, .1); color: #fff; font-size: 1.2rem;
}
.auth-form-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card {
    width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 22px; box-shadow: var(--shadow); padding: 2.5rem;
}
.auth-card .input-group-text { border-color: #cfd6e3; color: var(--text-2); }
.auth-card .input-group .form-control { min-height: 56px; }
@media (max-width: 575.98px) { .auth-card { padding: 1.5rem; } }

/* ---------- Eeleins logo ---------- */
/* The wordmark's gradient ends in deep navy, so it sits on a white tile over the dark sidebar. */
.sidebar-brand { padding: 1.25rem 1rem .5rem; }
.brand-logo {
    flex: 1; display: flex; align-items: center; justify-content: center;
    background: #fff; border-radius: 14px; padding: .8rem 1rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
.brand-logo img { width: 100%; max-width: 200px; height: auto; display: block; }
.brand-app {
    padding: .35rem 1.25rem .75rem; color: #93a6c6; font-size: .82rem; font-weight: 600;
    letter-spacing: .06em; text-transform: uppercase; text-align: center;
}
.auth-brand-top { color: #c8d6ee; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .9rem; }
.auth-logo { text-align: center; margin-bottom: 1.75rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.auth-logo img { width: 100%; max-width: 260px; height: auto; }

/* ---------- SweetAlert2 theme ---------- */
.swal2-container { font-family: var(--bs-body-font-family); }
.app-swal { border-radius: 22px !important; padding: 2rem 1.75rem 1.75rem !important; width: 30rem !important; }
.app-swal .swal2-title { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.app-swal .swal2-html-container { font-size: 1.08rem; color: var(--text-2); }
.app-swal .swal2-actions { margin-top: 1.5rem; }
.app-swal .swal2-timer-progress-bar { background: rgba(10, 138, 31, .45); }
.app-swal-toast { border-radius: 14px !important; box-shadow: 0 12px 30px rgba(16, 30, 60, .18) !important; padding: .85rem 1.1rem !important; min-width: 320px; }
.app-swal-toast .swal2-title { font-size: 1.02rem !important; font-weight: 600; color: var(--text); }
.app-swal-toast .swal2-timer-progress-bar { background: rgba(31, 99, 196, .35); }
