/* Ego Business Suite — app styles (Bootstrap 5.3 base) */
:root {
  --app-sidebar-w: 260px;
  --app-topbar-h: 60px;
  --app-radius: .75rem;
}
body { font-size: .925rem; background: var(--bs-tertiary-bg); }
[data-bs-theme="dark"] body { background: #12151a; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: var(--app-sidebar-w); flex: 0 0 var(--app-sidebar-w);
  background: var(--bs-body-bg); border-right: 1px solid var(--bs-border-color);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040;
}
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  height: var(--app-topbar-h); display: flex; align-items: center; gap: .5rem;
  padding: 0 1.25rem; background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color);
  position: sticky; top: 0; z-index: 1020;
}
.page-title { font-size: 1.1rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-content { padding: 1.5rem 1.25rem 3rem; }

.sidebar-brand { height: var(--app-topbar-h); display: flex; align-items: center; padding: 0 1.1rem; border-bottom: 1px solid var(--bs-border-color); }
.brand-logo { height: min(var(--app-logo-height), 40px); width: auto; max-width: 110px; object-fit: contain; }
.brand-mark { width: 34px; height: 34px; border-radius: .6rem; display: inline-grid; place-items: center; background: var(--bs-primary); color: #fff; }
.brand-name { font-weight: 700; color: var(--bs-body-color); font-size: .95rem; line-height: 1.15; }
.sidebar-nav { padding: .75rem .6rem; flex: 1 1 auto; }
.sidebar-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color); padding: 1rem .75rem .35rem; font-weight: 600; }
.sidebar-link {
  display: flex; align-items: center; gap: .7rem; padding: .5rem .75rem; border-radius: .55rem;
  color: var(--bs-body-color); text-decoration: none; margin-bottom: 2px;
}
.sidebar-link .bi { font-size: 1.05rem; opacity: .8; }
.sidebar-link:hover { background: var(--bs-secondary-bg); color: var(--bs-body-color); }
.sidebar-link.active { background: var(--app-primary-soft); color: var(--bs-primary); font-weight: 600; }
.sidebar-link.active .bi { opacity: 1; }
.sidebar-soon { font-size: .62rem; font-weight: 500; color: var(--bs-secondary-color) !important; background: transparent !important; }
.sidebar-footer { padding: .75rem 1.1rem; border-top: 1px solid var(--bs-border-color); }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
  .app-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .app-shell.sidebar-open .app-sidebar { transform: none; }
  .app-shell.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1030; }
  .app-content { padding: 1rem .9rem 3rem; }
  .app-topbar { padding: 0 .75rem; }
}

.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--app-primary-soft); color: var(--bs-primary); font-weight: 700; font-size: .8rem; }
.user-role { font-size: .72rem; }

/* ---------- Cards / tables ---------- */
.card { border-radius: var(--app-radius); border-color: var(--bs-border-color-translucent); }
.card-header { background: transparent; font-weight: 600; padding: .85rem 1.1rem; }
.stat-card .stat-label { font-size: .78rem; color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 1.25rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-card .stat-icon { width: 42px; height: 42px; border-radius: .7rem; display: grid; place-items: center; font-size: 1.2rem; }
.stat-icon.bg-p { background: var(--app-primary-soft); color: var(--bs-primary); }
.stat-icon.bg-s { background: rgba(var(--bs-success-rgb), .12); color: var(--bs-success); }
.stat-icon.bg-w { background: rgba(var(--bs-warning-rgb), .15); color: #b37a00; }
.stat-icon.bg-d { background: rgba(var(--bs-danger-rgb), .12); color: var(--bs-danger); }
[data-bs-theme="dark"] .stat-icon.bg-w { color: var(--bs-warning); }
.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); font-weight: 600; white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-box { position: relative; height: 280px; }
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--bs-secondary-color); }
.empty-state .bi { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .6; }

/* Permission matrix */
.perm-matrix td, .perm-matrix th { vertical-align: middle; }
.perm-matrix .form-check { margin: 0; min-height: 0; }

