/* =========================================================================
   C0001 — Customer & Payment Management
   Visual identity: deep slate shell, one disciplined blue accent, Inter type.
   ========================================================================= */

:root {
  --ink:      #0f172a;   /* near-black slate for text & sidebar */
  --ink-2:    #1e293b;
  --line:     #e2e8f0;   /* hairline borders */
  --line-2:   #cbd5e1;
  --muted:    #64748b;   /* secondary text */
  --bg:       #f1f5f9;   /* app background */
  --surface:  #ffffff;   /* cards, panels */
  --accent:   #2563eb;   /* the single accent — actions, active nav */
  --accent-d: #1d4ed8;
  --accent-l: #eff6ff;
  --ok:       #16a34a;
  --ok-bg:    #dcfce7;
  --warn:     #b45309;
  --warn-bg:  #fef3c7;
  --danger:   #dc2626;
  --danger-bg:#fee2e2;
  --radius:   10px;
  --shadow:   0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 15px; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Utility ---- */
.hidden { display: none !important; }
/* Page panels are stacked; hiding toggles only visibility (no reflow) */
.page-off { visibility: hidden; pointer-events: none; }
.req { color: var(--danger); margin-left: 2px; }

/* =========================================================================
   LOGIN
   ========================================================================= */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 100% -10%, #1e293b 0%, transparent 60%),
    linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border-radius: 16px; padding: 34px 32px; box-shadow: 0 24px 60px rgba(2,6,23,.45);
}
.brand { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.brand .code {
  font-size: 13px; font-weight: 800; letter-spacing: .12em; color: var(--accent);
  background: var(--accent-l); padding: 3px 8px; border-radius: 6px;
}
.brand h1 { margin: 0; font-size: 21px; font-weight: 700; }
.login-logo { text-align: center; margin-bottom: 16px; }
.login-logo img { width: 150px; max-width: 60%; height: auto; display: block; margin: 0 auto; }
.side-logo { width: 180px; height: auto; display: block; margin: 0 auto; }
.login-sub { color: var(--muted); font-size: 14px; margin: 2px 0 24px; }
.login label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 14px 0 6px; }
.login input {
  width: 100%; padding: 12px 13px; font-size: 15px;
  border: 1px solid var(--line-2); border-radius: 9px; background: #fff; outline: none;
}
.login input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
.login .err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; font-weight: 600; }
.login button {
  width: 100%; margin-top: 8px; padding: 13px; font-size: 15px; font-weight: 700;
  border: none; border-radius: 9px; background: var(--accent); color: #fff; cursor: pointer;
}
.login button:hover { background: var(--accent-d); }
.login button:disabled { background: #93c5fd; cursor: default; }

/* =========================================================================
   APP SHELL — fixed sidebar + scrolling content
   ========================================================================= */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111c31 100%);
  color: #cbd5e1; padding: 20px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.sidebar .brand { margin: 4px 6px 22px; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.sidebar .brand h1 { color: #fff; font-size: 18px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav button {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 11px 12px; font-size: 14.5px; font-weight: 600; color: #cbd5e1;
  background: transparent; border: none; border-radius: 9px; cursor: pointer;
}
.nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav button.active { background: var(--accent); color: #fff; }
.nav .ico { width: 18px; text-align: center; font-size: 15px; opacity: .95; }
.sidebar .spacer { flex: 1; }
.who { font-size: 12px; color: #64748b; padding: 0 8px 8px; word-break: break-all; text-align: center; }
.online { padding: 0 8px 14px; text-align: center; }
.online-label { font-size: 11.5px; font-weight: 600; color: #94a3b8; margin-bottom: 8px; }
.online-heads { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.online-head { position: relative; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 700; border: 2px solid #1e293b; cursor: default; }
.online-head::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px;
  border-radius: 50%; background: #22c55e; border: 2px solid #0f172a; }
.online-head img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.online-head.me { cursor: pointer; }
.online-head.me:hover { box-shadow: 0 0 0 2px #60a5fa; }
/* Profile picture editor */
.ph-stage { position: relative; width: 220px; height: 220px; margin: 4px auto 14px; border-radius: 50%;
  overflow: hidden; background: #f1f5f9; cursor: grab; touch-action: none; box-shadow: 0 0 0 1px var(--line-2); }
.ph-stage:active { cursor: grabbing; }
.ph-stage img { position: absolute; display: none; max-width: none; user-select: none; pointer-events: none; }
.ph-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; }
.ph-tools { display: flex; align-items: center; gap: 10px; margin: 0 24px; }
.ph-tools input[type=range] { flex: 1; padding: 0; border: none; box-shadow: none; accent-color: var(--accent); }
.ph-zoom-ico { width: 14px; text-align: center; color: var(--muted); font-weight: 700; }
.signout {
  width: 100%; padding: 10px; font-size: 13px; font-weight: 700; color: #cbd5e1; text-align: center;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
  border-radius: 9px; cursor: pointer;
}
.signout:hover { background: rgba(255,255,255,.1); color: #fff; }

.content { position: relative; height: 100vh; min-width: 0; overflow: hidden; }
.content > section { position: absolute; inset: 0; padding: 26px 30px 14px; overflow: auto; }
#page-customers, #page-payments, #page-dashboard, #page-expenses, #page-activity { display: flex; flex-direction: column; }
#page-customers .table-wrap, #page-payments .table-wrap, #page-dashboard .table-wrap, #page-expenses .table-wrap, #page-activity .table-wrap { flex: 1; min-height: 0; max-height: none; }
#dashYear { width: 190px; flex: 0 0 190px; padding: 10px 14px; font-size: 14px; font-weight: 600; }
.page-head .head-actions { align-items: center; }
#page-dashboard .table-wrap, #page-customers .table-wrap, #page-payments .table-wrap, #page-expenses .table-wrap, #page-activity .table-wrap { overflow-y: scroll; }
#page-customers table { font-size: 12px; }
#page-customers th { font-size: 11.5px; }
#page-customers th, #page-customers td { padding: 8px 9px; }
#page-customers .pill { font-size: 11px; padding: 2px 7px; }
/* Fixed column positions so filtering doesn't make the table shift */
#page-customers table { table-layout: fixed; width: 100%; }
#page-customers td { overflow: hidden; text-overflow: ellipsis; }
#page-customers th:nth-child(1)  { width: 5.5%; }  /* ID */
#page-customers th:nth-child(2)  { width: 5.5%; }  /* Installed */
#page-customers th:nth-child(3)  { width: 23.5%; } /* Payer / Account (with status dot) */
#page-customers th:nth-child(4)  { width: 7%; }    /* Site */
#page-customers th:nth-child(5)  { width: 7.5%; }  /* Area Manager */
#page-customers th:nth-child(6)  { width: 9%; }    /* Referral */
#page-customers th:nth-child(7)  { width: 6%; }    /* Plan */
#page-customers th:nth-child(8)  { width: 6.5%; }  /* Billing */
#page-customers th:nth-child(9)  { width: 7%; }    /* Due */
#page-customers th:nth-child(10) { width: 6.5%; }  /* Paid (mo) */
#page-customers th:nth-child(11) { width: 6%; }    /* Balance */
#page-customers th:nth-child(12) { width: 3.5%; text-align: center; }  /* Status */
#page-customers th:nth-child(13) { width: 6.5%; }  /* Total Paid */
.acct-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.acct-dot.on { background: var(--ok); }
.acct-dot.off { background: #cbd5e1; }
#page-customers td.center { text-align: center; }
#page-customers .toolbar select { width: 180px; flex: 0 0 180px; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.status-dot.pending { background: #f59e0b; }
.status-dot.paid { background: var(--ok); }
table.act th:nth-child(1), table.act td:nth-child(1) { width: 190px; }
table.act th:nth-child(2), table.act td:nth-child(2) { width: 160px; }
table.act th:nth-child(3), table.act td:nth-child(3) { width: 110px; }
.act-tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.act-tag.signin    { background: #e2e8f0; color: #475569; }
.act-tag.customer  { background: #dbeafe; color: #1d4ed8; }
.act-tag.payment   { background: #dcfce7; color: #15803d; }
.act-tag.expense   { background: #ffedd5; color: #c2410c; }
.act-tag.dropdowns { background: #ede9fe; color: #6d28d9; }
.act-tag.import    { background: #cffafe; color: #0e7490; }
.act-tag.users     { background: #fce7f3; color: #be185d; }
.act-tag.activity  { background: #fee2e2; color: #b91c1c; }
.act-tag.other     { background: #f1f5f9; color: #64748b; }
table.act td.act-details { white-space: normal; line-height: 1.35; }
/* Activity rows match the Customers table height */
#page-activity table { font-size: 12px; }
#page-activity th { font-size: 11.5px; }
#page-activity th, #page-activity td { padding: 8px 9px; }
table.dash { table-layout: fixed; width: 100%; font-size: 12px; }
table.dash th, table.dash td { white-space: normal; padding: 6px 5px; overflow: hidden; text-overflow: ellipsis; }
table.dash tbody td { height: auto; padding-top: 8px; padding-bottom: 8px; vertical-align: middle; }
table.dash tbody tr:hover td:nth-child(-n+3) { font-weight: 700; color: var(--ink); }
/* Hovered row: month cells get a darker fill */
table.dash tbody tr:hover td.dash-pending { background: #ef4444; color: #fff; }
table.dash tbody tr:hover td.dash-paid { background: #86efac; }
table.dash tbody tr:hover td.dash-partial { background: #fdba74; }
/* The single month cell under the mouse: one step darker than its row */
table.dash tbody tr:hover td.dash-pending:hover { background: #dc2626; }
table.dash tbody tr:hover td.dash-paid:hover { background: #4ade80; }
table.dash tbody tr:hover td.dash-partial:hover { background: #fb923c; }
/* hovered row: ID / date / name black; month cells a darker shade of their own colour */
table.dash tbody tr:hover td:nth-child(-n+3) { color: #000 !important; }
table.dash tbody tr:hover td.dash-pending { color: #450a0a !important; }
table.dash tbody tr:hover td.dash-paid { color: #052e16 !important; }
table.dash tbody tr:hover td.dash-partial { color: #431407 !important; }
table.dash th:nth-child(1), table.dash td:nth-child(1) { width: 6.5%; }
table.dash th:nth-child(2), table.dash td:nth-child(2) { width: 6.5%; }
table.dash th:nth-child(3), table.dash td:nth-child(3) { width: 19%; }
table.dash th.mon, .dash-paid, .dash-pending { text-align: center; }
.dash-paid { background: #bbf7d0; color: #14532d; font-weight: 700; font-size: 12px; line-height: 1.25; }
.dash-pending { background: #f87171; color: #7f1d1d; font-weight: 700; font-size: 12px; }
.dash-pending[data-cid], .dash-partial[data-cid] { cursor: pointer !important; }
.dash-partial { background: #fed7aa; color: #9a3412; font-weight: 700; font-size: 12px; text-align: center; }
.dash-partial:hover { background: #fdba74; cursor: default; }
.dash-paid .dp-date, .dash-partial .dp-date { display: none; }
.dash-paid:hover .dp-label, .dash-partial:hover .dp-label { display: none; }
.dash-paid:hover .dp-date, .dash-partial:hover .dp-date { display: inline; }
.dash-paid:hover { background: #86efac; cursor: default; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 16px; }
.page-head h2 { margin: 0; font-size: 22px; font-weight: 700; }
.page-head .muted { color: var(--muted); font-size: 14px; }

/* ---- Buttons ---- */
.btn {
  padding: 10px 18px; font-size: 14.5px; font-weight: 600; border: 1px solid transparent;
  border-radius: 9px; cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.page-head .btn-primary { min-width: 170px; text-align: center; }
.page-head .head-actions { display: flex; gap: 10px; }
.btn-primary:hover { background: var(--accent-d); }
.btn-primary:disabled { background: #93c5fd; cursor: default; }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn-ghost:hover { background: #f8fafc; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled { background: #fca5a5; cursor: not-allowed; }
.btn-ghost:disabled { opacity: .5; cursor: not-allowed; }
.col-actions { width: 56px; }
/* Expenses rows match the Customers table height */
#page-expenses table { font-size: 12px; }
#page-expenses th { font-size: 11.5px; }
#page-expenses th, #page-expenses td { padding: 8px 9px; }
#page-expenses .icon-del { width: 24px; height: 24px; margin: -4px 0; }
#page-expenses .icon-del svg { width: 14px; height: 14px; }
/* Payments rows match the Customers table height */
#page-payments table { font-size: 12px; }
#page-payments th { font-size: 11.5px; }
#page-payments th, #page-payments td { padding: 8px 9px; }
#page-payments .icon-del { width: 24px; height: 24px; margin: -4px 0; }
/* Payments: fixed column widths; Remarks takes the remaining space */
#page-payments table { table-layout: fixed; width: 100%; }
#page-payments td { overflow: hidden; text-overflow: ellipsis; }
#page-payments th:nth-child(1) { width: 6%; }    /* ID */
#page-payments th:nth-child(2) { width: 7%; }    /* Date Paid */
#page-payments th:nth-child(3) { width: 16%; }   /* Payer */
#page-payments th:nth-child(4) { width: 8%; }    /* Site */
#page-payments th:nth-child(5) { width: 8%; }    /* Area Manager */
#page-payments th:nth-child(6) { width: 7%; }    /* Amount Paid */
#page-payments th:nth-child(7) { width: 6.5%; }  /* Balance */
#page-payments th:nth-child(8) { width: 8%; }    /* Method */
#page-payments th:nth-child(9) { width: 9%; }    /* Reference */
/* 10th = Remarks: no width set, so it gets everything that's left (widest column) */
#page-payments .icon-del svg { width: 14px; height: 14px; }
.icon-del { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: #94a3b8; cursor: pointer; }
.icon-del:hover { background: var(--danger-bg); border-color: #fca5a5; color: var(--danger); }
.del-summary { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 12px 0 4px; }
.del-summary div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 14px; }
.del-summary span { color: var(--muted); }
.del-summary b { color: var(--ink); text-align: right; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
td .btn-sm + .btn-sm { margin-left: 6px; }
.settings-section { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.settings-section.is-locked .lists-grid,
.settings-section.is-locked #importBtn { opacity: .5; pointer-events: none; }
.warn-text { color: var(--warn); font-weight: 600; }
.site-checks { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: 9px; max-height: 240px; overflow-y: auto; }
.site-checks.error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.14); }
.site-check { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 500;
  color: var(--ink); cursor: pointer; }
.site-check input { width: auto; margin: 0; accent-color: var(--accent); }
.site-check.taken { color: #94a3b8; cursor: not-allowed; }
.site-check .by { font-size: 11.5px; color: #94a3b8; font-weight: 500; }
.lock-note { display: inline-block; margin: 0 0 14px; padding: 8px 12px; border-radius: 9px;
  background: #f1f5f9; color: var(--muted); font-size: 13.5px; font-weight: 600; }
#page-settings .table-wrap { max-height: none; }

/* ---- Toolbar (search + filters above a table) ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type="text"], .toolbar select {
  width: auto; padding: 10px 12px; font-size: 14px; border: 1px solid var(--line-2);
  border-radius: 9px; background: #fff; outline: none;
}
.toolbar input[type="text"]:focus, .toolbar select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.toolbar .grow { flex: 1; min-width: 180px; }
.icon-btn { width: 40px; height: 40px; flex: 0 0 auto; border: 1px solid var(--line-2); border-radius: 9px;
  background: #fff; color: var(--muted); font-size: 15px; cursor: pointer; }
.icon-btn:hover { background: #f1f5f9; color: var(--ink); }
.icon-btn.active { background: var(--accent-l); border-color: #93c5fd; color: var(--accent); }
.cal-wrap { position: relative; }
.cal-btn { white-space: nowrap; padding: 10px 14px; font-size: 14px; width: 190px; text-align: left; }
.cal-pop { display: none; position: absolute; top: calc(100% + 8px); left: 0; z-index: 50; width: 296px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  box-shadow: 0 18px 40px rgba(15,23,42,.18); }
.cal-pop.open { display: block; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.cal-nav { width: 32px; height: 32px; border: none; border-radius: 8px; background: transparent;
  color: var(--ink-2); font-size: 20px; line-height: 1; cursor: pointer; }
.cal-nav:hover { background: var(--accent-l); color: var(--accent); }
.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow span { text-align: center; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 4px 0 6px; }
.cal-grid { row-gap: 2px; }
.cal-day { position: relative; height: 36px; display: flex; align-items: center; justify-content: center;
  font-size: 13.5px; font-weight: 500; color: var(--ink); border: none; background: transparent;
  border-radius: 10px; cursor: pointer; }
.cal-day:hover { background: #f1f5f9; }
.cal-day.muted { color: #cbd5e1; cursor: default; }
.cal-day.muted:hover { background: transparent; }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); font-weight: 700; }
.cal-day.sel { background: var(--accent); color: #fff; font-weight: 700; box-shadow: none; }
.cal-day.has::after { content: ""; position: absolute; bottom: 5px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--ok); }
.cal-day.sel.has::after { background: #fff; }
.cal-foot { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line); }
.cal-link { border: none; background: none; font-size: 13px; font-weight: 600; color: var(--muted);
  cursor: pointer; padding: 6px 10px; border-radius: 8px; }
.cal-link:hover { background: #f1f5f9; color: var(--ink); }
.cal-link.strong { color: var(--accent); }
.cal-foot.end { justify-content: flex-end; }
/* Record payment: already-paid / partial note under Billing Month */
.pay-status { display: none; margin-right: auto; align-self: center; font-weight: 700; }
.pay-status.paid { display: flex; align-items: center; gap: 8px; color: var(--ok); font-size: 17px; }
.pay-status.partial { display: block; color: var(--warn); font-size: 14px; }
.pay-ok { width: 26px; height: 26px; border-radius: 50%; background: var(--ok); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
#p_full.is-off { pointer-events: none; opacity: .4; }
#page-dashboard th.col-hover { background: #cbd5e1 !important; color: #0f172a !important; }
.dash-fbtns { display: flex; gap: 6px; align-items: center; }
.dash-fbtn { min-height: 34px; padding: 0 14px; border: 1px solid #cbd5e1; border-radius: 9px;
  background: #fff; color: #334155; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.dash-fbtn:hover { background: #f1f5f9; }
.dash-fbtn[data-s] { width: 84px; padding: 0; text-align: center; }
.dash-bar select, .dash-bar input, .dash-bar button {
  height: 36px !important; min-height: 0 !important; box-sizing: border-box;
  padding-top: 0 !important; padding-bottom: 0 !important; line-height: normal !important; }
.dash-bar .dash-fclear { width: 36px !important; padding: 0 !important; flex: 0 0 36px;
  font-size: 14px; color: #64748b; margin-left: 0; }
.dash-bar .dash-fclear:hover { color: #dc2626; }
#page-lists input::placeholder { color: transparent; }
.saved-check.del { background: #dc2626 !important; color: #fff !important; border-color: #dc2626 !important; }
.bar-h36, .bar-h36-flex { height: 36px !important; min-height: 0 !important; box-sizing: border-box;
  padding-top: 0 !important; padding-bottom: 0 !important; line-height: normal !important; }
.bar-h36-flex { display: inline-flex !important; align-items: center; }
body[data-role="admin"] #page-dashboard tbody td:nth-child(3) { cursor: pointer; }

.dash-fbtn[data-s="pending"].on { background: #f87171; border-color: #ef4444; color: #fff; }
.dash-fbtn[data-s="partial"].on { background: #fed7aa; border-color: #fb923c; color: #7c2d12; }
.dash-fclear:not([data-synced]) { color: #64748b; padding: 0; width: 34px; font-size: 14px; }
.paid-row { display: flex; gap: 8px; align-items: stretch; }
.paid-row .amount-wrap { flex: 1; min-width: 0; }
.btn-full { flex: 0 0 auto; padding: 0 12px; font-size: 13px; font-weight: 600; white-space: nowrap;
  border: 1px solid #93c5fd; border-radius: 9px; background: var(--accent-l); color: var(--accent); cursor: pointer; }
.btn-full:hover { background: #dbeafe; }
input:disabled, select:disabled { background: #eef2f7; color: #94a3b8; cursor: not-allowed; }
.cal-day.range { background: var(--accent-l); color: var(--accent); font-weight: 600; }
.cal-day.range:hover { background: #dbeafe; }
.cal-link.on { background: var(--accent-l); color: var(--accent); }
.cal-title-btn { display: inline-flex; align-items: center; gap: 6px; border: none; background: none;
  padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.cal-title-btn:hover { background: var(--accent-l); color: var(--accent); }
.cal-caret { font-size: 11px; color: var(--muted); transition: transform .15s; }
.cal-caret.up { transform: rotate(180deg); }
.cal-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 4px 0 2px; }
.cal-month { position: relative; height: 52px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; }
.cal-month:hover { border-color: #93c5fd; background: var(--accent-l); color: var(--accent); }
.cal-month.today { border-color: var(--accent); color: var(--accent); }
.cal-month.sel { background: var(--accent); border-color: var(--accent); color: #fff; }
.cal-month.has::after { content: ""; position: absolute; bottom: 7px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.cal-month.sel.has::after { background: #fff; }
.cal-month.with-count { height: 60px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; }
.cal-month.with-count .m-name { font-size: 14px; font-weight: 700; }
.cal-month.with-count .m-count { font-size: 11px; font-weight: 600; color: var(--muted); }
.cal-month.with-count:hover .m-count { color: var(--accent); }
.cal-month.with-count.sel .m-count { color: rgba(255,255,255,.85); }
input.date-field[readonly] { background: #fff; color: var(--ink); cursor: pointer; padding-right: 40px; }
.date-ico { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); font-size: 15px; pointer-events: none; }
.count { color: var(--muted); font-size: 13px; font-weight: 600; }

/* ---- Table ---- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  overflow: auto; box-shadow: var(--shadow); max-height: 72vh;
  scrollbar-width: thin; scrollbar-color: #cbd5e1 #f1f5f9; }
.table-wrap::-webkit-scrollbar { width: 10px; height: 10px; }
.table-wrap::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 12px; }
.table-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 12px; border: 2px solid #f1f5f9; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 10px 13px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
th {
  background: #f8fafc; font-weight: 700; color: var(--ink-2); position: sticky; top: 0; z-index: 1;
  font-size: 12.5px; letter-spacing: .01em;
}
tbody tr:hover { background: #f8fafc; cursor: default; }
tbody tr.clickable:hover { background: var(--accent-l); cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.paid { background: var(--ok-bg); color: var(--ok); }
.pill.pending { background: var(--warn-bg); color: var(--warn); }
.pill.prepaid { background: #ede9fe; color: #6d28d9; }
.pill.postpaid { background: #fce7f3; color: #be185d; }
.pill.inactive { background: #e2e8f0; color: #475569; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* =========================================================================
   FORMS (modal + inline)
   ========================================================================= */
.field { margin-bottom: 12px; }
.row { display: grid; gap: 14px; margin-bottom: 12px; }
.row.two { grid-template-columns: 1fr 1fr; }
.row.three { grid-template-columns: 1fr 1fr 1fr; }
.row.uneven { grid-template-columns: 1fr 2fr; }
.row .field { margin-bottom: 0; }
label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input, select {
  width: 100%; padding: 11px 13px; font-size: 15px; border: 1px solid var(--line-2);
  border-radius: 9px; background: #fff; outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
input.error, select.error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.14); }
input[readonly] { background: #eef2f7; color: #475569; }
textarea.auto-grow { width: 100%; min-height: 88px; max-height: 260px; padding: 11px 13px; font-size: 15px;
  font-family: inherit; line-height: 1.45; color: var(--ink); border: 1px solid var(--line-2);
  border-radius: 9px; background: #fff; outline: none; resize: none; overflow-y: auto; display: block; }
textarea.auto-grow:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
textarea.auto-grow.error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.14); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.warn { display: none; font-size: 12.5px; color: var(--warn); margin-top: 5px; font-weight: 600; }
.warn.show { display: block; }
.amount-wrap { position: relative; }
.amount-wrap span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-2); font-weight: 600; }
.amount-wrap input { padding-left: 30px; }

.toggle { font-size: 15px; font-weight: 700; padding: 11px 20px; border: none; border-radius: 9px; cursor: pointer; width: 100%; }
.toggle.prepaid { background: #ede9fe; color: #6d28d9; }
.toggle.postpaid { background: #fce7f3; color: #be185d; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.5);
  display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 720px;
  box-shadow: 0 30px 70px rgba(2,6,23,.4); padding: 24px 26px;
}
.modal.narrow { max-width: 420px; }
.modal { position: relative; }
.form-saving { display: none; position: absolute; inset: 0; z-index: 20; border-radius: 14px;
  background: rgba(255,255,255,.85); flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.form-saving.open { display: flex; }
.page-saving { display: none; position: fixed; inset: 0; z-index: 300; background: rgba(241,245,249,.75);
  align-items: center; justify-content: center; }
.page-saving.open { display: flex; }
.saved-check { width: 42px; height: 42px; border-radius: 50%; background: var(--ok); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800;
  animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.saving-box { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  width: 160px; height: 130px; background: #fff; border-radius: 14px; box-shadow: 0 18px 40px rgba(15,23,42,.18); }
.form-saving-label { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 19px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.edit-strip { display: none; background: var(--warn-bg); color: var(--warn); border: 1px solid #fcd34d;
  border-radius: 9px; padding: 9px 13px; font-size: 13.5px; font-weight: 700; margin-bottom: 14px; }
.edit-strip.show { display: block; }

/* Combobox (payment ID / payer picker) */
.combo { position: relative; }
.combo-list {
  display: none; position: absolute; top: calc(100% + 3px); left: 0; right: 0; z-index: 30;
  background: #fff; border: 1px solid var(--line-2); border-radius: 9px; max-height: 210px;
  overflow-y: auto; box-shadow: 0 12px 28px rgba(15,23,42,.15);
}
.combo-list.open { display: block; }
.combo-item { padding: 9px 13px; font-size: 14px; cursor: pointer; }
.combo-item:hover { background: var(--accent-l); }
.combo-empty { padding: 9px 13px; font-size: 13px; color: var(--muted); }

/* Site Manager lists */
.lists-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.list-col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.list-col h4 { margin: 0 0 12px; font-size: 14px; font-weight: 700; padding-bottom: 8px; border-bottom: 2px solid var(--accent);
  display: flex; justify-content: space-between; align-items: baseline; }
.list-count { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.list-rows { display: flex; flex-direction: column; gap: 7px; max-height: 320px; overflow-y: auto; }
.list-row { display: flex; gap: 7px; }
.list-row input { flex: 1; min-width: 0; padding: 8px 11px; font-size: 14px; }
.list-row input.dupe { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.14); }
.row-del { width: 34px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; color: var(--muted); cursor: pointer; font-size: 16px; }
.row-del:hover { background: var(--danger-bg); color: var(--danger); }
.add-row { margin-top: 8px; width: 100%; padding: 8px; font-size: 13px; font-weight: 600; border: 1px dashed #93c5fd; border-radius: 8px; background: var(--accent-l); color: var(--accent); cursor: pointer; }
/* Dropdowns tab: list boxes fill the screen height */
#page-lists { display: flex; flex-direction: column; }
#page-lists .lists-grid { flex: 1; min-height: 0;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); grid-auto-rows: minmax(260px, 1fr); }
#page-lists .list-col { display: flex; flex-direction: column; min-height: 0; }
#page-lists .list-rows { flex: 0 1 auto; min-height: 0; max-height: none; }

/* Saving overlay */
.saving-overlay { display: none; position: fixed; inset: 0; z-index: 300; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 100% -10%, #1e293b 0%, transparent 60%),
    linear-gradient(160deg, #0f172a 0%, #1e293b 100%); }
.saving-overlay.open { display: flex; }
.saving-card { display: flex; flex-direction: column; align-items: center; background: none; padding: 0; border-radius: 0; box-shadow: none; }
.saving-label { display: none; }
.big-spinner { width: 42px; height: 42px; border: 4px solid #dbeafe; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-logo { width: 300px; height: auto; display: block; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(.94); } }
.saving-label { font-size: 14px; font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 400; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: 0 12px 30px rgba(2,6,23,.35); opacity: 0; transform: translateY(8px); transition: all .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { background: #166534; }
.toast.err { background: #b91c1c; }

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; overflow-x: auto; }
  .sidebar .brand, .sidebar .spacer, .who { display: none; }
  .nav { flex-direction: row; }
  .signout { width: auto; white-space: nowrap; }
  .row.two, .row.three, .row.uneven { grid-template-columns: 1fr; }
}
