/* =====================================================================
   HIVE Fusion — application shell on Bootstrap 5.3
   One palette, one type scale, light + dark via [data-bs-theme].
   The top bar and sidebar are brand chrome (deep green) in both themes;
   only content surfaces change with the theme.
   ===================================================================== */

:root {
  --hf-green-950: #08261a;
  --hf-green-900: #0b2e20;
  --hf-green-800: #0f3d24;
  --hf-green-700: #14512f;
  --hf-green-600: #176b3a;
  --hf-green-500: #1c7a45;
  --hf-green-400: #2e9e5b;
  --hf-mint: #7fe0a6;
  --hf-amber: #b7791f;
  --hf-red: #c62828;
  --hf-blue: #1b6ca8;

  --hf-topbar-h: 60px;
  --hf-sidebar-w: 252px;
  --hf-radius: 12px;
  --hf-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --hf-mono: 'JetBrains Mono', ui-monospace, Consolas, 'Liberation Mono', monospace;
}

[data-bs-theme="light"] {
  --bs-body-bg: #f4f8f5;
  --bs-body-color: #16241c;
  --bs-secondary-color: #5d7468;
  --bs-tertiary-bg: #eef4f0;
  --bs-border-color: #dbe6dd;
  --bs-border-color-translucent: rgba(15, 61, 36, .12);
  --bs-primary: #1c7a45;
  --bs-primary-rgb: 28, 122, 69;
  --bs-link-color: #1c7a45;
  --bs-link-color-rgb: 28, 122, 69;
  --bs-link-hover-color: #0f3d24;
  --bs-link-hover-color-rgb: 15, 61, 36;
  --bs-success: #1c7a45;
  --bs-success-rgb: 28, 122, 69;
  --hf-surface: #ffffff;
  --hf-surface-2: #f7faf8;
  --hf-hover: #eaf4ee;
  --hf-accent-soft: #e2f2e8;
  --hf-hash: #8a5f12;
}

[data-bs-theme="dark"] {
  --bs-body-bg: #0d1712;
  --bs-body-color: #dde9e1;
  --bs-secondary-color: #93ab9e;
  --bs-tertiary-bg: #16231c;
  --bs-border-color: #24372c;
  --bs-border-color-translucent: rgba(255, 255, 255, .08);
  --bs-primary: #35a865;
  --bs-primary-rgb: 53, 168, 101;
  --bs-link-color: #6fd39a;
  --bs-link-color-rgb: 111, 211, 154;
  --bs-link-hover-color: #9be6bb;
  --bs-link-hover-color-rgb: 155, 230, 187;
  --bs-success: #35a865;
  --bs-success-rgb: 53, 168, 101;
  --hf-surface: #121e18;
  --hf-surface-2: #16241d;
  --hf-hover: #1a2c22;
  --hf-accent-soft: #173525;
  --hf-hash: #e0b766;
}

