:root { --brand: #4f46e5; --sidebar-w: 248px; }
body { font-size: .925rem; background: #f6f7fb; color: #1f2937; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: color-mix(in srgb, var(--brand) 85%, #000); --bs-btn-hover-border-color: color-mix(in srgb, var(--brand) 85%, #000); --bs-btn-active-bg: color-mix(in srgb, var(--brand) 75%, #000); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand); --bs-btn-active-border-color: var(--brand); }
a { color: var(--brand); }
.text-brand { color: var(--brand) !important; }

/* App shell */
.app .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: #111827; color: #cbd5e1; display: flex; flex-direction: column; overflow-y: auto; z-index: 1040; transition: transform .2s; }
.app.admin .sidebar { background: #0f172a; }
.sidebar .brand { display: block; padding: 1.1rem 1.25rem; font-weight: 700; font-size: 1.15rem; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar .nav { padding: .5rem; }
.sidebar .nav-link { color: #cbd5e1; border-radius: .45rem; padding: .5rem .75rem; display: flex; align-items: center; gap: .6rem; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active { background: var(--brand); color: #fff; }
.app.admin .sidebar .nav-link.active { background: #334155; }
.sidebar .nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: .9rem .75rem .3rem; }
.app .main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid #e5e7eb; padding: .55rem 1.25rem; display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 1030; }
.content { padding: 1.5rem; flex: 1; }
.org-switch { display: flex; align-items: center; gap: .5rem; max-width: 280px; }
.org-logo { width: 24px; height: 24px; object-fit: contain; border-radius: 4px; }
.org-initial { width: 24px; height: 24px; border-radius: 6px; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
@media (max-width: 991.98px) {
  .app .sidebar { transform: translateX(-100%); }
  .app .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .app .main { margin-left: 0; }
  .content { padding: 1rem; }
}

/* Components */
.card { border: 1px solid #e5e7eb; border-radius: .75rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f3; font-weight: 600; border-radius: .75rem .75rem 0 0 !important; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-head p { margin: .15rem 0 0; color: #6b7280; }
.stat { padding: 1rem 1.15rem; }
.stat .label { color: #6b7280; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; font-weight: 600; background: #f9fafb; }
.table-card { margin: 0; }
.badge-soft-success { background: #dcfce7; color: #166534; }
.badge-soft-warning { background: #fef3c7; color: #92400e; }
.badge-soft-danger { background: #fee2e2; color: #991b1b; }
.badge-soft-info { background: #e0e7ff; color: #3730a3; }
.badge-soft-secondary { background: #f1f5f9; color: #475569; }
.usage .progress { height: 6px; }
.settings-tabs .nav-link { color: #374151; }
.settings-tabs .nav-link.active { color: var(--brand); border-bottom: 2px solid var(--brand); background: none; }
.perm-group { border: 1px solid #e5e7eb; border-radius: .6rem; padding: .9rem 1rem; margin-bottom: 1rem; background: #fff; }
.empty { text-align: center; padding: 2.5rem 1rem; color: #6b7280; }
.empty i { font-size: 2rem; display: block; margin-bottom: .5rem; color: #9ca3af; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 1rem; border-radius: .5rem; font-size: .8rem; white-space: pre-wrap; word-break: break-all; }

/* Auth / public */
.auth-body { background: linear-gradient(180deg, #eef2ff 0%, #f6f7fb 320px); min-height: 100vh; }
.auth-brand { font-weight: 800; font-size: 1.25rem; color: #111827; text-decoration: none; }
.auth-card { max-width: 440px; margin: 2rem auto; }
.auth-card.wide { max-width: 620px; }
.plan-card { height: 100%; transition: transform .15s, box-shadow .15s; }
.plan-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(16,24,40,.08); }
.plan-card.featured { border: 2px solid var(--brand); }
.plan-price { font-size: 2rem; font-weight: 800; }
.feature-list { list-style: none; padding: 0; margin: 0; }
.feature-list li { padding: .25rem 0; }
.feature-list li i { color: #16a34a; margin-right: .35rem; }

/* Print */
@media print { .no-print { display: none !important; } body { background: #fff; } }

/* Mobile topbar: keep org switcher from pushing the user menu off-screen */
@media (max-width: 575.98px) {
  .topbar { padding: .5rem .6rem; gap: .4rem; }
  .org-switch { max-width: calc(100vw - 175px); }
  .org-switch .text-truncate { min-width: 0; }
}
