:root {
    --bg: #e2e9f4;
    --surface: #ffffff;
    --surface-2: #eef3f9;
    --border: #c7d5e6;
    --border-strong: #93aec8;

    --navy: #0d2137;
    --navy-hover: #0a1b2c;
    --navy-mid: #1c5f92;
    --navy-faint: #dbe8f5;

    --accent: #1670c9;
    --accent-hover: #125a9e;
    --accent-light: #dbeefb;
    --accent-mid: #8fc3ec;

    --text: #16232f;
    --text-mid: #33526c;
    --text-muted: #5c7f9c;

    --green: #15803d;
    --green-bg: #f0fdf4;
    --green-border: #bbf7d0;
    --amber: #b45309;
    --amber-bg: #fffbeb;
    --amber-border: #fde68a;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --red-border: #fecaca;

    --radius: 10px;
    --radius-sm: 6px;

    --shadow: 0 1px 3px rgba(13,33,55,0.06), 0 2px 10px rgba(13,33,55,0.05);
    --shadow-md: 0 4px 18px rgba(13,33,55,0.10);
    --shadow-lg: 0 20px 56px rgba(0,0,0,0.22), 0 8px 24px rgba(0,0,0,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    font-family: 'DM Sans', -apple-system, sans-serif;
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─────────────────────────────────────────
   LOGIN
───────────────────────────────────────── */
#login-view {
    height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 20% 80%, #163554 0%, #0a1e30 55%, #060d17 100%);
    position: fixed;
    top: 0; left: 0;
    z-index: 999;
    transition: opacity 0.5s ease;
}

.login-card {
    background: var(--surface);
    padding: 2.75rem 2.5rem 2.25rem;
    border-radius: 14px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    animation: fadeUp 0.5s cubic-bezier(.22,.68,0,1.2) both;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-logo-box {
    background: transparent;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    height: 52px;
    width: auto;
}
.login-logo-box .logo-img {
    height: 100%;
    width: auto;
    object-fit: contain;
}

.login-header h1 {
    font-size: 1.375rem;
    color: var(--navy);
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.4px;
    line-height: 1.2;
}
.login-header p {
    font-size: 0.84rem;
    color: var(--text-muted);
    max-width: 320px;
    line-height: 1.5;
}

.login-error {
    display: none;
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid var(--red-border);
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.79rem;
    text-align: center;
    margin-bottom: 1.25rem;
    font-weight: 500;
}

.test-accounts {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-top: 1.5rem;
    font-size: 0.73rem;
    color: var(--text-mid);
    line-height: 1.85;
}
.test-accounts strong {
    color: var(--navy);
    display: block;
    margin-bottom: 4px;
    font-size: 0.71rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.test-accounts span {
    font-family: 'DM Mono', monospace;
    font-size: 0.71rem;
    color: var(--navy-mid);
    background: var(--navy-faint);
    padding: 1px 5px;
    border-radius: 3px;
}

/* ─────────────────────────────────────────
   DASHBOARD WRAPPER
───────────────────────────────────────── */
#dashboard-view { display: none; opacity: 0; transition: opacity 0.4s ease; }

/* ─────────────────────────────────────────
   TOPBAR
───────────────────────────────────────── */
.topbar {
    background: var(--navy);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(255,255,255,0.05), 0 4px 20px rgba(0,0,0,0.28);
}

.topbar-brand { display: flex; align-items: center; gap: 14px; }

.topbar-logo {
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    max-width: 158px;
    padding: 4px 12px;
    border-radius: 6px;
    background: #d6e5f2;
    border: 1px solid rgba(26,74,111,0.22);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 1px 4px rgba(0,0,0,0.18);
}
.topbar-logo .logo-img { width: auto; height: 100%; max-width: 100%; object-fit: contain; }

.topbar-divider { width: 1px; height: 20px; background: rgba(255,255,255,0.1); }

.topbar-title { display: flex; flex-direction: column; }
.topbar-title strong {
    font-size: 0.875rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.1px;
    line-height: 1.2;
}
.topbar-title span {
    font-size: 0.67rem;
    color: rgba(255,255,255,0.36);
    letter-spacing: 0.3px;
    font-weight: 400;
}

.topbar-pill {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.11);
    color: rgba(255,255,255,0.46);
    font-size: 0.66rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.7px;
    text-transform: uppercase;
}

.topbar-stats { display: flex; gap: 22px; align-items: center; }

.stat-chip { display: flex; flex-direction: column; align-items: flex-end; }
.stat-chip .num {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    letter-spacing: -0.3px;
}
.stat-chip .lbl {
    font-size: 0.58rem;
    color: rgba(255,255,255,0.34);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-top: 2px;
}

.stat-sep { width: 1px; height: 26px; background: rgba(255,255,255,0.08); }

.stat-chip-clickable {
    cursor: pointer;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 6px;
    transition: background 0.15s;
}
.stat-chip-clickable:hover { background: rgba(255,255,255,0.08); }
.stat-chip-clickable:hover .num { color: var(--accent-mid, #8fc3ec); }

.logout-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.11);
    color: rgba(255,255,255,0.6);
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    margin-left: 14px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: 'DM Sans', sans-serif;
    letter-spacing: 0.2px;
}
.logout-btn:hover {
    background: rgba(255,255,255,0.13);
    color: #fff;
    border-color: rgba(255,255,255,0.22);
}

.profile-menu { position: relative; margin-left: 14px; }
.profile-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.11);
    color: rgba(255,255,255,0.6);
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: 'DM Sans', sans-serif;
    max-width: 200px;
}
.profile-btn:hover,
.profile-menu.open .profile-btn {
    background: rgba(255,255,255,0.13);
    color: #fff;
    border-color: rgba(255,255,255,0.22);
}
.profile-avatar {
    font-size: 0.95rem;
    line-height: 1;
    flex-shrink: 0;
}
.profile-btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    line-height: 1.25;
}
.profile-btn-text strong {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.1px;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.profile-btn-text small {
    font-size: 0.63rem;
    font-weight: 400;
    color: rgba(255,255,255,0.4);
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.profile-caret {
    font-size: 0.6rem;
    opacity: 0.7;
    flex-shrink: 0;
    transition: transform 0.18s ease;
}
.profile-menu.open .profile-caret { transform: rotate(180deg); }

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 34px rgba(13,33,55,0.14), 0 2px 8px rgba(13,33,55,0.06);
    padding: 6px;
    display: none;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 1200;
}
.profile-menu.open .profile-dropdown {
    display: block;
    opacity: 1;
    transform: translateY(0);
}
.profile-dropdown-header {
    padding: 0.5rem 0.65rem 0.6rem;
}
.profile-dropdown-name {
    font-size: 0.83rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.profile-dropdown-email {
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.profile-dropdown-sep {
    height: 1px;
    margin: 2px 6px 6px;
    background: var(--border);
}
.profile-dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-mid);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.81rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.profile-dropdown-item:hover {
    background: var(--navy-faint);
    color: var(--navy);
}

/* ─────────────────────────────────────────
   TABS NAVIGATION
───────────────────────────────────────── */
.tabs-nav {
    background: var(--surface);
    padding: 0 2rem;
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(13,33,55,0.04);
    position: sticky;
    top: 58px;
    z-index: 99;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0 1.1rem;
    height: 46px;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, background 0.15s;
    font-family: 'DM Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: -1px;
    white-space: nowrap;
}
.tab-btn:hover { color: var(--accent); background: var(--accent-light); }
.tab-btn.active { color: var(--navy); border-bottom-color: var(--navy); background: transparent; }

.tab-pane { display: none; animation: fadeUp 0.22s ease both; }
.tab-pane.active { display: block; }

/* ─────────────────────────────────────────
   MAIN PAGE LAYOUT
───────────────────────────────────────── */
.page { max-width: 1800px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
.dashboard { display: grid; grid-template-columns: 245px 1fr; gap: 1rem; align-items: start; }
.hr-layout  { display: grid; grid-template-columns: 285px 1fr; gap: 1.25rem; align-items: start; }

/* ─────────────────────────────────────────
   FORM PANEL
───────────────────────────────────────── */
.form-panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    position: sticky;
    top: 110px;
}

.panel-header {
    background: var(--navy);
    padding: 0.6rem 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.panel-header h2 {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0;
    line-height: 1.3;
}
.panel-header p {
    font-size: 0.63rem;
    color: rgba(255,255,255,0.44);
    margin-top: 1px;
}

.panel-body { padding: 0.7rem 0.85rem 0.85rem; }

/* ─────────────────────────────────────────
   ARCHIVED ASSETS PANEL
   A compact list under the registration form: one line per unit,
   details open in place so the panel never grows past the form's footprint.
   The form drops its sticky positioning here, otherwise it would overlap
   the panel below it.
───────────────────────────────────────── */
.side-stack { display: flex; flex-direction: column; gap: 1rem; }
.side-stack .form-panel { position: static; }

.archive-count {
    background: rgba(255,255,255,0.14);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    min-width: 20px;
    padding: 1px 7px;
    border-radius: 20px;
    text-align: center;
}

.archive-list { max-height: 260px; overflow-y: auto; }

.archive-row { border-bottom: 1px solid var(--border); }
.archive-row:last-child { border-bottom: none; }

.archive-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    background: none;
    border: none;
    padding: 0.38rem 0.85rem;
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--navy);
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}
.archive-toggle:hover { background: var(--surface-2); }
.archive-row.open .archive-toggle { background: var(--navy-faint); }

.archive-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.archive-detail { padding: 0.1rem 0.85rem 0.6rem; }
.archive-field {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.68rem;
    padding: 2px 0;
}
.archive-field > span   { color: var(--text-muted); flex-shrink: 0; }
.archive-field > strong { color: var(--text-mid); font-weight: 600; text-align: right; word-break: break-word; }

.archive-empty {
    padding: 1.2rem 0.85rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ─────────────────────────────────────────
   FORM ELEMENTS
───────────────────────────────────────── */
.input-group { margin-bottom: 0.42rem; }

.input-group label {
    display: block;
    font-size: 0.61rem;
    font-weight: 700;
    color: var(--text-mid);
    margin-bottom: 2px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.28rem 0.55rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-family: 'DM Sans', sans-serif;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: auto;
}
.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(22,112,201,0.13);
}

.input-group input:disabled,
.input-group textarea:disabled {
    background: var(--surface-2);
    color: var(--text-mid);
    cursor: not-allowed;
}

.input-row { display: flex; gap: 5px; }
.input-row .input-group { flex: 1; }
.required-star { color: var(--red); }

.form-error {
    display: none;
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid var(--red-border);
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.79rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

/* ─────────────────────────────────────────
   BUTTONS
───────────────────────────────────────── */
.btn-primary {
    width: 100%;
    background: var(--navy);
    color: #fff;
    border: none;
    padding: 0.48rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.08s;
    margin-top: 0.25rem;
    letter-spacing: 0.1px;
}
.btn-primary:hover {
    background: var(--navy-hover);
    box-shadow: 0 2px 10px rgba(13,33,55,0.28);
}
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-mid);
    padding: 0.38rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    margin-top: 4px;
    transition: all 0.15s;
}
.btn-secondary:hover {
    background: var(--navy-faint);
    border-color: var(--navy-mid);
    color: var(--navy);
}