html { -webkit-text-size-adjust: 100%; }
:root, [data-bs-theme] { --bs-body-font-family: var(--hf-sans); --bs-body-font-size: .9rem; --bs-font-monospace: var(--hf-mono); }
body { font-family: var(--hf-sans); font-size: .9rem; line-height: 1.5; }
.mono, code, kbd, pre, .font-monospace { font-family: var(--hf-mono) !important; }
code { color: var(--hf-hash); font-size: .82em; word-break: break-all; }
.hash { font-family: var(--hf-mono); font-size: .78rem; color: var(--hf-hash); word-break: break-all; }
.min-w-0 { min-width: 0; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Bootstrap component tuning ---------- */
.btn { --bs-btn-font-size: .86rem; --bs-btn-padding-y: .42rem; --bs-btn-padding-x: .85rem; font-weight: 500; border-radius: 8px; }
.btn-sm { --bs-btn-font-size: .78rem; --bs-btn-padding-y: .25rem; --bs-btn-padding-x: .55rem; }
.btn-lg { --bs-btn-font-size: 1rem; --bs-btn-padding-y: .62rem; }
.form-control, .form-select, .input-group-text { font-size: .88rem; }
.form-control-lg { font-size: 1rem; }
.btn-primary { --bs-btn-bg: var(--hf-green-500); --bs-btn-border-color: var(--hf-green-500); --bs-btn-hover-bg: var(--hf-green-700); --bs-btn-hover-border-color: var(--hf-green-700); --bs-btn-active-bg: var(--hf-green-800); --bs-btn-active-border-color: var(--hf-green-800); --bs-btn-disabled-bg: var(--hf-green-500); --bs-btn-disabled-border-color: var(--hf-green-500); }
.btn-outline-primary { --bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary); --bs-btn-hover-bg: var(--hf-green-500); --bs-btn-hover-border-color: var(--hf-green-500); --bs-btn-active-bg: var(--hf-green-700); }
.form-control, .form-select { border-radius: 8px; }
.form-control:focus, .form-select:focus, .btn:focus-visible { border-color: var(--bs-primary); box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .2); }
.form-label { font-size: .78rem; font-weight: 600; color: var(--bs-secondary-color); margin-bottom: .3rem; }
.form-text { font-size: .76rem; }
.card { --bs-card-bg: var(--hf-surface); --bs-card-border-color: var(--bs-border-color); border-radius: var(--hf-radius); }
.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--hf-hover); font-size: .84rem; margin-bottom: 0; }
.table > thead th { font-size: .68rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--bs-secondary-color); white-space: nowrap; background: var(--hf-surface-2); border-bottom-width: 1px; }
.table td, .table th { padding: .65rem .8rem; vertical-align: middle; }
.dropdown-menu { --bs-dropdown-bg: var(--hf-surface); --bs-dropdown-link-hover-bg: var(--hf-hover); --bs-dropdown-link-active-bg: var(--hf-green-500); border-radius: 10px; font-size: .88rem; }
.nav-tabs { --bs-nav-tabs-link-active-bg: var(--hf-surface); --bs-nav-tabs-link-active-color: var(--bs-primary); --bs-nav-link-color: var(--bs-secondary-color); --bs-nav-link-hover-color: var(--bs-body-color); flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.nav-tabs .nav-link { white-space: nowrap; font-weight: 500; }
.modal-content { background: var(--hf-surface); border-radius: var(--hf-radius); }
.badge-status { text-transform: capitalize; font-weight: 600; letter-spacing: .02em; }
.alert { border-radius: 10px; font-size: .88rem; }
.alert-info { --bs-alert-bg: var(--hf-accent-soft); --bs-alert-border-color: rgba(var(--bs-primary-rgb), .25); --bs-alert-color: var(--bs-body-color); --bs-alert-link-color: var(--bs-primary); }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem 1rem; font-size: .84rem; }
.meta-grid span { display: block; font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-secondary-color); }
.list-group { --bs-list-group-bg: var(--hf-surface); }

/* ---------- top bar (brand chrome) ---------- */
.app-topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--hf-topbar-h); z-index: 1040;
  display: flex; align-items: center; gap: .75rem; padding: 0 1rem;
  background: linear-gradient(90deg, var(--hf-green-900), var(--hf-green-800));
  color: #e6f6ec; border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: inherit; min-width: 0; }
