/* ============================================================================
   Horizon Fitness Club Admin - Design tokens (red, white and black; always dark)
============================================================================ */
:root {
  color-scheme: dark;
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --radius: 10px;
  --radius-lg: 14px;

  --bg: #080808;
  --surface: #141414;
  --surface-2: #1c1c1c;
  --border: #2c2c2c;
  --text: #ffffff;
  --text-muted: #b5b5b5;
  --text-faint: #7d7d7d;

  --accent: #e5202e;
  --accent-hover: #c8141f;
  --accent-soft: #2b1013;
  --accent-text: #ff6b74;
  --accent-2: #ff4d57;

  --success: #22c55e;
  --success-soft: #0f2a1a;
  --warning: #f59e0b;
  --warning-soft: #32250a;
  --danger: #ff4d57;
  --danger-soft: #34131a;
  --info: #e6e6e6;
  --info-soft: #262626;
  --neutral: #a3a3a3;
  --neutral-soft: #242424;

  --sidebar-bg: #000000;
  --sidebar-bg-active: #1f1012;
  --sidebar-text: #b5b5b5;
  --sidebar-text-active: #ffffff;
  --sidebar-border: #232323;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.7);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

[hidden] { display: none !important; }

/* ============================================================================
   Login screen
============================================================================ */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(229, 32, 46, 0.28), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(229, 32, 46, 0.18), transparent 45%),
    var(--sidebar-bg);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px 28px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.login-brand .logo-mark {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #8f0f18);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px;
  box-shadow: var(--shadow-sm);
}
.login-brand h1 { font-size: 18px; margin: 0; }
.login-brand span { font-size: 12px; color: var(--text-muted); }
.login-card h2 { font-size: 22px; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-muted); font-size: 13.5px; margin: 0 0 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .03em; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1.5px solid var(--border);
  background: var(--surface-2); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 70px; }
.field-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }

.login-error {
  background: var(--danger-soft); color: var(--danger); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; margin-bottom: 16px; display: none;
}
.login-error.show { display: block; }

details.adv { margin: -6px 0 16px; }
details.adv summary { cursor: pointer; font-size: 12.5px; color: var(--text-muted); user-select: none; }
details.adv .field { margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; border-radius: 9px; font-weight: 600; font-size: 13.5px;
  padding: 10px 16px; transition: transform .05s ease, background .15s, box-shadow .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-success { background: var(--success-soft); color: var(--success); }
.btn-success:hover:not(:disabled) { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 8px; }

/* ============================================================================
   App shell
============================================================================ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--sidebar-bg);
  color: var(--sidebar-text); display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand .logo-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #8f0f18);
  display: grid; place-items: center; color: #fff; font-weight: 700;
}
.sidebar-brand strong { color: #fff; font-size: 15px; display: block; }
.sidebar-brand span { font-size: 11px; color: var(--sidebar-text); opacity: .7; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 12px 12px; }
.nav-section { margin-bottom: 4px; }
.nav-section-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
  color: var(--sidebar-text); opacity: .55; padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; cursor: pointer; margin-bottom: 2px; color: var(--sidebar-text);
}
.nav-item .nav-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--sidebar-bg-active); color: var(--sidebar-text-active); box-shadow: inset 2px 0 0 var(--accent); }

.sidebar-foot {
  padding: 14px 16px; border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar-foot .who { flex: 1; min-width: 0; }
.sidebar-foot .who strong { display: block; color: #fff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .who span { font-size: 11px; color: var(--sidebar-text); opacity: .7; }

.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 45;
}

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0; display: flex; align-items: center; gap: 14px;
  padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.hamburger { display: none; }
.topbar h1 { font-size: 17px; margin: 0; flex: 1; min-width: 0; }
.topbar .top-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--border);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; font-size: 15px;
}

.content { padding: 22px 24px 60px; flex: 1; }

/* ============================================================================
   Stat cards & dashboard
============================================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.stat-card .icon {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  font-size: 17px; margin-bottom: 12px;
}
.stat-card .value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.panel-head {
  padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; justify-content: space-between;
}
.panel-head h3 { font-size: 14.5px; margin: 0; }
.panel-body { padding: 6px 0; }
.panel-body.pad { padding: 16px 18px; }

.mini-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 18px; font-size: 13px; }
.mini-row:hover { background: var(--surface-2); }
.mini-row .r-title { font-weight: 600; }
.mini-row .r-sub { color: var(--text-muted); font-size: 12px; }
.bar-track { flex: 1; height: 7px; background: var(--neutral-soft); border-radius: 6px; margin: 0 12px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; }

.empty-state { padding: 40px 20px; text-align: center; color: var(--text-muted); }
.empty-state .glyph { font-size: 30px; margin-bottom: 10px; opacity: .6; }
.empty-state .msg { font-size: 13.5px; }

/* ============================================================================
   Page header / toolbar
============================================================================ */
.page-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px;
}
.page-toolbar .grow { flex: 1; }
.search-box {
  position: relative; min-width: 200px;
}
.search-box input {
  width: 100%; padding: 9px 12px 9px 32px; border-radius: 9px; border: 1.5px solid var(--border);
  background: var(--surface); outline: none;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 13px; }