/* ─────────────────────────────────────────
   INVENTORY PANEL & TABLES
───────────────────────────────────────── */
.inventory-panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.inventory-header h2 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -0.1px;
}

/* Matches the navy panel-header used by the form panels on other tabs,
   so Assignment History (which has no form panel) still reads as part
   of the same design language. */
.inventory-header-navy {
    background: var(--navy);
    border-bottom: none;
}
.inventory-header-navy h2 { color: #fff; }

/* Search + filter controls sit on one row and share the same pill shape,
   so a header with a search box and a dropdown reads as a single toolbar. */
.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-wrap input {
    /* Room on the left for the magnifier and on the right for the clear
       button, both injected as real elements by enhanceSearchField(). */
    padding: 0.5rem 2.15rem 0.5rem 2.2rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.81rem;
    font-family: 'DM Sans', sans-serif;
    color: var(--text);
    min-width: 240px;
    background-color: var(--surface-2);
    transition: border-color 0.18s, box-shadow 0.18s, background-color 0.18s;
}
.search-wrap input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}
.search-wrap input:hover {
    border-color: var(--border-strong);
    background-color: var(--surface);
}
.search-wrap input:focus {
    border-color: var(--accent);
    background-color: var(--surface);
    box-shadow: 0 0 0 3px rgba(22,112,201,0.12);
    outline: none;
}
/* Chrome's native clear "x" clashes with the pill, so it is hidden. */
.search-wrap input[type="text"]::-webkit-search-cancel-button { display: none; }

