/* Black Leaf CRM — same black/bone/gold identity as the website,
   tuned for dense operational screens instead of editorial ones. */
:root {
  --bg: #0B0B0B;
  --surface: #131313;
  --card: #181818;
  --card-2: #1F1F1F;
  --line: #262626;
  --line-gold: rgba(201,169,110,.18);
  --fg: #EFEAE2;
  --fg-dim: #9A948E;
  --fg-faint: #6A655F;
  --gold: #C9A96E;
  --gold-light: #E0C88F;
  --good: #4F9D69;
  --warn: #C9922E;
  --bad: #C2553F;
  --r: 10px;
  --side-w: 236px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Playfair Display', Georgia, serif;
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; display: block; }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
::selection { background: var(--gold); color: #0B0B0B; }
[hidden] { display: none !important; }

/* ── AUTH / INSTALL ───────────────────────────────── */
.auth-body {
  min-height: 100vh; display: grid; place-items: center;
  padding: max(20px, env(safe-area-inset-left,0px)) 20px;
  background: radial-gradient(ellipse 70% 50% at 50% 0%, rgba(201,169,110,.07), transparent 60%), var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 34px 28px;
}
.auth-logo { height: 58px; width: auto; margin: 0 auto 6px; }
.auth-title { font-family: var(--serif); font-size: 1.6rem; text-align: center; }
.auth-sub {
  font-size: .68rem; letter-spacing: .3em; text-transform: uppercase;
  color: var(--gold); text-align: center; margin-bottom: 26px;
}
.auth-note { color: var(--fg-dim); font-size: .85rem; margin-bottom: 18px; }

/* ── LAYOUT ───────────────────────────────────────── */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 60;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transition: transform .28s cubic-bezier(.22,1,.36,1);
}
.side-brand {
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 18px 16px; border-bottom: 1px solid var(--line);
}
.side-brand img { height: 30px; width: auto; }
.side-brand span {
  font-size: .56rem; letter-spacing: .34em; text-transform: uppercase; color: var(--gold);
}
.side-nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--fg-dim); font-size: .86rem; transition: background .2s, color .2s;
}
.side-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.side-link:hover { background: var(--card); color: var(--fg); }
.side-link.is-on { background: rgba(201,169,110,.12); color: var(--gold); }
.side-foot { padding: 14px 16px; border-top: 1px solid var(--line); }
.side-user strong { display: block; font-size: .85rem; font-weight: 500; }
.side-user span { font-size: .7rem; color: var(--gold); letter-spacing: .08em; text-transform: uppercase; }
.side-out { display: inline-block; margin-top: 9px; font-size: .8rem; color: var(--fg-dim); }
.side-out:hover { color: var(--bad); }

.main { margin-left: var(--side-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-right,0px)) 12px max(16px, env(safe-area-inset-left,0px));
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(11,11,11,.92); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-family: var(--serif); font-size: 1.15rem; font-weight: 500; flex: 1; min-width: 0; }
.topbar-menu { display: none; background: none; border: 0; color: var(--fg); padding: 6px; cursor: pointer; }
.topbar-menu svg { width: 22px; height: 22px; }

.content {
  flex: 1;
  padding: 20px max(16px, env(safe-area-inset-right,0px))
           calc(28px + env(safe-area-inset-bottom,0px)) max(16px, env(safe-area-inset-left,0px));
}

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; }

@media (max-width: 900px) {
  .side { transform: translateX(-100%); }
  .side.is-open { transform: none; }
  .main { margin-left: 0; }
  .topbar-menu { display: block; }
}

/* ── PRIMITIVES ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  font-family: var(--font); font-size: .82rem; font-weight: 500;
  cursor: pointer; transition: all .22s; white-space: nowrap;
}
.btn-gold { background: var(--gold); color: #0B0B0B; font-weight: 600; }
.btn-gold:hover { background: var(--gold-light); color: #0B0B0B; }
.btn-ghost { background: var(--card); color: var(--fg); border-color: var(--line); }
.btn-ghost:hover { background: var(--card-2); border-color: var(--line-gold); color: var(--fg); }
.btn-bad { background: transparent; color: var(--bad); border-color: rgba(194,85,63,.4); }
.btn-bad:hover { background: rgba(194,85,63,.1); color: var(--bad); }
.btn-sm { padding: 7px 13px; font-size: .78rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; font-size: .72rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--fg-faint); margin-bottom: 6px;
}
input, select, textarea {
  width: 100%; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-family: var(--font); font-size: .9rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
textarea { resize: vertical; min-height: 70px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--fg-dim) 50%), linear-gradient(135deg, var(--fg-dim) 50%, transparent 50%); background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type=checkbox] { width: auto; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px;
}
.card + .card { margin-top: 14px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.card-title { font-family: var(--serif); font-size: 1.02rem; font-weight: 500; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-end { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: var(--fg-dim); }
.faint { color: var(--fg-faint); }
.small { font-size: .8rem; }
.right { text-align: right; }
.nums { font-variant-numeric: tabular-nums; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

/* ── STAT TILES ───────────────────────────────────── */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.stat-label { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--fg-faint); }
.stat-value {
  font-family: var(--serif); font-size: 1.65rem; line-height: 1.15;
  margin-top: 6px; font-variant-numeric: tabular-nums;
}
.stat-foot { font-size: .76rem; color: var(--fg-dim); margin-top: 4px; }
.stat-gold .stat-value { color: var(--gold); }

