:root {
  --bg: #f5f6f8; --panel: #fff; --text: #1d2430; --muted: #677285; --line: #e3e6eb;
  --accent: #e8692c; --accent-dark: #c9541c; --side: #1f2a37; --side-text: #cfd6df;
  --good: #1b7a3d; --good-bg: #e6f6ec; --warn: #8a4b00; --warn-bg: #fff4e5; --bad: #b42318;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent-dark); }
button, input, select, textarea { font: inherit; }
.muted { color: var(--muted); } .small { font-size: 12px; }

/* login / setup */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth form { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.auth h1 { margin: 0; font-size: 20px; color: var(--accent); }
label.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
label.field input, label.field select, label.field textarea { font-weight: 400; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.btn { padding: 9px 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.error { color: var(--bad); font-size: 13px; }

/* app shell */
.shell { display: flex; height: 100%; }
nav.side { width: 210px; flex: none; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; }
nav.side .brand { color: #fff; font-weight: 800; font-size: 18px; padding: 4px 10px 14px; }
nav.side a { color: var(--side-text); text-decoration: none; padding: 8px 10px; border-radius: 6px; font-weight: 600; }
nav.side a.active, nav.side a:hover { background: rgba(255,255,255,.1); color: #fff; }
nav.side .spacer { flex: 1; }
nav.side .who { font-size: 12px; padding: 8px 10px; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 18px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar h1 { font-size: 18px; margin: 0 12px 0 0; }
.toolbar input[type=search] { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; min-width: 240px; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.on { background: #fdf0e9; color: var(--accent-dark); }
.view { flex: 1; overflow: auto; padding: 16px 18px; }

/* jobs board */
.board { display: flex; gap: 12px; align-items: flex-start; min-height: 100%; }
.col { width: 280px; flex: none; background: #eceef2; border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.col.drop { outline: 2px dashed var(--accent); }
.col h2 { font-size: 13px; margin: 2px 4px; display: flex; justify-content: space-between; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: pointer; }
.card:hover { border-color: var(--accent); }
.card .addr { font-weight: 600; }
.card .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.list th { font-size: 12px; color: var(--muted); background: #fafbfc; }
table.list tr.click { cursor: pointer; } table.list tr.click:hover td { background: #fdf6f2; }

/* job panel */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow: auto; z-index: 50; }
.jobpanel { background: #fff; border-radius: 12px; width: 100%; max-width: 980px; }
.jobpanel header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.jobpanel header h2 { margin: 0; font-size: 18px; flex: 1; }
.jobgrid { display: grid; grid-template-columns: 1fr 340px; gap: 16px; padding: 16px 20px 20px; }
.box { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.box h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.jobmap { height: 260px; border-radius: 8px; border: 1px solid var(--line); }
.prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.price { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.price .tier { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; }
.price .amt { font-size: 18px; font-weight: 800; }
.log { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow: auto; }
.log .item { background: #f6f7f9; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.log .item .when { font-size: 11px; color: var(--muted); }
.log .item.note { background: #fff8e6; }
textarea.note { width: 100%; min-height: 60px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }

/* settings */
.settings { max-width: 860px; }
.settings section { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.settings h2 { margin: 0 0 4px; font-size: 16px; }
.settings .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 10px 0; }
.settings table input { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
code.embed { display: block; white-space: pre-wrap; word-break: break-all; background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 8px; font-size: 12px; }
.ok { color: var(--good); font-weight: 600; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  nav.side { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  nav.side .spacer { display: none; }
  .jobgrid { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
}

/* combined build: home, tabs, calendar, analytics, products */
nav.side .navhead { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #8995a5; padding: 14px 10px 4px; }
.tabs a { padding: 6px 10px; border-radius: 6px; font-weight: 600; color: var(--muted); text-decoration: none; }
.tabs a.on { background: #fdf0e9; color: var(--accent-dark); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; color: inherit; text-decoration: none; }
.stat:hover { border-color: var(--accent); }
.stat .label { font-size: 12px; font-weight: 700; color: var(--muted); }
.stat .num { font-size: 30px; font-weight: 800; color: var(--accent); }
.twocol { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.view .box { background: #fff; }
.pipe { display: grid; grid-template-columns: 170px 1fr 40px 90px; gap: 10px; align-items: center; padding: 4px 0; }
.pipe .bar { height: 10px; background: #eceef2; border-radius: 5px; overflow: hidden; }
.pipe .bar span { display: block; height: 100%; background: var(--accent); }
.appt { border-left: 3px solid var(--good); background: #f6f7f9; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.appt.requested { border-color: #2563eb; } .appt.done, .appt.cancelled { border-color: #aab; opacity: .7; }
.click { cursor: pointer; } .appt.click:hover { background: #fdf6f2; }
.row-btns { margin-top: 6px; }
.newappt summary { list-style: none; display: inline-block; margin: 4px 0 8px; }
.newappt summary::-webkit-details-marker { display: none; }
.pill.grey { background: #eceef2; color: #4a5565; } .pill.blue { background: #e7efff; color: #1d4ed8; }
.badges { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
table.list.plain { border: 0; } table.list.plain td, table.list.plain th { padding: 6px 4px; }
tr.chosen td { background: #fff8e6; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin-bottom: 10px; }
.kv2 { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--line); }
h4 { margin: 14px 0 6px; font-size: 13px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)); gap: 6px; margin-bottom: 10px; }
.day { background: #fff; border: 1px solid var(--line); border-radius: 8px; min-height: 260px; padding: 6px; }
.day.today { border-color: var(--accent); }
.day .dh { font-weight: 700; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.ev { background: #fdf0e9; border-left: 3px solid var(--accent); border-radius: 5px; padding: 5px 6px; font-size: 12px; margin-bottom: 6px; cursor: pointer; }
.ev.done, .ev.cancelled { opacity: .55; text-decoration: line-through; }
.placeholder { max-width: 520px; margin: 60px auto; text-align: center; background: #fff; border: 1px dashed var(--line); border-radius: 12px; padding: 40px 24px; }
.placeholder h2 { margin: 0 0 6px; }
.prod { display: grid; grid-template-columns: 120px 1fr; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 10px 0; position: relative; }
.prod .photo { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.prod .photo img { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.prod .grid { margin: 0; }
.prod [data-delprod] { position: absolute; top: 8px; right: 8px; }
.settings label.field input { width: 100%; }
@media (max-width: 860px) {
  .twocol { grid-template-columns: 1fr; }
  .week { grid-template-columns: 1fr; } .day { min-height: 0; }
  .pipe { grid-template-columns: 110px 1fr 30px 70px; }
  .prod { grid-template-columns: 1fr; }
}