/* enhanceSearchField() wraps every search box in this, then drops a magnifier
   in front of the text and a clear button after it. */
.search-field {
    position: relative;
    display: flex;
    align-items: center;
}
.search-field .search-ico {
    position: absolute;
    left: 0.82rem;
    width: 14px;
    height: 14px;
    display: flex;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.18s;
}
.search-field .search-ico svg { width: 100%; height: 100%; display: block; }
.search-field:focus-within .search-ico { color: var(--accent); }

.search-clear {
    position: absolute;
    right: 0.42rem;
    width: 19px;
    height: 19px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-mid);
    font-size: 0.85rem;
    line-height: 1;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}
.search-clear:hover {
    background: var(--navy-mid);
    color: #fff;
    transform: scale(1.08);
}
.search-field.has-value .search-clear { display: flex; }

/* ─────────────────────────────────────────
   FILTER DROPDOWN (custom, replaces <select>)
───────────────────────────────────────── */
/* The real <select> stays in the DOM as the source of truth so existing code
   can keep reading .value, but it is taken out of the visual flow. */
.dd-native {
    position: absolute !important;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.dd { position: relative; display: inline-flex; }

.dd-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0.5rem 0.72rem 0.5rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface-2);
    color: var(--text-mid);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.81rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s, color 0.18s;
}
.dd-btn:hover {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--accent);
}
.dd.open .dd-btn {
    background: var(--surface);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 0 3px rgba(22,112,201,0.1);
}
/* A filter that is narrowing the list tints itself, so a short table is
   never a mystery. */