.filter-select {
  padding: 9px 30px 9px 12px; border-radius: 9px; border: 1.5px solid var(--border);
  background: var(--surface); outline: none; cursor: pointer;
}
.filter-select:focus { border-color: var(--accent); }

/* ============================================================================
   Table
============================================================================ */
.table-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
table.data-table thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap; cursor: pointer; user-select: none;
}
table.data-table thead th:hover { color: var(--text); }
table.data-table thead th .sort-ind { opacity: .4; margin-left: 4px; font-size: 10px; }
table.data-table tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--surface-2); }
.cell-sub { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.col-actions { text-align: right; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--neutral-soft); color: var(--text-muted); }

.table-foot {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 18px;
  border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); flex-wrap: wrap; gap: 10px;
}
.pager { display: flex; align-items: center; gap: 6px; }
.pager button {
  width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; color: var(--text);
}
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.skeleton-row td { padding: 14px 16px; }
.skeleton {
  height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ============================================================================
   Modal
============================================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .65); display: flex;
  align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 100; overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; margin: auto 0;
}
.modal-box.modal-wide { max-width: 760px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16.5px; }
.modal-close {
  width: 30px; height: 30px; border-radius: 8px; border: none; background: transparent;
  color: var(--text-muted); cursor: pointer; font-size: 16px;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 20px 22px; max-height: 65vh; overflow-y: auto; }
.modal-foot {
  padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.form-grid .field.full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: 17px; height: 17px; accent-color: var(--accent); }
.checkbox-field label { margin: 0; text-transform: none; font-size: 13.5px; font-weight: 500; color: var(--text); }

.items-editor { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.items-editor table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.items-editor th { text-align: left; padding: 8px 10px; background: var(--surface-2); font-size: 11px; text-transform: uppercase; color: var(--text-muted); }
.items-editor td { padding: 6px 8px; border-top: 1px solid var(--border); }
.items-editor input, .items-editor select { width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); }
.items-editor .rm-row { background: transparent; border: none; color: var(--danger); cursor: pointer; font-size: 15px; }
.items-add { padding: 8px 10px; }

.detail-list dt { font-size: 11.5px; text-transform: uppercase; color: var(--text-muted); margin-top: 12px; }
.detail-list dd { margin: 3px 0 0; font-size: 14px; }

