/* Apex Mobile Store — brand: charcoal + red + silver (from the shop logo) */
:root {
  --bg: #f3f4f7;
  --panel: #ffffff;
  --panel-light: #f6f7fa;
  --border: #e1e4ea;
  --text: #1b1e24;
  --muted: #6a7180;
  --brand: #e3262b;
  --brand-dark: #b81b20;
  --ink: #17181b;
  --accent: #2563eb;
  --green: #15a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 1px 2px rgba(20, 22, 30, 0.05), 0 4px 14px rgba(20, 22, 30, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--accent); }

/* ---------- header ---------- */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--ink);
  border-bottom: 3px solid var(--brand);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 44px; height: 44px; border-radius: 50%; display: block; }
.brand-name { color: #fff; font-weight: 800; font-size: 16px; letter-spacing: 0.2px; }
.brand-sub { color: #ff8a8d; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; }

nav { display: flex; gap: 6px; flex-wrap: wrap; }
nav button {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid transparent;
  color: #e6e8ec;
  padding: 9px 14px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 600;
  transition: background 0.15s;
}
nav button:hover { background: rgba(255, 255, 255, 0.16); }
nav button.active { background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(227, 38, 43, 0.45); }

.user-box { display: flex; gap: 8px; align-items: center; }
.user-box .muted { color: #b9bec8; }
.user-box .btn { padding: 6px 12px; font-size: 13px; }
header .btn.secondary { background: transparent; color: #e6e8ec; border-color: rgba(255, 255, 255, 0.25); }
header .btn.secondary:hover { background: rgba(255, 255, 255, 0.12); }

main { padding: 24px; max-width: 1140px; margin: 0 auto; }
h2 { font-size: 22px; }

/* ---------- stat cards ---------- */
.cards { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.card {
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 20px;
  min-width: 170px; flex: 1;
}
.card .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.card .value { font-size: 27px; font-weight: 800; margin-top: 6px; }

/* dashboard tiles: one colour each so they can be told apart at a glance */
.cards > .card { border: none; color: #fff; box-shadow: var(--shadow); }
.cards > .card .label { color: rgba(255, 255, 255, 0.9); }
.cards > .card .value { color: #fff; }
.cards > .card:nth-child(1) { background: linear-gradient(135deg, #2563eb, #4f8df7); }
.cards > .card:nth-child(2) { background: linear-gradient(135deg, #7c3aed, #a371f7); }
.cards > .card:nth-child(3) { background: linear-gradient(135deg, #0f9f6e, #2fc48d); }
.cards > .card:nth-child(4) { background: linear-gradient(135deg, #d97706, #f5a524); }
.cards > .card.alert { background: linear-gradient(135deg, #c81e24, #f0484d); }

/* ledger tiles */
.grid3 > .card { background: var(--panel); box-shadow: var(--shadow); border-top: 4px solid var(--accent); }
.grid3 > .card:nth-child(2) { border-top-color: var(--amber); }
.grid3 > .card:nth-child(3) { border-top-color: var(--green); }

/* ---------- panels & tables ---------- */
section.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}
section.panel h2 { margin-top: 0; font-size: 17px; }

table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th {
  color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px;
  background: var(--panel-light); white-space: nowrap;
}
th:first-child { border-radius: 8px 0 0 8px; }
th:last-child { border-radius: 0 8px 8px 0; }
tbody tr:last-child td { border-bottom: none; }
tr:hover td { background: #fff5f5; }
tr.clickable { cursor: pointer; }
tr.clickable td:first-child { font-weight: 600; }

.pill { padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; text-transform: capitalize; }
.pill.overdue { background: #fde3e3; color: #b91c1c; }
.pill.upcoming { background: #fdefd3; color: #a15c07; }
.pill.paid, .pill.completed { background: #d9f5e3; color: #0f7a37; }
.pill.active { background: #dde9ff; color: #1d4ed8; }
.pill.cancelled { background: #e9ebef; color: #5c6370; }

/* ---------- buttons ---------- */
.btn {
  background: var(--brand); color: #fff; border: 1px solid transparent;
  padding: 9px 16px; border-radius: 10px;
  font-weight: 700; cursor: pointer; font-size: 14px;
  display: inline-block; text-decoration: none; box-sizing: border-box;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--panel); color: var(--text); border-color: #cfd4dc; }
.btn.secondary:hover { background: var(--panel-light); border-color: #aab1bd; }
.btn.danger { background: #fff; color: var(--red); border-color: #f1b5b5; }
.btn.danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn.wa { background: #1fb855; color: #fff; }
.btn.wa:hover { background: #189a46; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

/* ---------- forms ---------- */
input, select, textarea {
  background: #fff; border: 1px solid #cfd4dc; color: var(--text);
  padding: 10px 12px; border-radius: 10px; font-size: 15px; width: 100%; font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(227, 38, 43, 0.15);
}
input.search { width: 260px; }
label { font-size: 13px; font-weight: 600; color: #444b57; display: block; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.muted { color: var(--muted); font-size: 13.5px; }
.back-link { color: var(--brand); font-weight: 600; cursor: pointer; font-size: 14px; margin-bottom: 12px; display: inline-block; }
.back-link:hover { text-decoration: underline; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 16, 20, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--panel); border-radius: 16px; border-top: 5px solid var(--brand);
  padding: 24px; width: 560px; max-width: 94vw; max-height: 90vh; overflow-y: auto;
  position: relative; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.modal.wide { width: 760px; }
.modal h3 { margin-top: 0; font-size: 19px; padding-right: 40px; }
.modal h4 { color: var(--brand-dark); }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px;
  border-radius: 50%; border: none; background: var(--panel-light);
  color: var(--text); font-size: 16px; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: var(--brand); color: #fff; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; right: 20px; background: #12803c; color: #fff; font-weight: 600;
  padding: 13px 20px; border-radius: 10px; z-index: 200; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.toast.error { background: #c81e24; }

.empty { text-align: center; padding: 40px; color: var(--muted); font-size: 15px; }

/* ---------- sign in ---------- */
.auth-panel { max-width: 390px; margin: 8vh auto 0; text-align: left; border-top: 5px solid var(--brand); }
.auth-panel h2 { text-align: center; font-size: 20px; }
.auth-logo { display: block; width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 14px; }

/* ---------- phones & small tablets ---------- */
@media (max-width: 720px) {
  header { padding: 10px 14px; }
  nav { order: 3; width: 100%; }
  nav button { flex: 1; padding: 9px 8px; font-size: 13px; white-space: nowrap; }
  main { padding: 14px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .cards > .card { min-width: 44%; }
  input.search { width: 100%; }
  section.panel { padding: 14px; }
  .modal { padding: 18px; }
  td { white-space: nowrap; }
  .toast { left: 14px; right: 14px; text-align: center; }
}
