/* WebSeicho Billing - app styles (Bootstrap 5.3 base) */
:root {
    --brand: #AC2121;
    --brand-dark: #8A1A1A;
    --brand-soft: #FBEDED;
    --ink: #1D1D1F;
    --muted: #6B7280;
    --line: #E7E5E4;
    --surface: #FFFFFF;
    --page: #F6F5F3;
    --sidebar: #1C1917;
    --sidebar-ink: #D6D3D1;
    --radius: 12px;
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 172, 33, 33;
    --bs-link-hover-color: var(--brand-dark);
}

body { font-family: var(--bs-body-font-family); color: var(--ink); background: var(--page); }
h1, h2, h3, .brand-name, .auth-title, .stat-value, .welcome-hi { font-family: 'Bricolage Grotesque', var(--bs-body-font-family); }
a { text-decoration: none; }

/* Buttons */
.btn-brand { --bs-btn-color: #fff; --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark); --bs-btn-active-color: #fff;
    --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); font-weight: 600; }
.btn-icon { border: 0; font-size: 1.4rem; line-height: 1; padding: .25rem .5rem; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(172, 33, 33, .15); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.btn-check:checked + .btn-outline-secondary { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }

/* Brand */
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; }
.brand-name span { color: var(--brand); }

/* Auth pages */
.auth-body { min-height: 100vh; background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), var(--page)); }
.auth-wrap { max-width: 520px; margin: 0 auto; padding: 40px 16px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-brand .brand-tag { font-size: .8rem; color: var(--muted); }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 10px 30px rgba(28, 25, 23, .06); }
.auth-title { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.auth-foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 20px; }
.dev-chip { display: inline-flex; gap: 6px; align-items: center; font-size: .75rem; font-weight: 600; background: var(--ink); color: #fff; padding: 4px 10px; border-radius: 99px; margin-bottom: 12px; }
.form-section { font-size: .95rem; font-weight: 700; margin: 8px 0 12px; color: var(--brand); font-family: var(--bs-body-font-family); }
.check-list li { font-size: .875rem; padding: 3px 0; display: flex; gap: 8px; align-items: center; }
.check-list .ok i { color: #15803D; } .check-list .bad { color: #B91C1C; } .check-list .warn i { color: #B45309; }
.company-pick { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line);
    border-radius: var(--radius); background: var(--surface); transition: border-color .15s, background .15s; }
.company-pick:hover { border-color: var(--brand); background: var(--brand-soft); }
.company-pick-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand);
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.error-code { font-size: 1rem; font-weight: 700; color: var(--brand); margin-bottom: 8px; }