/* Settings */
.settings-nav .nav-link { color: var(--bs-body-color); border-radius: .55rem; }
.settings-nav .nav-link.active { background: var(--app-primary-soft); color: var(--bs-primary); font-weight: 600; }
.logo-preview { max-height: var(--app-logo-height); max-width: 260px; object-fit: contain; }
.logo-preview-box { border: 1px dashed var(--bs-border-color); border-radius: .6rem; padding: 1rem; min-height: 80px; display: flex; align-items: center; justify-content: center; background: var(--bs-body-bg); }
.form-control-color { width: 3.5rem; }

/* ---------- Guest / auth ---------- */
.guest-body { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, var(--app-primary-soft), transparent), var(--bs-tertiary-bg); }
.guest-wrap { max-width: 420px; margin: 0 auto; padding: 8vh 1rem 2rem; }
.auth-card { border-radius: 1rem; }
.auth-logo { max-height: var(--app-logo-height); max-width: 220px; object-fit: contain; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Password strength meter */
.pw-meter { height: 4px; border-radius: 2px; background: var(--bs-secondary-bg); overflow: hidden; }
.pw-meter > span { display: block; height: 100%; width: 0; transition: width .2s, background-color .2s; }

@media print {
  .app-sidebar, .app-topbar, .no-print { display: none !important; }
  .app-content { padding: 0; }
  body { background: #fff; }
}
.min-w-0 { min-width: 0; }
.favicon-preview { width: 48px; height: 48px; object-fit: contain; }
.form-range::-webkit-slider-thumb { background: var(--bs-primary); }
.form-range::-moz-range-thumb { background: var(--bs-primary); }
.stat-card .stat-value { word-break: break-word; }

/* 2FA */
.qr-box { width: 240px; height: 240px; background: #fff; border-radius: .75rem; padding: 0; border: 1px solid var(--bs-border-color); overflow: hidden; }
.qr-box canvas { width: 100%; height: 100%; display: block; }
.otp-input { letter-spacing: .25em; font-variant-numeric: tabular-nums; }
@media print { .recovery-codes ~ .btn { display: none; } }

/* Profile / detail pages */
.detail-list dt { font-weight: 500; color: var(--bs-secondary-color); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.detail-list dd { margin-bottom: .85rem; }
.nav-tabs .nav-link { color: var(--bs-secondary-color); }
.nav-tabs .nav-link.active { color: var(--bs-body-color); font-weight: 600; }
.code-pill { font-family: var(--bs-font-monospace); font-size: .8rem; background: var(--bs-secondary-bg); border-radius: .35rem; padding: .1rem .4rem; white-space: nowrap; }
.mini-stat { border: 1px solid var(--bs-border-color-translucent); border-radius: .6rem; padding: .7rem .9rem; height: 100%; }
.mini-stat .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); }
.mini-stat .val { font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.table-sticky thead th { position: sticky; top: 0; background: var(--bs-body-bg); z-index: 1; }

/* Document editor */
.ac-menu { width: 100%; max-height: 320px; overflow-y: auto; top: 100%; left: 0; z-index: 1060; }
.ac-menu .dropdown-item { white-space: normal; }
.lines-table td { vertical-align: top; padding: .4rem .35rem; }
.lines-table .form-control, .lines-table .form-select { font-size: .85rem; padding: .3rem .45rem; }
.lines-table textarea { resize: vertical; min-height: 34px; }
.lines-table .line-total { font-weight: 600; padding-top: .45rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines-table .col-qty { width: 80px; } .lines-table .col-price { width: 120px; } .lines-table .col-disc { width: 150px; } .lines-table .col-total { width: 120px; } .lines-table .col-act { width: 44px; }
.totals-box dt { font-weight: 400; color: var(--bs-secondary-color); }
.totals-box dd { text-align: right; font-variant-numeric: tabular-nums; margin-bottom: .35rem; }
.totals-box .grand { font-size: 1.15rem; font-weight: 700; color: var(--bs-body-color); }
.doc-status-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.lines-table { min-width: 860px; }
.fp-table { min-width: 1480px; }
.fp-table td:first-child { min-width: 230px; }
.fp-table .col-spec { min-width: 170px; }
.lines-table .col-disc .form-control { min-width: 64px; }
