:root {
  --bg: #f4f5f7; --panel: #fff; --text: #1d2330; --muted: #6b7385; --line: #e2e5ec;
  --brand: #fdd62a; --brand-dark: #3a3a3a; --brand-ink: #111; --side: #1a1a1a; --ok: #1f9d55; --warn: #c98a00; --bad: #c0392b;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 16px; margin: 0 0 10px; }
a { color: var(--brand-dark); cursor: pointer; text-decoration: none; } a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }
.side { width: 210px; background: var(--side); color: #d8d8d8; padding: 16px 0; display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.side .logo { padding: 0 14px 16px; } .side .logo img { width: 100%; display: block; }

.side a { display: block; padding: 9px 18px; color: #d8d8d8; border-left: 3px solid transparent; }
.side a:hover { background: #2e2e2e; text-decoration: none; }
.side a.active { background: #2e2e2e; border-left-color: var(--brand); color: #fff; }
.side .me { margin-top: auto; padding: 14px 18px 0; border-top: 1px solid #333; font-size: 12px; }
.side .me a { padding: 4px 0; display: inline; color: #a8a8a8; }
.main { flex: 1; padding: 22px 28px; min-width: 0; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.head .grow { flex: 1; }

.card { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--brand); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.stat b { display: block; font-size: 26px; } .stat span { color: var(--muted); font-size: 12px; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th { background: #2e2e2e; color: #fdd62a; font-size: 12px; text-transform: uppercase;  letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
tbody tr.click:hover { background: #fff9d6; cursor: pointer; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 6px; cursor: pointer; }
button:hover { background: #f1f3f7; }
button.primary { background: var(--brand); border-color: #111; color: #111; font-weight: 700; }
button.primary:hover { background: #f0c500; }
button.danger { color: var(--bad); }
button.small { padding: 3px 9px; font-size: 12px; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #cdd2dd; border-radius: 6px; width: 100%; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #f6e08a; border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input { max-width: 300px; } .toolbar select { width: auto; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; background: #e8ebf2; color: #3b4357; white-space: nowrap; }
.badge.new, .badge.available, .badge.quote { background: #dbeafe; color: #1d4ed8; }
.badge.contacted, .badge.pending, .badge.hold, .badge.in_transit { background: #fef3c7; color: #92600a; }
.badge.appointment, .badge.negotiating, .badge.approved, .badge.service { background: #ede9fe; color: #6d28d9; }
.badge.won, .badge.delivered { background: #d9f5e3; color: #166534; }
.badge.lost, .badge.cancelled, .badge.sold { background: #f3d9d6; color: #922b21; }
.badge.L-new { background: #dbeafe; color: #1d4ed8; }
.badge.L-contacted_no_response { background: #ffe4cc; color: #9a4a0a; }
.badge.L-contacted_waiting { background: #fef3c7; color: #92600a; }
.badge.L-pending_sale { background: #ede9fe; color: #6d28d9; }
.badge.L-sold { background: #d9f5e3; color: #166534; }
.badge.L-lost { background: #e5e7eb; color: #4b5563; }
td a[href^="tel"] { white-space: nowrap; }
td a { color: inherit; text-decoration: underline; text-decoration-color: #cdd2dd; }
.overdue { color: var(--bad); font-weight: 600; }

.modal { position: fixed; inset: 0; background: rgba(15, 20, 32, .5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 10; }
.modal-box { background: #fff; border-radius: 10px; padding: 22px; width: 100%; max-width: 640px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .full { grid-column: 1 / -1; }
.form label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 3px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #1d2330; color: #fff; padding: 10px 16px; border-radius: 6px; z-index: 20; }
.toast.err { background: var(--bad); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline small { color: var(--muted); display: block; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }
.totals td { border: 0; padding: 3px 0; } .totals tr:last-child td { font-weight: 700; border-top: 1px solid var(--line); padding-top: 6px; }
.totals { background: none; border: 0; } .totals td:last-child { text-align: right; }

.login { max-width: 360px; margin: 12vh auto; }
.login img { width: 100%; margin-bottom: 10px; } .login p { color: var(--muted); margin-top: 0; }
.login .row { margin-bottom: 12px; } .login label { font-size: 12px; color: var(--muted); }
.err-msg { color: var(--bad); min-height: 20px; }



th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: #fff; }
th.sortable .arr { margin-left: 6px; font-size: 10px; opacity: .45; }
th.sortable[aria-sort="ascending"] .arr, th.sortable[aria-sort="descending"] .arr { opacity: 1; color: #fff; }
