/* ==========================================================================
   App styles on top of Bootstrap 5.3 (dark mode: <html data-bs-theme="dark">).
   Shells: body.app (signed in: .ns-user / .ns-admin), body.auth (sign-in pages),
   body.site (the 404 page and any Bootstrap public page).

   Black and gold - the same tokens as the home page (Http/Site/Home/views/home.php, built with
   the design-taste-frontend skill): ground #0b0b0c, surface #161513, ink #f2ede3,
   muted #a89f8c, gold #d4af37 with black text on it. One accent: gold marks the primary
   button, the focus ring, links, the active nav item and small state marks - nothing else.
   Type: Schibsted Grotesk, headings at 400-500 with tight tracking. Buttons: pills.
   ========================================================================== */

:root,
[data-bs-theme="dark"] {
    --np-bg: #0b0b0c;
    --np-surface: #161513;
    --np-surface-2: #1e1c19;
    --np-ink: #f2ede3;
    --np-text: #d9d3c6;
    --np-muted: #a89f8c;
    --np-line: rgba(242, 237, 227, .10);
    --np-line-strong: rgba(242, 237, 227, .18);
    --np-gold: #d4af37;
    --np-gold-hover: #e2c158;
    --np-gold-ink: #0b0b0c;
    --np-gold-soft: rgba(212, 175, 55, .12);
    --np-radius: 16px;
    --np-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 24px 48px -32px rgba(0, 0, 0, .8);
    --sidebar-w: 260px;

    --bs-body-bg: var(--np-bg);
    --bs-body-color: var(--np-text);
    --bs-emphasis-color: var(--np-ink);
    --bs-secondary-color: var(--np-muted);
    --bs-secondary-bg: var(--np-surface);
    --bs-tertiary-bg: var(--np-surface-2);
    --bs-border-color: var(--np-line);
    --bs-border-color-translucent: var(--np-line);
    --bs-primary: var(--np-gold);
    --bs-primary-rgb: 212, 175, 55;
    --bs-link-color: var(--np-gold);
    --bs-link-color-rgb: 212, 175, 55;
    --bs-link-hover-color: var(--np-gold-hover);
    --bs-link-hover-color-rgb: 226, 193, 88;
    --bs-body-font-family: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
    --bs-font-monospace: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
    --bs-border-radius: 10px;
    --bs-focus-ring-color: rgba(212, 175, 55, .35);
    --bs-form-valid-color: #8fc98f;
    --bs-form-invalid-color: #ef8a80;
    --bs-form-invalid-border-color: #ef8a80;
    --bs-danger-text-emphasis: #f3a59d;
    --bs-dropdown-bg: var(--np-surface);
}

