:root {
  --bg: #f5f4ef; --panel: #ffffff; --panel-2: #faf9f5; --ink: #1b2622; --muted: #66726d; --line: #e4e1d8;
  --brand: #1f5c4a; --brand-2: #17463a; --on-brand: #ffffff; --brand-soft: #e4efe9;
  --accent: #b7791f; --danger: #b3261e; --danger-soft: #fbe9e7; --warn-soft: #fdf3dc; --warn-ink: #7a5200;
  --s-new: #2563eb; --s-quoted: #b7791f; --s-booked: #1f7a4d; --s-completed: #5b6770; --s-stale: #9aa3a0; --s-cancelled: #b3261e;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121816; --panel: #1a2220; --panel-2: #1f2826; --ink: #e8eeeb; --muted: #9aa8a2; --line: #2c3835;
    --brand: #4fb393; --brand-2: #68c4a6; --on-brand: #0d1a15; --brand-soft: #1e3a31;
    --accent: #e0a94e; --danger: #f2877f; --danger-soft: #3a1f1d; --warn-soft: #3a3018; --warn-ink: #f0cf8a;
    --s-new: #7aa7ff; --s-quoted: #e0a94e; --s-booked: #5ed39b; --s-completed: #a3b0b8; --s-stale: #7f8a86; --s-cancelled: #f2877f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 13px; margin: 0; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* layout */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.logo { font-weight: 700; font-size: 16px; padding: 4px 10px 16px; letter-spacing: -.01em; }
.logo span { color: var(--brand); }
.side a { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.side a:hover { background: var(--panel-2); text-decoration: none; }
.side a.on { background: var(--brand-soft); color: var(--brand); }
.side .sep { height: 1px; background: var(--line); margin: 8px 4px; }
.side .count { background: var(--s-new); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; }
.side .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px 10px; }
.main { padding: 24px 28px 60px; max-width: 1240px; width: 100%; min-width: 0; }
.banner { background: var(--warn-soft); color: var(--warn-ink); border-radius: 10px; padding: 10px 14px; margin-bottom: 18px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card > .pad { padding: 14px 16px; }
.card > .empty, .empty { padding: 26px 16px; text-align: center; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.kpi .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.kpi .s { color: var(--muted); font-size: 12px; }

/* buttons + inputs */
.btn { appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 7px 12px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 4px 6px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { resize: vertical; }
input[type=checkbox] { width: auto; }
.grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.field { grid-column: span 6; display: flex; flex-direction: column; gap: 4px; }
.field.half { grid-column: span 3; } .field.third { grid-column: span 2; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.search { max-width: 260px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
td.r, th.r { text-align: right; }
.tablewrap { overflow-x: auto; }
.off td { opacity: .5; }

/* status */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-new { color: var(--s-new); } .st-quoted { color: var(--s-quoted); } .st-booked { color: var(--s-booked); }
.st-completed { color: var(--s-completed); } .st-stale { color: var(--s-stale); } .st-cancelled { color: var(--s-cancelled); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 5px 12px; cursor: pointer; font: inherit; font-weight: 550; color: var(--muted); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.flag { background: var(--warn-soft); color: var(--warn-ink); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.flag.bad { background: var(--danger-soft); color: var(--danger); }
.flag + .flag { margin-top: 8px; }

/* event page */
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.quote { border: 1px solid var(--line); border-radius: 10px; margin: 14px 16px; overflow: hidden; }
.quote.accepted { border-color: var(--s-booked); box-shadow: 0 0 0 1px var(--s-booked); }
.quote > header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; background: var(--panel-2); flex-wrap: wrap; }
.quote table td { padding: 7px 14px; border: 0; }
.quote .sum td { color: var(--muted); padding-top: 3px; padding-bottom: 3px; }
.quote .total td { font-weight: 700; font-size: 15px; border-top: 1px solid var(--line); padding-top: 9px; }
.avail { display: flex; justify-content: space-between; padding: 5px 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.log { list-style: none; margin: 0; padding: 0; }
.log li { padding: 8px 16px; border-bottom: 1px solid var(--line); }
.log li:last-child { border: 0; }
.log time { display: block; color: var(--muted); font-size: 12px; }
.attn { display: flex; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); color: inherit; }
.attn:last-child { border: 0; }
.attn:hover { background: var(--panel-2); text-decoration: none; }
.attn .ico { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.k-lead { background: var(--s-new); } .k-staff { background: var(--s-quoted); } .k-money { background: var(--danger); } .k-follow { background: var(--s-completed); }

/* bars */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: end; height: 150px; padding: 16px 16px 0; }
.bars .b { background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .b.zero { background: var(--line); }
.bars .b:hover::after { content: attr(data-v); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); font-size: 11px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; margin-bottom: 4px; }
.barlabels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; padding: 6px 16px 14px; font-size: 11px; color: var(--muted); text-align: center; }
.hbar { height: 8px; border-radius: 4px; background: var(--brand); min-width: 2px; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.cal .dow { padding: 8px 10px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
.day { min-height: 104px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.day:nth-child(7n) { border-right: 0; }
.day.other { background: var(--panel-2); } .day.other .dn { opacity: .45; }
.day .dn { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 12.5px; }
.day.today .dn b { background: var(--brand); color: var(--on-brand); border-radius: 99px; padding: 0 7px; }
.day .add { visibility: hidden; border: 0; background: none; color: var(--brand); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.day:hover .add, .day .add:focus { visibility: visible; }
.ev { display: block; font-size: 12px; padding: 2px 6px; border-radius: 5px; border-left: 3px solid currentColor; background: var(--panel-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { color: var(--ink); }
.blk { font-size: 11.5px; color: var(--danger); background: var(--danger-soft); border-radius: 5px; padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(15, 22, 19, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal.wide { max-width: 780px; }
.modal > header, .modal > footer { display: flex; align-items: center; gap: 8px; padding: 14px 18px; }
.modal > header { justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal > footer { border-top: 1px solid var(--line); }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-err { margin: 0 18px 12px; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 99px; font-weight: 550; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
#toast.show { opacity: 1; }
.qe-items input { padding: 5px 8px; }
.qe-items td { padding: 5px 6px; border: 0; }
.qe-items th { padding: 4px 6px; border: 0; }
.totals { background: var(--panel-2); border-radius: 10px; padding: 10px 14px; display: grid; grid-template-columns: 1fr auto; gap: 3px 16px; }
.totals .t { font-weight: 700; font-size: 16px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .side .logo { width: 100%; padding-bottom: 6px; } .side .sep, .side .foot { display: none; }
  .main { padding: 16px; }
  .cols, .two { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .field.half, .field.third { grid-column: span 6; }
  .day { min-height: 70px; }
}

/* sign-in + client pages */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth .card { width: 100%; max-width: 380px; }
.pub { max-width: 820px; margin: 0 auto; padding: 28px 16px 70px; }
.pub .brand { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.pub h1 { font-size: 26px; margin: 18px 0 4px; }
.pub .card { margin-top: 18px; }
.opt { border: 2px solid var(--line); border-radius: 12px; margin-top: 14px; cursor: pointer; display: block; overflow: hidden; }
.opt.sel { border-color: var(--brand); }
.opt > header { display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px; background: var(--panel-2); font-weight: 700; align-items: center; }
.opt table td { padding: 6px 14px; border: 0; }
.contract { white-space: pre-wrap; max-height: 300px; overflow: auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 13px; }
.stamp { display: inline-block; border: 2px solid currentColor; border-radius: 6px; padding: 1px 8px; font-weight: 800; letter-spacing: .08em; font-size: 12px; transform: rotate(-3deg); }
@media print { .noprint, .side { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }
input[type=radio] { width: auto; margin-right: 6px; }
