:root {
  --bg: #f6f6f4; --panel: #fff; --ink: #1f2328; --muted: #6b7076; --line: #e6e6e3; --side: #17181a; --side-ink: #b9bcc0;
  --accent: #2f6f5e; --accent-soft: #e5f0ec; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2; --ok: #15803d; --ok-soft: #dcfce7;
  --r: 8px; font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--app-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif); color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.app { display: flex; min-height: 100vh; }
.side { width: 220px; background: var(--side); color: var(--side-ink); flex: 0 0 220px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .brand { color: var(--side-strong, #fff); font-weight: 600; font-size: 15px; padding: 18px 18px 14px; letter-spacing: .02em; display: flex; gap: 8px; align-items: center; }
.side nav { flex: 1; overflow: auto; padding: 4px 8px; }
.side a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 8px 10px; border-radius: 6px; font-size: 13.5px; text-decoration: none; }
.side a:hover { background: var(--side-hi, #24262a); color: var(--side-strong, #fff); } .side a.on { background: var(--side-hi, #2b2e33); color: var(--side-strong, #fff); font-weight: 500; }
.side .brand img { max-height: 34px; max-width: 180px; width: auto; display: block; }
.side .sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #6b6f75; padding: 14px 10px 4px; }
.side .ic { width: 18px; text-align: center; opacity: .9; }
.side .foot { padding: 12px 18px; font-size: 12px; border-top: 1px solid var(--side-hi, #26282c); }
.side .foot a { display: inline; padding: 0; }
.main { flex: 1; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top .search { flex: 1; max-width: 420px; position: relative; }
.top .search input { width: 100%; padding: 8px 12px 8px 32px; border-radius: 6px; background: var(--bg); border: 1px solid transparent; }
.top .search::before { content: "⌕"; position: absolute; left: 11px; top: 6px; color: var(--muted); font-size: 16px; }
.results { position: absolute; top: 40px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 30px rgba(0,0,0,.12); padding: 6px; z-index: 30; }
.results a { display: block; padding: 7px 10px; border-radius: 5px; color: var(--ink); } .results a:hover { background: var(--bg); text-decoration: none; }
.page { padding: 24px 28px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: #f3f3f1; } .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); } .btn.sm { padding: 4px 9px; font-size: 12.5px; } .btn.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 2px 6px; font-size: 14px; border-radius: 4px; } .icon-btn:hover { background: var(--bg); color: var(--ink); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g-side { grid-template-columns: minmax(0, 1fr) 340px; }
.stat .n { font-size: 26px; font-weight: 600; letter-spacing: -.02em; } .stat .l { color: var(--muted); font-size: 12.5px; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; } table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: #fafaf8; }
table.t input, table.t select { padding: 5px 7px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #efefec; color: var(--muted); text-transform: capitalize; white-space: nowrap; }
.badge.ok, .badge.paid, .badge.signed, .badge.accepted, .badge.submitted, .badge.sent.mail, .badge.booked { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.partial, .badge.due, .badge.sent, .badge.proposal, .badge.in_progress, .badge.logged { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.overdue, .badge.failed, .badge.lost { background: var(--bad-soft); color: var(--bad); }
.badge.inquiry { background: #e0e7ff; color: #3730a3; } .badge.fulfillment { background: #f3e8ff; color: #7e22ce; } .badge.completed { background: #e5e7eb; color: #374151; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
input, select, textarea { font: inherit; color: inherit; padding: 8px 10px; border: 1px solid #d9d9d5; border-radius: 6px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: auto; } input[type=color] { padding: 2px; height: 36px; }
textarea { resize: vertical; } textarea.code { font: 13px/1.5 ui-monospace, Menlo, monospace; }
.field { margin-bottom: 12px; } .field label { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 4px; color: #3b3f44; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.row { display: flex; gap: 12px; } .row > * { flex: 1; min-width: 0; }
.flex { display: flex; align-items: center; gap: 8px; } .between { justify-content: space-between; } .wrap { flex-wrap: wrap; } .grow { flex: 1; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; white-space: nowrap; text-decoration: none; }
.tabs a.on { color: var(--ink); border-color: var(--accent); } .tabs a .c { font-size: 11px; background: #ececea; border-radius: 99px; padding: 0 6px; margin-left: 4px; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.col { background: #eeeeeb; border-radius: var(--r); padding: 10px; min-height: 300px; }
.col.over { background: var(--accent-soft); }
.col h3 { display: flex; justify-content: space-between; padding: 2px 4px 8px; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; border-left: 3px solid var(--c, #ccc); }
.kcard:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); } .kcard .t { font-weight: 600; } .kcard .m { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; margin-top: 4px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); } .list-item:last-child { border: 0; }
.task-done { text-decoration: line-through; color: var(--muted); }
.overdue-txt { color: var(--bad); font-weight: 500; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.modal-bg { position: fixed; inset: 0; background: rgba(20,20,22,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 15px; }
.modal .body { padding: 18px 20px; } .modal footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 99; }
#toast div { background: #1f2328; color: #fff; padding: 10px 18px; border-radius: 8px; margin-top: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: fade .2s; }
#toast div.err { background: var(--bad); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
.job-head { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 18px; }
.job-head .meta { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 12px; color: var(--muted); font-size: 13px; }
.job-head .meta b { color: var(--ink); font-weight: 600; }
.pipeline-bar { display: flex; gap: 4px; margin-top: 14px; }
.pipeline-bar button { flex: 1; border: 0; padding: 7px 4px; font: 600 11.5px/1 inherit; text-transform: uppercase; letter-spacing: .04em; background: #efefec; color: var(--muted); cursor: pointer; clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%, 8px 50%); }
.pipeline-bar button:first-child { clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%); }
.pipeline-bar button.done { background: var(--accent-soft); color: var(--accent); } .pipeline-bar button.cur { background: var(--accent); color: #fff; }
.contract-preview { border: 1px solid var(--line); border-radius: 6px; padding: 20px 26px; font: 14.5px/1.65 Georgia, serif; max-height: 520px; overflow: auto; background: #fffffd; }
.contract-preview h2 { font-size: 20px; font-weight: 400; } .contract-preview h3 { text-transform: none; letter-spacing: 0; font-size: 16px; color: var(--ink); }
.contract-preview table { border-collapse: collapse; width: 100%; font: 13px system-ui; } .contract-preview td, .contract-preview th { border-bottom: 1px solid var(--line); padding: 5px; text-align: left; }
.sig-img { max-height: 60px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: #fff; border-radius: var(--r); overflow: hidden; }
.cal .dh { padding: 8px; font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 600; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fafaf8; }
.cal .d { min-height: 110px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 6px; font-size: 12px; }
.cal .d.other { background: #fafaf8; color: #b5b5b0; } .cal .d.today .num { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 6px; }
.cal .num { font-weight: 600; display: inline-block; margin-bottom: 2px; }
.cal .ev { display: block; padding: 2px 6px; border-radius: 4px; margin-bottom: 2px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; text-decoration: none; }
.cal .ev.task { background: #efefec; color: var(--ink); } .cal .ev.pay { background: var(--warn-soft); color: var(--warn); }
.cal .ev.tent { opacity: .55; }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.bar-chart .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 11px; color: var(--muted); }
.bar-chart .b div { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.qfield { border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-bottom: 8px; background: #fafaf8; }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { width: 100%; max-width: 400px; padding: 30px; }
.copy { font: 12px ui-monospace, Menlo, monospace; background: var(--bg); padding: 8px 10px; border-radius: 6px; word-break: break-all; }
.timeline .ti { padding: 6px 0 6px 16px; border-left: 2px solid var(--line); font-size: 13px; position: relative; }
.timeline .ti::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #c7c7c2; position: absolute; left: -5px; top: 12px; }
.mergehelp code { display: inline-block; background: var(--bg); padding: 1px 6px; border-radius: 4px; margin: 2px; font-size: 11.5px; cursor: pointer; }
.tokens { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; background: var(--bg); }
.tokens-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 6px; }
.tokens-head .tokens-search { margin-left: auto; width: 180px; padding: 4px 8px; font-size: 12.5px; }
.tokens-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px 0; }
.tokens-label { width: 86px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.token { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 2px 9px; font: inherit; font-size: 12px; cursor: pointer; color: var(--ink); }
.token:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
@media (max-width: 1100px) { .g-side, .g2 { grid-template-columns: 1fr; } .g3, .g4 { grid-template-columns: 1fr 1fr; } }
.card { overflow-x: auto; }
@media (max-width: 760px) {
  .side { position: fixed; left: -230px; z-index: 40; transition: left .2s; } .side.open { left: 0; }
  .g-side, .g2, .g3, .g4 { grid-template-columns: 1fr; } .page { padding: 16px; } .top { padding: 10px 16px; } .row { flex-direction: column; gap: 0; }
  .menu-btn { display: inline-block !important; }
}
.menu-btn { display: none; }
.side .grp > a .cnt, .side .sub .cnt { font-size: 11px; background: var(--side-hi, #2b2e33); color: var(--side-ink, #d1d5db); border-radius: 99px; padding: 0 7px; line-height: 18px; }
.side .caret { background: none; border: 0; color: #8b8f95; cursor: pointer; padding: 0 2px; font-size: 11px; }
.side .sub { padding: 2px 0 6px 18px; }
.side .sub a { padding: 4px 8px; font-size: 12.5px; gap: 8px; }
.side .sub a.on { background: var(--side-hi, #2b2e33); color: var(--side-strong, #fff); }
.side .sub .bar, .chip .bar, .checks .bar { display: inline-block; width: 4px; height: 14px; border-radius: 2px; flex: 0 0 4px; }
.side .subsec { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: #6b6f75; padding: 8px 8px 2px; }
.side .subnew { padding: 6px 8px 2px; } .side .subnew .btn { background: #fff; color: #111; border: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover { color: var(--ink); }
.icon-btn.pin { font-size: 15px; } .icon-btn.pin.on, .pin-btn { color: #d97706; }
.fb h3 { margin: 14px 0 6px; } .fb h3:first-child { margin-top: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; } .checks label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

.report-link { display: flex; flex-direction: column; padding: 9px 0; border-bottom: 1px solid var(--line); text-decoration: none !important; }
.report-link:last-child { border: 0; } .report-link span:first-child { color: var(--accent); font-weight: 500; } .report-link:hover span:first-child { text-decoration: underline; }
.pnl-chart { display: flex; gap: 6px; height: 200px; margin: 8px 0; }
.pnl-chart .col { flex: 1; display: flex; flex-direction: column; align-items: stretch; font-size: 11px; color: var(--muted); text-align: center; }
.pnl-chart .up, .pnl-chart .down { flex: 1; display: flex; } .pnl-chart .up { align-items: flex-end; border-bottom: 1px solid #d6d6d2; } .pnl-chart .down { align-items: flex-start; }
.pnl-chart .up div { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; } .pnl-chart .down div { width: 100%; background: #60a5fa; border-radius: 0 0 3px 3px; }
@media print { .side, .top, .page-head .flex { display: none !important; } .page { padding: 0; } .card { break-inside: avoid; } }

/* settings tabs & branding */
.set-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.set-tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.set-tabs a.on { color: var(--ink); border-color: var(--accent); text-decoration: none; }
.img-up { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px dashed var(--line); border-radius: var(--r); margin-bottom: 12px; }
.img-up .thumb { width: 140px; height: 70px; display: flex; align-items: center; justify-content: center; border-radius: 6px; background: #f3f3f1; overflow: hidden; flex: 0 0 140px; }
.img-up .thumb.dark { background: #1f2124; } .img-up .thumb img { max-width: 100%; max-height: 100%; }
.img-up .meta { flex: 1; } .img-up b { display: block; }
.brand-preview { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; position: sticky; top: 80px; }
.brand-preview .pv-head { background: #fff; border-bottom: 1px solid #eee; padding: 14px 18px; display: flex; align-items: center; gap: 12px; }
.brand-preview .pv-head img { max-height: 40px; max-width: 180px; }
.brand-preview .pv-body { padding: 22px 18px; }
.brand-preview .pv-card { background: #fff; border: 1px solid #e7e5e0; padding: 18px; margin-top: 12px; }
.brand-preview .pv-btn { display: inline-block; padding: 10px 18px; margin-top: 12px; font-size: 14px; }
.email-frame { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: var(--r); background: #f4f4f2; }
.font-sample { font-size: 12px; color: var(--muted); margin-top: -6px; margin-bottom: 8px; }

/* email thread & inbox */
.thread { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.mail { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: #fff; }
.mail.in { border-left: 3px solid var(--accent); } .mail.out { background: #fafaf8; }
.mail.unread { box-shadow: 0 0 0 2px var(--accent-soft, #e6f0ed); }
.mail-subj { font-weight: 600; margin: 4px 0 6px; }
.mail-body { white-space: pre-wrap; font-size: 13.5px; line-height: 1.55; word-break: break-word; }
.inbox-row.unread b { color: var(--ink); } .inbox-row.unread { background: var(--accent-soft, #f3f7f5); }
.initials-box { display: inline-block; border: 1px solid #999; border-radius: 4px; padding: 2px 10px; font-size: 12px; color: #555; margin: 4px 0; }
.tokens-sub { margin: 10px 0 2px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
details.tokens-group { display: block; }
details.tokens-group > summary { width: auto; cursor: pointer; padding: 3px 0; list-style: none; }
details.tokens-group > summary::-webkit-details-marker { display: none; }
details.tokens-group > summary::before { content: "▸ "; } details.tokens-group[open] > summary::before { content: "▾ "; }
details.tokens-group[open] { padding-bottom: 6px; } details.tokens-group .token { margin: 2px 2px 0 0; }
.tokens-pick { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; } .tokens-pick select { width: 200px; padding: 4px 6px; font-size: 12.5px; }

.t tr.sec-row td{background:var(--bg-soft,#f6f5f2);border-top:2px solid var(--line);padding:10px 8px}
.t tr.sec-row input{background:transparent}

.who{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:50%;background:var(--accent,#3f6f5f);color:#fff;font-size:9px;font-weight:700;vertical-align:middle}
.inline-sel{width:auto;padding:2px 6px;font-weight:600;border-color:transparent;background:transparent}
.inline-sel:hover{border-color:var(--line)}
.perm-grid label{display:flex;gap:8px;align-items:flex-start;font-weight:400;margin:6px 0}
.perm-grid input{width:auto;margin-top:3px}

.ev.busy{background:repeating-linear-gradient(135deg,#eef0f3 0 6px,#e2e5ea 6px 12px);color:#4b5563;cursor:default}
.sms-bubble{display:inline-block;max-width:420px;background:#e9f5ee;border-radius:14px 14px 14px 4px;padding:8px 12px;margin:6px 0 2px;white-space:pre-wrap;font-size:13px}