.dd.filtered .dd-btn {
    background: var(--accent-light);
    border-color: var(--accent-mid);
    color: var(--accent);
    font-weight: 700;
}

.dd-label { flex: 1; text-align: left; }
.dd-chev {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.dd.open .dd-chev { transform: rotate(180deg); }

/* Status dots reuse the badge palette so the dropdown and the table agree. */
.dd-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--text-muted);
}
.dot-green  { background: var(--green); }
.dot-red    { background: var(--red); }
.dot-accent { background: var(--accent); }
.dot-amber  { background: #ca8a04; }
.dot-all,
.dot-muted  { background: var(--text-muted); }
/* "All" is drawn as a ring rather than a filled dot: it is the absence of a
   filter, not another status. */
.dot-all {
    background: transparent;
    box-shadow: inset 0 0 0 2px var(--text-muted);
}

/* The menu is appended to <body> and positioned with fixed coordinates,
   because .inventory-panel clips overflow and would cut it off. */
.dd-menu {
    position: fixed;
    z-index: 1200;
    display: none;
    padding: 5px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 34px rgba(13,33,55,0.14), 0 2px 8px rgba(13,33,55,0.06);
    overflow-y: auto;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.dd-menu.show { display: block; }
.dd-menu.in   { opacity: 1; transform: translateY(0); }

.dd-group {
    padding: 0.5rem 0.6rem 0.25rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}
.dd-sep {
    height: 1px;
    margin: 4px 6px;
    background: var(--border);
}

.dd-opt {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 0.44rem 0.6rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-mid);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.81rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.dd-opt:hover,
.dd-opt.cursor {
    background: var(--navy-faint);
    color: var(--navy);
}
.dd-opt[aria-selected="true"] {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 700;
}
.dd-opt-lbl { flex: 1; white-space: nowrap; }
.dd-check {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.12s;
}
.dd-opt[aria-selected="true"] .dd-check { opacity: 1; }

.dd-menu::-webkit-scrollbar { width: 8px; }
.dd-menu::-webkit-scrollbar-track { background: transparent; }
.dd-menu::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
    border: 2px solid var(--surface);
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
thead tr { background: var(--surface-2); }

th {
    padding: 0.5rem 0.6rem;
    text-align: left;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.65px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--navy-faint); transition: background 0.12s; }

/* ─────────────────────────────────────────
   ASSIGNMENT HISTORY TABLE
   Same row rhythm as the IT Assets table; a stronger rule marks
   where one asset's block of assignments ends and the next begins.
───────────────────────────────────────── */
#perHistBody td { padding: 0.55rem 0.6rem; vertical-align: middle; }
#perHistBody tr.hist-group-start > td { border-top: 2px solid var(--border-strong); }
#perHistBody tr.hist-group-start:first-child > td { border-top: none; }
#perHistBody td.hist-asset-cell { vertical-align: top; }
/* Blocks with more than one assignment centre their merged cells vertically. */
#perHistBody td.hist-asset-cell.hist-multi { vertical-align: middle; }
#perHistBody .holder-name { font-weight: 700; }
#perHistBody td.hist-date {
    text-align: center;
    white-space: nowrap;
    color: var(--text-mid);
    font-size: 0.85rem;
}
/* Hovering any assignment lights up the whole asset block, including the
   merged cells on the left — otherwise only half the row highlights. */