.brand-mark { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 9px; background: #fff; display: grid; place-items: center; }
.brand-mark img { width: 26px; height: 26px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 700; letter-spacing: .14em; font-size: .95rem; color: #fff; white-space: nowrap; }
.brand-name b { color: var(--hf-mint); font-weight: 700; }
.brand-tag { font-size: .62rem; letter-spacing: .2em; text-transform: uppercase; color: #9cc7ad; white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.topbar-btn { --bs-btn-color: #dcefe3; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: rgba(255, 255, 255, .08); --bs-btn-active-color: #fff; --bs-btn-active-bg: rgba(255, 255, 255, .12); --bs-btn-border-color: rgba(255, 255, 255, .14); --bs-btn-hover-border-color: rgba(255, 255, 255, .28); height: 38px; min-width: 38px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: 0 .65rem; font-size: .85rem; }
.topbar-btn .bi { font-size: 1.05rem; }
.topbar-tool { --bs-btn-bg: rgba(127, 224, 166, .12); --bs-btn-border-color: rgba(127, 224, 166, .35); }
.topbar-dot { position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #f2b33d; color: #2b1d04; font-size: .62rem; font-weight: 700; line-height: 16px; text-align: center; }
.role-pill { align-items: center; gap: .35rem; height: 30px; padding: 0 .7rem; border-radius: 15px; border: 1px solid rgba(255, 255, 255, .18); color: #cfe7d8; font-size: .74rem; font-weight: 500; }
.topbar-user { display: inline-flex; align-items: center; gap: .5rem; height: 42px; padding: 0 .55rem 0 .3rem; color: #fff; border: 1px solid rgba(255, 255, 255, .14); border-radius: 22px; }
.topbar-user:hover, .topbar-user:focus-visible, .topbar-user.show { color: #fff; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .28); }
.topbar-user::after { margin-left: .1rem; }
.user-name { max-width: 170px; font-size: .85rem; font-weight: 500; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--hf-mint); color: var(--hf-green-900); display: inline-grid; place-items: center; font-weight: 700; font-size: .78rem; flex: 0 0 32px; }
.user-menu { min-width: 250px; }

/* ---------- sidebar ---------- */
.app-sidebar { --bs-offcanvas-width: var(--hf-sidebar-w); --bs-offcanvas-bg: var(--hf-green-900); background-color: var(--hf-green-900) !important; color: #cfe7d8; }
@media (min-width: 992px) {
  .app-sidebar { position: fixed; top: var(--hf-topbar-h); bottom: 0; left: 0; width: var(--hf-sidebar-w); overflow-y: auto; display: flex; flex-direction: column; z-index: 1030; border-right: 1px solid rgba(255, 255, 255, .05); }
}
@media (max-width: 991.98px) { .app-sidebar { display: flex; flex-direction: column; } }
.sidebar-nav { padding: .75rem .65rem; flex: 1; }
.nav-section { font-size: .64rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #6fa286; padding: 1rem .75rem .4rem; }
.nav-section:first-child { padding-top: .35rem; }
.app-sidebar .nav-link { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: 9px; color: #cfe7d8; font-size: .88rem; font-weight: 500; text-decoration: none; }
.app-sidebar .nav-link .bi { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .9; }
.app-sidebar .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.app-sidebar .nav-link:focus-visible { outline: 2px solid var(--hf-mint); outline-offset: -2px; }
.app-sidebar .nav-link.active { background: #fff; color: var(--hf-green-800); font-weight: 600; }
.nav-badge { margin-left: auto; min-width: 22px; padding: 0 6px; height: 20px; border-radius: 10px; background: rgba(255, 255, 255, .14); color: #fff; font-size: .7rem; font-weight: 600; display: grid; place-items: center; }
.nav-link.active .nav-badge { background: var(--hf-accent-soft); color: var(--hf-green-800); }
[data-bs-theme="dark"] .app-sidebar .nav-link.active { background: #e3f3e9; color: var(--hf-green-900); }
.sidebar-foot { padding: .9rem 1.4rem 1.1rem; font-size: .7rem; color: #6fa286; border-top: 1px solid rgba(255, 255, 255, .06); }

/* ---------- main ---------- */
.app-main { padding-top: var(--hf-topbar-h); min-height: 100vh; display: flex; flex-direction: column; }
@media (min-width: 992px) { .app-main { margin-left: var(--hf-sidebar-w); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1.4rem 1.5rem 1.1rem; background: var(--hf-surface); border-bottom: 1px solid var(--bs-border-color); }
.page-eyebrow { font-size: .68rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--bs-secondary-color); margin-bottom: .25rem; }
.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; display: flex; align-items: center; gap: .6rem; min-width: 0; letter-spacing: -.01em; }
.page-title .bi { color: var(--bs-primary); font-size: 1.25rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.page-body { padding: 1.5rem; flex: 1; width: 100%; max-width: 1600px; }
.app-footer { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .9rem 1.5rem; font-size: .74rem; color: var(--bs-secondary-color); border-top: 1px solid var(--bs-border-color); }
.skip-link { position: absolute; z-index: 2000; top: .5rem; left: .5rem; background: #fff; padding: .4rem .8rem; border-radius: 6px; }
@media (max-width: 575.98px) {
  .brand-text { display: none; }
  .topbar-user::after { display: none; }
  .topbar-user { padding: 0 .3rem; }
  .page-head { padding: 1rem; }
  .page-body { padding: 1rem; }
  .page-title { font-size: 1.15rem; }
  .app-topbar { padding: 0 .5rem; gap: .4rem; }
}

/* ---------- stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 1199.98px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .stat-grid { grid-template-columns: 1fr; } }
.stat-link { text-decoration: none; color: inherit; display: block; }
.stat-card { position: relative; background: var(--hf-surface); border: 1px solid var(--bs-border-color); border-radius: var(--hf-radius); padding: 1.1rem 1.2rem; height: 100%; overflow: hidden; transition: border-color .15s, transform .15s; }
.stat-link:hover .stat-card { border-color: rgba(var(--bs-primary-rgb), .5); }
.stat-icon { position: absolute; top: 1rem; right: 1rem; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--hf-accent-soft); color: var(--bs-primary); font-size: 1.15rem; }
.stat-label { font-size: .68rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--bs-secondary-color); padding-right: 3rem; }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin: .35rem 0 .2rem; letter-spacing: -.02em; }
.stat-sub { font-size: .78rem; color: var(--bs-secondary-color); }
.tone-red .stat-icon { background: rgba(198, 40, 40, .1); color: var(--hf-red); }
.tone-red .stat-value { color: var(--hf-red); }
.tone-amber .stat-icon { background: rgba(183, 121, 31, .12); color: var(--hf-amber); }
.tone-amber .stat-value { color: var(--hf-amber); }
.tone-blue .stat-icon { background: rgba(27, 108, 168, .1); color: var(--hf-blue); }
[data-bs-theme="dark"] .tone-blue .stat-icon { color: #6fb3e6; }
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 1199.98px) { .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mini-stat { background: var(--hf-surface); border: 1px solid var(--bs-border-color); border-radius: var(--hf-radius); padding: 1rem; text-align: center; }
.mini-stat .bi { font-size: 1.3rem; color: var(--bs-primary); }
.mini-stat .v { font-size: 1.35rem; font-weight: 700; margin-top: .25rem; }
.mini-stat .l { font-size: .66rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--bs-secondary-color); }

/* ---------- panels ---------- */
.panel { height: 100%; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; background: transparent; padding: .85rem 1.1rem; }
.panel-title { display: flex; align-items: center; gap: .5rem; font-size: .74rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.panel-title .bi { color: var(--bs-primary); font-size: .95rem; }
.panel-link { font-size: .78rem; font-weight: 500; text-decoration: none; white-space: nowrap; }
.panel .table-responsive { border-radius: 0 0 var(--hf-radius) var(--hf-radius); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--bs-secondary-color); }
.empty-state .bi { font-size: 2.4rem; opacity: .45; display: block; margin-bottom: .6rem; }
.es-title { font-weight: 600; color: var(--bs-body-color); }
.es-text { font-size: .82rem; margin-top: .2rem; }
.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: .45rem 1rem; font-size: .86rem; margin: 0; }
.kv dt { color: var(--bs-secondary-color); font-weight: 500; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.list-row { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.1rem; border-top: 1px solid var(--bs-border-color); }
.list-row:first-child { border-top: 0; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; background: var(--hf-accent-soft); color: var(--bs-primary); }
.chip-warn { background: rgba(183, 121, 31, .14); color: var(--hf-amber); }
.chip-danger { background: rgba(198, 40, 40, .12); color: var(--hf-red); }
.toolbar-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- auth pages ---------- */
.auth-shell { display: grid; grid-template-columns: minmax(340px, 42%) 1fr; min-height: 100vh; }
@media (max-width: 991.98px) { .auth-shell { grid-template-columns: 1fr; } }
.auth-brand { background: radial-gradient(900px 500px at -10% -20%, #1c7a45 0, transparent 60%), linear-gradient(160deg, var(--hf-green-800), var(--hf-green-950)); color: #e6f6ec; padding: 2.8rem 3rem; flex-direction: column; }
.ab-top { display: flex; align-items: center; gap: .9rem; }
.ab-mark { width: 46px; height: 46px; background: #fff; border-radius: 11px; padding: 6px; object-fit: contain; }
.ab-name { font-weight: 700; letter-spacing: .14em; font-size: 1.05rem; }
.ab-name span { color: var(--hf-mint); }
.ab-tag { font-size: .62rem; letter-spacing: .3em; text-transform: uppercase; color: #9cc7ad; margin-top: .15rem; }
.ab-mid { margin: auto 0; max-width: 460px; }
.ab-mid h1 { font-size: 1.85rem; line-height: 1.25; font-weight: 700; margin: 0 0 1.6rem; letter-spacing: -.01em; }
.ab-mid ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1rem; }
.ab-mid li { display: flex; gap: .9rem; font-size: .9rem; line-height: 1.55; color: #cfe7d8; }
.ab-mid li span { font-family: var(--hf-mono); font-size: .7rem; color: var(--hf-mint); border: 1px solid #2c5a3e; border-radius: 6px; padding: .15rem .4rem; height: fit-content; }
.ab-foot { font-size: .72rem; color: #7fa890; letter-spacing: .04em; }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 460px; border-radius: 16px; }
.auth-card.auth-wide { max-width: 760px; }
.auth-logo { height: 38px; object-fit: contain; }
[data-bs-theme="dark"] .auth-logo { background: #fff; border-radius: 8px; padding: 3px 6px; }
.auth-legal { font-size: .72rem; color: var(--bs-secondary-color); margin-top: 1rem; }
.otp-input { font-family: var(--hf-mono); font-size: 1.6rem; letter-spacing: .5em; text-align: center; padding-left: .5em; }
.qr-box { background: #fff; border-radius: 12px; padding: 12px; display: inline-block; border: 1px solid var(--bs-border-color); }
.qr-box canvas, .qr-box img, .qr-box svg { display: block; width: 196px; height: 196px; }
.secret-code { font-family: var(--hf-mono); font-size: .95rem; letter-spacing: .12em; word-break: break-all; background: var(--hf-surface-2); border: 1px dashed var(--bs-border-color); border-radius: 8px; padding: .55rem .75rem; }
.recovery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; font-family: var(--hf-mono); font-size: 1rem; }
.recovery-grid div { background: var(--hf-surface-2); border: 1px solid var(--bs-border-color); border-radius: 8px; padding: .45rem .6rem; text-align: center; letter-spacing: .08em; }
.check-list { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .2rem 1rem; font-size: .8rem; }
@media (max-width: 575.98px) { .check-list { grid-template-columns: 1fr; } .recovery-grid { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .app-topbar, .app-sidebar, .page-actions, .app-footer { display: none !important; } .app-main { margin: 0; padding: 0; } }
