/* Windows 11 "light" theme for the Asset Manager.
   Segoe UI typography, soft Mica-grey surfaces, rounded cards, the
   familiar #0067c0 accent, and subtle elevation shadows. */

:root {
    --accent: #0067c0;
    --accent-hover: #005ba1;
    --bg: #f3f3f3;
    --surface: #ffffff;
    --surface-2: #fbfbfb;
    --stroke: #e5e5e5;
    --stroke-strong: #d6d6d6;
    --text: #1b1b1b;
    --text-soft: #5f5f5f;
    --danger: #c42b1c;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", "Segoe UI Variable", system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--stroke-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: #f5f5f5; }
.btn:active { background: #ededed; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fdf2f1; }
/* Icon-only button (e.g. the Settings gear in the assets toolbar). Square,
   tighter padding so the icon sits flush; otherwise inherits the .btn look. */
.btn.btn-icon {
    padding: 6px 8px;
    line-height: 0;
}
.btn.btn-icon svg { display: block; }

/* ---- Auth pages (login / setup / forgot / reset) ---- */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--stroke);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 32px;
}
.auth-card h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 4px;
}
.auth-card .sub { color: var(--text-soft); margin: 0 0 24px; }
.field { margin-bottom: 16px; }
.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-soft);
}
.field input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--stroke-strong);
    border-bottom-width: 2px;
    border-radius: var(--radius);
    font: inherit;
    background: var(--surface-2);
}
.field input:focus {
    outline: none;
    border-bottom-color: var(--accent);
    background: #fff;
}
.auth-card .btn { width: 100%; justify-content: center; }
.auth-links {
    margin-top: 18px;
    text-align: center;
    font-size: 13px;
}
.auth-links a { color: var(--accent); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* ---- Flash messages ---- */
.flashes { list-style: none; margin: 0 0 18px; padding: 0; }
.flashes li {
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    border: 1px solid transparent;
}
.flashes .error { background: #fdf2f1; border-color: #f3c9c4; color: var(--danger); }
.flashes .info  { background: #eef6fd; border-color: #c5e0f5; color: var(--accent); }

/* ---- App shell ---- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    box-shadow: var(--shadow);
    display: flex;
    align-items: stretch;
}
.app-header .logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    background: var(--surface);
    text-decoration: none;
}
.app-header .logo:hover { background: var(--surface-2); }
.app-header .logo img {
    display: block;
    max-height: 80px;
    width: auto;
}
.app-header > .header-rows {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.tabs-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--stroke);
}
.tabs-bar .spacer { flex: 1; }
.tabs-bar .toolbar { padding: 6px 0; }
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--stroke);
}
.topbar .title { font-weight: 600; font-size: 15px; margin-right: 8px; }
/* Double-click the title to rename the app in place. */
.topbar .title.editable { cursor: pointer; border-radius: 5px; }
.topbar .title.editable:hover { color: var(--accent); }
.topbar .title input.title-rename {
    font: inherit;
    font-weight: 600;
    color: var(--text);
    padding: 2px 6px;
    border: 1px solid var(--accent);
    border-radius: 5px;
    background: #fff;
}
.topbar .spacer { flex: 1; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; }
.topbar .who { color: var(--text-soft); font-size: 13px; }

.toolbar-search { display: inline-flex; align-items: center; gap: 4px; }
.toolbar-search input[type="search"] {
    font: inherit;
    width: 180px;
    padding: 4px 8px;
    border: 1px solid var(--stroke);
    border-radius: 5px;
    background: #fff;
    color: var(--text);
}
.toolbar-search input[type="search"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 103, 192, 0.15);
}

.content { max-width: 1060px; margin: 0 auto; padding: 22px 18px 60px; }

/* ---- Category sections ---- */
.category {
    margin-bottom: 26px;
}
.category h2 {
    font-size: 13px;
    color: var(--text-soft);
    margin: 0 0 10px;
    padding-left: 2px;
}
/* Click a category heading to rename the whole group. */
.category h2.editable { cursor: pointer; border-radius: 5px; display: inline-block; }
.category h2.editable:hover { color: var(--accent); }
.category h2 input.cat-rename {
    font: inherit;
    color: var(--text);
    padding: 3px 6px;
    border: 1px solid var(--accent);
    border-radius: 5px;
    background: #fff;
}
/* Blue up/down arrows shown beside the rename box to reorder whole sections. */
.category h2 .cat-move { margin-left: 8px; display: inline-flex; gap: 2px; vertical-align: middle; }
.cat-move-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--accent);
    font-size: 14px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 5px;
}
.cat-move-btn:hover { background: #eef6fd; }
.card-list {
    background: var(--surface);
    border: 1px solid var(--stroke);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ---- Item rows ---- */
.item {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr minmax(120px, 1fr);
    gap: 14px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--stroke);
    cursor: default;
    user-select: none;
}
.item:last-child { border-bottom: none; }
.item:hover { background: var(--surface-2); }
.item.selected { background: #eef6fd; }
.item .name { font-weight: 600; }
.item .username { color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; }
/* Click-to-copy username: shown in full (not secret); a "copy" hint appears
   only on hover, and a green "copied!" confirmation flashes on click. */
.item .username.copyable {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.item .username.copyable .uval { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .username.copyable .copy-hint {
    font-size: 12px;
    color: var(--text-soft);
    opacity: 0;
    transition: opacity 0.12s ease;
}
.item .username.copyable:hover .copy-hint { opacity: 1; }
.item .username.copyable.copied .copy-hint { opacity: 1; color: #2e7d32; }
/* URL column: clickable link, truncated with an ellipsis if long. */
.item .url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .url a { color: var(--accent); text-decoration: none; }
.item .url a:hover { text-decoration: underline; }

/* The blurred password box — click to copy. */
.pw-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-self: start;
    padding: 5px 10px;
    border: 1px dashed var(--stroke-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    cursor: pointer;
    font-family: "Cascadia Mono", Consolas, monospace;
    max-width: 100%;
}
.pw-box:hover { border-color: var(--accent); background: #fff; }
.pw-dots {
    filter: blur(4px);
    letter-spacing: 2px;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
}
.pw-box .copy-hint { font-family: "Segoe UI", sans-serif; color: var(--text-soft); font-size: 12px; }
.pw-box.copied { border-color: #4caf50; background: #f1faf1; }
.pw-box.copied .copy-hint { color: #2e7d32; }

.empty {
    text-align: center;
    color: var(--text-soft);
    padding: 60px 20px;
}

/* ---- Right-click context menu ---- */
.context-menu {
    position: fixed;
    z-index: 100;
    min-width: 160px;
    background: var(--surface);
    border: 1px solid var(--stroke-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    padding: 5px;
    display: none;
}
.context-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    background: none;
    font: inherit;
    border-radius: 5px;
    cursor: pointer;
}
.context-menu button:hover { background: #f0f0f0; }
.context-menu button.danger { color: var(--danger); }
.context-menu button.danger:hover { background: #fdf2f1; }
.context-menu .sep { height: 1px; background: var(--stroke); margin: 5px 0; }

/* ---- Modal dialog (add / edit) ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    display: none;
    place-items: center;
    z-index: 200;
    padding: 24px;
}
.modal-backdrop.open { display: grid; }
.modal {
    width: 100%;
    max-width: 460px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-pop);
    padding: 24px;
    /* Settings modal now hosts 6 sections (changelog 81) and clips off the
     * bottom on shorter viewports. Internal scroll lets every section be
     * reachable without restructuring the HTML. Applied to .modal globally
     * so any future modal that grows past viewport height gets the same
     * safety net at no extra cost. The 48px cancels the 24px+24px padding
     * on .modal-backdrop so the modal exactly fills the visible area with
     * one 24px gap top and bottom. overscroll-behavior stops a scroll-past-
     * the-bottom from chaining to the body behind the modal. */
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.modal h3 { margin: 0 0 18px; font-size: 18px; font-weight: 600; }
/* Category "pick existing" dropdown, stacked above the free-text box. */
.modal .field select.cat-select {
    width: 100%;
    padding: 9px 11px;
    margin-bottom: 8px;
    border: 1px solid var(--stroke-strong);
    border-radius: var(--radius);
    font: inherit;
    background: var(--surface-2);
    cursor: pointer;
}
.modal .field textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--stroke-strong);
    border-radius: var(--radius);
    font: inherit;
    background: var(--surface-2);
    resize: vertical;
    min-height: 64px;
}
.modal .field input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--stroke-strong);
    border-radius: var(--radius);
    font: inherit;
    background: var(--surface-2);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---- Import from clipboard ---- */
.modal.modal-wide { max-width: 760px; }
/* Asset-edit modal width. Started at 920px in changelog 51 ("twice as wide")
   then shrunk by 1/4 to 690px in changelog 52. Class name kept for stability
   even though 690px is now NARROWER than .modal-wide's 760px. */
.modal.modal-extra-wide { max-width: 690px; }

/* Auto Backup "Browse..." popup — a modal nested inside the Auto Backup
   modal. Sits above the parent backdrop via a higher z-index. */
.modal-backdrop.nested-modal { z-index: 300; }
.folder-list {
    list-style: none;
    padding: 0;
    margin: 6px 0;
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
}
.folder-list li {
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 4px;
}
.folder-list li:hover { background: #f0f0f0; }
.folder-list li.hint { cursor: default; }
.folder-list li.hint:hover { background: transparent; }
.modal .hint { margin: -8px 0 16px; color: var(--text-soft); font-size: 13px; }
.clip-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.clip-table th { text-align: left; padding: 4px 6px; color: var(--text-soft);
    font-size: 12px; font-weight: 600; }
.clip-table td { padding: 3px 6px; vertical-align: middle; }
.clip-table td:first-child, .clip-table th:first-child { width: 24px; text-align: center; }
.clip-table input[type="checkbox"] { width: auto; }
.clip-table input { width: 100%; padding: 6px 8px; border: 1px solid var(--stroke-strong);
    border-radius: var(--radius); font: inherit; font-size: 13px; background: var(--surface-2); }
#clip-review { margin-top: 8px; }
.clip-table-wrap { max-height: 45vh; overflow-y: auto; margin-bottom: 8px; }

/* ---- Admin table ---- */
.admin-table { width: 100%; border-collapse: collapse; background: var(--surface);
    border: 1px solid var(--stroke); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.admin-table th, .admin-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--stroke); }
.admin-table th { color: var(--text-soft); font-size: 13px; }
.admin-table tr:last-child td { border-bottom: none; }
/* Click a user row to select it (blue), matching a selected vault entry. */
.admin-table tbody tr { cursor: pointer; }
.admin-table tbody tr.selected td { background: #eef6fd; }
.badge { background: var(--accent); color: #fff; border-radius: 10px; padding: 2px 8px; font-size: 12px; }

/* Section tabs (Password Manager / Asset Manager).
   Background, border, and sticky positioning are owned by the parent
   .tabs-bar inside .app-header. */
.tabs {
    display: flex;
    gap: 4px;
}
.tab {
    padding: 10px 16px;
    color: var(--text-soft);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab:hover {
    color: var(--text);
    background: rgba(0, 0, 0, 0.03);
}
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
/* Running-version badge shown centered under the mltech logo (inside .brand).
   Value comes from the install folder name (e.g. "v49.1.1") via the app_version
   global, so it reflects the version that is ACTUALLY running. */
.app-version {
    align-self: center;
    margin-right: 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    background: var(--surface-2);
    border: 1px solid var(--stroke);
    border-radius: 999px;
    padding: 1px 8px;
}
/* The logo + version badge are stacked vertically in the header's left cell. */
.brand { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.app-version--logo { margin: 4px 0 6px; }

/* Placeholder empty state on the Asset Manager page */
.empty-state {
    max-width: 560px;
    margin: 60px auto;
    text-align: center;
    color: var(--text-soft);
}
.empty-state h2 {
    margin: 0 0 8px;
    color: var(--text);
    font-weight: 600;
}

/* ---- Data tables (assets + sites + vault) ---- */
.asset-table, .site-table, .vault-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.asset-table th, .asset-table td,
.site-table  th, .site-table  td,
.vault-table th, .vault-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--stroke);
    vertical-align: middle;
}
.asset-table th, .site-table th, .vault-table th {
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
    background: var(--surface-2);
}
.asset-table tr:last-child td,
.site-table  tr:last-child td,
.vault-table tr:last-child td { border-bottom: none; }
.asset-table tbody tr,
.site-table  tbody tr,
.vault-table tbody tr { cursor: pointer; }
.asset-table tbody tr:hover,
.site-table  tbody tr:hover,
.vault-table tbody tr:hover { background: rgba(0,103,192,0.04); }
.asset-table tbody tr.selected td,
.site-table  tbody tr.selected td,
.vault-table tbody tr.selected td { background: #eef6fd; }

/* CL103: Groups checkbox block (used in the Edit User modal AND in the
   right-pane of the Edit Groups modal). Vertical list of labels with
   small left-aligned checkboxes. */
.e-groups-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
    padding: 6px 8px;
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    background: #fff;
}
.e-group-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    cursor: pointer;
}
.e-group-row input[type=checkbox] { width: auto; }

/* CL103: Edit Groups modal — two-pane layout. */
.modal.eg-modal { max-width: 720px; }
.eg-body {
    display: grid;
    grid-template-columns: 230px 1fr;
    gap: 16px;
    min-height: 360px;
}
.eg-pane { display: flex; flex-direction: column; }
.eg-pane-left {
    border-right: 1px solid var(--stroke);
    padding-right: 16px;
}
.eg-grouplist {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    background: #fff;
    margin-bottom: 8px;
    min-height: 200px;
}
.eg-grouprow {
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--stroke);
    display: flex;
    align-items: center;
    gap: 6px;
}
.eg-grouprow:last-child { border-bottom: none; }
.eg-grouprow:hover { background: rgba(0,103,192,0.04); }
.eg-grouprow.selected { background: #eef6fd; font-weight: 600; }
.eg-default-tag {
    margin-left: auto;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-soft);
    background: #eee;
    border-radius: 3px;
    padding: 1px 6px;
}
.eg-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* CL103: per-group section header rows in the vault. Not clickable, not
   hover-highlighted, never selected. The accent-coloured left border
   visually anchors the section. */
.vault-table tr.group-header { cursor: default; background: #f4f7fb; }
.vault-table tr.group-header:hover { background: #f4f7fb; }
.vault-table tr.group-header th {
    text-align: left;
    padding: 10px 12px 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    border-bottom: 1px solid var(--stroke-strong);
    border-left: 3px solid var(--accent);
    background: #f4f7fb;
}

/* Split-selection model (shared by assets and vault):
   .ticked = checkbox is checked (bulk-delete selection). Subtle light blue.
   .focused = user clicked the row body (single-row Edit/Copy/Move target).
              Stronger blue + accent stripe on the left edge (via inset
              box-shadow so row height doesn't shift). */
.asset-table tbody tr.ticked td,
.vault-table tbody tr.ticked td,
.site-table tbody tr.ticked td { background: #eef6fd; }
.asset-table tbody tr.focused td,
.vault-table tbody tr.focused td,
.site-table tbody tr.focused td { background: #d4e9fb; }
.asset-table tbody tr.focused td:first-child,
.vault-table tbody tr.focused td:first-child,
.site-table tbody tr.focused td:first-child {
    box-shadow: inset 3px 0 0 var(--accent);
}
.asset-table tbody tr.ticked.focused td,
.vault-table tbody tr.ticked.focused td,
.site-table tbody tr.ticked.focused td { background: #c8e0fa; }

.asset-table .col-select,
.vault-table .col-select,
.site-table .col-select { width: 36px; }
.asset-table .col-pic    { width: 40px; }
.vault-table .col-pw     { width: 130px; }

/* Transient " copied!" badge shown next to the username after a successful
   click-to-copy. Inserted/removed by flashUsernameCopied() in vault.js. */
.vault-table td.username.copyable .copy-confirm {
    color: #2e7d32;
    font-size: 12px;
    font-weight: 500;
}
.asset-table .pic-placeholder {
    display: inline-block;
    width: 28px; height: 28px;
    line-height: 28px;
    text-align: center;
    background: var(--stroke);
    color: var(--text-soft);
    border-radius: 4px;
    font-size: 14px;
}
.pic-thumb {
    height: 36px;
    width: 36px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--stroke);
    display: block;
}
.pic-current {
    display: block;
    margin: 6px 0;
    max-height: 140px;
    max-width: 100%;
    border-radius: 6px;
    border: 1px solid var(--stroke);
}

/* Persistent read-only header inside the Edit Asset modal: thumbnail on
   the left, label/value pairs on the right. Sits outside the tab panes
   so it stays visible whichever tab is active. */
#asset-header {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 14px;
    align-items: start;
    margin: 8px 0 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--stroke);
}
#asset-header-pic {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--stroke);
}
#asset-header-pic-empty {
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--stroke);
    border-radius: 6px;
    color: var(--text-soft);
    font-size: 12px;
}
#asset-header-fields {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 12px;
    margin: 0;
}
#asset-header-fields dt {
    font-weight: 600;
    color: var(--text-soft);
}
#asset-header-fields dd {
    margin: 0;
    word-break: break-word;
}
#asset-header-cal.overdue { color: #c0392b; font-weight: 600; }
#asset-header-cal.missing { color: var(--text-soft); font-style: italic; }
#asset-header-cal.warn    { color: #c97c1d; }

/* Calibration column in the main asset table — same warn/overdue colours
   as the edit panel's header cal field. Colour only; the cell text stays
   the plain date. */
.asset-table td.cal-cell.overdue { color: #c0392b; font-weight: 600; }
.asset-table td.cal-cell.warn    { color: #c97c1d; }
#asset-header-status {
    display: inline-block;
    margin-top: 1.5px;
}

/* Head-office routing lock disables this select on purpose; the adjacent
   hint text explains why. Keep the visible site name in normal body
   colour so the only valid destination doesn't look unavailable. */
#asset-site-select:disabled {
    color: var(--text);
    -webkit-text-fill-color: var(--text);
    opacity: 1;
}

/* Sortable column headers on the asset + vault + admin user + sites tables —
   two stacked triangles on the right edge (▲ above ▼). Both muted by
   default; the active direction's triangle lights up in accent blue.
   Click cycle is asc → desc → cleared. */
.asset-table th.sortable,
.vault-table th.sortable,
.admin-table th.sortable,
.site-table th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 22px;
    position: relative;
}
.asset-table th.sortable:hover,
.vault-table th.sortable:hover,
.admin-table th.sortable:hover,
.site-table th.sortable:hover { color: var(--accent); }
.asset-table th.sortable::before,
.asset-table th.sortable::after,
.vault-table th.sortable::before,
.vault-table th.sortable::after,
.admin-table th.sortable::before,
.admin-table th.sortable::after,
.site-table th.sortable::before,
.site-table th.sortable::after {
    content: '';
    position: absolute;
    right: 6px;
    width: 0; height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: 0.3;
}
.asset-table th.sortable::before,
.vault-table th.sortable::before,
.admin-table th.sortable::before,
.site-table th.sortable::before {
    top: 50%;
    margin-top: -6px;          /* triangle above midline, with a 1px gap to the midline */
    border-bottom: 5px solid var(--text-soft);
}
.asset-table th.sortable::after,
.vault-table th.sortable::after,
.admin-table th.sortable::after,
.site-table th.sortable::after {
    top: 50%;
    margin-top: 1px;           /* triangle below midline, with a 1px gap to the midline (~2px total) */
    border-top: 5px solid var(--text-soft);
}
.asset-table th.sortable.sort-asc::before,
.vault-table th.sortable.sort-asc::before,
.admin-table th.sortable.sort-asc::before,
.site-table th.sortable.sort-asc::before {
    opacity: 1;
    border-bottom-color: var(--accent);
}
.asset-table th.sortable.sort-desc::after,
.vault-table th.sortable.sort-desc::after,
.admin-table th.sortable.sort-desc::after,
.site-table th.sortable.sort-desc::after {
    opacity: 1;
    border-top-color: var(--accent);
}

/* Status pills (used in the asset table's Status cell) */
.status-available {
    background: #d4edda;
    color: #155724;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}
.status-out {
    background: #cce5ff;
    color: #004085;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}
/* The check-in/out date sits inline in the check-row, between the site
   selector and the Check In / Check Out buttons. Styled to match the
   selector/buttons height so the whole row aligns. Pre-filled with today;
   change it only to stamp a check-in/out for a different day. */
.modal .check-row input[type=date] {
    padding: 7px 10px;
    border: 1px solid var(--stroke-strong);
    border-radius: var(--radius);
    font: inherit;
    background: #fff;
}

/* ---- Asset/Site modal extras (work alongside the original .modal-backdrop
       .open convention defined further up in this file) ---- */
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal h3 { margin: 14px 0 8px; font-size: 14px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.modal label {
    display: block;
    font-size: 13px;
    color: var(--text-soft);
    margin-bottom: 12px;
}
.modal label input[type=text],
.modal label input[type=password],
.modal label input[type=date],
.modal label textarea,
.modal select {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 7px 10px;
    border: 1px solid var(--stroke-strong);
    border-radius: var(--radius);
    font: inherit;
    background: #fff;
    box-sizing: border-box;
}
.modal label textarea { resize: vertical; }
.modal label small.hint {
    display: block;
    color: var(--text-soft);
    font-size: 12px;
    margin-top: 4px;
}
.modal hr {
    border: none;
    border-top: 1px solid var(--stroke);
    margin: 16px 0;
}
.modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}
.modal .check-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.modal .check-row select { flex: 0 1 302px; max-width: 302px; }
/* Lock the three check-row controls to one shared height so Chrome stops
   inflating the inline-flex Check In / Check Out buttons relative to the date
   box / site select on the same line. Firefox already renders at this height;
   this just makes Chrome match. Width is untouched - the buttons keep fitting
   their label. */
.modal .check-row > select,
.modal .check-row > input[type=date],
.modal .check-row > .btn {
    height: 34px;
    box-sizing: border-box;
}
/* Keep the whole row on one line in Chrome/Edge, where <input type=date>
   renders wider than in Firefox (spinner + calendar-picker chrome) and was
   squeezing the buttons until their labels wrapped to two lines. The date box
   and buttons keep their natural width; the site select is the only element
   allowed to shrink (min-width:0) to absorb any overflow. */
.modal .check-row { flex-wrap: nowrap; }
.modal .check-row > select { min-width: 0; }
.modal .check-row > input[type=date],
.modal .check-row > .btn { flex-shrink: 0; }
.modal .check-row > .btn { white-space: nowrap; }
.asset-tab-pane {
    min-height: 520px;
}
.asset-tab-pane[data-pane="history"] {
    display: flex;
    flex-direction: column;
}
.modal .history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    background: var(--surface-2);
}
.modal .history-list li {
    padding: 6px 10px;
    font-size: 13px;
    border-bottom: 1px solid var(--stroke);
}
.modal .history-list li:last-child { border-bottom: none; }
.modal .history-list .hint { color: var(--text-soft); font-style: italic; }
.modal .hint { color: var(--text-soft); font-size: 13px; }
/* Inline message under the check-in/out controls in the asset edit modal,
 * shown only when "Force returns via head office" is enabled (changelog 83).
 * The element carries the `hidden` attribute when there's no message; on
 * .modal the UA's [hidden]{display:none} would otherwise lose to
 * .lock-hint{display:block}, so [hidden] is restated explicitly to win. */
.modal .lock-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-soft);
    font-style: italic;
    font-size: 13px;
}
.modal .lock-hint[hidden] { display: none; }

/* ---- Clipboard import modal (three sub-modes) ---- */
.modal .clip-modes {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--stroke);
    margin: -4px -4px 14px;
}
.modal .asset-tabs { margin-top: 0.5mm; }
.modal .clip-modes .mode-tab {
    background: none;
    border: none;
    padding: 8px 14px;
    color: var(--text-soft);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
}
.modal .clip-modes .mode-tab:hover { color: var(--text); }
.modal .clip-modes .mode-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.modal .clip-pane > .hint { margin-top: 0; }
.modal .clip-input {
    width: 100%;
    min-height: 140px;
    padding: 9px 11px;
    border: 1px solid var(--stroke-strong);
    border-radius: var(--radius);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 13px;
    background: #fff;
    box-sizing: border-box;
    resize: vertical;
}
.modal .clip-review { max-height: 280px; overflow-y: auto; margin-top: 8px; }
.modal .clip-asset-pick {
    width: 100%;
    max-width: 480px;
    margin-bottom: 8px;
}
.clip-table { width: 100%; border-collapse: collapse; }
.clip-table th, .clip-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--stroke);
    font-size: 13px;
}
.clip-table th { color: var(--text-soft); text-align: left; font-weight: 600; }
.clip-table input[type=text],
.clip-table input:not([type]) {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--stroke);
    border-radius: 4px;
    font: inherit;
    box-sizing: border-box;
}