#perHistBody tr.hist-hover > td { background: var(--navy-faint); }

.item-name  { font-weight: 600; color: var(--navy); font-size: 0.74rem; }
.item-desc  { color: var(--text-mid); font-size: 0.74rem; }
.editable-desc {
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px;
    transition: background 0.12s;
}
.editable-desc:hover {
    background: var(--accent-light);
    color: var(--accent);
}

/* Fields that store their value in caps — the transform is cosmetic, the
   value itself is uppercased in JS so what's saved matches what's shown. */
.uppercase-input { text-transform: uppercase; }

.serial-tag {
    font-family: 'DM Mono', monospace;
    font-size: 0.82rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-mid);
    padding: 2px 7px;
    border-radius: 4px;
    display: inline-block;
    letter-spacing: 0.2px;
}

/* ─────────────────────────────────────────
   STATUS & CONDITION BADGES
───────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.2px;
}
.badge::before {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-assigned   { background: var(--accent-light); color: var(--accent); }
.status-assigned::before { background: var(--accent); }
.status-available  { background: var(--green-bg);    color: var(--green);  }
.status-available::before { background: var(--green); }
.status-defective  { background: #fee2e2; color: #dc2626; }
.status-defective::before { background: #dc2626; }
.condition-new     { background: #dcfce7; color: #15803d; }
.condition-new::before { background: #15803d; }
.condition-good    { background: #fef9c3; color: #a16207; }
.condition-good::before { background: #ca8a04; }
.condition-defect  { background: var(--red-bg); color: var(--red); }
.condition-defect::before { background: var(--red); }

/* Assignment History — category + revoked states */
.cat-it            { background: var(--accent-light); color: var(--accent);  }
.cat-it::before    { background: var(--accent); }
.cat-peripheral    { background: var(--navy-faint);  color: var(--navy-mid); }
.cat-peripheral::before { background: var(--navy-mid); }
.status-active     { background: #dcfce7;            color: var(--green);      }
.status-active::before  { background: var(--green); }
.status-revoked    { background: var(--surface-2);   color: var(--text-muted); }
.status-revoked::before { background: var(--text-muted); }

/* ─────────────────────────────────────────
   ACTION BUTTONS
───────────────────────────────────────── */
.action-btns { display: flex; gap: 5px; align-items: center; }

.edit-icon, .delete-icon, .print-icon {
    border: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 5px;
    transition: all 0.12s;
    font-family: 'DM Sans', sans-serif;
    letter-spacing: 0.1px;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    line-height: 1.4;
}
.edit-icon       { background: var(--accent-light); color: var(--accent); }
.edit-icon:hover { background: var(--accent-mid);   color: var(--navy);   }
.delete-icon         { background: var(--red-bg);   color: var(--red);   }
.delete-icon:hover   { background: var(--red-border); }
.print-icon          { background: #dcfce7; color: var(--green); }
.print-icon:hover:not(:disabled) { background: var(--green-border); color: #14532d; }
.print-icon:disabled {
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.45;
}

/* ─────────────────────────────────────────
   PURCHASING TAB
───────────────────────────────────────── */
.grand-total-banner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.3rem 1.75rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}
.grand-total-banner h2 {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 5px;
}
.grand-total-amount {
    font-family: 'DM Sans', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -0.5px;
    line-height: 1;
}

.project-total-badge {
    background: rgba(255,255,255,0.11);
    color: rgba(255,255,255,0.88);
    padding: 4px 12px;
    border-radius: 6px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.1px;
    border: 1px solid rgba(255,255,255,0.1);
}

.slick-price {
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    letter-spacing: -0.1px;
    font-size: 0.87rem;
    color: var(--text);
}
.slick-total {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    letter-spacing: -0.2px;
    font-size: 0.9rem;
    color: var(--green);
}

/* ─────────────────────────────────────────
   HR DIRECTORY
───────────────────────────────────────── */
.employee-list {
    display: flex;
    flex-direction: column;
    max-height: 72vh;
    overflow-y: auto;
}
.employee-item {
    padding: 0.9rem 1.5rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.12s;
    display: flex;
    flex-direction: column;
}
.employee-item:hover { background: var(--surface-2); }
.employee-item.active {
    background: var(--accent-light);
    border-left: 3px solid var(--navy);
    padding-left: calc(1.5rem - 3px);
}
.employee-item strong { font-size: 0.875rem; color: var(--navy); font-weight: 600; }
.employee-item span {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 2px;
    letter-spacing: 0.3px;
}

.empty-state-card {
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Kept as a fallback: if script.js fails to upgrade a filter <select>, it
   still renders as a pill instead of a bare browser control. */
.filter-select,
.dept-filter-select {
    padding: 0.5rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.81rem;
    font-family: 'DM Sans', sans-serif;
    color: var(--text-mid);
    background: var(--surface-2);
    cursor: pointer;
    outline: none;
}

/* ─────────────────────────────────────────
   HR TABLE SORT
───────────────────────────────────────── */
.hr-sort-col, .sort-col { cursor: pointer; user-select: none; transition: background 0.12s, color 0.12s; }
.hr-sort-col:hover, .sort-col:hover { background: var(--accent-light); color: var(--accent); }
.sort-icon { font-size: 0.65rem; opacity: 0.28; margin-left: 4px; vertical-align: middle; }
.sort-icon.active { opacity: 1; color: var(--accent); }

.hr-emp-row { cursor: pointer; }
.hr-emp-row.active td { background: var(--navy-faint); }
.hr-emp-row.active .item-name { color: var(--navy); }
.hr-detail-row td { background: var(--accent-light) !important; }
.hr-detail-row:hover td { background: var(--accent-light) !important; }

/* ─────────────────────────────────────────
   ANIMATION
───────────────────────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────── */

/* Tablet: collapse sidebar to single column */
@media (max-width: 960px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    .form-panel {
        position: static;
    }
    .page {
        padding: 1.25rem 1.25rem 3rem;
    }
    .grand-total-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .grand-total-amount {
        font-size: 1.75rem;
    }
}

/* Mobile: simplify topbar and tabs */
@media (max-width: 768px) {
    .topbar {
        padding: 0 1.25rem;
        height: auto;
        min-height: 54px;
        flex-wrap: wrap;
        gap: 6px;
        padding-top: 9px;
        padding-bottom: 9px;
    }
    .topbar-brand {
        gap: 10px;
    }
    .topbar-stats {
        gap: 10px;
        flex-wrap: wrap;
    }
    .stat-chip .lbl {
        display: none;
    }
    .stat-chip .num {
        font-size: 0.9rem;
    }
    .tabs-nav {
        padding: 0 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .tab-btn {
        padding: 0 0.85rem;
        font-size: 0.7rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .page {
        padding: 1rem 1rem 3rem;
    }
    .input-row {
        flex-direction: column;
        gap: 0;
    }
    .inventory-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
    }
    .search-wrap {
        width: 100%;
    }
    .search-wrap input {
        min-width: 0;
        flex: 1 1 100%;
    }
    .search-field {
        flex: 1 1 100%;
    }
    .dd,
    .filter-select,
    .dept-filter-select {
        flex: 1 1 100%;
    }
    .login-card {
        margin: 1rem;
        padding: 2rem 1.5rem 1.75rem;
    }
}

/* Small mobile: hide less critical topbar elements */
@media (max-width: 480px) {
    .topbar-pill {
        display: none;
    }
    .stat-sep {
        display: none;
    }
    .topbar-divider {
        display: none;
    }
    .topbar-title span {
        display: none;
    }
    .grand-total-amount {
        font-size: 1.45rem;
    }
    .action-btns {
        flex-wrap: wrap;
    }
}

/* ── Refresh button ── */
.refresh-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.55);
    font-size: 1.15rem;
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, transform 0.3s;
    padding: 0; margin-left: 6px;
}
.refresh-btn:hover { background: rgba(255,255,255,0.13); color:#fff; border-color:rgba(255,255,255,0.3); }
.refresh-btn:active { transform: rotate(180deg); }

/* ── Toast notifications ── */
#toast-container {
    position: fixed; bottom: 28px; right: 28px;
    z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: 10px;
    background: #fff; border-radius: 10px; padding: 13px 18px;
    box-shadow: 0 8px 32px rgba(13,33,55,0.18), 0 2px 8px rgba(13,33,55,0.09);
    font-size: 0.875rem; font-weight: 500; color: var(--navy);
    min-width: 240px; max-width: 340px;
    border-left: 4px solid var(--green);
    animation: toastIn 0.28s cubic-bezier(.22,.68,0,1.2) both;
    pointer-events: auto;
}
.toast.toast-error { border-left-color: var(--red); }
.toast.toast-hide  { animation: toastOut 0.25s ease forwards; }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg  { flex: 1; line-height: 1.4; }
@keyframes toastIn  { from{opacity:0;transform:translateY(18px) scale(0.95)} to{opacity:1;transform:translateY(0) scale(1)} }
@keyframes toastOut { from{opacity:1;transform:translateY(0) scale(1)} to{opacity:0;transform:translateY(10px) scale(0.96)} }

/* ── Inventory Report Tab ── */
.rpt-page { padding: 1.25rem 1.25rem 3rem; }

.rpt-kpi-banner {
    display: flex; align-items: center;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.5rem 1.5rem; margin-bottom: 1.25rem; gap: 0;
}
.rpt-kpi         { flex: 1; text-align: center; padding: 0 0.5rem; }
.rpt-kpi-sep     { width: 1px; height: 50px; background: var(--border); flex-shrink: 0; }
.rpt-kpi-num     { font-size: 2rem; font-weight: 700; color: var(--navy); line-height: 1; letter-spacing: -1px; }
.rpt-kpi-lbl     { font-size: 0.67rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 7px; }

.rpt-chart-card  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.rpt-chart-title { padding: 0.65rem 1rem; font-size: 0.8rem; font-weight: 700; color: var(--navy); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.rpt-chart-body  { padding: 0.75rem 1rem 1rem; height: 230px; position: relative; }
.rpt-pie-body    { height: 210px; }

.rpt-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
.rpt-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }

@media (max-width: 1100px) { .rpt-row-2 { grid-template-columns: 1fr; } .rpt-row-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px)  { .rpt-row-3 { grid-template-columns: 1fr; } }
@media (max-width: 640px)  { .rpt-kpi-banner { flex-wrap: wrap; gap: 1rem; } .rpt-kpi-sep { display: none; } }