/* Ophir brand colours (same as the Ophir website): orange #E8822B, warm off-white, near-black. */
:root {
    --ophir-accent: #E8822B;
    --ophir-accent-dark: #c96c1e;
    --ophir-ink: #141210;
    --ophir-paper: #FCFAF7;

    --fh-bg: #FCFAF7;
    --fh-surface: #ffffff;
    --fh-text: #1d1b18;
    --fh-muted: #5c5852;
    --fh-border: #e7e2d8;
    --fh-hover: #f6f2ec;
    /* A deeper orange than the logo for links and buttons, so text stays readable on white. */
    --fh-accent: #b9580d;
    --fh-accent-text: #ffffff;
    --fh-danger: #c50f1f;
    --fh-header: #141210;
}

@media (prefers-color-scheme: dark) {
    :root {
        --fh-bg: #171513;
        --fh-surface: #22201d;
        --fh-text: #f4f1ec;
        --fh-muted: #b0aaa1;
        --fh-border: #3a3631;
        --fh-hover: #2d2a26;
        --fh-accent: #f29a4a;
        --fh-accent-text: #1a0f05;
        --fh-danger: #f1707b;
        --fh-header: #0e0d0b;
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--fh-bg);
    color: var(--fh-text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 14px;
}
a { color: var(--fh-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 20px 0 8px; }
.muted { color: var(--fh-muted); }
.error-text { color: var(--fh-danger); }

/* ---------- shell ---------- */
.app-shell { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 48px 1fr; min-height: 100vh; }
.app-header {
    grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; background: var(--fh-header); color: #fff; border-bottom: 2px solid var(--ophir-accent);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 16px; }
.brand .ophir-logo { display: block; }
.brand-name { padding-left: 10px; border-left: 1px solid rgba(255,255,255,.25); letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.header-user { display: flex; align-items: center; gap: 12px; }
.header-user form { margin: 0; }
.header-button {
    background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5);
    border-radius: 4px; padding: 4px 10px; cursor: pointer; font: inherit;
}
.app-nav { background: var(--fh-surface); border-right: 1px solid var(--fh-border); padding-top: 8px; }
.app-main { padding: 20px 28px; overflow: auto; min-width: 0; }
.page-loading { display: flex; justify-content: center; padding: 48px; }

@media (max-width: 760px) {
    .app-shell { grid-template-columns: 1fr; grid-template-rows: 48px auto 1fr; }
    .app-nav { border-right: none; border-bottom: 1px solid var(--fh-border); }
    .app-main { padding: 16px; }
    .hide-sm, .hide-md { display: none; }
    .two-col { grid-template-columns: 1fr !important; }
}

/* ---------- pages ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.head-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 16px; }
.breadcrumb .sep { color: var(--fh-muted); }
.empty { text-align: center; padding: 48px 16px; color: var(--fh-muted); }
.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin: 8px 0; }

.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.site-card {
    display: flex; gap: 12px; align-items: center; padding: 16px; background: var(--fh-surface);
    border: 1px solid var(--fh-border); border-radius: 8px; color: var(--fh-text);
}
.site-card:hover { background: var(--fh-hover); text-decoration: none; }
.site-icon {
    width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center;
    background: var(--fh-accent); color: var(--fh-accent-text); font-size: 20px; font-weight: 600; flex: none;
}
.site-name { font-weight: 600; font-size: 15px; }

.dropzone { border-radius: 8px; min-height: 160px; }
.dropzone.dragging { outline: 2px dashed var(--fh-accent); outline-offset: 4px; }

.file-table { width: 100%; border-collapse: collapse; background: var(--fh-surface); border: 1px solid var(--fh-border); border-radius: 8px; }
.file-table th { text-align: left; font-weight: 600; color: var(--fh-muted); padding: 8px 12px; border-bottom: 1px solid var(--fh-border); font-size: 13px; }
.file-table td { padding: 6px 12px; border-bottom: 1px solid var(--fh-border); vertical-align: middle; }
.file-table tr:last-child td { border-bottom: none; }
.file-table tbody tr:hover { background: var(--fh-hover); }
.name-cell { display: inline-flex; align-items: center; gap: 8px; }
.file-icon { width: 20px; text-align: center; }
.actions-col { width: 48px; text-align: right; }

/* ---------- selection & command bar (SharePoint-style) ---------- */
.command-bar {
    display: flex; align-items: center; gap: 2px; flex-wrap: wrap; min-height: 44px;
    margin: 8px 0 12px; padding: 4px 8px; background: var(--fh-surface);
    border: 1px solid var(--fh-border); border-radius: 8px;
}
.selection-count { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--fh-muted); }
.check-col { width: 36px; text-align: center; }
.check-col input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--fh-accent); }
.file-table.selectable tbody tr { cursor: default; user-select: none; }
.file-table.selectable tbody tr.selected { background: color-mix(in srgb, var(--fh-accent) 14%, transparent); }
.file-table.selectable tbody tr.selected:hover { background: color-mix(in srgb, var(--fh-accent) 20%, transparent); }
.context-menu {
    position: fixed; z-index: 30; width: 210px; padding: 4px 0;
    background: var(--fh-surface); border: 1px solid var(--fh-border); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.context-menu button {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 14px; border: none; background: none;
    color: var(--fh-text); font: inherit; text-align: left; cursor: pointer;
}
.context-menu button:hover { background: var(--fh-hover); }
.context-menu .danger { color: var(--fh-danger); }
.menu-wrap { position: relative; display: inline-block; }
.menu-backdrop { position: fixed; inset: 0; z-index: 25; }
.row-menu {
    position: absolute; right: 0; top: 100%; z-index: 30; min-width: 180px; padding: 4px 0; text-align: left;
    background: var(--fh-surface); border: 1px solid var(--fh-border); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.row-menu button, .row-menu a {
    display: block; width: 100%; padding: 8px 14px; border: none; background: none; color: var(--fh-text);
    font: inherit; text-align: left; cursor: pointer; text-decoration: none;
}
.row-menu button:hover, .row-menu a:hover { background: var(--fh-hover); }
.row-menu .danger { color: var(--fh-danger); }
.row-menu.upload-menu { left: 0; right: auto; min-width: 150px; }
.row-menu.upload-menu button { display: flex; align-items: center; gap: 10px; }

.upload-panel {
    position: fixed; right: 16px; bottom: 16px; width: 320px; max-width: calc(100vw - 32px); z-index: 20;
    background: var(--fh-surface); border: 1px solid var(--fh-border); border-radius: 8px; padding: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.upload-head { display: flex; justify-content: space-between; align-items: center; }
.upload-row { margin-top: 8px; font-size: 13px; }
.upload-line { display: flex; justify-content: space-between; gap: 8px; }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- access ---------- */
.access-dialog::part(control) { width: min(640px, calc(100vw - 32px)); }
.dialog-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; width: 100%; }
.dialog-title h2 { margin: 0; overflow-wrap: anywhere; }
.access-source { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; background: var(--fh-hover); border-radius: 6px; }
.access-list { list-style: none; padding: 0; margin: 0; }
.access-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--fh-border); }
.access-list .who { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.access-list .level { color: var(--fh-muted); white-space: nowrap; }
.link-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--fh-border); }
.new-link { margin-top: 12px; }
.new-link summary { cursor: pointer; color: var(--fh-accent); margin-bottom: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.picker { margin: 6px 0; }
.picker-results { list-style: none; padding: 0; margin: 4px 0; border: 1px solid var(--fh-border); border-radius: 6px; max-height: 220px; overflow: auto; }
.picker-results li { display: flex; gap: 6px; align-items: center; padding: 6px 10px; cursor: pointer; }
.picker-results li:hover { background: var(--fh-hover); }
.picked { display: flex; align-items: center; gap: 6px; padding: 4px 0; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.panel { background: var(--fh-surface); border: 1px solid var(--fh-border); border-radius: 8px; padding: 16px; }
.group-list { list-style: none; padding: 0; margin: 0 0 8px; }
.group-list li { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 6px; cursor: pointer; }
.group-list li:hover, .group-list li.selected { background: var(--fh-hover); }
.group-list li .muted { margin-left: auto; font-size: 12px; }

/* ---------- SharePoint-style library extras ---------- */
@media (max-width: 1100px) { .hide-md { display: none; } }
.site-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.star { border: none; background: none; cursor: pointer; font-size: 20px; line-height: 1; color: var(--fh-muted); padding: 2px 4px; }
.star.small { font-size: 16px; }
.star.on { color: #c19c00; }
.star:hover { color: #c19c00; }
.star-col { width: 28px; text-align: center; }
.sync-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; margin: -4px 0 8px; }
.command-right { margin-left: auto; }
.file-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.file-table th.sortable:hover { color: var(--fh-text); }
.person { display: inline-block; padding: 2px 8px; border-radius: 12px; background: var(--fh-hover); font-size: 13px; white-space: nowrap; }
.missing { font-size: 12px; color: var(--fh-danger); }
.library-body { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.library-body.with-details { grid-template-columns: minmax(0, 1fr) 300px; }
@media (max-width: 900px) { .library-body.with-details { grid-template-columns: 1fr; } }
.details-pane { background: var(--fh-surface); border: 1px solid var(--fh-border); border-radius: 8px; padding: 16px; position: sticky; top: 8px; }
.details-pane h2 { font-size: 16px; overflow-wrap: anywhere; }
.details-icon { font-size: 48px; text-align: center; margin: 8px 0; }
.details-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.details-list dt { color: var(--fh-muted); }
.details-list dd { margin: 0; overflow-wrap: anywhere; }
.activity { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.activity li { padding: 6px 0; border-bottom: 1px solid var(--fh-border); }
.breadcrumb.small { font-size: 13px; margin-bottom: 6px; }
.folder-picker { list-style: none; padding: 0; margin: 4px 0; border: 1px solid var(--fh-border); border-radius: 6px; max-height: 260px; overflow: auto; }
.folder-picker li { padding: 7px 10px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.folder-picker li:hover { background: var(--fh-hover); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.field > span:first-child { font-weight: 600; }
.field select, .share-level, .wizard select {
    padding: 6px 8px; border: 1px solid var(--fh-border); border-radius: 4px; font: inherit;
    background: var(--fh-surface); color: var(--fh-text); min-width: 180px;
}
.wizard { display: flex; flex-direction: column; gap: 12px; }
.wizard h3 { margin: 8px 0 0; }
.site-card-wrap { position: relative; }
.site-card-wrap .star { position: absolute; top: 8px; right: 8px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; }
.person-form { margin-bottom: 8px; }
.row-actions { display: inline-flex; }

/* ---------- Share dialog (SharePoint look) ---------- */
.share-dialog::part(control) { width: min(520px, calc(100vw - 32px)); }
.share { display: flex; flex-direction: column; gap: 12px; }
.share-head-actions { display: inline-flex; }
.share-people {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px;
    border: 1px solid var(--fh-border); border-radius: 6px; background: var(--fh-surface);
}
.share-people:focus-within { outline: 2px solid var(--fh-accent); outline-offset: -1px; }
.share-input { flex: 1; min-width: 160px; border: none; outline: none; background: transparent; color: var(--fh-text); font: inherit; padding: 4px 2px; }
.share-level { min-width: 0; border: none; border-left: 1px solid var(--fh-border); border-radius: 0; }
.share-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 12px; background: var(--fh-hover); font-size: 13px; }
.share-chip button { border: none; background: none; cursor: pointer; color: var(--fh-muted); font-size: 11px; padding: 2px 4px; }
.share-message { display: flex; gap: 8px; padding: 8px; border: 1px solid var(--fh-border); border-radius: 6px; }
.share-message textarea { flex: 1; border: none; outline: none; resize: vertical; background: transparent; color: var(--fh-text); font: inherit; }
.share-notify { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.share-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.share-buttons { display: inline-flex; gap: 8px; align-items: center; }
.split-button { display: inline-flex; }
.share-avatars { display: inline-flex; border: none; background: none; cursor: pointer; padding: 0; }
.avatar {
    width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; margin-left: -6px;
    background: var(--fh-hover); border: 2px solid var(--fh-surface); font-size: 11px; font-weight: 600; color: var(--fh-text);
}
.avatar:first-child { margin-left: 0; }
.link-scopes { display: flex; flex-direction: column; gap: 6px; }
.link-scopes label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--fh-border); border-radius: 6px; cursor: pointer; }
.link-scopes label.on { border-color: var(--fh-accent); background: color-mix(in srgb, var(--fh-accent) 8%, transparent); }
.link-scopes label > span { display: flex; flex-direction: column; gap: 2px; }
.link-scopes .muted { font-size: 12px; }

/* ---------- public "Anyone" folder page ---------- */
.public-page { max-width: 1000px; margin: 0 auto; padding: 16px; }
.public-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 0 16px; border-bottom: 1px solid var(--fh-border); margin-bottom: 16px; }

/* ---------- admin settings ---------- */
.nav-section {
    margin: 16px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
    text-transform: uppercase; color: var(--fh-muted);
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.admin { max-width: 1100px; }
.admin-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.admin-head p { margin: 4px 0 0; max-width: 720px; }
.admin-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--fh-accent); }
.admin-tabs { display: flex; gap: 4px; margin: 16px 0 20px; border-bottom: 1px solid var(--fh-border); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.admin-tabs a {
    padding: 10px 14px; color: var(--fh-muted); font-weight: 600; border-bottom: 2px solid transparent;
    margin-bottom: -1px; white-space: nowrap;
}
.admin-tabs a:hover { color: var(--fh-text); text-decoration: none; background: var(--fh-hover); border-radius: 6px 6px 0 0; }
.admin-tabs a.active { color: var(--fh-accent); border-bottom-color: var(--fh-accent); }
.admin-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.admin-search { width: 260px; max-width: 100%; }
.admin-count { margin-left: auto; font-size: 13px; }
.admin-select {
    height: 32px; padding: 0 8px; border: 1px solid var(--fh-border); border-radius: 4px; font: inherit;
    background: var(--fh-surface); color: var(--fh-text);
}
.admin-select.wide { width: 100%; }
.admin-input {
    width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--fh-border); border-radius: 4px; font: inherit;
    background: var(--fh-surface); color: var(--fh-text);
}
.admin-input:focus, .admin-select:focus { outline: 2px solid var(--fh-accent); outline-offset: -1px; }
.admin-input[aria-invalid="true"] { border-color: var(--fh-danger); }
.segmented { display: inline-flex; border: 1px solid var(--fh-border); border-radius: 6px; overflow: hidden; }
.segmented button { border: none; background: var(--fh-surface); color: var(--fh-text); font: inherit; padding: 5px 12px; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--fh-border); }
.segmented button.on { background: var(--fh-accent); color: var(--fh-accent-text); }
.admin-card { background: var(--fh-surface); border: 1px solid var(--fh-border); border-radius: 10px; overflow: hidden; }
.admin-card.notice { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 20px; margin-top: 16px; flex-wrap: wrap; border-left: 4px solid #c19c00; }
.admin-card.notice p { margin: 4px 0 0; }
.admin-card.how { padding: 16px 20px; margin-top: 16px; }
.admin-card.how h3 { margin-top: 0; }
.admin-card.how ol { margin: 0; padding-left: 20px; line-height: 1.8; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
    text-align: left; font-size: 12px; font-weight: 600; color: var(--fh-muted); text-transform: uppercase; letter-spacing: .03em;
    padding: 10px 16px; border-bottom: 1px solid var(--fh-border); background: color-mix(in srgb, var(--fh-hover) 50%, transparent);
}
.admin-table td { padding: 10px 16px; border-bottom: 1px solid var(--fh-border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr.clickable { cursor: pointer; }
.admin-table tr.clickable:hover { background: var(--fh-hover); }
.admin-table tr.selected { background: color-mix(in srgb, var(--fh-accent) 12%, transparent); }
.admin-table .num { text-align: right; width: 100px; }
.row-actions-col { width: 96px; text-align: right; white-space: nowrap; }
.entity { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.entity-text { display: flex; flex-direction: column; min-width: 0; }
.entity-text .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.entity-badge {
    width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; flex: none;
    font-weight: 700; color: #fff; background: var(--fh-accent);
}
.entity-badge.company { background: var(--fh-accent); }
.entity-badge.vendor { background: #8a3ffc; }
.entity-badge.large { width: 44px; height: 44px; font-size: 18px; border-radius: 10px; }
.entity-badge.small { width: 22px; height: 22px; font-size: 11px; border-radius: 6px; }
.avatar-lg {
    width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
    background: color-mix(in srgb, var(--fh-accent) 18%, var(--fh-surface)); color: var(--fh-accent); font-weight: 700; font-size: 13px;
}
.count-pill { display: inline-block; min-width: 28px; padding: 2px 10px; border-radius: 12px; background: var(--fh-hover); text-align: center; font-weight: 600; font-size: 13px; }
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.company { background: color-mix(in srgb, var(--fh-accent) 14%, transparent); color: var(--fh-accent); }
.tag.vendor { background: color-mix(in srgb, #8a3ffc 15%, transparent); color: #8a3ffc; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.ok { color: #107c10; background: color-mix(in srgb, #107c10 14%, transparent); }
.status-pill.wait { color: #b85c00; background: color-mix(in srgb, #b85c00 14%, transparent); }
@media (prefers-color-scheme: dark) {
    .tag.company { color: var(--fh-accent); }
    .tag.vendor { color: #be95ff; }
    .status-pill.ok { color: #6ccb5f; }
    .status-pill.wait { color: #f7a35c; }
}
.admin-empty { text-align: center; padding: 48px 16px; background: var(--fh-surface); border: 1px dashed var(--fh-border); border-radius: 10px; }
.admin-empty-icon { font-size: 40px; }
.admin-empty h3 { margin: 8px 0 4px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.stat-card {
    display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center;
    padding: 18px; background: var(--fh-surface); border: 1px solid var(--fh-border); border-radius: 10px; color: var(--fh-text);
    transition: border-color .15s, transform .15s;
}
.stat-card:hover { text-decoration: none; border-color: var(--fh-accent); transform: translateY(-1px); }
.stat-icon { grid-row: span 2; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 22px; background: var(--fh-hover); }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--fh-muted); font-size: 13px; }
.field-error { color: var(--fh-danger); margin: 8px 0 0; font-size: 13px; }
.small { font-size: 12px; }

/* side panel (drawer) */
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); animation: fade-in .15s ease-out; }
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(440px, 100vw); display: flex; flex-direction: column;
    background: var(--fh-surface); border-left: 1px solid var(--fh-border); box-shadow: -12px 0 32px rgba(0,0,0,.2);
    animation: slide-in .2s ease-out;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--fh-border); }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.drawer-body h3 { margin: 0; }
.drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--fh-border); }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.person-list { list-style: none; margin: 0; padding: 0; }
.person-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--fh-border); }
.person-list li > span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
.person-list .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.check-list { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--fh-border); border-radius: 8px; max-height: 340px; overflow: auto; }
.check-list li + li { border-top: 1px solid var(--fh-border); }
.check-list label { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; }
.check-list li:hover { background: var(--fh-hover); }
.check-list li.on { background: color-mix(in srgb, var(--fh-accent) 10%, transparent); }
.check-list input { width: 16px; height: 16px; accent-color: var(--fh-accent); }
.check-list .count { margin-left: auto; font-size: 12px; }

/* ---------- login (static page, plain HTML) ---------- */
.login-page {
    min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    background: var(--fh-bg);
}
.login-brand {
    position: relative; overflow: hidden; color: #fff; background: var(--ophir-ink);
    background-image:
        radial-gradient(900px 500px at 110% 110%, rgba(232,130,43,.35), transparent 60%),
        radial-gradient(600px 400px at -10% -10%, rgba(232,130,43,.12), transparent 60%);
}
/* The logo's mountain line, large and faint, as a backdrop. */
.login-brand::after {
    content: ""; position: absolute; right: -8%; bottom: -6%; width: 70%; aspect-ratio: 54 / 26; opacity: .08;
    background: var(--ophir-accent);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 54 26'%3E%3Cpath d='M23.2 4.8c.3-.5.8-.8 1.3-.8.4 0 .8.1 1.2.7l9.3 16.1a1.7 1.7 0 0 0 3-1.7L28.7 3A4.9 4.9 0 0 0 20.2 3.1l-2.5 3.9c-.3.4-.7.9-1.2 1-.5.1-1-.3-1.2-.5-1.7-1.5-3.2-1.7-4.2-1.6-1.4.1-2.7.9-3.7 2.2C5.3 10.6.9 18.7.8 19c-.9 1.7-1 3.4-.2 4.7.8 1.3 2.3 2.1 4.2 2.1h28.8a1.7 1.7 0 0 0 0-3.4H4.9c-.7 0-1-.2-1.1-.5-.2-.2-.3-.7 0-1.3 0-.1 4.4-8.1 6.2-10.4.3-.4.8-.8 1.3-.9.6-.1 1.3.4 1.7.8 1.2 1 2.6 1.5 4 1.3 1.4-.2 2.7-1.1 3.6-2.5l2.6-4.1Z'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 54 26'%3E%3Cpath d='M23.2 4.8c.3-.5.8-.8 1.3-.8.4 0 .8.1 1.2.7l9.3 16.1a1.7 1.7 0 0 0 3-1.7L28.7 3A4.9 4.9 0 0 0 20.2 3.1l-2.5 3.9c-.3.4-.7.9-1.2 1-.5.1-1-.3-1.2-.5-1.7-1.5-3.2-1.7-4.2-1.6-1.4.1-2.7.9-3.7 2.2C5.3 10.6.9 18.7.8 19c-.9 1.7-1 3.4-.2 4.7.8 1.3 2.3 2.1 4.2 2.1h28.8a1.7 1.7 0 0 0 0-3.4H4.9c-.7 0-1-.2-1.1-.5-.2-.2-.3-.7 0-1.3 0-.1 4.4-8.1 6.2-10.4.3-.4.8-.8 1.3-.9.6-.1 1.3.4 1.7.8 1.2 1 2.6 1.5 4 1.3 1.4-.2 2.7-1.1 3.6-2.5l2.6-4.1Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.login-brand-inner {
    position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; justify-content: space-between;
    gap: 40px; padding: 56px clamp(32px, 6vw, 88px);
}
.login-logo { color: #fff; }
.login-kicker {
    margin: 0 0 14px; color: var(--ophir-accent); font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
}
.login-brand h2 { margin: 0; font-size: clamp(30px, 3.4vw, 44px); line-height: 1.12; font-weight: 700; letter-spacing: -.01em; }
.login-brand h2 span { color: var(--ophir-accent); }
.login-points { list-style: none; margin: 32px 0 0; padding: 0; display: grid; gap: 14px; color: rgba(255,255,255,.82); font-size: 15px; }
.login-points li { display: flex; align-items: center; gap: 12px; }
.login-points .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ophir-accent); flex: none; box-shadow: 0 0 0 4px rgba(232,130,43,.18); }
.login-brand-foot { margin: 0; color: rgba(255,255,255,.45); font-size: 12px; }

.login-panel { position: relative; overflow: hidden; display: grid; place-items: center; padding: 40px 24px; }
.login-card { position: relative; z-index: 1; width: 100%; max-width: 400px; }
.login-floats { display: none; }

/* Light mode: warm paper with soft orange light and a dot grid, a floating white card,
   and a few drifting "file" chips. Dark mode keeps the plain panel. */
@media (prefers-color-scheme: light) {
    .login-panel {
        background:
            radial-gradient(520px 420px at 105% -5%, rgba(232,130,43,.22), transparent 62%),
            radial-gradient(460px 380px at -10% 110%, rgba(232,130,43,.14), transparent 62%),
            radial-gradient(circle, rgba(20,18,16,.075) 1px, transparent 1.3px) 0 0 / 22px 22px,
            var(--ophir-paper);
    }
    .login-card {
        max-width: 440px; padding: 40px 40px 30px; background: #fff; border-radius: 22px;
        border: 1px solid #efe6d8;
        box-shadow: 0 40px 80px -30px rgba(120,62,12,.35), 0 12px 24px -12px rgba(20,18,16,.12);
    }
    /* Orange line along the top of the card, like the header. */
    .login-card::before {
        content: ""; position: absolute; left: 28px; right: 28px; top: -1px; height: 4px; border-radius: 0 0 4px 4px;
        background: linear-gradient(90deg, var(--ophir-accent), #f4b06c);
    }
    .login-card h1 { font-size: 32px; }
    .login-input { background: #fffdfa; border-color: #ebe2d4; }
    .login-input:hover { border-color: #dccfbc; }
    .login-help { padding-top: 18px; border-top: 1px dashed #eadfcf; }

    .login-floats { display: block; position: absolute; inset: 0; pointer-events: none; }
    .login-float {
        position: absolute; display: flex; align-items: center; gap: 12px; padding: 12px 16px 12px 12px;
        background: rgba(255,255,255,.88); backdrop-filter: blur(6px); border: 1px solid #efe6d8; border-radius: 14px;
        box-shadow: 0 18px 40px -18px rgba(120,62,12,.35); font-size: 13px; color: #1d1b18;
        animation: login-drift 7s ease-in-out infinite;
    }
    .login-float strong { display: block; font-weight: 600; }
    .login-float small { display: flex; align-items: center; gap: 6px; color: #7a736a; font-size: 12px; margin-top: 2px; }
    .float-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; }
    .float-icon.folder { background: #fff1e3; }
    .float-icon.file { background: #fdeceb; }
    .float-icon.share { background: #eaf3ff; }
    .ok-dot { width: 7px; height: 7px; border-radius: 50%; background: #2e9e4f; box-shadow: 0 0 0 3px rgba(46,158,79,.15); }
    /* Above and below the card, never on it. */
    .login-float.f1 { top: 6%; right: 6%; transform: rotate(3deg); }
    .login-float.f2 { bottom: 5%; left: 6%; transform: rotate(-3deg); animation-delay: -2.5s; }
    .login-float.f3 { bottom: 12%; right: 5%; transform: rotate(2deg); animation-delay: -5s; }
}
@keyframes login-drift {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -10px; }
}
@media (prefers-reduced-motion: reduce) { .login-float { animation: none; } }
/* The chips only fit beside the card on wide screens. */
@media (max-width: 1360px), (max-height: 820px) { .login-float.f3 { display: none; } }
@media (max-width: 1180px), (max-height: 680px) { .login-floats { display: none !important; } }
.login-logo-small { display: none; color: var(--fh-text); margin-bottom: 24px; }
.login-card h1 { margin: 0; font-size: 30px; letter-spacing: -.01em; }
.login-sub { margin: 6px 0 0; color: var(--fh-muted); }
.login-form { display: flex; flex-direction: column; gap: 18px; margin-top: 28px; }
.login-field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
.login-input {
    display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 12px;
    background: var(--fh-surface); border: 1px solid var(--fh-border); border-radius: 10px; color: var(--fh-muted);
    transition: border-color .15s, box-shadow .15s;
}
.login-input:focus-within { border-color: var(--ophir-accent); box-shadow: 0 0 0 4px rgba(232,130,43,.18); color: var(--ophir-accent); }
.login-input input {
    flex: 1; min-width: 0; height: 34px; padding: 0 8px; border: none; border-radius: 6px; outline: none; background: transparent;
    color: var(--fh-text); font: inherit; font-weight: 400; font-size: 15px;
}
.login-input input::placeholder { color: var(--fh-muted); opacity: .7; }
/* Browser autofill paints its own (light blue) box over the field; keep the field's own colours
   so saved email/password sit centred in the box like typed text. */
.login-input input:-webkit-autofill,
.login-input input:-webkit-autofill:hover,
.login-input input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--fh-text);
    caret-color: var(--fh-text);
    -webkit-box-shadow: 0 0 0 1000px var(--fh-surface) inset;
    box-shadow: 0 0 0 1000px var(--fh-surface) inset;
    transition: background-color 9999s ease-out 0s;
}
.login-input input:autofill { background: transparent; }
.login-reveal {
    border: none; background: none; color: var(--fh-muted); font: inherit; font-size: 12px; font-weight: 600;
    cursor: pointer; padding: 6px 4px; border-radius: 6px;
}
.login-reveal:hover { color: var(--fh-text); }
.login-submit {
    position: relative; height: 46px; margin-top: 6px; border: none; border-radius: 10px; cursor: pointer;
    background: var(--ophir-accent); color: #1a0f05; font: inherit; font-size: 15px; font-weight: 700;
    box-shadow: 0 6px 18px rgba(232,130,43,.32); transition: background .15s, transform .05s, box-shadow .15s;
}
.login-submit:hover { background: var(--ophir-accent-dark); color: #fff; }
.login-submit:active { transform: translateY(1px); }
.login-submit:focus-visible { outline: 3px solid var(--fh-text); outline-offset: 2px; }
.login-submit .spinner {
    display: none; position: absolute; right: 16px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
    border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite;
}
.login-submit.busy { cursor: progress; opacity: .85; }
.login-submit.busy .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-error {
    display: flex; gap: 10px; align-items: flex-start; margin-top: 20px; padding: 12px 14px; border-radius: 10px;
    background: color-mix(in srgb, var(--fh-danger) 10%, transparent); color: var(--fh-danger);
    border: 1px solid color-mix(in srgb, var(--fh-danger) 30%, transparent); font-size: 14px;
}
.login-error svg { flex: none; margin-top: 1px; }
.login-help { margin: 28px 0 0; color: var(--fh-muted); font-size: 12px; line-height: 1.6; }

@media (max-width: 900px) {
    .login-page { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .login-logo-small { display: block; }
    .login-panel { align-items: start; padding-top: 8vh; }
    .login-card { padding: 28px 22px 22px; }
}

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    padding: 8px 16px; background: #fde7e9; color: #000;
}

/* ---------- recycle bin ---------- */
.bin-note { margin: 0 0 8px; max-width: 820px; }
.bin-footer { font-size: 12px; margin-top: 8px; }
.danger-button { color: var(--fh-danger); }
.danger-button::part(control) { color: var(--fh-danger); }

/* ---------- site search ---------- */
.site-toolbar { margin-bottom: 16px; }
.site-search { width: 340px; max-width: 100%; }
mark.hit { background: color-mix(in srgb, var(--ophir-accent) 30%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }

/* ---------- admin: light mode ----------
   Same warm Ophir feel as the login page: a banner header, pill tabs, white cards with soft
   warm shadows and orange highlights. Dark mode keeps its plain style. */
@media (prefers-color-scheme: light) {
    .admin-head {
        position: relative; overflow: hidden; padding: 26px 28px; border-radius: 18px;
        border: 1px solid #efe6d8;
        background:
            radial-gradient(420px 220px at 100% 0%, rgba(232,130,43,.20), transparent 65%),
            radial-gradient(circle, rgba(20,18,16,.06) 1px, transparent 1.3px) 0 0 / 20px 20px,
            linear-gradient(135deg, #ffffff 0%, #fdf6ee 100%);
        box-shadow: 0 18px 40px -28px rgba(120,62,12,.35);
    }
    /* The logo's mountain line, faint, at the banner's right edge. */
    .admin-head::after {
        content: ""; position: absolute; right: -20px; bottom: -18px; width: 220px; aspect-ratio: 54 / 26; opacity: .10;
        background: var(--ophir-accent); pointer-events: none;
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 54 26'%3E%3Cpath d='M23.2 4.8c.3-.5.8-.8 1.3-.8.4 0 .8.1 1.2.7l9.3 16.1a1.7 1.7 0 0 0 3-1.7L28.7 3A4.9 4.9 0 0 0 20.2 3.1l-2.5 3.9c-.3.4-.7.9-1.2 1-.5.1-1-.3-1.2-.5-1.7-1.5-3.2-1.7-4.2-1.6-1.4.1-2.7.9-3.7 2.2C5.3 10.6.9 18.7.8 19c-.9 1.7-1 3.4-.2 4.7.8 1.3 2.3 2.1 4.2 2.1h28.8a1.7 1.7 0 0 0 0-3.4H4.9c-.7 0-1-.2-1.1-.5-.2-.2-.3-.7 0-1.3 0-.1 4.4-8.1 6.2-10.4.3-.4.8-.8 1.3-.9.6-.1 1.3.4 1.7.8 1.2 1 2.6 1.5 4 1.3 1.4-.2 2.7-1.1 3.6-2.5l2.6-4.1Z'/%3E%3C/svg%3E") center / contain no-repeat;
                mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 54 26'%3E%3Cpath d='M23.2 4.8c.3-.5.8-.8 1.3-.8.4 0 .8.1 1.2.7l9.3 16.1a1.7 1.7 0 0 0 3-1.7L28.7 3A4.9 4.9 0 0 0 20.2 3.1l-2.5 3.9c-.3.4-.7.9-1.2 1-.5.1-1-.3-1.2-.5-1.7-1.5-3.2-1.7-4.2-1.6-1.4.1-2.7.9-3.7 2.2C5.3 10.6.9 18.7.8 19c-.9 1.7-1 3.4-.2 4.7.8 1.3 2.3 2.1 4.2 2.1h28.8a1.7 1.7 0 0 0 0-3.4H4.9c-.7 0-1-.2-1.1-.5-.2-.2-.3-.7 0-1.3 0-.1 4.4-8.1 6.2-10.4.3-.4.8-.8 1.3-.9.6-.1 1.3.4 1.7.8 1.2 1 2.6 1.5 4 1.3 1.4-.2 2.7-1.1 3.6-2.5l2.6-4.1Z'/%3E%3C/svg%3E") center / contain no-repeat;
    }
    .admin-head > * { position: relative; z-index: 1; }
    .admin-head h1 { font-size: 28px; letter-spacing: -.01em; }
    .admin-eyebrow { color: var(--ophir-accent-dark); }

    /* Pill tabs. */
    .admin-tabs {
        display: inline-flex; gap: 4px; padding: 4px; margin: 18px 0 22px; border: 1px solid #efe6d8;
        border-radius: 999px; background: #fff; box-shadow: 0 6px 16px -10px rgba(120,62,12,.30); max-width: 100%;
    }
    .admin-tabs a { border: none; margin: 0; padding: 8px 18px; border-radius: 999px; color: #5c5852; }
    .admin-tabs a:hover { background: #fbf3e9; border-radius: 999px; color: #1d1b18; }
    .admin-tabs a.active { background: var(--ophir-accent); color: #1a0f05; box-shadow: 0 6px 14px -6px rgba(232,130,43,.6); }

    /* Cards and tables. */
    .admin-card { border-color: #efe6d8; border-radius: 14px; box-shadow: 0 16px 36px -26px rgba(120,62,12,.40); }
    .admin-table th { background: #fbf6ef; color: #7a736a; border-bottom-color: #efe6d8; }
    .admin-table td { border-bottom-color: #f3ece2; }
    .admin-table tr.clickable:hover { background: #fdf8f2; }
    .admin-table tr.selected { background: #fdeedd; box-shadow: inset 3px 0 0 var(--ophir-accent); }
    .count-pill { background: #fbf0e3; color: #8a4a12; }
    .entity-badge.company { background: linear-gradient(135deg, #f0973f, #c96c1e); box-shadow: 0 6px 12px -6px rgba(201,108,30,.6); }
    .entity-badge.vendor { background: linear-gradient(135deg, #9b5cff, #6a3fd6); box-shadow: 0 6px 12px -6px rgba(106,63,214,.55); }
    .avatar-lg { background: linear-gradient(135deg, #fde4c8, #f9cfa2); color: #8a4a12; }
    .admin-select, .admin-input { border-color: #e6dccd; background: #fffdfa; }
    .segmented { border-color: #e6dccd; background: #fff; }
    .segmented button.on { background: var(--ophir-accent); color: #1a0f05; }

    /* Overview stat cards: white tiles, tinted icons, an orange line on hover. */
    .stat-card {
        position: relative; overflow: hidden; border-color: #efe6d8; border-radius: 16px;
        box-shadow: 0 16px 34px -26px rgba(120,62,12,.45);
    }
    .stat-card::before {
        content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
        background: linear-gradient(90deg, var(--ophir-accent), #f4b06c); opacity: 0; transition: opacity .15s;
    }
    .stat-card:hover { border-color: #f1c99e; transform: translateY(-2px); box-shadow: 0 22px 40px -24px rgba(120,62,12,.5); }
    .stat-card:hover::before { opacity: 1; }
    .stat-icon { border-radius: 12px; }
    .stat-icon.company { background: #fff1e3; }
    .stat-icon.vendor { background: #f2ebff; }
    .stat-icon.people { background: #e9f5ee; }
    .stat-icon.invited { background: #fdeceb; }
    .stat-value { color: #1d1b18; }
    .admin-card.notice { background: linear-gradient(90deg, #fff8ec, #fff); border-left-color: var(--ophir-accent); }
    .admin-card.how ol li::marker { color: var(--ophir-accent); font-weight: 700; }

    /* Empty states. */
    .admin-empty {
        border-color: #eadfcf; border-radius: 16px;
        background: radial-gradient(circle, rgba(20,18,16,.05) 1px, transparent 1.3px) 0 0 / 18px 18px, #fffdfa;
    }
    .admin-empty-icon {
        width: 72px; height: 72px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
        background: #fff1e3; box-shadow: 0 10px 24px -14px rgba(201,108,30,.6);
    }

    /* Side panel. */
    .drawer { border-left-color: #efe6d8; box-shadow: -24px 0 48px -24px rgba(120,62,12,.35); }
    .drawer-head { background: linear-gradient(135deg, #ffffff, #fdf3e7); border-bottom-color: #efe6d8; }
    .drawer-foot { background: #fffdfa; border-top-color: #efe6d8; }
    .check-list { border-color: #efe6d8; }
    .check-list li.on { background: #fdf0e1; }
    .drawer-backdrop { background: rgba(40,24,10,.28); }
}
