: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; }