body { background: var(--np-bg); color: var(--np-text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6 { color: var(--np-ink); font-weight: 500; letter-spacing: -0.02em; }
.text-secondary { color: var(--np-muted) !important; }
.min-w-0 { min-width: 0; }
::selection { background: rgba(212, 175, 55, .35); color: var(--np-ink); }

/* ---------- Buttons: pills, gold primary with black text ---------- */
.btn { border-radius: 999px; font-weight: 500; padding-inline: 1.15rem; transition: transform .15s ease, background-color .15s ease, border-color .15s ease, color .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-lg { padding-inline: 1.6rem; }
.btn-primary {
    --bs-btn-color: var(--np-gold-ink); --bs-btn-bg: var(--np-gold); --bs-btn-border-color: var(--np-gold);
    --bs-btn-hover-color: var(--np-gold-ink); --bs-btn-hover-bg: var(--np-gold-hover); --bs-btn-hover-border-color: var(--np-gold-hover);
    --bs-btn-active-color: var(--np-gold-ink); --bs-btn-active-bg: var(--np-gold-hover); --bs-btn-active-border-color: var(--np-gold-hover);
    --bs-btn-disabled-color: var(--np-gold-ink); --bs-btn-disabled-bg: var(--np-gold); --bs-btn-disabled-border-color: var(--np-gold);
    --bs-btn-focus-shadow-rgb: 212, 175, 55;
}
.btn-outline-primary {
    --bs-btn-color: var(--np-gold); --bs-btn-border-color: rgba(212, 175, 55, .55);
    --bs-btn-hover-color: var(--np-gold-ink); --bs-btn-hover-bg: var(--np-gold); --bs-btn-hover-border-color: var(--np-gold);
    --bs-btn-active-color: var(--np-gold-ink); --bs-btn-active-bg: var(--np-gold); --bs-btn-active-border-color: var(--np-gold);
}
.btn-outline-secondary {
    --bs-btn-color: var(--np-ink); --bs-btn-border-color: var(--np-line-strong);
    --bs-btn-hover-color: var(--np-ink); --bs-btn-hover-bg: rgba(242, 237, 227, .06); --bs-btn-hover-border-color: rgba(242, 237, 227, .32);
    --bs-btn-active-color: var(--np-ink); --bs-btn-active-bg: rgba(242, 237, 227, .1); --bs-btn-active-border-color: rgba(242, 237, 227, .32);
}
.btn-link { color: var(--np-gold); }
.btn-light { --bs-btn-bg: var(--np-ink); --bs-btn-border-color: var(--np-ink); --bs-btn-color: var(--np-bg); --bs-btn-hover-bg: #fff; --bs-btn-hover-border-color: #fff; }

/* ---------- Forms ---------- */
.form-control, .form-select { background-color: var(--np-surface-2); border-color: var(--np-line-strong); color: var(--np-ink); border-radius: 12px; }
.form-control::placeholder { color: rgba(168, 159, 140, .7); }
.form-control:focus, .form-select:focus {
    background-color: var(--np-surface-2); color: var(--np-ink);
    border-color: rgba(212, 175, 55, .7); box-shadow: 0 0 0 .25rem rgba(212, 175, 55, .18);
}
.form-check-input { background-color: var(--np-surface-2); border-color: var(--np-line-strong); }
.form-check-input:focus { border-color: rgba(212, 175, 55, .7); box-shadow: 0 0 0 .25rem rgba(212, 175, 55, .18); }
.form-check-input:checked { background-color: var(--np-gold); border-color: var(--np-gold); }
.form-check-input:checked[type=checkbox] { --bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%230b0b0c' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e"); }
.form-label { font-weight: 500; font-size: .875rem; color: var(--np-ink); }
.form-text { color: var(--np-muted); }
.invalid-feedback { color: #ef8a80; }
a:focus-visible, .btn:focus-visible, button:focus-visible { outline: 2px solid var(--np-gold); outline-offset: 2px; box-shadow: none; }

/* ---------- Bootstrap surfaces in the dark theme ---------- */
.alert { border-radius: 12px; border-width: 1px; }
.alert-success { --bs-alert-bg: rgba(143, 201, 143, .08); --bs-alert-border-color: rgba(143, 201, 143, .25); --bs-alert-color: #b9e0b9; }
.alert-danger { --bs-alert-bg: rgba(239, 138, 128, .08); --bs-alert-border-color: rgba(239, 138, 128, .28); --bs-alert-color: #f3b3ac; }
.alert-warning { --bs-alert-bg: var(--np-gold-soft); --bs-alert-border-color: rgba(212, 175, 55, .35); --bs-alert-color: #ead28a; }
.alert-info { --bs-alert-bg: rgba(242, 237, 227, .05); --bs-alert-border-color: var(--np-line-strong); --bs-alert-color: var(--np-text); }
.dropdown-menu { --bs-dropdown-bg: var(--np-surface); --bs-dropdown-border-color: var(--np-line-strong); --bs-dropdown-link-color: var(--np-text); --bs-dropdown-link-hover-bg: rgba(242, 237, 227, .06); --bs-dropdown-link-hover-color: var(--np-ink); --bs-dropdown-link-active-bg: var(--np-gold); --bs-dropdown-link-active-color: var(--np-gold-ink); --bs-dropdown-divider-bg: var(--np-line); border-radius: 14px; }
.badge.text-bg-success { background-color: rgba(143, 201, 143, .16) !important; color: #b9e0b9 !important; }
.badge.text-bg-secondary { background-color: rgba(242, 237, 227, .1) !important; color: var(--np-muted) !important; }
.badge.text-bg-dark { background-color: var(--np-gold-soft) !important; color: var(--np-gold) !important; border: 1px solid rgba(212, 175, 55, .35); }
.badge.text-bg-warning { background-color: var(--np-gold) !important; color: var(--np-gold-ink) !important; }
.progress { background-color: rgba(242, 237, 227, .08); }
.progress-bar { background-color: var(--np-gold); }
.list-group { --bs-list-group-bg: transparent; --bs-list-group-color: var(--np-text); --bs-list-group-border-color: var(--np-line); --bs-list-group-action-hover-bg: rgba(242, 237, 227, .04); --bs-list-group-action-hover-color: var(--np-ink); --bs-list-group-action-color: var(--np-text); }
.nav-underline .nav-link { color: var(--np-muted); font-weight: 500; }
.nav-underline .nav-link:hover { color: var(--np-ink); }
.nav-underline .nav-link.active, .nav-underline .show > .nav-link { color: var(--np-gold); border-bottom-color: var(--np-gold); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--np-text); --bs-table-border-color: var(--np-line); --bs-table-hover-bg: rgba(242, 237, 227, .03); --bs-table-hover-color: var(--np-ink); }
.toast.text-bg-success { background: var(--np-surface) !important; color: var(--np-ink) !important; border: 1px solid rgba(212, 175, 55, .4) !important; }
.toast.text-bg-success .bi { color: var(--np-gold); }
.toast.text-bg-danger { background: #2a1513 !important; color: #f3b3ac !important; border: 1px solid rgba(239, 138, 128, .4) !important; }
.toast .btn-close-white { filter: invert(1) grayscale(100%) brightness(200%); }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 500; font-size: 1.2rem; color: var(--np-ink); text-decoration: none; letter-spacing: -0.02em; }
.brand:hover { color: var(--np-ink); }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--np-gold); color: var(--np-gold-ink); font-size: .95rem; }
.brand-mark.sm { width: 24px; height: 24px; border-radius: 7px; font-size: .75rem; }
.brand-mark { background: linear-gradient(180deg, #e2c158, var(--np-gold) 55%, #b8952a); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35); flex-shrink: 0; }
.brand-glyph { width: 74%; height: 74%; display: block; }
.brand-area { display: block; font-size: .72rem; font-weight: 500; color: var(--np-gold); margin-top: -2px; letter-spacing: 0; }
.brand-light, .brand-light:hover { color: var(--np-ink); }

/* ---------- Avatars ---------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--np-gold-soft); color: var(--np-gold); font-weight: 500; font-size: .85rem; border: 1px solid rgba(212, 175, 55, .3); }
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }

/* ==========================================================================
   Public Bootstrap shell (404, any future site page using views/site.php)
   ========================================================================== */
body.site { background: var(--np-bg); }
.site-nav { background: var(--np-bg); border-bottom: 1px solid var(--np-line); padding: .8rem 0; }
.site-nav .nav-link { font-weight: 500; color: var(--np-text); }
.site-nav .nav-link:hover { color: var(--np-gold); }
.site-footer { padding: 2rem 0; border-top: 1px solid var(--np-line); }
.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.error-code { font-size: clamp(5rem, 18vw, 8rem); font-weight: 500; line-height: 1; letter-spacing: -0.05em; color: var(--np-gold); }

/* ==========================================================================
   Auth pages
   ========================================================================== */
.auth-wrap { min-height: 100vh; display: flex; }
.auth-aside {
    width: 44%; max-width: 560px; flex-direction: column; justify-content: space-between; padding: 3rem;
    color: var(--np-text); border-right: 1px solid var(--np-line);
    background: radial-gradient(520px 380px at 0% 100%, rgba(212, 175, 55, .16), transparent 70%), var(--np-surface);
}
body.auth.ns-admin .auth-aside { background: radial-gradient(520px 380px at 100% 0%, rgba(212, 175, 55, .14), transparent 70%), #070707; }
.auth-aside-title { color: var(--np-ink); font-weight: 400; font-size: 2.25rem; letter-spacing: -0.035em; line-height: 1.1; margin-bottom: 1rem; }
.auth-aside-text { font-size: 1.05rem; color: var(--np-muted); margin-bottom: 2rem; max-width: 26rem; }
.auth-aside-list { list-style: none; padding: 0; margin: 0; }
.auth-aside-list li { display: flex; gap: .6rem; margin-bottom: .8rem; }
.auth-aside-list i { color: var(--np-gold); }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2.5rem 16px; background: var(--np-bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-title { font-size: 2rem; font-weight: 400; letter-spacing: -0.035em; margin-bottom: .4rem; }
.auth-sub { color: var(--np-muted); margin-bottom: 1.75rem; }
.auth-switch { text-align: center; margin-top: 1.75rem; color: var(--np-muted); font-size: .95rem; }
.auth-switch a { font-weight: 500; text-decoration: none; }
.auth-badge { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; background: var(--np-gold-soft); color: var(--np-gold); font-size: 1.6rem; margin-bottom: 1.25rem; border: 1px solid rgba(212, 175, 55, .3); }
.auth-badge.is-warn { background: rgba(239, 138, 128, .08); color: #f3b3ac; border-color: rgba(239, 138, 128, .3); }
.auth-help { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--np-line); font-size: .9rem; color: var(--np-muted); }
.auth-help details { margin-bottom: .75rem; }
.auth-help summary { cursor: pointer; font-weight: 500; color: var(--np-gold); }
.auth-help details p { margin: .6rem 0; }
.auth-help .btn-link { font-weight: 500; text-decoration: none; font-size: .9rem; }

.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--np-muted); z-index: 5; pointer-events: none; }
.input-icon .form-control { padding-left: 2.6rem; }
.otp-input { font-family: var(--bs-font-monospace); font-variant-numeric: tabular-nums; letter-spacing: .35em; text-align: center; font-weight: 500; font-size: 1.4rem; }

.pw-toggle-wrap { position: relative; }
.pw-toggle-wrap .form-control { padding-right: 2.75rem; }
.pw-toggle-wrap .form-control.is-invalid { background-image: none; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--np-muted); padding: .35rem .5rem; z-index: 5; }
.pw-toggle:hover { color: var(--np-gold); }

.pw-strength { height: 6px; border-radius: 999px; background: rgba(242, 237, 227, .08); overflow: hidden; }
.pw-strength-bar { height: 100%; width: 0; border-radius: 999px; transition: width .25s, background-color .25s; background: #ef8a80; }
.pw-strength[data-level="fair"] .pw-strength-bar { background: #e0a54a; }
.pw-strength[data-level="good"] .pw-strength-bar { background: #c9b26a; }
.pw-strength[data-level="strong"] .pw-strength-bar { background: var(--np-gold); }

/* ==========================================================================
   Signed-in app shell
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { --bs-offcanvas-width: var(--sidebar-w); --bs-offcanvas-bg: var(--np-surface); display: flex; flex-direction: column; background: var(--np-surface); border-right: 1px solid var(--np-line); }
@media (min-width: 992px) {
    .app-sidebar { width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.25rem 1rem; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem .85rem; }
.nav-group-label { font-size: .75rem; font-weight: 500; color: var(--np-muted); padding: 1rem .75rem .4rem; }
.nav-item-link { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: 10px; color: var(--np-text); font-weight: 400; text-decoration: none; margin-bottom: 2px; font-size: .95rem; }
.nav-item-link i { font-size: 1.1rem; color: var(--np-muted); }
.nav-item-link:hover { background: rgba(242, 237, 227, .05); color: var(--np-ink); }
.nav-item-link.active { background: var(--np-gold-soft); color: var(--np-gold); font-weight: 500; box-shadow: inset 2px 0 0 var(--np-gold); }
.nav-item-link.active i { color: var(--np-gold); }
.sidebar-foot { padding: .85rem; border-top: 1px solid var(--np-line); }
.app-sidebar .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* Admin: a step darker, with the gold area label */
body.ns-admin .app-sidebar { --bs-offcanvas-bg: #070707; background: #070707; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .85rem 1.75rem; background: var(--np-bg); border-bottom: 1px solid var(--np-line); }
.topbar-title { font-size: 1.25rem; font-weight: 500; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-icon { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; border-radius: 10px; color: var(--np-ink); }
.btn-icon:hover { background: rgba(242, 237, 227, .06); transform: none; }
.user-chip { display: flex; align-items: center; gap: .5rem; padding: .25rem .7rem .25rem .25rem; border: 1px solid var(--np-line-strong); border-radius: 999px; background: var(--np-surface); color: var(--np-ink); font-weight: 500; }
.user-chip:hover, .user-chip.show { border-color: rgba(212, 175, 55, .5); background: var(--np-surface); color: var(--np-ink); transform: none; }
.user-chip-name { max-width: 160px; }
.app-content { padding: 1.75rem; flex: 1; }
@media (max-width: 575.98px) {
    .app-content { padding: 1.25rem 16px; }
}

/* ---------- Cards ---------- */
.panel-card { border: 1px solid var(--np-line); border-radius: var(--np-radius); box-shadow: var(--np-shadow); background: var(--np-surface); --bs-card-bg: var(--np-surface); --bs-card-color: var(--np-text); }
.panel-card > .card-header { background: transparent; border-bottom: 1px solid var(--np-line); padding: 1rem 1.25rem; font-weight: 500; color: var(--np-ink); }
.panel-card > .card-body { padding: 1.25rem; }
.panel-card .table th { font-size: .8rem; color: var(--np-muted); font-weight: 500; padding: .75rem 1.25rem; background: rgba(242, 237, 227, .02); }
.panel-card .table td { padding: .85rem 1.25rem; }

.stat-card { display: flex; align-items: center; gap: 1rem; padding: 1.25rem; border: 1px solid var(--np-line); border-radius: var(--np-radius); background: var(--np-surface); box-shadow: var(--np-shadow); height: 100%; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0; background: var(--np-gold-soft); color: var(--np-gold); border: 1px solid rgba(212, 175, 55, .22); }
.stat-icon.is-green { background: rgba(143, 201, 143, .1); color: #a9d6a9; border-color: rgba(143, 201, 143, .22); }
.stat-icon.is-amber { background: rgba(224, 165, 74, .1); color: #e7b86a; border-color: rgba(224, 165, 74, .25); }
.stat-icon.is-slate { background: rgba(242, 237, 227, .05); color: var(--np-text); border-color: var(--np-line); }
.stat-label { font-size: .82rem; color: var(--np-muted); font-weight: 500; }
.stat-value { font-size: 1.4rem; font-weight: 500; color: var(--np-ink); letter-spacing: -0.02em; }

.welcome-card {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.75rem;
    border-radius: var(--np-radius); color: var(--np-ink); border: 1px solid rgba(212, 175, 55, .28);
    background: radial-gradient(560px 220px at 100% 0%, rgba(212, 175, 55, .22), transparent 70%), var(--np-surface);
}
.welcome-card h2 { color: var(--np-ink); font-weight: 400; letter-spacing: -0.03em; }
.welcome-card .opacity-75 { color: var(--np-muted); opacity: 1 !important; }

.detail-list dt { font-weight: 500; color: var(--np-muted); font-size: .9rem; padding: .55rem 0; border-bottom: 1px solid var(--np-line); }
.detail-list dd { padding: .55rem 0; margin: 0; border-bottom: 1px solid var(--np-line); color: var(--np-ink); }

.glance-list li { display: flex; justify-content: space-between; align-items: center; padding: .75rem 0; border-bottom: 1px solid var(--np-line); }
.glance-list li:last-child { border-bottom: 0; }
.glance-list i { color: var(--np-gold); margin-right: .6rem; }
.glance-list strong { color: var(--np-ink); font-weight: 500; }

.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding-top: 1.25rem; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.bar { width: 100%; max-width: 36px; border-radius: 6px 6px 2px 2px; background: rgba(212, 175, 55, .35); min-height: 2px; transition: background-color .15s; }
.bar-col:last-child .bar, .bar-col:hover .bar { background: var(--np-gold); }
.bar-val { font-size: .72rem; font-weight: 500; color: var(--np-muted); margin-bottom: 4px; min-height: 1em; }
.bar-label { font-size: .72rem; color: var(--np-muted); margin-top: 6px; }

.account-head { display: flex; align-items: center; gap: 1rem; }
.tips-list { list-style: none; padding: 0; }
.tips-list li { display: flex; gap: .5rem; margin-bottom: .6rem; color: var(--np-text); }
.tips-list i { color: var(--np-gold); }

/* ---------- Two-factor panel (Http/Site/Account/views/twofactor.php) ---------- */
.tf-status { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.25rem; }
.tf-status-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tf-status-icon svg { width: 24px; height: 24px; }
.tf-status.is-on .tf-status-icon { background: var(--np-gold-soft); color: var(--np-gold); border: 1px solid rgba(212, 175, 55, .3); }
.tf-status.is-off .tf-status-icon { background: rgba(224, 165, 74, .1); color: #e7b86a; border: 1px solid rgba(224, 165, 74, .25); }
.tf-status-title { font-weight: 500; color: var(--np-ink); font-size: 1.05rem; margin-bottom: .25rem; }
.tf-status-sub { color: var(--np-muted); font-size: .9rem; }
.tf-step { display: flex; gap: 1rem; padding: 1.25rem 0; border-top: 1px solid var(--np-line); }
.tf-step h6 { font-weight: 500; margin-bottom: .75rem; }
.tf-step-n { width: 30px; height: 30px; border-radius: 50%; background: var(--np-gold); color: var(--np-gold-ink); font-weight: 500; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tf-qr-row { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: flex-start; }
.tf-qr { width: 192px; height: 192px; padding: 8px; border-radius: 12px; background: #fff; flex-shrink: 0; }
.tf-qr img, .tf-qr canvas { width: 100% !important; height: auto !important; }
.tf-key { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-radius: 10px; background: var(--np-surface-2); border: 1px solid var(--np-line); max-width: 100%; }
.tf-key code { font-family: var(--bs-font-monospace); font-size: .9rem; color: var(--np-ink); word-break: break-all; }
.tf-copy { border: 0; background: transparent; color: var(--np-muted); padding: 2px; display: inline-flex; }
.tf-copy svg { width: 16px; height: 16px; }
.tf-copy:hover { color: var(--np-gold); }
.tf-copy.copied { color: var(--np-gold); }
.tf-inline-form { display: flex; flex-wrap: wrap; gap: .5rem; }
.tf-code-input { max-width: 160px; font-family: var(--bs-font-monospace); font-variant-numeric: tabular-nums; letter-spacing: .25em; font-weight: 500; text-align: center; }
.tf-field-error { display: none; color: #ef8a80; font-size: .85rem; margin-top: .35rem; }
.tf-field-error.show { display: block; }
.tf-section { padding: 1.25rem 0; border-top: 1px solid var(--np-line); }
.tf-confirm { margin-top: 1rem; padding: 1rem; border-radius: 12px; background: var(--np-surface-2); border: 1px solid var(--np-line); }
.tf-codes { padding-top: 1.25rem; border-top: 1px solid var(--np-line); }
.tf-codes-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; max-width: 380px; }
.tf-codes-grid code { display: block; text-align: center; padding: .5rem; border-radius: 8px; background: var(--np-surface-2); border: 1px solid var(--np-line); color: var(--np-ink); font-family: var(--bs-font-monospace); font-size: .95rem; letter-spacing: .05em; }

.toast-container { z-index: 1090; }

@media (prefers-reduced-motion: reduce) {
    .btn, .bar { transition: none; }
    .btn:hover, .btn:active { transform: none; }
}

/* ==========================================================================
   Light theme (<html data-bs-theme="light">): the same system, gold accent kept. Gold text on a
   light ground is darkened (#8a6d12) to stay readable; the gold button keeps black text.
   ========================================================================== */
[data-bs-theme="light"] {
    --np-bg: #f6f4ee;
    --np-surface: #ffffff;
    --np-surface-2: #f3f0e8;
    --np-ink: #16140f;
    --np-text: #39342a;
    --np-muted: #6b6455;
    --np-line: rgba(22, 20, 15, .10);
    --np-line-strong: rgba(22, 20, 15, .18);
    --np-gold-soft: rgba(212, 175, 55, .16);
    --np-shadow: 0 1px 2px rgba(22, 20, 15, .04), 0 12px 32px -24px rgba(22, 20, 15, .35);
    --bs-link-color: #8a6d12;
    --bs-link-color-rgb: 138, 109, 18;
    --bs-link-hover-color: #6f570b;
    --bs-link-hover-color-rgb: 111, 87, 11;
    --bs-form-invalid-color: #b42318;
    --bs-form-invalid-border-color: #b42318;
}
[data-bs-theme="light"] .btn-link,
[data-bs-theme="light"] .nav-underline .nav-link.active,
[data-bs-theme="light"] .nav-item-link.active,
[data-bs-theme="light"] .nav-item-link.active i,
[data-bs-theme="light"] .brand-area,
[data-bs-theme="light"] .stat-icon,
[data-bs-theme="light"] .avatar,
[data-bs-theme="light"] .auth-badge,
[data-bs-theme="light"] .glance-list i,
[data-bs-theme="light"] .tips-list i,
[data-bs-theme="light"] .auth-help summary,
[data-bs-theme="light"] .auth-aside-list i { color: #8a6d12; }
[data-bs-theme="light"] .btn-outline-primary { --bs-btn-color: #8a6d12; --bs-btn-border-color: rgba(138, 109, 18, .55); }
[data-bs-theme="light"] .badge.text-bg-dark { color: #6f570b !important; }
[data-bs-theme="light"] body.ns-admin .app-sidebar { --bs-offcanvas-bg: #16140f; background: #16140f; }
[data-bs-theme="light"] body.ns-admin .app-sidebar .brand,
[data-bs-theme="light"] body.ns-admin .nav-item-link { color: #e9e4d8; }
[data-bs-theme="light"] body.ns-admin .nav-item-link.active,
[data-bs-theme="light"] body.ns-admin .nav-item-link.active i { color: #d4af37; }
[data-bs-theme="light"] body.ns-admin .nav-group-label { color: #a89f8c; }
[data-bs-theme="light"] body.ns-admin .app-sidebar .btn-close { filter: invert(1); }
[data-bs-theme="light"] .app-sidebar .btn-close { filter: none; }
[data-bs-theme="light"] .auth-aside { background: radial-gradient(520px 380px at 0% 100%, rgba(212, 175, 55, .22), transparent 70%), #16140f; color: #d9d3c6; }
[data-bs-theme="light"] .auth-aside .auth-aside-title, [data-bs-theme="light"] .auth-aside .brand { color: #f2ede3; }
[data-bs-theme="light"] .auth-aside .auth-aside-text { color: #a89f8c; }
[data-bs-theme="light"] .auth-aside-list i { color: #d4af37; }
[data-bs-theme="light"] .alert-warning { --bs-alert-color: #6f570b; }
[data-bs-theme="light"] .alert-success { --bs-alert-color: #1f6b33; }
[data-bs-theme="light"] .alert-danger { --bs-alert-color: #a12a1f; }
[data-bs-theme="light"] .badge.text-bg-success { color: #1f6b33 !important; background-color: rgba(31, 107, 51, .12) !important; }

/* ==========================================================================
   Components added with the Passwords365 admin and user portals
   ========================================================================== */
.brand-logo { height: 32px; width: auto; max-width: 140px; border-radius: 6px; }
.topbar-actions { display: flex; align-items: center; gap: .35rem; }
.nav-badge { margin-left: auto; font-size: .72rem; padding: .05rem .45rem; border-radius: 999px; background: var(--np-gold); color: var(--np-gold-ink); font-weight: 500; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.toolbar .form-select { width: auto; min-width: 150px; }
.toolbar .input-icon { min-width: 220px; }
@media (max-width: 575.98px) { .toolbar .form-select, .toolbar .input-icon, .toolbar .btn { width: 100%; } }

[data-table] { transition: opacity .15s; }
[data-table].is-loading [data-table-body] { opacity: .5; }
tr.row-link { cursor: pointer; }
.pagination { --bs-pagination-bg: var(--np-surface); --bs-pagination-color: var(--np-text); --bs-pagination-border-color: var(--np-line-strong); --bs-pagination-hover-bg: rgba(242, 237, 227, .06); --bs-pagination-hover-color: var(--np-ink); --bs-pagination-active-bg: var(--np-gold); --bs-pagination-active-border-color: var(--np-gold); --bs-pagination-active-color: var(--np-gold-ink); --bs-pagination-disabled-bg: var(--np-surface); --bs-pagination-disabled-color: var(--np-muted); --bs-pagination-border-radius: 10px; }
.card-footer { background: transparent; border-top: 1px solid var(--np-line); }

.stat-card--link { color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.stat-card--link:hover { color: inherit; border-color: rgba(212, 175, 55, .45); transform: translateY(-2px); }

.notif-dot { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--np-gold); color: var(--np-gold-ink); font-size: .68rem; font-weight: 600; line-height: 18px; text-align: center; }
.notif-menu { width: min(360px, calc(100vw - 32px)); }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { border-bottom: 1px solid var(--np-line); }
.notif-item:hover { background: rgba(242, 237, 227, .04); }
.notif-item.is-unread { box-shadow: inset 3px 0 0 var(--np-gold); }

.vault-state { align-items: center; gap: .4rem; padding: .25rem .7rem; border-radius: 999px; border: 1px solid var(--np-line-strong); font-size: .82rem; color: var(--np-muted); }
.vault-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--np-muted); }
.vault-state[data-state="unlocked"] { color: var(--np-gold); border-color: rgba(212, 175, 55, .45); }
.vault-state[data-state="unlocked"]::before { background: var(--np-gold); box-shadow: 0 0 0 3px rgba(212, 175, 55, .2); }

.plan-card.is-featured { border-color: rgba(212, 175, 55, .55); }
.plan-card.is-current { box-shadow: inset 0 0 0 1px var(--np-gold); }
.plan-limits li { display: flex; gap: .5rem; padding: .2rem 0; }
.plan-limits i { color: var(--np-gold); }
.limits-grid dt, .limits-grid dd { padding: .15rem 0; }

.checklist li { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--np-line); }
.checklist li:last-child { border-bottom: 0; }
.checklist i { color: var(--np-muted); }
.checklist li.is-done i { color: var(--np-gold); }
.checklist li.is-done span { color: var(--np-muted); text-decoration: line-through; }
.history-list li { padding: .25rem 0; border-bottom: 1px dashed var(--np-line); }

.brand-preview { min-height: 64px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--np-line-strong); border-radius: 12px; padding: .75rem; }
.brand-preview img { max-height: 64px; max-width: 100%; }
.email-preview { width: 100%; height: 480px; border: 1px solid var(--np-line); border-radius: 12px; background: #f3f4f6; }
.modal { --bs-modal-bg: var(--np-surface); --bs-modal-border-color: var(--np-line-strong); --bs-modal-border-radius: 18px; }
.modal-header, .modal-footer { border-color: var(--np-line); }
.table-warning { --bs-table-bg: rgba(212, 175, 55, .08); --bs-table-color: var(--np-ink); }

/* ---------- Vault (phase 3) ---------- */
.vault-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; padding: 1.75rem; border-radius: var(--np-radius); border: 1px solid rgba(212, 175, 55, .28); background: radial-gradient(520px 220px at 100% 0%, rgba(212, 175, 55, .18), transparent 70%), var(--np-surface); }
.vault-hero .vault-lock { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 1.8rem; background: var(--np-gold-soft); color: var(--np-gold); border: 1px solid rgba(212, 175, 55, .35); }
.fingerprint { font-family: var(--bs-font-monospace); font-size: .85rem; letter-spacing: .04em; word-break: break-all; }
.recovery-key { font-family: var(--bs-font-monospace); font-size: 1.05rem; letter-spacing: .06em; padding: 1rem; border-radius: 12px; background: var(--np-surface-2); border: 1px dashed rgba(212, 175, 55, .5); word-break: break-all; text-align: center; color: var(--np-ink); }
.kdf-progress { height: 4px; border-radius: 99px; overflow: hidden; background: rgba(242, 237, 227, .08); }
.kdf-progress > i { display: block; height: 100%; width: 40%; background: var(--np-gold); animation: kdf 1.1s ease-in-out infinite; }
@keyframes kdf { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) { .kdf-progress > i { animation: none; width: 100%; } }

/* ==========================================================================
   Vault browser (Http/User/Vault/views/browser.php, pv-items.js)
   ========================================================================== */
.vault-search { min-width: 220px; }
.vault-list .vault-row { display: flex; align-items: center; gap: .85rem; padding: .7rem 1rem; background: transparent; border-color: var(--np-line); }
.vault-list .vault-row:hover { background: var(--np-surface-2); }
.vault-check, .vault-check-spacer { flex-shrink: 0; width: 1rem; margin: 0; }
.vault-ico { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--np-gold-soft); color: var(--np-gold); border: 1px solid rgba(212, 175, 55, .22); }
.vault-ico.type-note { background: rgba(242, 237, 227, .05); color: var(--np-ink); border-color: var(--np-line); }
.vault-ico.type-totp { background: rgba(143, 201, 143, .1); color: #a9d6a9; border-color: rgba(143, 201, 143, .22); }
.vault-ico.type-file { background: rgba(224, 165, 74, .1); color: #e7b86a; border-color: rgba(224, 165, 74, .25); }
.vault-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; text-align: left; background: none; border: 0; padding: 0; color: inherit; }
.vault-main:focus-visible { outline: 2px solid var(--np-gold); outline-offset: 3px; border-radius: 6px; }
.vault-title { font-weight: 500; color: var(--np-ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vault-sub { font-size: .85rem; color: var(--np-muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vault-badges { gap: .35rem; flex-wrap: wrap; justify-content: flex-end; max-width: 40%; }
.vault-badges .badge { font-weight: 500; background: var(--np-surface-2); color: var(--np-text); border: 1px solid var(--np-line); }
.vault-badges .vault-2fa-badge { color: #a9d6a9; }
.vault-badges .vault-shared-badge, .vault-badges .vault-sharedout-badge { color: var(--np-gold); border-color: rgba(212, 175, 55, .3); }
.vault-actions { display: flex; gap: .15rem; flex-shrink: 0; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--np-muted); background: transparent; border: 0; }
.btn-icon:hover, .btn-icon:focus-visible { color: var(--np-ink); background: var(--np-surface-2); }
.vault-otp { display: inline-flex; align-items: center; gap: .45rem; --otp: 1; }
.vault-otp .otp-code { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 1.05rem; color: var(--np-ink); letter-spacing: .04em; background: none; padding: 0; }
.vault-otp .otp-ring { width: 16px; height: 16px; border-radius: 50%; background: conic-gradient(var(--np-gold) calc(var(--otp) * 360deg), var(--np-line) 0); flex-shrink: 0; }
.vault-otp.is-ending .otp-ring { background: conic-gradient(#e0a54a calc(var(--otp) * 360deg), var(--np-line) 0); }
.vault-otp-lg .otp-code { font-size: 2.2rem; }
.vault-otp-lg .otp-ring { width: 22px; height: 22px; }
.vault-otp-preview { padding: .65rem .85rem; border-radius: 10px; background: var(--np-surface-2); border: 1px solid var(--np-line); font-size: .9rem; }
.vault-otp-preview .otp-code { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 1.1rem; color: var(--np-ink); }
.vault-field { display: grid; grid-template-columns: 9rem 1fr auto; gap: .5rem 1rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--np-line); }
.vault-field-label { color: var(--np-muted); font-size: .85rem; }
.vault-field-value { min-width: 0; overflow-wrap: anywhere; color: var(--np-ink); }
.vault-field-btns { display: flex; gap: .15rem; }
.vault-field-block { grid-template-columns: 1fr; }
.vault-secret { font-family: "JetBrains Mono", ui-monospace, monospace; letter-spacing: .06em; }
.vault-note { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: .95rem; color: var(--np-ink); margin: 0; background: var(--np-surface-2); border: 1px solid var(--np-line); border-radius: 10px; padding: .75rem 1rem; max-height: 50vh; overflow: auto; }
.vault-note-lg { min-height: 8rem; }
.vault-file-preview { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .82rem; }
.vault-section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--np-muted); margin-bottom: .4rem; }
.vault-linked { display: flex; align-items: center; gap: 1rem; justify-content: space-between; padding: .6rem .8rem; border: 1px solid var(--np-line); border-radius: 12px; margin-bottom: .5rem; background: var(--np-surface-2); }
.vault-strength { font-weight: 500; }
.vault-strength.s0, .vault-strength.s1 { background: rgba(220, 80, 60, .16); color: #f08c7a; }
.vault-strength.s2 { background: rgba(224, 165, 74, .16); color: #e7b86a; }
.vault-strength.s3, .vault-strength.s4 { background: rgba(143, 201, 143, .14); color: #a9d6a9; }
.vault-empty-icon { width: 64px; height: 64px; margin: 0 auto; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; background: var(--np-gold-soft); color: var(--np-gold); border: 1px solid rgba(212, 175, 55, .22); }
.vault-folder-card .vault-folder-icon { width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; color: var(--fc); background: color-mix(in srgb, var(--fc) 14%, transparent); border: 1px solid color-mix(in srgb, var(--fc) 30%, transparent); }
.vault-crumb { padding: .6rem .9rem; border: 1px solid var(--np-line); border-radius: 12px; background: var(--np-surface); }
.vault-usage span b { color: var(--np-ink); font-weight: 500; }
.vault-cf .form-check-input { margin-top: 0; }
.vault-checks .form-check-label { font-size: .9rem; }
.vault-gen-pw { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .95rem; color: var(--np-ink); word-break: break-all; background: none; }
.vault-health-score { font-size: 3.2rem; font-weight: 500; color: var(--np-gold); letter-spacing: -.03em; line-height: 1.1; }
.vault-health-tile:hover { border-color: var(--np-line-strong); }
@media (max-width: 575.98px) {
    .vault-field { grid-template-columns: 1fr auto; }
    .vault-field-label { grid-column: 1 / -1; }
    .vault-list .vault-otp .otp-left { display: none; }
}
[data-bs-theme="light"] .vault-ico.type-totp, [data-bs-theme="light"] .vault-badges .vault-2fa-badge { color: #2f6b3a; }
[data-bs-theme="light"] .vault-ico.type-file { color: #8a5a12; }
[data-bs-theme="light"] .vault-strength.s0, [data-bs-theme="light"] .vault-strength.s1 { color: #b42318; }
[data-bs-theme="light"] .vault-strength.s2 { color: #8a5a12; }
[data-bs-theme="light"] .vault-strength.s3, [data-bs-theme="light"] .vault-strength.s4 { color: #2f6b3a; }
[data-bs-theme="light"] .vault-ico, [data-bs-theme="light"] .vault-empty-icon, [data-bs-theme="light"] .vault-health-score, [data-bs-theme="light"] .vault-badges .vault-shared-badge { color: #8a6d12; }
.topbar-search { position: relative; width: 240px; }
.topbar-search .bi { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--np-muted); font-size: .85rem; pointer-events: none; }
.topbar-search .form-control { padding-left: 2rem; border-radius: 999px; background: var(--np-surface-2); }
/* Sharing (pv-shares.js) */
.vault-person { display: flex; gap: .75rem; align-items: flex-start; padding: .6rem .75rem; border: 1px solid var(--np-line); border-radius: 12px; margin-bottom: .5rem; background: var(--np-surface-2); }
.vault-person.is-warning { border-color: rgba(224, 165, 74, .5); }
.vault-fp { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .8rem; color: var(--np-ink); background: none; }
.vault-invite .card-body { padding: .8rem 1rem; }
.vault-shareinfo { padding-top: .75rem; border-top: 1px solid var(--np-line); }
.vault-share-what .badge { font-weight: 500; font-size: .85rem; background: var(--np-surface-2); color: var(--np-ink); border: 1px solid var(--np-line); padding: .4rem .6rem; }
.avatar-img { object-fit: cover; padding: 0; }

/* ==========================================================================
   Mobile app (Android/iOS). pv-native.js adds .pv-native only inside the Passwords365 app,
   which draws edge to edge: Capacitor sets --safe-area-inset-* on Android, iOS has env().
   ========================================================================== */
.pv-native {
    --pv-safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
    --pv-safe-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
    --pv-safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
    --pv-safe-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
}
.pv-native body {
    padding: var(--pv-safe-top) var(--pv-safe-right) var(--pv-safe-bottom) var(--pv-safe-left);
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
}
/* A strip of page colour behind the status bar: content scrolling up never shows under the clock. */
.pv-native body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: var(--pv-safe-top); background: var(--np-bg); z-index: 1100; pointer-events: none; }
.pv-native .app-topbar, .pv-native .site-header { top: var(--pv-safe-top); }
.pv-native .app-shell, .pv-native .auth-wrap { min-height: calc(100vh - var(--pv-safe-top) - var(--pv-safe-bottom)); }
@media (min-width: 992px) {
    .pv-native .app-sidebar { top: var(--pv-safe-top); height: calc(100vh - var(--pv-safe-top) - var(--pv-safe-bottom)); }
}
/* Fixed layers (off-canvas menu, dialogs, toasts) stay inside the safe area too. */
.pv-native .offcanvas { padding: var(--pv-safe-top) 0 var(--pv-safe-bottom) var(--pv-safe-left); }
@media (max-width: 991.98px) {
    .pv-native .offcanvas-lg { padding: var(--pv-safe-top) 0 var(--pv-safe-bottom) var(--pv-safe-left); }
}
.pv-native .modal { padding-top: var(--pv-safe-top); padding-bottom: var(--pv-safe-bottom); }
.pv-native .toast-container.top-0 { top: var(--pv-safe-top) !important; }

/* ==========================================================================
   Phones and tablets: the signed-in app below lg (992px), where the sidebar is an off-canvas
   menu. Everything here is inside a max-width query or applies to markup that only renders
   there, so the desktop layout above is unchanged. Sizes: 44px touch targets, 12-16px gutters.
   ========================================================================== */
:root { --tabbar-h: 60px; }

/* Bottom navigation (Layout/views/tabs_user.php) */
.app-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    padding: 0 var(--pv-safe-right, 0px) var(--pv-safe-bottom, env(safe-area-inset-bottom, 0px)) var(--pv-safe-left, 0px);
    background: color-mix(in srgb, var(--np-surface) 94%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
    border-top: 1px solid var(--np-line);
}
.app-tab {
    height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--np-muted); text-decoration: none; font-size: .7rem; font-weight: 500; -webkit-tap-highlight-color: transparent;
}
.app-tab .bi { font-size: 1.3rem; line-height: 1; }
.app-tab.active { color: var(--np-gold); }
.app-tab:active { opacity: .65; }
.app-tab:focus-visible { outline: 2px solid var(--np-gold); outline-offset: -4px; border-radius: 12px; }
[data-bs-theme="light"] .app-tab.active { color: #8a6d12; }

/* Theme choice inside the account menu (phones and tablets) */
.theme-switch { display: flex; gap: .3rem; padding: .25rem .75rem .35rem; }
.theme-switch .btn { flex: 1; font-size: .8rem; padding: .35rem .3rem; border: 1px solid var(--np-line-strong); border-radius: 999px; color: var(--np-text); background: transparent; }

/* Segmented switch: Shared with me / Shared by me */
.seg-control { display: flex; padding: 4px; gap: 4px; border: 1px solid var(--np-line); border-radius: 999px; background: var(--np-surface); }
.seg-control a { flex: 1; min-height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 999px; color: var(--np-muted); font-weight: 500; font-size: .9rem; text-decoration: none; }
.seg-control a.active { background: var(--np-gold-soft); color: var(--np-gold); box-shadow: inset 0 0 0 1px rgba(212, 175, 55, .3); }
[data-bs-theme="light"] .seg-control a.active { color: #8a6d12; }

/* 2FA codes never wrap, and the seconds left don't shift the layout as they count down. */
.vault-otp .otp-code { white-space: nowrap; }
.vault-otp .otp-left { min-width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; }

/* Vault filters: inline from md up (display: contents keeps the toolbar exactly as before). */
.vault-filters { display: contents; }

@media (max-width: 991.98px) {
    /* Room for the bottom navigation (plus the home indicator in the app). */
    body.has-tabbar, .pv-native body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + var(--pv-safe-bottom, env(safe-area-inset-bottom, 0px))); }

    /* Compact header: menu, title, add, notifications, account. */
    .app-topbar { padding: .45rem 12px; gap: .35rem; }
    .topbar-title { font-size: 1.1rem; }
    .topbar-actions { gap: .1rem; }
    .user-chip { padding: 2px; border-color: transparent; background: transparent; }
    .user-chip.dropdown-toggle::after { display: none; }
    .btn-icon { width: 42px; height: 42px; }

    /* Touch targets */
    .form-control, .form-select { min-height: 44px; }
    .form-control-sm, .form-select-sm { min-height: 38px; }
    .btn:not(.btn-sm):not(.btn-link):not(.btn-close):not(.btn-icon):not(.user-chip) { min-height: 44px; }
    .btn-sm:not(.btn-link) { min-height: 36px; }
    .dropdown-item { padding-top: .6rem; padding-bottom: .6rem; }
    .dropdown-menu { max-width: calc(100vw - 24px); }
}

@media (max-width: 767.98px) {
    /* Dashboard: compact summary tiles, actions in one swipeable row, status as one list. */
    .welcome-card { padding: 1.15rem 1.2rem; }
    .welcome-card h2 { font-size: 1.25rem; }
    .welcome-card .btn { width: 100%; }
    .dash-stats { --bs-gutter-x: .6rem; --bs-gutter-y: .6rem; }
    .dash-stats .stat-card { gap: .65rem; padding: .7rem .8rem; border-radius: 14px; box-shadow: none; }
    .dash-stats .stat-icon, .dash-status .stat-icon { width: 34px; height: 34px; font-size: 1rem; border-radius: 10px; }
    .dash-stats .stat-label { font-size: .74rem; line-height: 1.2; }
    .dash-stats .stat-value { font-size: 1.05rem; }
    .dash-actions { width: 100%; flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; padding-bottom: 2px; }
    .dash-actions::-webkit-scrollbar { display: none; }
    .dash-actions .btn { flex: 0 0 auto; scroll-snap-align: start; border-radius: 999px; }
    .dash-status { --bs-gutter-x: 0; --bs-gutter-y: 0; margin-left: 0; margin-right: 0; border: 1px solid var(--np-line); border-radius: var(--np-radius); background: var(--np-surface); overflow: hidden; }
    .dash-status > * + * { border-top: 1px solid var(--np-line); }
    .dash-status .stat-card { border: 0; border-radius: 0; box-shadow: none; background: transparent; padding: .7rem 1rem; gap: .75rem; }
    .dash-status .stat-card > div { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; column-gap: .75rem; }
    .dash-status .stat-label { font-size: .9rem; color: var(--np-text); }
    .dash-status .stat-value { font-size: .95rem; }
    .dash-status .stat-card .small { flex-basis: 100%; text-align: right; }
    .dash-activity .list-group-item:nth-child(n+5) { display: none !important; } /* beats the rows' d-flex */

    /* Vault lists: search, a filter button and Add on one row; filters fold out below it. */
    .vault-toolbar .card-body { padding: .5rem; flex-wrap: nowrap !important; }
    .vault-toolbar .card-body:has(.vault-filters.show) { flex-wrap: wrap !important; }
    .vault-toolbar .vault-search { flex: 1 1 0; min-width: 0; }
    .vault-filters { display: none; }
    .vault-filters.show { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; width: 100%; order: 5; }
    .vault-filters .form-select { width: 100% !important; }
    .vault-filter-toggle { position: relative; flex-shrink: 0; border: 1px solid var(--np-line-strong); border-radius: 12px; font-size: 1.15rem; }
    .vault-filter-toggle[aria-expanded="true"] { border-color: rgba(212, 175, 55, .5); color: var(--np-gold); }
    .vault-filter-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--np-gold); }
    .vault-add-label { display: none; }
    .vault-add .dropdown-toggle { width: 44px; padding: 0; }
    .vault-add .dropdown-toggle::after { display: none; }
    .vault-usage { white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
    .vault-usage::-webkit-scrollbar { display: none; }
    .vault-list .vault-row { gap: .7rem; padding: .65rem .5rem .65rem .85rem; min-height: 62px; }
    .vault-list .vault-row:active { background: var(--np-surface-2); }
    .vault-main { align-self: stretch; justify-content: center; }
    /* 2FA rows: name on the first line, then a large code with its countdown and copy button. */
    .vault-row.is-totp { flex-wrap: wrap; row-gap: .25rem; }
    .vault-row.is-totp .vault-main { flex-basis: 0; }
    .vault-row.is-totp .vault-otp { order: 5; flex-basis: 100%; padding-left: calc(36px + .7rem); } /* under the name, past the icon */
    .vault-row.is-totp .vault-otp .otp-code { font-size: 1.45rem; letter-spacing: .06em; }
    .vault-row.is-totp .vault-otp .otp-left { display: inline; }
    .vault-row.is-totp .vault-otp [data-copy-otp] { margin-left: auto; }
    .vault-linked { flex-wrap: wrap; gap: .5rem 1rem; }
    /* Item details: one row of actions (More, Share, Copy all, Edit). */
    #pvViewFoot { flex-wrap: nowrap; padding: .6rem .75rem; }
    #pvViewFoot > div { flex-wrap: nowrap !important; }
    #pvViewFoot .btn { padding-left: .8rem; padding-right: .8rem; white-space: nowrap; }

    /* Tables that are lists of records read as cards (add class table-stack and data-label). */
    .table-stack thead { display: none; }
    .table-stack tr { display: block; padding: .6rem 0; border-bottom: 1px solid var(--np-line); }
    .table-stack tr:last-child { border-bottom: 0; }
    .panel-card .table-stack td, .table-stack td { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 1rem; border: 0; text-align: right; }
    .table-stack td[data-label]::before { content: attr(data-label); color: var(--np-muted); font-size: .85rem; text-align: left; }
    .table-stack td[colspan] { display: block; text-align: center; }
}

@media (max-width: 575.98px) {
    /* Selection boxes take room every row needs; only the trash (restore / delete) keeps them. */
    #vaultApp:not([data-section="trash"]) .vault-check, #vaultApp:not([data-section="trash"]) .vault-check-spacer { display: none; }
}

@media (max-width: 379.98px) {
    /* Small phones: the detail actions take two rows, the main ones full width. */
    #pvViewFoot { flex-wrap: wrap; }
    #pvViewFoot > div:last-child { flex: 1 1 100%; }
    #pvViewFoot > div:last-child .btn { flex: 1; }
}

/* Login editor: "More options" (pv-items.js). Always open from md up, where the summary is hidden. */
.vault-more-fields > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .6rem; padding: .75rem 1rem; border: 1px solid var(--np-line); border-radius: 12px; background: var(--np-surface-2); color: var(--np-ink); font-weight: 500; }
.vault-more-fields > summary::-webkit-details-marker { display: none; }
.vault-more-fields > summary::after { content: "\F282"; font-family: bootstrap-icons; margin-left: auto; color: var(--np-muted); transition: transform .15s; }
.vault-more-fields[open] > summary::after { transform: rotate(180deg); }
.vault-more-fields > summary span { font-size: .8rem; font-weight: 400; color: var(--np-muted); }
.vault-more-fields[open] > summary { margin-bottom: 1rem; }
@media (min-width: 768px) { .vault-more-fields > summary { display: none; } }

/* ==========================================================================
   Skeleton loading: placeholders shaped like the content on its way.
   Server side: skeleton() in Lib/Functions.php (first paint). Client side: PV.skeleton() in
   app.js (dialogs, tables, lists, page-to-page navigation). Keep the two in step.
   ========================================================================== */
.skel-wrap { pointer-events: none; }
.skel {
    display: block; height: .75rem; border-radius: 6px;
    background: linear-gradient(90deg, var(--np-surface-2) 0%, color-mix(in srgb, var(--np-surface-2) 60%, var(--np-line-strong)) 50%, var(--np-surface-2) 100%);
    background-size: 200% 100%; animation: skel-shimmer 1.4s ease-in-out infinite;
}
.skel-title { height: 1rem; }
.skel-lg { height: 1.6rem; }
.skel-icon { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; }
.skel-tile-icon { width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0; }
.skel-input { height: 2.6rem; border-radius: 12px; }
.skel-pill { height: 2.4rem; border-radius: 999px; }
.skel-otp { height: 1.35rem; width: 6.5rem; }
.skel-dot { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.skel-row { display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; border-bottom: 1px solid var(--np-line); }
.skel-row:last-child { border-bottom: 0; }
.skel-row .skel-text { flex: 1; min-width: 0; display: grid; gap: .45rem; }
.skel-stack { display: grid; gap: .65rem; }
@keyframes skel-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }
/* Page-to-page: the next page's skeleton replaces the current content while it loads (app.js). */
.app-content.is-navigating > :not(.skel-page) { display: none !important; }