/* ===== Print ===========================================================
 * #print-area is injected at print time by code/static/print.js and
 * removed again on `afterprint`. On screen it is hidden; in the print
 * dialog every other body child is hidden, leaving only the print
 * content visible.
 * ======================================================================= */
#print-area { display: none; }
@media print {
    body > *:not(#print-area) { display: none !important; }
    #print-area {
        display: block !important;
        color: #000;
        font: 11pt/1.35 sans-serif;
    }
    #print-area h1 { font-size: 16pt; margin: 0 0 8pt; }
    #print-area h2 { font-size: 13pt; margin: 12pt 0 4pt;
                     page-break-after: avoid; }
    #print-area dl {
        display: grid;
        grid-template-columns: 40mm 1fr;
        gap: 2pt 8pt;
        margin: 4pt 0;
    }
    #print-area dt { font-weight: 600; }
    #print-area dd { margin: 0; }
    #print-area table { width: 100%; border-collapse: collapse;
                        margin-top: 4pt; }
    #print-area th, #print-area td {
        border: 1px solid #000;
        padding: 3pt 6pt;
        text-align: left;
        vertical-align: top;
    }
    #print-area thead { display: table-header-group; }
    #print-area tr, #print-area li { page-break-inside: avoid; }
    #print-area img { max-width: 60mm; max-height: 60mm;
                      display: block; margin: 4pt 0; }
    #print-area p { white-space: pre-wrap; margin: 4pt 0; }
    #print-area .print-history { padding-left: 18pt; }
    @page { margin: 15mm; }

    /* Fit-to-one-page mode: slightly compacted (vs the modal print) but kept at
     * a comfortably readable size so a typical short asset list lands on a
     * single A4 page. A very long list may flow to a second page — an accepted
     * trade-off for predictable, larger text. Toggle controlled by the "Fit
     * asset list to one page" checkbox in Asset Settings; the wrapper
     * <div class="fit-one-page"> is added by print.js when the toggle is on.
     */
    #print-area .fit-one-page h1    { font-size: 16.5pt; margin: 0 0 6pt; }
    #print-area .fit-one-page p     { font-size: 11pt;   margin: 0 0 6pt; }
    #print-area .fit-one-page table { font-size: 12.1pt; }
    #print-area .fit-one-page th,
    #print-area .fit-one-page td    { padding: 2.2pt 6.6pt; line-height: 1.2; }
}

/* Recycle Bin page sections (changelog 137). The page lists deleted equipment
   and deleted disposed records as two independent sections, each with its own
   toolbar and table. */
.bin-section { margin-bottom: 26px; }
.bin-section:last-child { margin-bottom: 0; }
.bin-heading {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 8px;
    padding: 0 2px;
    color: var(--text);
}
.bin-section .topbar {
    border: 1px solid var(--stroke);
    border-radius: 7px 7px 0 0;
    border-bottom: none;
    padding: 8px 10px;
}