/* ── TABLE ────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th {
  text-align: left; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--fg-faint); font-weight: 500; padding: 9px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.015); }
.t-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: .7rem; letter-spacing: .04em;
  background: var(--card-2); color: var(--fg-dim); border: 1px solid var(--line);
}
.pill-good { background: rgba(79,157,105,.14); color: #7FBF95; border-color: rgba(79,157,105,.3); }
.pill-warn { background: rgba(201,146,46,.14); color: #D9AE5C; border-color: rgba(201,146,46,.3); }
.pill-bad  { background: rgba(194,85,63,.14); color: #D98571; border-color: rgba(194,85,63,.3); }
.pill-gold { background: rgba(201,169,110,.14); color: var(--gold); border-color: var(--line-gold); }

.alert { padding: 11px 14px; border-radius: 8px; font-size: .85rem; margin-bottom: 16px; }
.alert-good { background: rgba(79,157,105,.12); border: 1px solid rgba(79,157,105,.3); color: #8FCCA4; }
.alert-bad  { background: rgba(194,85,63,.12); border: 1px solid rgba(194,85,63,.3); color: #E09B86; }
.alert-warn { background: rgba(201,146,46,.12); border: 1px solid rgba(201,146,46,.3); color: #DFB96E; }

.empty { text-align: center; padding: 40px 20px; color: var(--fg-faint); }
.empty strong { display: block; color: var(--fg-dim); font-size: .95rem; margin-bottom: 5px; }

/* ── BILLING ──────────────────────────────────────── */
.bill-wrap { display: grid; grid-template-columns: 1fr 370px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .bill-wrap { grid-template-columns: 1fr; } }

.svc-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px; }
.svc-btn {
  text-align: left; background: var(--card-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 11px 12px; cursor: pointer; color: var(--fg);
  font-family: var(--font); transition: all .2s;
}
.svc-btn:hover { border-color: var(--gold); background: #242424; }
.svc-btn b { display: block; font-size: .83rem; font-weight: 500; }
.svc-btn span { font-size: .78rem; color: var(--gold); font-variant-numeric: tabular-nums; }
.svc-btn.no-price span { color: var(--warn); }

.cart-row {
  display: grid; grid-template-columns: 1fr 86px 92px 30px;
  gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line);
}
.cart-row:last-of-type { border-bottom: 0; }
.cart-name { font-size: .86rem; min-width: 0; }
.cart-name small { display: block; color: var(--fg-faint); font-size: .72rem; }
.cart-row input { padding: 7px 9px; font-size: .84rem; text-align: right; }
.cart-amt { text-align: right; font-variant-numeric: tabular-nums; font-size: .87rem; }
.cart-x {
  background: none; border: 0; color: var(--fg-faint); cursor: pointer;
  font-size: 1.2rem; line-height: 1; padding: 4px;
}
.cart-x:hover { color: var(--bad); }
@media (max-width: 560px) {
  .cart-row { grid-template-columns: 1fr 64px 80px 28px; gap: 6px; }
}

.sum-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: .87rem; }
.sum-row span:last-child { font-variant-numeric: tabular-nums; }
.sum-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 13px 0 4px; margin-top: 8px; border-top: 1px solid var(--line-gold);
}
.sum-total b { font-family: var(--serif); font-size: 1.5rem; color: var(--gold); font-variant-numeric: tabular-nums; }

.gst-toggle {
  display: flex; align-items: center; gap: 9px; padding: 11px 12px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.gst-toggle input { width: 17px; height: 17px; accent-color: var(--gold); cursor: pointer; }
.gst-toggle span { font-size: .85rem; }
.gst-toggle small { display: block; color: var(--fg-faint); font-size: .74rem; }

.cust-hits {
  border: 1px solid var(--line); border-radius: 8px; margin-top: 5px;
  background: var(--card-2); max-height: 190px; overflow-y: auto;
}
.cust-hit { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: .85rem; }
.cust-hit:last-child { border-bottom: 0; }
.cust-hit:hover { background: #242424; }
.cust-hit span { color: var(--fg-faint); font-size: .78rem; }

/* ── SCORE BAR ────────────────────────────────────── */
.bar { height: 5px; background: var(--card-2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--gold); border-radius: 3px; }
.bar-good i { background: var(--good); }
.bar-warn i { background: var(--warn); }
.bar-bad  i { background: var(--bad); }

/* ── TOAST ────────────────────────────────────────── */
.toast {
  position: fixed; z-index: 200;
  left: 50%; transform: translateX(-50%);
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  background: var(--card-2); border: 1px solid var(--line-gold);
  color: var(--fg); padding: 12px 20px; border-radius: 9px;
  font-size: .86rem; box-shadow: 0 12px 34px rgba(0,0,0,.55);
  max-width: calc(100vw - 32px);
}
.toast.is-bad { border-color: rgba(194,85,63,.5); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
