:root {
  --bg: #0b0f0d;
  --surface: #131a16;
  --surface-2: #1a231e;
  --surface-3: #223028;
  --border: #263429;
  --text: #e9f1ec;
  --muted: #90a49a;
  --accent: #9bf0ae;
  --accent-strong: #4ade80;
  --accent-ink: #06130a;
  --danger: #ff7b72;
  --warn: #fbbf24;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(74, 222, 128, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
}
h1, h2, h3 { font-family: var(--font-head); margin: 0; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
[hidden] { display: none !important; }

/* ---------- PIN screen ---------- */
.pin-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pin-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
  animation: rise 0.4s ease both;
}
.pin-logo {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  font-size: 30px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.pin-title { font-size: 26px; letter-spacing: -0.02em; }
.pin-sub { color: var(--muted); margin: 6px 0 26px; }
.pin-dots {
  display: flex; gap: 16px; justify-content: center; margin-bottom: 10px;
  transition: transform 0.1s;
}
.pin-dots.shake { animation: shake 0.4s ease; }
.dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--muted);
  transition: all 0.15s ease;
}
.dot.filled {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.5);
  transform: scale(1.1);
}
.pin-error { color: var(--danger); font-size: 14px; min-height: 21px; margin: 4px 0 14px; font-weight: 500; }
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 300px;
  margin: 0 auto;
}
.keypad button {
  height: 68px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 24px;
  font-family: var(--font-head);
  font-weight: 600;
  transition: transform 0.08s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.keypad button:active { transform: scale(0.94); background: var(--surface-3); }
.keypad .key-back { font-size: 20px; color: var(--muted); }
.keypad-spacer { pointer-events: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(11, 15, 13, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 12px; font-size: 20px;
  background: linear-gradient(145deg, rgba(74,222,128,0.18), rgba(74,222,128,0.05));
  border: 1px solid rgba(74, 222, 128, 0.3);
}
.brand h1 { font-size: 18px; letter-spacing: -0.01em; }
.brand-sub { margin: 0; font-size: 12px; color: var(--muted); }
.icon-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 17px;
  transition: transform 0.08s ease, background 0.15s;
}
.icon-btn:active { transform: scale(0.92); background: var(--surface-3); }

/* ---------- Layout ---------- */
.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: flex; flex-direction: column; gap: 20px;
}

/* ---------- Dashboard ---------- */
.dash { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
.dash-card {
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
  animation: rise 0.35s ease both;
}
.dash-money {
  background: linear-gradient(150deg, rgba(74,222,128,0.16), rgba(74,222,128,0.03) 65%), var(--surface);
  border-color: rgba(74, 222, 128, 0.35);
}
.dash-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.dash-value { font-family: var(--font-head); font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.dash-money .dash-value { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent-strong); color: var(--accent-ink); box-shadow: 0 6px 18px rgba(74, 222, 128, 0.25); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 14px; font-size: 13.5px; border-radius: 11px; }

/* ---------- Panels / forms ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.form-panel { margin-top: 12px; padding: 18px; display: flex; flex-direction: column; gap: 14px; animation: rise 0.25s ease both; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field em { color: var(--accent-strong); font-style: normal; }
.field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 13px 14px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15); }
.field input::placeholder { color: #5a6b62; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Customers ---------- */
.customers { display: flex; flex-direction: column; gap: 14px; }
.customer-card { overflow: hidden; animation: rise 0.3s ease both; }
.cust-head {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px;
  background: none; border: none; color: inherit; text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.cust-avatar {
  flex: 0 0 44px;
  width: 44px; height: 44px;
  border-radius: 13px;
  display: grid; place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-family: var(--font-head);
  font-weight: 700; font-size: 16px;
  color: var(--accent);
}
.cust-info { flex: 1; min-width: 0; }
.cust-name { font-size: 17px; letter-spacing: -0.01em; }
.cust-meta-line { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.owed-chip {
  font-size: 13px; font-weight: 700;
  font-family: var(--font-head);
  color: var(--warn);
}
.owed-chip.settled { color: var(--accent-strong); }
.chevron { color: var(--muted); font-size: 12px; transition: transform 0.2s ease; }
.customer-card.open .chevron { transform: rotate(180deg); }

.cust-body { border-top: 1px solid var(--border); padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.cust-contact { display: flex; flex-wrap: wrap; gap: 8px; }
.contact-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 13px;
  text-decoration: none;
}
a.contact-pill:active { background: var(--surface-3); }

/* jobs */
.job-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.job {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px 12px 12px 14px;
}
.job-main { flex: 1; min-width: 0; }
.job-desc { font-weight: 600; font-size: 14.5px; }
.job-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.job-price { font-family: var(--font-head); font-weight: 700; font-size: 15px; white-space: nowrap; }
.job.paid { opacity: 0.72; }
.job.paid .job-desc { text-decoration: line-through; text-decoration-color: rgba(233,241,236,0.4); }
.job.paid .job-price { color: var(--accent-strong); }
.job:not(.paid) .job-price { color: var(--warn); }

.pay-toggle {
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 12.5px;
  font-weight: 700;
  border: 1px solid transparent;
  min-width: 78px;
  transition: transform 0.08s;
}
.pay-toggle:active { transform: scale(0.94); }
.pay-toggle.unpaid { background: rgba(251, 191, 36, 0.14); color: var(--warn); border-color: rgba(251, 191, 36, 0.4); }
.pay-toggle.is-paid { background: rgba(74, 222, 128, 0.14); color: var(--accent-strong); border-color: rgba(74, 222, 128, 0.4); }

.del-btn {
  background: none; border: none;
  color: #61756a; font-size: 16px;
  width: 36px; height: 36px; border-radius: 10px;
  flex: 0 0 36px;
  transition: color 0.15s, background 0.15s;
}
.del-btn:hover { color: var(--danger); background: rgba(255, 123, 114, 0.08); }

.no-jobs { color: var(--muted); font-size: 14px; text-align: center; padding: 10px 0 2px; }

/* add-job form */
.job-form { display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 13px; padding: 14px; animation: rise 0.25s ease both; }
.rate-chips { display: flex; gap: 8px; }
.rate-chip {
  flex: 1;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.rate-chip:active { background: var(--surface); border-color: var(--accent-strong); }

.cust-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.remove-cust { color: #61756a; background: none; border: none; font-size: 13px; padding: 8px; }
.remove-cust:hover { color: var(--danger); }

/* ---------- Misc ---------- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state strong { color: var(--text); font-family: var(--font-head); display: block; font-size: 18px; margin-bottom: 6px; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 40px 0; }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

.footnote {
  text-align: center;
  color: #5a6b62;
  font-size: 12.5px;
  padding: 0 20px calc(28px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}

.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(255, 123, 114, 0.5); color: var(--danger); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

@media (min-width: 640px) {
  .brand h1 { font-size: 20px; }
  .dash-value { font-size: 34px; }
}
