/* ==========================================================
   Haojue Business Suite — brand theme
   Red #E20612 · Navy #353575 · Bronze #944120
   ========================================================== */
:root {
  --hj-red: #E20612;
  --hj-red-dark: #B8040E;
  --hj-red-soft: rgba(226, 6, 18, .1);
  --hj-navy: #353575;
  --hj-navy-dark: #1E1F4B;
  --hj-bronze: #944120;
  --hj-sidebar-w: 268px;
  --hj-radius: 14px;
  --hj-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --hj-body: #F4F5FA;
  --hj-surface: #FFFFFF;
  --hj-surface-2: #F8F9FC;
  --hj-border: #E6E8F0;
  --hj-text: #1D2033;
  --hj-muted: #6B7090;
  --hj-sidebar: linear-gradient(180deg, #23245A 0%, #1A1B45 100%);
  --hj-shadow: 0 1px 2px rgba(20, 22, 60, .04), 0 6px 24px rgba(20, 22, 60, .06);

  --bs-primary: #E20612;
  --bs-primary-rgb: 226, 6, 18;
  --bs-link-color: #E20612;
  --bs-link-color-rgb: 226, 6, 18;
  --bs-link-hover-color: #B8040E;
  --bs-body-font-family: var(--hj-font);
}

[data-bs-theme="dark"] {
  --hj-body: #0E1018;
  --hj-surface: #161925;
  --hj-surface-2: #1C2030;
  --hj-border: #272B3D;
  --hj-text: #E7E9F3;
  --hj-muted: #9095B3;
  --hj-sidebar: linear-gradient(180deg, #12132E 0%, #0B0C20 100%);
  --hj-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --bs-body-bg: #0E1018;
  --bs-body-color: #E7E9F3;
  --bs-border-color: #272B3D;
  --bs-secondary-bg: #1C2030;
  --bs-tertiary-bg: #1A1E2C;
  --bs-link-color: #FF4D57;
  --bs-link-color-rgb: 255, 77, 87;
}

html, body { font-family: var(--hj-font); }
body { background: var(--hj-body); color: var(--hj-text); }
a { text-decoration: none; }
.text-muted, .text-secondary { color: var(--hj-muted) !important; }
.text-brand { color: var(--hj-red) !important; }
.text-navy { color: var(--hj-navy) !important; }
[data-bs-theme="dark"] .text-navy { color: #A9ABF0 !important; }
.bg-brand { background: var(--hj-red) !important; color: #fff; }
.bg-navy { background: var(--hj-navy) !important; color: #fff; }

/* Buttons */
.btn-primary { --bs-btn-bg: var(--hj-red); --bs-btn-border-color: var(--hj-red); --bs-btn-hover-bg: var(--hj-red-dark); --bs-btn-hover-border-color: var(--hj-red-dark); --bs-btn-active-bg: var(--hj-red-dark); --bs-btn-active-border-color: var(--hj-red-dark); --bs-btn-disabled-bg: var(--hj-red); --bs-btn-disabled-border-color: var(--hj-red); }
.btn-outline-primary { --bs-btn-color: var(--hj-red); --bs-btn-border-color: var(--hj-red); --bs-btn-hover-bg: var(--hj-red); --bs-btn-hover-border-color: var(--hj-red); --bs-btn-active-bg: var(--hj-red); --bs-btn-active-border-color: var(--hj-red); }
.btn-navy { --bs-btn-color: #fff; --bs-btn-bg: var(--hj-navy); --bs-btn-border-color: var(--hj-navy); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--hj-navy-dark); --bs-btn-hover-border-color: var(--hj-navy-dark); --bs-btn-active-bg: var(--hj-navy-dark); --bs-btn-active-color: #fff; }
.btn { border-radius: 10px; font-weight: 500; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.form-control, .form-select { border-radius: 10px; border-color: var(--hj-border); background-color: var(--hj-surface); }
.form-control:focus, .form-select:focus { border-color: var(--hj-red); box-shadow: 0 0 0 .2rem var(--hj-red-soft); }
.form-check-input:checked { background-color: var(--hj-red); border-color: var(--hj-red); }
.form-label { font-weight: 500; font-size: .875rem; margin-bottom: .3rem; }
.nav-pills .nav-link.active { background: var(--hj-red); }
.page-link { color: var(--hj-red); }
.active > .page-link, .page-link.active { background: var(--hj-red); border-color: var(--hj-red); }

/* ---------- Page loader ---------- */
#page-loader {
  position: fixed; inset: 0; z-index: 9999; background: var(--hj-red);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  transition: opacity .45s ease, visibility .45s ease;
}
#page-loader.hide { opacity: 0; visibility: hidden; }
#page-loader img { width: 150px; max-width: 42vw; animation: hj-pulse 1.4s ease-in-out infinite; filter: drop-shadow(0 8px 24px rgba(0,0,0,.18)); }
#page-loader .bar { width: 160px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.25); overflow: hidden; position: relative; }
#page-loader .bar::after { content: ""; position: absolute; inset: 0; width: 40%; background: #fff; border-radius: 3px; animation: hj-bar 1.1s ease-in-out infinite; }
@keyframes hj-pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.92); opacity: .85; } }
@keyframes hj-bar { 0% { left: -40%; } 100% { left: 100%; } }

/* ---------- App shell ---------- */
.app-sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--hj-sidebar-w); z-index: 1040;
  background: var(--hj-sidebar); color: #C9CBEA; display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.app-sidebar .brand { padding: 18px 20px 14px; display: flex; align-items: center; gap: 12px; }
.app-sidebar .brand .mark { width: 42px; height: 42px; background: var(--hj-red); border-radius: 12px; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(226,6,18,.35); }
.app-sidebar .brand .mark img { width: 26px; }
.app-sidebar .brand .name { color: #fff; font-weight: 800; font-size: 1.15rem; letter-spacing: .2px; line-height: 1.1; }
.app-sidebar .brand small { color: #8E90C4; font-size: .72rem; display: block; font-weight: 500; }
.branch-chip { margin: 6px 16px 12px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); display: flex; gap: 10px; align-items: center; color: #fff; }
.branch-chip .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 1.05rem; flex-shrink: 0; }
.branch-chip .t { font-size: .7rem; color: #9fa2d6; text-transform: uppercase; letter-spacing: .6px; }
.branch-chip .n { font-weight: 600; font-size: .88rem; line-height: 1.15; }
.app-sidebar .menu { overflow-y: auto; flex: 1; padding: 4px 12px 24px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.app-sidebar .menu-title { font-size: .68rem; text-transform: uppercase; letter-spacing: 1px; color: #7275AE; padding: 16px 12px 6px; font-weight: 600; }
.app-sidebar .menu a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; color: #C9CBEA; border-radius: 10px; font-size: .9rem; font-weight: 500; position: relative; margin-bottom: 2px; }
.app-sidebar .menu a i { font-size: 1.1rem; width: 20px; text-align: center; opacity: .9; }
.app-sidebar .menu a:hover { background: rgba(255,255,255,.06); color: #fff; }
.app-sidebar .menu a.active { background: linear-gradient(90deg, rgba(226,6,18,.95), rgba(226,6,18,.75)); color: #fff; box-shadow: 0 6px 16px rgba(226,6,18,.3); }
.app-sidebar .menu a .badge { margin-left: auto; }
.app-sidebar .sidebar-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.06); font-size: .75rem; color: #7275AE; }

.app-main { margin-left: var(--hj-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar {
  position: sticky; top: 0; z-index: 1030; height: 64px; display: flex; align-items: center; gap: 10px;
  padding: 0 22px; background: color-mix(in srgb, var(--hj-surface) 86%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hj-border);
}
.app-topbar .page-title { font-weight: 700; font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-topbar .tb-btn { width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; color: var(--hj-text); background: var(--hj-surface-2); border: 1px solid var(--hj-border); }
.app-topbar .tb-btn:hover { color: var(--hj-red); }
.avatar { width: 38px; height: 38px; border-radius: 12px; background: var(--hj-navy); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: .85rem; }
.app-content { padding: 22px; flex: 1; }
.app-footer { padding: 14px 22px; font-size: .78rem; color: var(--hj-muted); border-top: 1px solid var(--hj-border); }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  body.sidebar-open .app-sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(10,10,30,.5); z-index: 1035; }
  .app-main { margin-left: 0; }
  .app-content { padding: 16px; }
  .app-topbar { padding: 0 14px; }
}

/* ---------- Cards & widgets ---------- */
.card { border: 1px solid var(--hj-border); border-radius: var(--hj-radius); background: var(--hj-surface); box-shadow: var(--hj-shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--hj-border); padding: 14px 18px; font-weight: 600; }
.card-body { padding: 18px; }
.card-title-sm { font-size: .95rem; font-weight: 700; margin: 0; }
.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; }
.stat-card .stat-label { font-size: .78rem; color: var(--hj-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.stat-card .stat-value { font-size: 1.45rem; font-weight: 800; line-height: 1.2; margin-top: 2px; word-break: break-word; }
.stat-card .stat-sub { font-size: .78rem; color: var(--hj-muted); }
.stat-card::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: currentColor; opacity: .04; }
.ic-red { background: rgba(226,6,18,.1); color: #E20612; }
.ic-navy { background: rgba(53,53,117,.12); color: #4B4BB0; }
.ic-bronze { background: rgba(148,65,32,.12); color: #B2552E; }
.ic-green { background: rgba(14,159,110,.12); color: #0E9F6E; }
.ic-amber { background: rgba(245,158,11,.14); color: #D98A06; }
.ic-cyan { background: rgba(6,148,190,.12); color: #0694BE; }
[data-bs-theme="dark"] .ic-navy { color: #9C9EF5; }

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .7rem .8rem; border-bottom-color: var(--hj-border); }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--hj-muted); font-weight: 600; background: var(--hj-surface-2); white-space: nowrap; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--hj-red-soft); }
.badge-status { font-weight: 600; font-size: .72rem; padding: .38em .7em; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--hj-muted); }
.empty-state i { font-size: 2.6rem; opacity: .4; display: block; margin-bottom: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.section-head h1 { font-size: 1.35rem; font-weight: 800; margin: 0; }
.section-head .crumb { color: var(--hj-muted); font-size: .82rem; }
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 230px; }
.list-compact .item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--hj-border); }
.list-compact .item:last-child { border-bottom: 0; }
.dropdown-menu { border-radius: 12px; border-color: var(--hj-border); box-shadow: var(--hj-shadow); }
.branch-switch-item .ic { width: 30px; height: 30px; border-radius: 9px; display: inline-grid; place-items: center; color: #fff; font-size: .9rem; }
.progress { border-radius: 10px; background: var(--hj-surface-2); }

/* Branch cards (global dashboard) */
.branch-card { border-left: 4px solid var(--c, var(--hj-red)); transition: transform .15s ease; }
.branch-card:hover { transform: translateY(-2px); }

/* ---------- POS ---------- */
.pos-wrap { display: grid; grid-template-columns: 1fr 400px; gap: 18px; }
.pos-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pos-item { cursor: pointer; border: 1px solid var(--hj-border); border-radius: 14px; padding: 12px; background: var(--hj-surface); transition: all .15s; position: relative; user-select: none; }
.pos-item:hover { border-color: var(--hj-red); box-shadow: 0 6px 18px rgba(226,6,18,.12); transform: translateY(-1px); }
.pos-item .thumb { height: 74px; border-radius: 10px; background: var(--hj-surface-2); display: grid; place-items: center; font-size: 1.9rem; color: var(--hj-muted); margin-bottom: 8px; overflow: hidden; }
.pos-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.pos-item .nm { font-weight: 600; font-size: .85rem; line-height: 1.2; height: 2.4em; overflow: hidden; }
.pos-item .pr { color: var(--hj-red); font-weight: 800; font-size: .92rem; }
.pos-item .st { position: absolute; top: 8px; right: 8px; font-size: .68rem; }
.pos-item.out { opacity: .45; pointer-events: none; }
.pos-cart { position: sticky; top: 80px; display: flex; flex-direction: column; max-height: calc(100vh - 100px); }
.pos-cart .lines { overflow-y: auto; flex: 1; min-height: 120px; }
.pos-line { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 10px 0; border-bottom: 1px dashed var(--hj-border); }
.pos-line .q { display: inline-flex; align-items: center; gap: 4px; }
.pos-line .q input { width: 56px; text-align: center; padding: 2px 4px; }
.pos-total { font-size: 1.6rem; font-weight: 800; color: var(--hj-red); }
.cat-pills { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.cat-pills .btn { white-space: nowrap; }
@media (max-width: 1199.98px) { .pos-wrap { grid-template-columns: 1fr; } .pos-cart { position: static; max-height: none; } }

/* Hotel front desk */
.room-tile { border-radius: 14px; padding: 14px; color: #fff; min-height: 110px; position: relative; overflow: hidden; display: block; }
.room-tile .no { font-size: 1.5rem; font-weight: 800; }
.room-tile small { opacity: .9; }
.room-tile.available { background: linear-gradient(135deg, #0E9F6E, #0B7F58); }
.room-tile.occupied { background: linear-gradient(135deg, #E20612, #A8040D); }
.room-tile.cleaning { background: linear-gradient(135deg, #F59E0B, #C77C05); }
.room-tile.maintenance { background: linear-gradient(135deg, #4B5563, #303846); }
.room-tile.reserved { background: linear-gradient(135deg, #353575, #23245A); }
.room-tile i.bg-ic { position: absolute; right: -6px; bottom: -14px; font-size: 4.2rem; opacity: .15; }

/* Booking calendar */
.cal-wrap { overflow-x: auto; }
.cal { display: grid; min-width: 900px; font-size: .78rem; }
.cal .h, .cal .c { border-right: 1px solid var(--hj-border); border-bottom: 1px solid var(--hj-border); padding: 6px 4px; min-height: 40px; }
.cal .h { background: var(--hj-surface-2); text-align: center; font-weight: 600; color: var(--hj-muted); }
.cal .h.today { color: var(--hj-red); }
.cal .room { position: sticky; left: 0; background: var(--hj-surface); z-index: 2; font-weight: 700; padding-left: 10px; }
.cal .bk { grid-row: auto; margin: 4px 1px; border-radius: 8px; color: #fff; padding: 4px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; z-index: 1; align-self: center; }
.cal .bk.reserved { background: #353575; } .cal .bk.pending { background: #F59E0B; border: 2px dashed #fff; } .cal .bk.blocked { background: repeating-linear-gradient(45deg, #6B7090, #6B7090 6px, #8A8FAE 6px, #8A8FAE 12px); } .cal .bk.checked_in { background: #E20612; } .cal .bk.checked_out { background: #6B7090; }

/* Kanban (repairs) */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kanban .col-k { background: var(--hj-surface-2); border: 1px solid var(--hj-border); border-radius: 14px; padding: 10px; min-height: 200px; }
.kanban .col-k h6 { font-size: .78rem; text-transform: uppercase; letter-spacing: .6px; color: var(--hj-muted); display: flex; justify-content: space-between; padding: 4px 4px 8px; }
.kanban .job { background: var(--hj-surface); border: 1px solid var(--hj-border); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; display: block; color: var(--hj-text); }
.kanban .job:hover { border-color: var(--hj-red); }

/* Timeline (activity) */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--hj-border); }
.timeline .tl { position: relative; padding-bottom: 14px; }
.timeline .tl::before { content: ""; position: absolute; left: -21px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--hj-surface); border: 3px solid var(--hj-red); }
.timeline .tl.update::before { border-color: #F59E0B; } .timeline .tl.delete::before { border-color: #111; } .timeline .tl.login::before { border-color: #0E9F6E; }

/* Toasts */
.toast-stack { position: fixed; top: 76px; right: 18px; z-index: 1090; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 36px); }
.toast { border: 0; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: linear-gradient(150deg, var(--hj-red) 0%, #A8040D 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(255,255,255,.07); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 18px; background: var(--hj-surface); }
.auth-form .inner { width: 100%; max-width: 400px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* Report pages */
.report-tile { display: block; padding: 18px; border-radius: var(--hj-radius); border: 1px solid var(--hj-border); background: var(--hj-surface); color: var(--hj-text); height: 100%; transition: all .15s; }
.report-tile:hover { border-color: var(--hj-red); transform: translateY(-2px); box-shadow: var(--hj-shadow); }
.report-tile i { font-size: 1.6rem; }
.filter-bar { background: var(--hj-surface); border: 1px solid var(--hj-border); border-radius: var(--hj-radius); padding: 12px; margin-bottom: 18px; }
.pl-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.pl-table .total td { font-weight: 800; border-top: 2px solid var(--hj-text); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

@media print {
  .app-sidebar, .app-topbar, .app-footer, .no-print, .toast-stack, #page-loader, .filter-bar { display: none !important; }
  .app-main { margin: 0 !important; }
  .app-content { padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .card { box-shadow: none !important; border-color: #ccc !important; break-inside: avoid; }
  .chart-box { height: 260px !important; }
}