/* ============================================================================
   Toasts
============================================================================ */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 260px; max-width: 360px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px;
  padding: 12px 14px; box-shadow: var(--shadow-md); font-size: 13.5px; display: flex; gap: 10px;
  animation: toast-in .18s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast .t-ic { font-size: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================================
   Misc
============================================================================ */
.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff; animation: spin .7s linear infinite; display: inline-block;
}
.spinner.dark { border: 2.5px solid var(--border); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

.center-loader { display: flex; align-items: center; justify-content: center; padding: 60px 0; }

.text-muted { color: var(--text-muted); }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.hint-banner {
  background: var(--info-soft); color: var(--info); border-radius: 10px; padding: 10px 14px;
  font-size: 13px; margin-bottom: 16px;
}

/* ============================================================================
   Responsive
============================================================================ */
@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .main { margin-left: 0; }
  .hamburger {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 16px;
  }
}
@media (max-width: 640px) {
  .content { padding: 16px 14px 40px; }
  .topbar { padding: 0 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-box { max-width: 100%; }
  .page-toolbar { flex-direction: column; align-items: stretch; }
  .page-toolbar .search-box { min-width: 0; }
}

/* ============================================================================
   Invoice document (soft copy) — screen + print
============================================================================ */
.invoice-doc-toolbar { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 14px; }
.invoice-doc-sheet {
  background: #ffffff; color: #14172a; border: 1px solid #e2e5ee; border-radius: 10px;
  padding: 32px; max-width: 720px; margin: 0 auto; box-shadow: 0 4px 16px rgba(20,24,45,.08);
  font-size: 13.5px; line-height: 1.5;
}
.invoice-doc-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 2px solid #14172a; padding-bottom: 16px; }
.invoice-doc-logo { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, #e5202e, #8f0f18); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 24px; flex-shrink: 0; }
.invoice-doc-title { font-size: 26px; font-weight: 800; letter-spacing: .06em; color: #14172a; }
.invoice-doc-branch { text-align: right; color: #4a5170; max-width: 260px; font-size: 12.5px; }
.invoice-doc-branch strong { display: block; color: #14172a; font-size: 14px; margin-bottom: 3px; }
.invoice-doc-parties { display: flex; justify-content: space-between; gap: 24px; margin: 20px 0; }
.invoice-doc-parties h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #8087a3; margin: 0 0 6px; }
.invoice-doc-billto, .invoice-doc-meta { flex: 1; }
.invoice-doc-billto p, .invoice-doc-meta p { margin: 0; color: #14172a; }
.invoice-doc-meta { text-align: right; }
table.invoice-doc-items { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 13px; }
table.invoice-doc-items thead th { background: #f1f3f9; text-align: left; padding: 8px 10px; font-size: 11px; text-transform: uppercase; color: #5b6280; }
table.invoice-doc-items thead th.num, table.invoice-doc-items td.num { text-align: right; }
table.invoice-doc-items tbody td { padding: 9px 10px; border-bottom: 1px solid #eceef5; color: #14172a; }
table.invoice-doc-items tfoot td { padding: 6px 10px; border: none; }
table.invoice-doc-items tfoot tr.grand-total td { font-weight: 800; font-size: 15px; border-top: 2px solid #14172a; padding-top: 10px; }
.invoice-doc-terms h4 { font-size: 12px; margin: 18px 0 6px; color: #14172a; }
.invoice-doc-terms p { font-size: 11.5px; color: #5b6280; white-space: pre-line; margin: 0; }
.invoice-doc-signature { margin-top: 36px; display: flex; justify-content: flex-end; }
.invoice-doc-signature .sig-box { text-align: center; }
.invoice-doc-signature .sig-line { width: 180px; border-top: 1px solid #8087a3; margin-top: 40px; padding-top: 6px; font-size: 11.5px; color: #8087a3; }

@media print {
  body * { visibility: hidden; }
  .invoice-doc, .invoice-doc * { visibility: visible; }
  .invoice-doc { position: fixed; inset: 0; margin: 0; }
  .invoice-doc-toolbar { display: none !important; }
  .invoice-doc-sheet { box-shadow: none; border: none; max-width: 100%; }
}

/* ============================================================================
   Admin redesign: branch chip, cards, tabs, charts, member / staff pages
============================================================================ */

/* ---- sidebar: selected branch ---- */
.branch-chip {
  display: flex; align-items: center; gap: 8px; margin: 12px 12px 0; padding: 10px 10px 10px 12px;
  background: var(--sidebar-bg-active); border: 1px solid var(--sidebar-border); border-radius: 10px;
}
.branch-chip-body { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; cursor: pointer; }
.branch-chip-icon { font-size: 16px; }
.branch-chip-text { display: flex; flex-direction: column; min-width: 0; }
.branch-chip-text strong { color: #fff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-chip-text span { font-size: 11px; color: var(--sidebar-text); opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-chip .btn-outline { border-color: var(--sidebar-border); color: var(--sidebar-text); padding: 5px 9px; }
.branch-chip .btn-outline:hover { color: #fff; border-color: var(--accent); }
.sidebar-hint { display: none; padding: 16px 18px; font-size: 12.5px; color: var(--sidebar-text); opacity: .75; }
.sidebar.no-branch .sidebar-nav { display: none; }
.sidebar.no-branch .sidebar-hint { display: block; }
.sidebar-nav { padding-top: 10px; }
.page-back { font-size: 13px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.page-back:hover { text-decoration: underline; }

/* ---- page header & generic cards ---- */
.page-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head .sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.page-head .grow { flex: 1; min-width: 200px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 18px;
}
.card.clickable { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.empty-state.slim { padding: 22px 18px; }

/* ---- branch cards ---- */
.branch-card { display: flex; flex-direction: column; gap: 10px; }
.branch-card .top { display: flex; align-items: center; gap: 12px; }
.branch-card .logo {
  width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), #8f0f18);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; flex-shrink: 0;
}
.branch-card h3 { margin: 0; font-size: 16px; }
.branch-card .meta { font-size: 13px; color: var(--text-muted); line-height: 1.55; }
.branch-card .actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.branch-card .actions .btn-primary { flex: 1; }
.branch-card.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* ---- home: stats, chart, quick cards ---- */
.stat-card .stat-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-top: 4px; }
.quick-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.quick-card .qi { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex-shrink: 0; }
.quick-card .qn { font-size: 22px; font-weight: 700; line-height: 1.1; }
.quick-card .ql { font-size: 13px; color: var(--text-muted); }
.quick-card .qs { font-size: 11.5px; color: var(--text-faint); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--text-muted); margin: 22px 0 10px; }

.bar-chart { padding: 14px 18px 8px; overflow-x: auto; }
.bar-chart:not(.pair) { display: flex; gap: 10px; align-items: flex-end; min-height: 190px; }
.bar-chart.pair { display: block; }
.bar-chart .bar-row { display: flex; gap: 10px; align-items: flex-end; min-height: 190px; }
.bar-col { flex: 1; min-width: 38px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 190px; }
.bar-val { font-size: 11.5px; font-weight: 600; color: var(--text); min-height: 16px; }
.bar-area { width: 100%; flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.bar-area.two { gap: 3px; }
.bar-stick { width: 70%; max-width: 34px; background: var(--accent); border-radius: 6px 6px 2px 2px; transition: height .3s ease; }
.bar-area.two .bar-stick { width: 42%; max-width: 20px; }
.bar-stick.zero { height: 2px !important; background: var(--border); }
.bar-label { font-size: 11px; color: var(--text-muted); margin-top: 6px; white-space: nowrap; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* ---- filter chips, toolbars, tabs ---- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip-btn {
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; font-family: inherit;
}
.chip-btn:hover { border-color: var(--accent); }
.chip-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-btn .n { background: var(--neutral-soft); color: var(--text-muted); border-radius: 999px; padding: 1px 8px; font-size: 11.5px; }
.chip-btn.active .n { background: rgba(255,255,255,.25); color: #fff; }
.tab-strip { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab-btn {
  border: 0; background: transparent; padding: 11px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; border-bottom: 2.5px solid transparent; white-space: nowrap; font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- person cards (members, staff) ---- */
.person-card { display: flex; flex-direction: column; gap: 12px; }
.person-card .row { display: flex; align-items: center; gap: 14px; }
.person-card .who { min-width: 0; flex: 1; }
.person-card .who strong { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-card .who span { display: block; font-size: 12.5px; color: var(--text-muted); }
.person-card .status-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); }
.person-card .actions { display: flex; gap: 8px; }
.person-card .actions .btn { flex: 1; }
.sticky-bar {
  position: sticky; bottom: 0; z-index: 20; margin: 22px -24px -60px; padding: 14px 24px;
  background: var(--surface); border-top: 1px solid var(--border); display: flex; justify-content: center; gap: 10px;
  box-shadow: 0 -6px 20px rgba(20, 24, 45, .06);
}
.load-more { text-align: center; margin-top: 16px; }

/* ---- detail pages ---- */
.detail-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 18px 20px; margin-bottom: 14px; }
.detail-head .who { flex: 1; min-width: 220px; }
.detail-head h2 { margin: 0 0 4px; font-size: 20px; }
.detail-head .line { font-size: 13px; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.detail-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-nav { display: flex; gap: 6px; flex-wrap: wrap; position: sticky; top: var(--topbar-h); z-index: 25; background: var(--bg); padding: 8px 0 10px; margin-bottom: 8px; }
.section-nav a { font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); }
.section-nav a:hover { color: var(--accent); border-color: var(--accent); }
.detail-body .panel { margin-bottom: 16px; scroll-margin-top: calc(var(--topbar-h) + 56px); }
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-head h3 { flex: 1; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel-body.pad { padding: 14px 18px; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 22px; padding: 16px 18px; margin: 0; }
.kv-grid dt { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 700; margin: 0 0 3px; }
.kv-grid dd { margin: 0; font-size: 14px; word-break: break-word; }
.sub-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--text-muted); padding: 12px 18px 4px; }
.msg-row { padding: 10px 18px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.msg-row:last-child { border-bottom: 0; }
.msg-row .when { font-size: 11.5px; color: var(--text-faint); }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; }
.mini-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ---- add-customer page ---- */
.form-page { max-width: 880px; }
.form-section { margin-bottom: 16px; }
.form-section .panel-body { padding: 16px 18px 6px; }
.summary-box { background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; padding: 14px 16px; margin: 4px 0 16px; font-size: 14px; }
.summary-box .line { display: flex; justify-content: space-between; padding: 3px 0; }
.summary-box .line.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; font-weight: 700; font-size: 15px; }
.summary-box .line.due { color: var(--danger); font-weight: 600; }
.submit-bar { display: flex; gap: 10px; justify-content: flex-end; margin: 10px 0 40px; }

/* ---- reports ---- */
.rpt-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.rpt-tools .grow { flex: 1; }
.rpt-tools label { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.rpt-tools input, .rpt-tools select { padding: 7px 10px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-family: inherit; font-size: 13px; }
.rpt-note { font-size: 12px; color: var(--text-faint); margin: -6px 0 14px; }
.pos { color: var(--success); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }

/* ---- master hub ---- */
.master-card { display: flex; align-items: center; gap: 14px; }
.master-card .mi { width: 46px; height: 46px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; font-size: 22px; flex-shrink: 0; }
.master-card strong { font-size: 14.5px; display: block; }
.master-card span { font-size: 12.5px; color: var(--text-muted); }

@media (max-width: 860px) {
  .sticky-bar { margin: 22px -16px -60px; padding: 12px 16px; }
  .detail-head { padding: 14px; }
}

.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
