:root {
    --bg: #f5f5f7;
    --card: #ffffff;
    --card2: #f5f5f7;
    --border: #e3e3e8;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --red: #e5322d;
    --green: #1f9d55;
    --amber: #b7791f;
    --blue: #0066cc;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}
h1, h2 { font-weight: 700; letter-spacing: -.02em; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* nav */
.topnav {
    display: flex; align-items: center; gap: 22px;
    padding: 12px 26px;
    background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.topnav a { color: var(--muted); font-weight: 500; font-size: 14px; text-decoration: none; }
.topnav a:hover { color: var(--text); }
.brand { font-size: 19px; font-weight: 700; color: var(--text) !important; letter-spacing: -.02em; }
.brand span { color: var(--red); }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 13px; }
.logout { color: var(--red) !important; }

main { max-width: 1250px; margin: 0 auto; padding: 26px 22px; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 28px; }

.pagehead { font-size: 28px; margin: 2px 0 18px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pagehead .count { color: var(--muted); font-size: 17px; font-weight: 500; }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .num { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi .lbl { color: var(--muted); font-size: 13px; margin-top: 5px; }
.kpi.red .num { color: var(--red); }
.kpi.warn .num { color: var(--amber); }
.kpi.green .num { color: var(--green); }

/* cards & layout */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 950px) { .cols { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.slim { max-width: 760px; }
.card h2 { font-size: 17px; margin: 0 0 12px; color: var(--text); }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; color: var(--muted); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 7px 8px; border-bottom: 1px solid var(--border); }
td { padding: 9px 8px; border-bottom: 1px solid #eeeef2; vertical-align: top; font-size: 14px; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafafc; }
td.r, th.r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.wide td a { font-weight: 600; color: var(--text); }
table.wide td a:hover { color: var(--blue); }

/* pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.s-active   { background: #e4f4e9; color: var(--green); }
.s-prospect { background: #faf0dc; color: var(--amber); }
.s-inactive { background: #ededf0; color: var(--muted); }
.s-lost     { background: #fdeaea; color: #c4302b; }
.c-signed   { background: #e4f4e9; color: var(--green); }
.c-pending  { background: #faf0dc; color: var(--amber); }
.c-none     { background: #fdeaea; color: #c4302b; }
.pill.stage { background: #e5f0fb; color: var(--blue); }
.e-CIVA        { background: #ededf0; color: var(--text); }
.e-EpicStitch  { background: #fdeaea; color: var(--red); }
.e-Shared      { background: #efe9fa; color: #6b46c1; }
.t-note, .t-call, .t-email, .t-meeting, .t-deliverable { background: #ededf0; color: var(--muted); }
.t-action { background: #fdeaea; color: #c4302b; }
.k-income  { background: #e4f4e9; color: var(--green); }
.k-expense { background: #fdeaea; color: #c4302b; }

/* forms */
input, select, textarea, button {
    font-family: inherit; font-size: 14px;
    background: var(--card); color: var(--text);
    border: 1px solid #d6d6dc; border-radius: 9px;
    padding: 8px 11px;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0,102,204,.14);
}
button {
    background: var(--red); border-color: var(--red); color: #fff;
    font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.06); }
button.ghost, .btnlink.ghost {
    background: transparent; color: var(--muted); border: 1px solid #d6d6dc;
    text-decoration: none; padding: 8px 13px; border-radius: 9px; font-weight: 500;
    display: inline-block;
}
button.ghost:hover, .btnlink.ghost:hover { color: var(--text); background: #ededf0; text-decoration: none; }
button.tiny { padding: 0 8px; font-size: 14px; }
form.inline { display: inline; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.grid-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.grid-form .span2 { grid-column: span 2; }
.grid-form .chkline, .chkline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.checks { display: flex; flex-wrap: wrap; gap: 14px; }
.chk { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; font-weight: 400; }

/* segmented control (entity tabs) */
.seg { display: inline-flex; background: #ededf0; border-radius: 10px; padding: 3px; gap: 2px; }
.seg a { padding: 6px 16px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 13.5px; text-decoration: none; }
.seg a.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.seg a:hover { text-decoration: none; color: var(--text); }

/* contacts + activities */
.contact { padding: 9px 0; border-bottom: 1px solid #eeeef2; position: relative; }
.contact form { position: absolute; right: 0; top: 9px; }
.activity { padding: 11px 0; border-bottom: 1px solid #eeeef2; }
.activity .meta { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.nextaction { color: var(--amber); font-weight: 600; margin-top: 5px; font-size: 13.5px; }

/* alerts */
.alert { padding: 11px 15px; border-radius: 10px; margin-bottom: 12px; font-weight: 500; font-size: 14px; }
.alert.err { background: #fdeaea; color: #c4302b; }
.alert.ok { background: #e4f4e9; color: var(--green); }
.page-flash { max-width: 1250px; margin: 14px auto 0; }
.devotp { color: var(--red); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 38px 42px; width: 370px; box-shadow: 0 8px 30px rgba(0,0,0,.07); }
.login-card h1 { font-size: 30px; margin: 0; letter-spacing: -.02em; }
.login-card h1 span { color: var(--red); }
.login-card .tagline { color: var(--muted); margin: 4px 0 22px; font-size: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card label { color: var(--muted); font-size: 13px; font-weight: 500; }

.userline { display: grid; grid-template-columns: 1fr 1.6fr auto auto auto; gap: 8px; padding: 7px 0; border-bottom: 1px solid #eeeef2; align-items: center; }
@media (max-width: 800px) { .userline { grid-template-columns: 1fr 1fr; } .grid-form { grid-template-columns: 1fr; } .grid-form .span2 { grid-column: span 1; } }

/* inline status select on companies list */
.statsel { padding: 3px 8px; font-size: 13px; border-radius: 20px; font-weight: 600; border: none; cursor: pointer; -webkit-appearance: none; appearance: none; }
.st-active     { background: #e4f4e9; color: #1f9d55; }
.st-onboarding { background: #e5f0fb; color: #0066cc; }
.st-prospect   { background: #faf0dc; color: #b7791f; }
.st-inactive   { background: #ededf0; color: #6e6e73; }
.st-lost       { background: #fdeaea; color: #c4302b; }

/* standup drill-down modal */
.kpi.click { cursor: pointer; transition: box-shadow .12s; }
.kpi.click:hover { box-shadow: 0 3px 10px rgba(0,0,0,.10); }
a.cnt { cursor: pointer; font-weight: 700; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
#tmodal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.34); z-index: 90; }
#tmodal { display: none; position: fixed; z-index: 91; top: 7vh; left: 50%; transform: translateX(-50%);
    width: min(960px, 94vw); max-height: 82vh; overflow-y: auto;
    background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 20px 24px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-x { background: #ededf0; color: #1d1d1f; border: none; border-radius: 50%;
    width: 30px; height: 30px; font-size: 18px; line-height: 1; cursor: pointer; padding: 0; }
.modal-x:hover { background: #e0e0e4; }

/* KPI weekly bars */
.bar { height: 7px; border-radius: 4px; margin: 2px 0; min-width: 2px; }
.bar.in  { background: #e5322d; opacity: .8; }
.bar.out { background: #1f9d55; opacity: .8; }
.legend { display: inline-block; width: 11px; height: 7px; border-radius: 3px; vertical-align: middle; }
.legend.in { background: #e5322d; } .legend.out { background: #1f9d55; }

/* department pills */
.pill[class*="dept-"] { background: #ededf0; color: #4b4b52; }
.dept-support     { background: #e5f0fb; color: #0066cc; }
.dept-development { background: #efe9fa; color: #6b46c1; }
.dept-billing, .dept-accounts { background: #faf0dc; color: #b7791f; }

/* team notes */
.note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #eeeef2; }
.note-body { flex: 1; }
.note-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.note-done .note-body > div:first-child { text-decoration: line-through; color: var(--muted); }
.btnlink.ghost.on { background: #ededf0; color: var(--text); }

/* skip-awaiting toggle */
.awtoggle { font-size: 13px; color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.ok-msg { color: var(--green); font-weight: 600; padding: 8px 0; }

/* standup add mini-modal (sits above the ticket modal) */
#su-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.34); z-index: 100; }
#su-modal { display: none; position: fixed; z-index: 101; top: 12vh; left: 50%; transform: translateX(-50%);
    width: min(560px, 92vw); background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.28); padding: 20px 24px; }
.su-ticket { background: #f5f5f7; border-radius: 9px; padding: 8px 12px; }

/* admin user-management help */
.admin-help { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; margin-bottom: 16px; box-shadow: var(--shadow); font-size: 14px; }
.admin-help p { margin: 6px 0; }
.admin-help ul { margin: 6px 0 6px 4px; padding-left: 18px; }
.admin-help li { margin: 3px 0; }

/* help page */
.help-toc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.help-toc a { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 5px 14px; font-size: 13px; text-decoration: none; color: var(--text); }
.help-toc a:hover { border-color: var(--red); text-decoration: none; }
.help-sec { scroll-margin-top: 70px; }
.help-sec h2 { color: var(--text); }
.help-sec h3 { font-size: 15px; margin: 16px 0 4px; color: var(--red); }
.help-sec ol, .help-sec ul { margin: 6px 0; padding-left: 22px; }
.help-sec li { margin: 4px 0; }
.help-shot { margin: 14px 0; }
.help-shot img { max-width: 100%; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); display: block; }
.help-shot figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.shot-missing { border: 2px dashed #d0d0d6; border-radius: 10px; padding: 26px; text-align: center; color: var(--muted); background: #fafafc; font-size: 13px; }
.shot-missing code { background: #ededf0; padding: 1px 6px; border-radius: 4px; color: var(--text); }
.shot-missing span { font-size: 12px; }

/* sales pipeline board */
.pipe-cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; align-items: start; }
@media (max-width: 1000px) { .pipe-cols { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .pipe-cols { grid-template-columns: 1fr; } }
.pipe-col { background: #f0f0f3; border-radius: 12px; padding: 8px; }
.pipe-head { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 4px 6px 8px; }
.pipe-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); }
.pipe-name { font-weight: 600; margin-bottom: 3px; }
.pipe-name a { text-decoration: none; color: var(--text); }
.pipe-next { font-size: 12.5px; color: var(--blue); margin-top: 5px; }
.pipe-next.stale { color: var(--red); font-weight: 600; }
.pipe-next.none { color: var(--muted); font-style: italic; }
.pipe-docs { display: flex; gap: 4px; margin-top: 7px; }
.pipe-docs .pill { font-size: 10.5px; padding: 1px 7px; }
.pill-waived { background: #ededf0; color: #6e6e73; }
.pipe-move { margin-top: 8px; }
.pipe-move select { width: 100%; padding: 4px 6px; font-size: 13px; }
.formdivider { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; }

/* standup agenda grouped by person */
.agenda-group { margin-bottom: 16px; }
.agenda-who { font-weight: 700; font-size: 14px; color: var(--text); padding: 6px 2px; border-bottom: 2px solid var(--red); margin-bottom: 4px; }
.lose-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.34); z-index: 100; display: flex; align-items: center; justify-content: center; }
.lose-box { background: #fff; border-radius: 14px; padding: 22px 26px; width: min(460px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.lose-box h2 { margin: 0 0 10px; font-size: 17px; }

/* QuickBooks panels */
.qb-card { border-left: 3px solid #2ca01c; }
.qb-figs { display: flex; gap: 28px; margin: 8px 0; }
.qb-num { font-size: 24px; font-weight: 700; }
.qb-num.red { color: var(--red); }
.pill.pill-waived { background:#ededf0; color:#6e6e73; }

/* QuickBooks drill-down modal */
#qb-backdrop{display:none;position:fixed;inset:0;background:rgba(0,0,0,.34);z-index:100;}
#qb-modal{display:none;position:fixed;z-index:101;top:8vh;left:50%;transform:translateX(-50%);
  width:min(820px,94vw);max-height:82vh;overflow:auto;background:#fff;border-radius:16px;
  box-shadow:0 20px 60px rgba(0,0,0,.28);padding:20px 24px;}
td.od{color:var(--red);font-weight:600;}
.kpi.click{cursor:pointer;transition:transform .06s;}
.kpi.click:hover{transform:translateY(-1px);}

/* P&L period selector */
.period-bar { display:flex; flex-wrap:wrap; gap:10px; margin:2px 0 12px; }
.period-bar .seg a { font-size:12.5px; padding:3px 9px; }
.cnt { color: var(--red); cursor:pointer; text-decoration:none; }
.cnt:hover { text-decoration:underline; }

/* preset range dropdown */
.preset-select { padding:5px 10px; border:1px solid var(--border); border-radius:8px; font-size:13px; background:#fff; }
.custom-range { display:inline-flex; align-items:center; gap:6px; margin-left:8px; }
.custom-range input[type=date] { padding:4px 8px; border:1px solid var(--border); border-radius:8px; font-size:13px; }

.remember { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--muted); font-weight:400; margin:2px 0 10px; }
.remember input { width:auto; margin:0; }

/* Vendors / subscriptions */
.sub { color:var(--muted); font-size:13.5px; margin:-6px 0 14px; }
.filterbar { margin-bottom:12px; }
.vendors td { vertical-align:top; }
tr.dim { opacity:.55; }
.tag { display:inline-block; font-size:11px; background:#eef; color:#556; padding:1px 7px; border-radius:6px; }
.pill.c-active{background:#e7f7ec;color:#1a7f37;} .pill.c-trial{background:#fff4e5;color:#a15c00;}
.pill.c-paused{background:#eef;color:#556;} .pill.c-cancelled{background:#f3f3f4;color:#888;}
.bignum{font-size:26px;font-weight:700;} .bignum .lbl{font-size:12px;color:var(--muted);font-weight:400;margin-left:6px;}
.mini{width:100%;border-collapse:collapse;} .mini td{padding:5px 0;border-bottom:1px solid var(--border);}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:12px;} .grid2 .span2{grid-column:1/3;}
.grid2 label{display:flex;flex-direction:column;font-size:12px;color:var(--muted);gap:3px;}
.grid2 input,.grid2 select,.grid2 textarea{padding:7px 9px;border:1px solid var(--border);border-radius:8px;font-size:14px;}
.checkline{flex-direction:row!important;align-items:center;gap:8px!important;}
.checkline input{width:auto;}
.linklike{background:none;border:none;color:var(--red);cursor:pointer;padding:0;font-size:inherit;}
.col-side .card.slim{margin-bottom:14px;}

/* Grouped dropdown nav */
.navgroup { position:relative; display:inline-block; }
.navgroup-btn { background:none; border:none; font:inherit; color:inherit; cursor:pointer; padding:6px 8px; border-radius:6px; }
.navgroup-btn:hover { background:rgba(0,0,0,.04); }
.navgroup-menu { display:none; position:absolute; top:100%; left:0; background:#fff; border:0.5px solid var(--border,#e3e3e6);
  border-radius:10px; box-shadow:0 8px 28px rgba(0,0,0,.12); padding:6px; min-width:180px; z-index:50; }
.navgroup:hover .navgroup-menu, .navgroup:focus-within .navgroup-menu { display:block; }
.navgroup-menu a { display:block; padding:8px 12px; border-radius:6px; white-space:nowrap; font-size:13.5px; }
.navgroup-menu a:hover { background:#f5f5f7; }
/* tabs on customers page */
.tabs { display:flex; gap:4px; flex-wrap:wrap; border-bottom:0.5px solid var(--border,#e3e3e6); margin:8px 0 16px; }
.tabs a { padding:8px 15px; font-size:13.5px; color:#6e6e73; border-bottom:2px solid transparent; }
.tabs a.on { color:var(--red,#e5322d); border-bottom-color:var(--red,#e5322d); font-weight:600; }
.tabs .tab-add { margin-left:auto; color:var(--red,#e5322d); }
