:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --text: #1d2433;
    --muted: #6b7385;
    --border: #e3e7ef;
    --primary: #0d2c6e;          /* navy, from the poster's "Join Us" button */
    --primary-dark: #081e4d;
    --accent: #f26a21;           /* logo orange */
    --accent-light: #f99d2a;
    --helpbar-h: 46px;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --sidebar: #111111;          /* logo black */
    --sidebar-text: #d6d6d6;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
/* The hidden attribute must win over component display rules (e.g. .avatar-img, textarea) */
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.25; }
h1 { font-size: 1.3rem; margin: 0; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
code { background: #eef0f6; padding: 1px 5px; border-radius: 4px; font-size: .88em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.right { text-align: right; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.15rem; margin: 0 6px 28px; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 800; font-size: .85rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a { color: var(--sidebar-text); padding: 10px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.nav-icon { width: 20px; text-align: center; }
.sidebar-logout .btn-ghost { color: var(--sidebar-text); border-color: rgba(255,255,255,.15); background: transparent; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar h1 { flex: 1; }
.menu-toggle { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-meta { display: flex; flex-direction: column; align-items: flex-start; font-size: .85rem; gap: 2px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #e0e7ff; color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.content { padding: 28px; flex: 1; }
.footer { padding: 16px 28px; color: var(--muted); font-size: .85rem; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.grid-2 .card { margin-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 20px; margin-bottom: 20px; }
.stat { margin: 0; display: flex; flex-direction: column; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.9rem; font-weight: 700; }
.welcome p { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--primary); background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #f1f3f9; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-block { width: 100%; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-admin { background: #fee2e2; color: #b91c1c; }
.badge-manager { background: #dbeafe; color: #1d4ed8; }
.badge-user { background: #dcfce7; color: #15803d; }
.status { font-size: .85rem; font-weight: 600; }
.status::before { content: "●"; margin-right: 5px; }
.status.on { color: var(--success); }
.status.off { color: var(--muted); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .75rem; background: #eef0f6; color: #3a4256; text-transform: capitalize; white-space: nowrap; }
.tag-login { background: #dcfce7; color: #15803d; }
.tag-login_failed, .tag-access_denied, .tag-user_deleted { background: #fee2e2; color: #b91c1c; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ---------- Forms ---------- */
form label { display: block; margin-bottom: 14px; font-weight: 500; font-size: .92rem; }
input[type=text], input[type=email], input[type=password], input[type=search], select {
    display: block; width: 100%; margin-top: 5px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid #c7d2fe; border-color: var(--primary); }
input:disabled, select:disabled { background: #f4f6fb; color: var(--muted); }
label.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 400; }
small.error { color: var(--danger); display: block; margin-top: 4px; }
small.muted { display: block; margin-top: 4px; }
.form-card { max-width: 560px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Tables ---------- */
.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select { margin: 0; width: auto; min-width: 180px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table th.right, .table td.right { text-align: right; }
.table tbody tr:hover { background: #fafbfe; }
.actions { white-space: nowrap; }
.actions form { display: inline; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; }

/* ---------- Dashboard widgets ---------- */
.bars { list-style: none; padding: 0; margin: 0 0 16px; }
.bars li { display: grid; grid-template-columns: 110px 1fr 36px; gap: 10px; align-items: center; margin-bottom: 10px; }
.bar-track { height: 10px; background: #eef0f6; border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.bar-admin { background: #ef4444; }
.bar-manager { background: #3b82f6; }
.bar-user { background: #22c55e; }
.bar-value { text-align: right; font-weight: 600; }
.activity { list-style: none; padding: 0; margin: 0 0 12px; }
.activity li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.activity li:last-child { border-bottom: 0; }
.perm-list { list-style: none; padding: 0; margin: 0; }
.perm-list li { padding: 5px 0; }
.perm-list .yes { color: var(--success); }
.perm-list .no { color: var(--muted); }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(135deg, #eef2ff, #f4f6fb 60%); }
.auth-wrap > .alert { width: 100%; max-width: 400px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 30px rgba(30, 41, 80, .08); padding: 32px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; margin-bottom: 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .sidebar { position: fixed; left: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
    .menu-toggle { display: block; }
    .topbar, .content { padding-left: 16px; padding-right: 16px; }
    .user-meta { display: none; }
    .activity li { grid-template-columns: auto 1fr; }
    .activity time { grid-column: 2; }
}

/* ---------- Shared bits (pages, editors, toolbars) ---------- */
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.empty-state { text-align: center; padding: 28px 12px; }
textarea { display: block; width: 100%; margin-top: 5px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; resize: vertical; }
input[type=number], input[type=date], input[type=tel] {
    display: block; width: 100%; margin-top: 5px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.badge-draft { background: #eef0f6; color: #4b5468; }

.q-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.field { margin-bottom: 14px; }
.field-label { display: block; font-weight: 500; font-size: .92rem; margin-bottom: 8px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.save-bar { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 14px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }

.req { color: var(--danger); font-weight: 700; }
.toolbar .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .actions form { display: inline; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Registration ---------- */
.auth-card-wide { max-width: 620px; }
.auth-wrap > .alert { max-width: 620px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid label:has(select.span-2) { grid-column: 1 / -1; }
.auth-alt { text-align: center; margin: 16px 0 0; color: var(--muted); }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.options-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.options-grid textarea { font-size: .9rem; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 8px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 500; }

/* ---------- Origins Collective branding ---------- */
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; }
.brand-logo { height: 34px; width: auto; background: #fff; border-radius: 8px; padding: 4px 6px; }
.brand-name { font-weight: 900; letter-spacing: .3px; font-size: .95rem; line-height: 1.1; }
.brand-accent { background: linear-gradient(90deg, var(--accent-light), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sidebar .brand { margin-bottom: 24px; }
.sidebar .brand-name { color: #fff; }
.sidebar nav a.active { background: linear-gradient(90deg, var(--accent-light), var(--accent)); color: #fff; }
.topbar { border-bottom: 3px solid var(--accent); }
.avatar { background: #fde8da; color: var(--accent); }
.brand-stacked { flex-direction: column; gap: 8px; }
.brand-stacked .brand-logo { height: 72px; background: none; padding: 0; }
.brand-stacked .brand-name { font-size: 1.35rem; color: #111; }
.auth-brand { justify-content: center; margin-bottom: 16px; }
.auth-wrap { background: linear-gradient(160deg, #fff7f0 0%, #fdebdc 55%, #f9d9c0 100%); }
.auth-card { border-top: 4px solid var(--accent); }
.brand-mark { background: var(--accent); }
.stat-value { color: var(--primary); }

/* "Need help? Call us" bar, fixed to the bottom of every page */
body { padding-bottom: var(--helpbar-h); }
.help-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: var(--helpbar-h);
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: #111; color: #d6d6d6; font-size: .95rem; text-decoration: none;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .15);
}
.help-bar:hover { text-decoration: none; background: #000; color: #fff; }
.help-bar strong { color: var(--accent-light); letter-spacing: .3px; }
.help-icon {
    display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-light), var(--accent)); color: #fff; font-size: 15px;
}
.sidebar { height: calc(100vh - var(--helpbar-h)); }
.layout { min-height: calc(100vh - var(--helpbar-h)); }
.save-bar { bottom: var(--helpbar-h); }
.auth-wrap { min-height: calc(100vh - var(--helpbar-h)); }
@media (max-width: 860px) { .sidebar { height: calc(100vh - var(--helpbar-h)); } }

/* ---------- News ---------- */
.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.news-card { padding: 0; margin: 0; overflow: hidden; display: flex; flex-direction: column; }
.news-cover { position: relative; display: block; aspect-ratio: 16 / 9; background: #f1f3f9; }
.news-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.news-cover.no-image { display: grid; place-items: center; font-size: 2.4rem; text-decoration: none; }
.news-count { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, .65); color: #fff; font-size: .78rem; padding: 2px 8px; border-radius: 99px; }
.news-card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.news-card-body h3 { margin: 6px 0 6px; font-size: 1.08rem; }
.news-card-body h3 a { color: var(--text); }
.news-card-body p { margin: 0 0 12px; font-size: .92rem; flex: 1; }
.news-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.news-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge-pinned { background: #fff1e6; color: #b45309; }
.news-article { max-width: 820px; margin: 0 auto; }
.news-title { font-size: 1.6rem; margin: 10px 0 16px; }
.news-hero { max-width: 100%; max-height: 480px; width: auto; height: auto; border-radius: 10px; display: block; margin: 0 auto 18px; }
.news-body { font-size: 1.02rem; line-height: 1.7; overflow-wrap: anywhere; }
.news-body p { margin: 0 0 14px; }
.news-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.news-gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; border: 1px solid var(--border); }
.news-edit-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.news-edit-image { border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: #fcfcfe; }
.news-edit-image img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: block; margin-bottom: 6px; }
.news-edit-image label.checkbox { margin: 4px 0 0; font-size: .85rem; }
.news-edit-image.removing { opacity: .45; border-color: #fca5a5; }
.danger-text { color: var(--danger); }
.news-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.news-strip-item { display: flex; gap: 12px; align-items: center; color: var(--text); padding: 8px; border-radius: 10px; border: 1px solid var(--border); }
.news-strip-item:hover { background: #fafbfe; text-decoration: none; }
.news-strip-item img, .news-strip-placeholder { width: 72px; height: 56px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.news-strip-placeholder { display: grid; place-items: center; background: #f1f3f9; font-size: 1.5rem; }
.news-strip-item strong { display: block; font-size: .92rem; line-height: 1.3; }
.tag-news_created, .tag-news_updated { background: #e0f2fe; color: #075985; }
.tag-news_deleted { background: #fee2e2; color: #b91c1c; }

/* ---------- News editor ---------- */
.rte { border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: hidden; }
.rte:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(13, 44, 110, .12); }
.rte-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); background: #f7f8fb; position: sticky; top: 0; z-index: 2; }
.rte-btn { min-width: 34px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; font: inherit; font-size: .88rem; color: var(--text); display: inline-flex; align-items: center; justify-content: center; }
.rte-btn:hover { background: #e9ecf4; }
.rte-btn.active { background: #e0e7ff; border-color: #c7d2fe; color: var(--primary); }
.rte-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.rte-content { position: relative; min-height: 260px; max-height: 70vh; overflow-y: auto; padding: 14px 16px; outline: none; }
.rte-content.is-empty::before { content: attr(data-placeholder); color: var(--muted); position: absolute; pointer-events: none; }
.rte-content p:first-child { margin-top: 0; }
.news-body h2 { font-size: 1.35rem; margin: 20px 0 10px; }
.news-body h3 { font-size: 1.12rem; margin: 18px 0 8px; }
.news-body ul, .news-body ol { margin: 0 0 14px; padding-left: 26px; }
.news-body li { margin-bottom: 4px; }
.news-body blockquote { margin: 0 0 14px; padding: 8px 16px; border-left: 4px solid var(--accent, var(--primary)); background: #fafafa; color: #444; }
.news-body a { text-decoration: underline; }

.upload-drop { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 22px 16px; border: 2px dashed var(--border); border-radius: 12px; cursor: pointer; font-weight: 400; margin: 0; }
.upload-drop:hover { border-color: var(--primary); background: #fafbfe; }
.upload-icon { font-size: 1.8rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.news-edit-image.is-featured { border-color: var(--accent, var(--primary)); box-shadow: 0 0 0 2px var(--accent, var(--primary)); }
.news-edit-image.is-new { border-style: dashed; }
.new-tag { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- News: toolbar, list view, pagination ---------- */
.news-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; }
.news-search { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; min-width: 260px; }
.news-search select { width: auto; margin: 0; }
.search-box { position: relative; flex: 1; min-width: 180px; max-width: 420px; }
.search-box input { margin: 0; padding-left: 36px; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: .9rem; opacity: .6; }
.news-toolbar-right { display: flex; gap: 10px; align-items: center; }
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle a { display: grid; place-items: center; width: 40px; height: 38px; color: var(--muted); background: #fff; }
.view-toggle a + a { border-left: 1px solid var(--border); }
.view-toggle a:hover { background: #f1f3f9; text-decoration: none; }
.view-toggle a.active { background: var(--primary); color: #fff; }
.results-count { margin: -6px 0 12px; }
mark { background: #fde68a; color: inherit; padding: 0 1px; border-radius: 2px; }

.news-list { padding: 0; overflow: hidden; }
.news-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 18px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.news-row:last-child { border-bottom: 0; }
.news-row:hover { background: #fafbfe; }
.news-row-thumb { display: block; width: 150px; aspect-ratio: 16 / 10; border-radius: 8px; overflow: hidden; background: #f1f3f9; }
.news-row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.news-row-thumb.no-image { display: grid; place-items: center; font-size: 1.8rem; text-decoration: none; }
.news-row-main { min-width: 0; }
.news-row-main h3 { margin: 0 0 4px; font-size: 1.05rem; }
.news-row-main h3 a { color: var(--text); }
.news-row-main p { margin: 0 0 6px; font-size: .9rem; }
.news-row-actions { display: flex; gap: 6px; }

.pagination { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 22px 0 8px; }
.page-link { min-width: 38px; height: 38px; padding: 0 10px; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font-weight: 500; }
.page-link:hover { background: #f1f3f9; text-decoration: none; }
.page-link.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.disabled { opacity: .4; pointer-events: none; }
.page-gap { color: var(--muted); padding: 0 2px; }

@media (max-width: 640px) {
    .news-row { grid-template-columns: 96px 1fr; gap: 12px; padding: 12px; }
    .news-row-thumb { width: 96px; }
    .news-row-actions { grid-column: 1 / -1; justify-content: flex-end; }
    .news-row-main p { display: none; }
    .page-nav { padding: 0 8px; }
    .search-box { max-width: none; }
}

/* ---------- Image popup (assets/js/lightbox.js) ---------- */
a[data-lightbox] { cursor: zoom-in; display: block; }
body.lightbox-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(10, 12, 20, .92); padding: 56px 72px; animation: lb-fade .15s ease-out; }
.lightbox[hidden] { display: none; }
@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }
.lb-figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; }
.lb-img { max-width: 100%; max-height: calc(100% - 44px); object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); background: #222; transition: opacity .15s; }
.lightbox.loading .lb-img { opacity: .35; }
.lb-caption { display: flex; gap: 14px; justify-content: center; align-items: baseline; color: #e5e7eb; font-size: .92rem; margin-top: 12px; text-align: center; }
.lb-counter { color: #9ca3af; font-variant-numeric: tabular-nums; }
.lb-btn { position: absolute; display: grid; place-items: center; width: 46px; height: 46px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; text-decoration: none; }
.lb-btn:hover, .lb-btn:focus-visible { background: rgba(255, 255, 255, .26); text-decoration: none; outline: none; }
.lb-close { top: 14px; right: 14px; font-size: 1.15rem; }
.lb-open { top: 14px; right: 70px; font-size: 1.15rem; }
.lb-prev { left: 14px; top: 50%; transform: translateY(-50%); font-size: 2rem; }
.lb-next { right: 14px; top: 50%; transform: translateY(-50%); font-size: 2rem; }
.lightbox.single .lb-prev, .lightbox.single .lb-next { display: none; }
@media (max-width: 640px) {
    .lightbox { padding: 60px 8px 24px; }
    .lb-prev, .lb-next { top: auto; bottom: 18px; transform: none; width: 42px; height: 42px; }
    .lb-prev { left: calc(50% - 60px); }
    .lb-next { right: calc(50% - 60px); }
    .lb-img { max-height: calc(100% - 90px); }
}

/* ---------- Users: search & filters ---------- */
.user-search { padding: 14px 16px; }
.user-search .toolbar { margin: 0; }
.user-search .filters { flex: 1; align-items: center; }
.user-search .search-box { max-width: 460px; }
.filter-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent, var(--primary)); color: #fff; font-size: .75rem; }
.filter-panel { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 16px; }
.filter-grid select:disabled { opacity: .5; }
.range-inputs { display: flex; align-items: center; gap: 6px; }
.range-inputs input { margin: 0; min-width: 0; }
.range-inputs span { color: var(--muted); font-size: .85rem; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: #e0e7ff; color: var(--primary); font-size: .85rem; font-weight: 500; }
.chip:hover { background: #c7d2fe; text-decoration: none; }
.chip-clear { background: none; color: var(--muted); text-decoration: underline; }
.users-table td { vertical-align: top; }
.users-table td:first-child { min-width: 190px; }

/* ---------- Profile photos ---------- */
.avatar { flex-shrink: 0; overflow: hidden; }
.avatar-img { object-fit: cover; display: block; padding: 0; background: #f1f3f9; }
.avatar-sm { width: 34px; height: 34px; font-size: .85rem; }
.avatar-lg { width: 76px; height: 76px; font-size: 1.8rem; }
.avatar-xl { width: 128px; height: 128px; font-size: 3rem; }
.avatar-placeholder { background: #f1f3f9; color: var(--muted); }
.user-cell { display: flex; align-items: center; gap: 10px; }
.photo-edit { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.photo-edit-inline { margin-bottom: 16px; gap: 14px; }
.photo-frame { position: relative; }
.photo-frame .avatar { border: 3px solid #fff; box-shadow: 0 0 0 1px var(--border); }
.photo-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.photo-actions form { margin: 0; }
.photo-actions label.btn { margin: 0; cursor: pointer; }
.photo-actions label.checkbox { margin: 0; }
.register-photo { justify-content: center; margin-bottom: 18px; }

/* ---------- Users: search area v2 ---------- */
.user-search { padding: 18px 20px 0; overflow: visible; }
.search-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search-box-lg { flex: 1 1 320px; max-width: none !important; }
.search-box-lg input { height: 46px; border-radius: 10px; font-size: 1rem; padding-left: 42px; background: #f7f8fb; border-color: transparent; }
.search-box-lg input:focus { background: #fff; border-color: var(--primary); }
.search-box-lg .search-icon { left: 14px; font-size: 1rem; }
.search-row > .btn { height: 46px; padding: 0 18px; }
.filter-toggle svg { vertical-align: -3px; }
.search-row-actions { display: flex; gap: 8px; margin-left: auto; }
.search-row-actions .btn { height: 46px; }
.status-tabs { display: flex; gap: 4px; margin: 16px -20px 0; padding: 0 20px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.status-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--muted); font-weight: 600; font-size: .92rem; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.status-tabs a:hover { color: var(--text); text-decoration: none; }
.status-tabs a.active { color: var(--primary); border-bottom-color: var(--accent, var(--primary)); }
.tab-count { min-width: 24px; padding: 1px 8px; border-radius: 99px; background: #eef0f6; color: var(--muted); font-size: .78rem; text-align: center; }
.status-tabs a.active .tab-count { background: var(--primary); color: #fff; }
.user-search .filter-panel { margin: 0 -20px; padding: 18px 20px; background: #f8f9fc; border-top: 0; border-bottom: 1px solid var(--border); }
.filter-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.filter-groups fieldset { margin: 0; padding: 12px 14px 2px; border: 1px solid var(--border); border-radius: 10px; background: #fff; min-width: 0; }
.filter-groups legend { padding: 0 6px; font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.filter-groups label, .filter-groups .field { margin-bottom: 12px; font-size: .86rem; }
.filter-groups select, .filter-groups input { margin-top: 4px; }
.user-search .form-actions { margin-top: 14px; }
.user-search .filter-chips { margin: 0 -20px; padding: 12px 20px; align-items: center; border-bottom: 1px solid var(--border); }
.user-search > :last-child { margin-bottom: 0; }
.user-search .status-tabs:last-child, .user-search .filter-chips:last-child { border-bottom: 0; }

.users-results { padding: 0; overflow: hidden; }
.results-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.results-bar .results-count { margin: 0; }
.results-controls { display: flex; gap: 14px; }
.results-controls label { display: flex; align-items: center; gap: 6px; margin: 0; font-size: .85rem; color: var(--muted); font-weight: 500; }
.results-controls select { width: auto; margin: 0; padding: 6px 10px; font-size: .88rem; }
.users-results .table-wrap { padding: 0 8px; }
.users-table th { background: #fafbfd; }
.users-table tbody tr:nth-child(even) { background: #fcfcfe; }
.users-table td { padding-top: 12px; padding-bottom: 12px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 6px; background: #fff1e6; color: #9c4221; font-size: .78rem; font-weight: 700; }
.row-actions { display: inline-flex; gap: 6px; align-items: flex-start; }
.more-menu { position: relative; }
.more-menu summary { list-style: none; }
.more-menu summary::-webkit-details-marker { display: none; }
.more-menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 190px; display: flex; flex-direction: column; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(16, 24, 40, .14); }
.more-menu-list button { text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 6px; font: inherit; font-size: .9rem; cursor: pointer; color: var(--text); }
.more-menu-list button:hover { background: #f1f3f9; }
.more-menu-list .danger-text { color: var(--danger); }
.empty-row { padding: 0 !important; }
.pager-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); }
.pager-bar .pagination { margin: 0; }

.reset-notice { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; border-left: 4px solid var(--accent, var(--primary)); background: #fffaf3; }
.reset-notice h3 { margin-bottom: 4px; }
.reset-notice p { margin: 0; }
.temp-password { display: flex; align-items: center; gap: 10px; }
.temp-password code { font-size: 1.25rem; padding: 8px 14px; background: #fff; border: 1px dashed var(--accent, var(--primary)); border-radius: 8px; letter-spacing: .04em; user-select: all; }
.forgot-link { margin: -6px 0 14px; text-align: right; font-size: .88rem; }
.steps { padding-left: 20px; line-height: 1.6; }
.steps li { margin-bottom: 8px; }
.card.must-change { border-color: var(--accent, var(--primary)); box-shadow: 0 0 0 2px var(--accent, var(--primary)); }

@media (max-width: 760px) {
    .search-row-actions { margin-left: 0; width: 100%; }
    .search-row-actions .btn { flex: 1; }
    .results-bar { padding: 12px 14px; }
    .pager-bar { justify-content: center; }
}
.status-tabs { overflow-y: hidden; scrollbar-width: none; }
.status-tabs::-webkit-scrollbar { display: none; }
.users-table td > div:first-child { white-space: nowrap; }

/* ---------- Popup dialogs ---------- */
dialog.modal { width: min(460px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 14px; box-shadow: 0 24px 60px rgba(16, 24, 40, .3); }
dialog.modal::backdrop { background: rgba(10, 14, 30, .55); }
dialog.modal form { padding: 20px 22px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-head h3 { margin: 0; }
.modal-close { border: 0; background: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: #f1f3f9; color: var(--text); }
.password-field { display: flex; gap: 8px; align-items: center; margin-top: 5px; }
.password-field input { margin: 0; flex: 1; }
.password-field .btn { white-space: nowrap; }
.generate-row { display: flex; align-items: center; gap: 10px; margin: -4px 0 14px; }
dialog.modal .form-actions { margin-top: 18px; }
.reset-notice { position: relative; padding-right: 52px; }
.notice-close { position: absolute; top: 12px; right: 12px; }

/* ---------- Collapsible sidebar ---------- */
.sidebar { transition: width .2s ease, padding .2s ease; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 24px; }
.sidebar-head .brand { margin: 0 4px; min-width: 0; overflow: hidden; }
.sidebar-collapse { flex-shrink: 0; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.15); border-radius: 8px; background: transparent; color: var(--sidebar-text); font-size: 1.1rem; line-height: 1; cursor: pointer; transition: transform .2s ease; }
.sidebar-collapse:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a, .sidebar-logout .btn { white-space: nowrap; overflow: hidden; }
.sidebar-logout .btn { gap: 8px; }
.sidebar-logout .nav-icon { display: none; }

@media (min-width: 861px) {
    .sidebar-collapsed .sidebar { width: 72px; padding-left: 10px; padding-right: 10px; }
    .sidebar-collapsed .sidebar-head { flex-direction: column; gap: 12px; }
    .sidebar-collapsed .brand { margin: 0; }
    .sidebar-collapsed .brand-name { display: none; }
    .sidebar-collapsed .brand-logo { height: 30px; padding: 3px 4px; }
    .sidebar-collapsed .sidebar-collapse { transform: rotate(180deg); }
    .sidebar-collapsed .nav-label { display: none; }
    .sidebar-collapsed .sidebar nav a { justify-content: center; padding: 11px 0; }
    .sidebar-collapsed .nav-icon { width: auto; font-size: 1.1rem; }
    .sidebar-collapsed .sidebar-logout .nav-icon { display: inline; }
    .sidebar-collapsed .sidebar-logout .btn { padding: 9px 0; }

    /* Name tooltip on hover while collapsed */
    .sidebar-collapsed .sidebar [data-tip] { position: relative; overflow: visible; }
    .sidebar-collapsed .sidebar [data-tip]:hover::after,
    .sidebar-collapsed .sidebar [data-tip]:focus-visible::after {
        content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
        padding: 6px 10px; border-radius: 6px; background: #111; color: #fff; font-size: .85rem; font-weight: 500;
        white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.25); z-index: 40; pointer-events: none;
    }
}
@media (max-width: 860px) {
    .sidebar-collapse { display: none; }
}
.sidebar-logout .nav-icon svg { display: block; }
@media (min-width: 861px) { .sidebar-collapsed .sidebar { z-index: 25; overflow: visible; } .sidebar-collapsed .sidebar nav { overflow: visible; } }
.badge-notified { background: #e0f2fe; color: #075985; }
.tag-news_notified { background: #e0f2fe; color: #075985; }
.tag-news_notify_failed { background: #fee2e2; color: #b91c1c; }