/* App shell */
.app-body { min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); width: 256px; }
@media (min-width: 992px) {
    .sidebar { position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; overflow-y: auto; }
    .main { margin-left: 256px; }
    .impersonation-bar + .sidebar { top: 44px; }
}
.sidebar.offcanvas-lg { --bs-offcanvas-bg: var(--sidebar); --bs-offcanvas-width: 270px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 10px; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.sidebar-brand .brand-name { color: #fff; }
.sidebar-brand .brand-name span { color: #F87171; }
.sidebar-panel { margin: 4px 16px 10px; padding: 8px 10px; font-size: .8rem; border-radius: 8px; background: rgba(255, 255, 255, .06);
    color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-developer .sidebar-panel { background: rgba(172, 33, 33, .35); }
.sidebar-nav { padding: 0 10px 24px; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #78716C; padding: 14px 8px 6px; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--sidebar-ink); font-size: .9rem; }
.sidebar-nav .nav-link i { font-size: 1.1rem; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--brand); color: #fff; }
.sidebar-nav .nav-link.disabled { color: #78716C; cursor: default; }
.badge-soon { margin-left: auto; font-size: .62rem; padding: 2px 6px; border-radius: 99px; background: rgba(255, 255, 255, .08); color: #A8A29E; }

.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 10px; padding: 12px 20px;
    background: rgba(246, 245, 243, .9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-title { font-size: 1.15rem; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-user { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 12px 4px 4px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; }
.content { padding: 20px; max-width: 1400px; }
@media (max-width: 575.98px) { .content { padding: 14px; } .topbar { padding: 10px 14px; } }

.impersonation-bar { position: sticky; top: 0; z-index: 1050; display: flex; align-items: center; gap: 10px; min-height: 44px;
    padding: 6px 16px; background: #111827; color: #fff; font-size: .85rem; }
.impersonation-bar .ri-spy-line { font-size: 1.2rem; color: #FBBF24; }

/* Cards & tiles */
.card-soft { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; }
.card-soft > .card-header { background: var(--surface); border-bottom: 1px solid var(--line); padding: 12px 16px; }
.card-soft > .card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.table > :not(caption) > * > * { padding: .65rem 1rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #FAFAF9; }

.stat-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; height: 100%; }
.stat-tile i { font-size: 1.3rem; display: inline-flex; width: 38px; height: 38px; align-items: center; justify-content: center; border-radius: 10px; background: #F5F5F4; color: var(--ink); }
.stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 10px; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--muted); }
.tile-brand i { background: var(--brand-soft); color: var(--brand); }
.tile-green i { background: #DCFCE7; color: #15803D; }
.tile-blue i { background: #DBEAFE; color: #1D4ED8; }
.tile-amber i { background: #FEF3C7; color: #B45309; }
.tile-red i { background: #FEE2E2; color: #B91C1C; }

.welcome-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 20px; border-radius: var(--radius);
    background: linear-gradient(135deg, var(--brand), #6E1414); color: #fff; }
.welcome-hi { font-size: 1.4rem; font-weight: 700; }
.welcome-sub { opacity: .85; font-size: .9rem; }
.setup-list .list-group-item { display: flex; gap: 10px; align-items: center; font-size: .9rem; }
.setup-list .list-group-item i { color: #A8A29E; font-size: 1.1rem; }
.setup-list .done i { color: #15803D; }
.credentials-box code { font-size: .95em; }

/* ---------- Page structure ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-sub { font-size: .85rem; color: var(--muted); }
.page-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; background: rgba(246, 245, 243, .95); padding: 10px 0; border-top: 1px solid var(--line); }
.tab-scroll { overflow-x: auto; }
.tab-scroll .nav-link { white-space: nowrap; color: var(--ink); }
.nav-pills .nav-link.active { background: var(--brand); color: #fff; }
.w-70 { width: 70px !important; } .w-90 { width: 90px !important; } .w-110 { width: 110px !important; } .w-130 { width: 130px !important; }
.border-dashed { border-style: dashed !important; }

/* ---------- Typeahead pickers ---------- */
.picker { position: relative; }
.picker-list { position: absolute; z-index: 1060; left: 0; right: 0; top: 100%; margin-top: 4px; max-height: 320px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.picker-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; font-size: .9rem; border-bottom: 1px solid #f5f5f4; }
.picker-item:hover, .picker-item.active { background: var(--brand-soft); }
.picker-empty { padding: 10px 12px; color: var(--muted); font-size: .85rem; }

/* ---------- Document editor ---------- */
.doc-scan { display: flex; flex-wrap: wrap; align-items: center; background: var(--surface); }
.doc-lines td { padding: 6px 6px; vertical-align: top; }
.doc-lines .w-item { min-width: 240px; } .doc-lines .w-hsn { width: 100px; } .doc-lines .w-num { width: 110px; } .doc-lines .w-sm { width: 90px; }
.doc-lines .amt { padding-top: 12px; font-weight: 600; white-space: nowrap; }
.totals-card .tot-row { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: .92rem; }
.totals-card .grand { font-size: 1.35rem; font-weight: 800; border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 8px; }

/* ---------- Misc ---------- */
.brand-preview { max-height: 70px; max-width: 100%; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: #fff; }
.item-photo { max-height: 220px; object-fit: cover; }
.perm-overrides { max-height: 560px; overflow-y: auto; }
.perm-module { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.perm-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: .85rem; }
.perm-row span { flex: 1; } .perm-row select { width: 130px; }
.label-pick { max-height: 480px; overflow-y: auto; columns: 2; }
@media (max-width: 767.98px) { .label-pick { columns: 1; } }
.report-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); height: 100%; transition: border-color .15s; }
.report-card:hover { border-color: var(--brand); color: var(--ink); }
.report-card i { font-size: 1.4rem; color: var(--brand); background: var(--brand-soft); border-radius: 10px; width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.report-card small { display: block; color: var(--muted); }
.coa .grp-row td { background: #fafaf9; }
.coa .depth-1 td:first-child { padding-left: 28px; } .coa .depth-2 td:first-child { padding-left: 48px; } .coa .depth-3 td:first-child { padding-left: 68px; } .coa .depth-4 td:first-child { padding-left: 88px; }
.selfie-video { width: 100%; max-width: 320px; border-radius: 12px; margin: 0 auto 12px; display: block; transform: scaleX(-1); }
.selfie-video.d-none { display: none !important; }
a.stat-tile:hover { border-color: var(--brand); }
@media print {
    .sidebar, .topbar, .no-print, .impersonation-bar, .page-actions, .form-actions { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0; max-width: none; }
    .card-soft { border: 0; }
}

/* Bootstrap makes .offcanvas-lg transparent on desktop; keep the dark sidebar */
@media (min-width: 992px) {
    .sidebar.offcanvas-lg { background-color: var(--sidebar) !important; }
}
