/* ============================================================
   EASYWATER — HQ CRM (staff-only). Desktop admin.
   Brand tokens from ../styles/brand.css. Status colors allowed here.
   ============================================================ */
.geo { --font-head: "Archivo", system-ui, sans-serif; --font-body: "Archivo", system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font-body); color: var(--ink); background: var(--paper-2); font-weight: 450; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; }

/* status palette (CRM-only) */
:root {
  --st-requested: #b08338; --st-scheduled: #5b6166; --st-assigned: #4f7d5b; --st-completed: #a9adb2; --st-cancelled: #a8473c;
}

/* ---------- login gate ---------- */
.gate { position: fixed; inset: 0; z-index: 200; background: var(--ink); color: var(--paper); display: grid; place-items: center; }
.gate.hide { display: none; }
.gate .box { width: min(380px, 88vw); text-align: center; }
.gate .ew-lockup { color: var(--paper); justify-content: center; margin-bottom: 26px; }
.gate h1 { font-family: var(--font-head); font-weight: 800; font-size: 1.5rem; margin: 0 0 6px; }
.gate p { color: var(--fog); font-size: .9rem; margin: 0 0 22px; }
.gate input { width: 100%; text-align: center; letter-spacing: .3em; font-size: 1.1rem; padding: 14px; border-radius: 8px; border: 1px solid var(--line-d); background: var(--ink-2); color: var(--paper); }
.gate input:focus { outline: none; border-color: var(--paper); }
.gate .hint { margin-top: 14px; font-size: .78rem; color: var(--steel); }
.gate .err { color: var(--st-cancelled); font-size: .82rem; min-height: 18px; margin-top: 10px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: var(--paper); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 20px 20px 18px; border-bottom: 1px solid var(--line-d); }
.side .brand .ew-lockup { color: var(--paper); }
.side nav { padding: 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 8px; color: var(--mist); text-decoration: none; font-weight: 600; font-size: .92rem; cursor: pointer; transition: .15s; }
.side nav a svg { width: 19px; height: 19px; opacity: .8; }
.side nav a:hover { background: var(--ink-2); color: var(--paper); }
.side nav a.active { background: var(--paper); color: var(--ink); }
.side nav a.active svg { opacity: 1; }
.side nav a .count { margin-left: auto; background: var(--st-requested); color: #fff; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.side .foot { padding: 16px; border-top: 1px solid var(--line-d); font-size: .8rem; color: var(--fog); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--paper); border-bottom: 1px solid var(--line-l); padding: 16px 28px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30; }
.topbar h2 { font-family: var(--font-head); font-weight: 800; font-size: 1.3rem; margin: 0; }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.gbtn { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--line-l); background: var(--white); border-radius: 8px; padding: 9px 13px; font-weight: 600; font-size: .85rem; cursor: pointer; }
.gbtn.on { border-color: var(--st-assigned); color: var(--st-assigned); background: #f0f6f1; }
.gbtn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mist); } .gbtn.on .dot { background: var(--st-assigned); }
.who { display: flex; align-items: center; gap: 9px; font-size: .85rem; font-weight: 600; }
.who .av { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }

.content { padding: 26px 28px 60px; }
.crm-view { display: none; } .crm-view.active { display: block; }

/* ---------- cards / kpis ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.kpi { background: var(--white); border: 1px solid var(--line-l); border-radius: 12px; padding: 18px 18px; }
.kpi .l { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--steel); font-weight: 700; }
.kpi .n { font-family: var(--font-head); font-weight: 800; font-size: 2.1rem; line-height: 1; margin-top: 10px; letter-spacing: -.02em; }
.kpi .s { font-size: .8rem; color: var(--graphite); margin-top: 6px; }
.panel { background: var(--white); border: 1px solid var(--line-l); border-radius: 12px; padding: 20px; margin-bottom: 18px; }
.panel h3 { font-family: var(--font-head); font-weight: 800; font-size: 1.05rem; margin: 0 0 14px; display: flex; align-items: center; justify-content: space-between; }
.panel h3 .link { font-family: var(--font-body); font-size: .82rem; font-weight: 600; color: var(--steel); cursor: pointer; }
.cols2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }

/* job rows */
.job { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-l); }
.job:last-child { border-bottom: 0; }
.job .time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .9rem; width: 74px; flex: none; }
.job .info { min-width: 0; flex: 1; }
.job .info .nm { font-weight: 700; font-size: .92rem; }
.job .info .meta { color: var(--steel); font-size: .8rem; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 4px 9px; border-radius: 99px; white-space: nowrap; color: #fff; }
.pill.requested { background: var(--st-requested); } .pill.scheduled { background: var(--st-scheduled); }
.pill.assigned { background: var(--st-assigned); } .pill.completed { background: var(--st-completed); color: var(--ink); } .pill.cancelled { background: var(--st-cancelled); }
.who-chip { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; }
.who-chip .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.empty { color: var(--steel); font-size: .9rem; padding: 16px 0; }

/* ---------- calendar ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.seg { display: inline-flex; border: 1px solid var(--line-l); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--white); border: 0; padding: 8px 16px; font-weight: 600; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.seg button.active { background: var(--ink); color: var(--paper); }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav button { width: 34px; height: 34px; border: 1px solid var(--line-l); background: var(--white); border-radius: 8px; cursor: pointer; font-size: 1rem; }
.cal-title { font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; min-width: 200px; }
.cal-grid { background: var(--white); border: 1px solid var(--line-l); border-radius: 12px; overflow: hidden; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--paper-2); border-bottom: 1px solid var(--line-l); }
.cal-dow div { padding: 9px; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--steel); text-align: center; }
.cal-month { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell { min-height: 104px; border-right: 1px solid var(--line-l); border-bottom: 1px solid var(--line-l); padding: 6px 6px; position: relative; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.dim { background: var(--paper); }
.cal-cell .dn { font-size: .8rem; font-weight: 700; color: var(--graphite); }
.cal-cell.today .dn { background: var(--ink); color: var(--paper); border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; }
.cal-cell .evs { display: flex; flex-direction: column; gap: 3px; margin-top: 5px; }
.ev { font-size: .72rem; font-weight: 600; padding: 3px 6px; border-radius: 5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; border-left: 3px solid rgba(255,255,255,.5); }
.ev.unassigned { background: var(--graphite); }
.cal-more { font-size: .7rem; color: var(--steel); cursor: pointer; padding: 1px 6px; }

/* week view */
.cal-week { display: grid; grid-template-columns: 56px repeat(6, 1fr); background: var(--white); border: 1px solid var(--line-l); border-radius: 12px; overflow: hidden; }
.cal-week .wk-h { padding: 8px 4px; text-align: center; font-size: .74rem; font-weight: 700; border-bottom: 1px solid var(--line-l); border-right: 1px solid var(--line-l); color: var(--graphite); }
.cal-week .wk-h.today { background: var(--ink); color: var(--paper); }
.cal-week .wk-corner { border-bottom: 1px solid var(--line-l); border-right: 1px solid var(--line-l); }
.cal-week .hr { font-size: .68rem; color: var(--steel); text-align: right; padding: 4px 6px 0 0; border-right: 1px solid var(--line-l); height: 46px; }
.cal-week .wk-col { border-right: 1px solid var(--line-l); position: relative; }
.cal-week .wk-col:last-child { border-right: 0; }
.wk-cell { height: 46px; border-bottom: 1px solid var(--line-l); }
.wk-ev { position: absolute; left: 3px; right: 3px; border-radius: 6px; color: #fff; font-size: .7rem; font-weight: 600; padding: 4px 6px; overflow: hidden; cursor: pointer; border-left: 3px solid rgba(255,255,255,.55); }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(12,12,13,.45); z-index: 90; opacity: 0; pointer-events: none; transition: .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(420px, 92vw); background: var(--paper); z-index: 100; transform: translateX(100%); transition: transform .26s cubic-bezier(.16,1,.3,1); display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(0,0,0,.25); }
.drawer.open { transform: none; }
.drawer .dh { padding: 20px 22px; border-bottom: 1px solid var(--line-l); display: flex; justify-content: space-between; align-items: flex-start; }
.drawer .dh h3 { font-family: var(--font-head); font-weight: 800; font-size: 1.3rem; margin: 0; }
.drawer .dh .x { background: none; border: 0; font-size: 1.5rem; cursor: pointer; line-height: 1; color: var(--steel); }
.drawer .db { padding: 22px; overflow-y: auto; flex: 1; }
.drawer .row { margin-bottom: 18px; }
.drawer .row label { display: block; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--steel); margin-bottom: 7px; }
.drawer .row input, .drawer .row select, .drawer .row textarea { width: 100%; border: 1.5px solid var(--line-l); border-radius: 9px; padding: 11px 12px; font: inherit; font-size: .95rem; background: var(--white); }
.drawer .row textarea { min-height: 64px; resize: vertical; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-l); font-size: .9rem; }
.kv .k { color: var(--steel); } .kv .v { font-weight: 700; text-align: right; }
.df { padding: 16px 22px; border-top: 1px solid var(--line-l); display: flex; gap: 10px; }
.df .btn { flex: 1; justify-content: center; }
.assign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.assign-grid .pm { border: 1.5px solid var(--line-l); border-radius: 9px; padding: 10px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .85rem; background: var(--white); }
.assign-grid .pm.sel { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.assign-grid .pm .sw { width: 12px; height: 12px; border-radius: 50%; flex: none; }

/* ---------- tables ---------- */
.tbl { width: 100%; background: var(--white); border: 1px solid var(--line-l); border-radius: 12px; border-collapse: separate; border-spacing: 0; overflow: hidden; }
.tbl th { text-align: left; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--steel); padding: 12px 16px; background: var(--paper-2); border-bottom: 1px solid var(--line-l); }
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--line-l); font-size: .9rem; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.clk { cursor: pointer; } .tbl tr.clk:hover td { background: var(--paper); }

/* dispatch */
.disp { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.disp .unassigned .job { cursor: grab; }
.pumper-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; }
.pcol { background: var(--white); border: 1px solid var(--line-l); border-radius: 12px; padding: 14px; min-height: 160px; }
.pcol.drop { outline: 2px dashed var(--ink); outline-offset: -4px; }
.pcol .ph { display: flex; align-items: center; gap: 9px; font-weight: 700; margin-bottom: 12px; }
.pcol .ph .sw { width: 12px; height: 12px; border-radius: 50%; }
.pcol .ph .ct { margin-left: auto; font-size: .8rem; color: var(--steel); }
.pjob { border: 1px solid var(--line-l); border-radius: 9px; padding: 10px; margin-bottom: 8px; font-size: .84rem; }
.pjob .nm { font-weight: 700; } .pjob .mt { color: var(--steel); font-size: .78rem; margin-top: 2px; }

/* route map */
.route-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.map { position: relative; background: var(--ink); border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; }
.map .grid-bg { position: absolute; inset: 0; background-image: linear-gradient(var(--line-d) 1px, transparent 1px), linear-gradient(90deg, var(--line-d) 1px, transparent 1px); background-size: 38px 38px; opacity: .5; }
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map .pin { position: absolute; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .82rem; border: 2px solid rgba(255,255,255,.7); cursor: pointer; }
.map .hub { position: absolute; transform: translate(-50%,-50%); width: 14px; height: 14px; border-radius: 50%; background: var(--paper); box-shadow: 0 0 0 6px rgba(244,241,234,.18); }
.map .hub-l { position: absolute; transform: translate(-50%,-50%); color: var(--fog); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; }
.route-side .pcol { margin-bottom: 0; }
.stop { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-l); }
.stop:last-child { border-bottom: 0; }
.stop .no { width: 24px; height: 24px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: .76rem; font-weight: 800; flex: none; }
.stop .nm { font-weight: 700; font-size: .88rem; } .stop .mt { color: var(--steel); font-size: .78rem; }

/* pumpers */
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 14px; }
.pcard { background: var(--white); border: 1px solid var(--line-l); border-radius: 12px; padding: 18px; }
.pcard .top { display: flex; align-items: center; gap: 12px; }
.pcard .av { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: var(--ink); }
.pcard .nm { font-weight: 800; font-family: var(--font-head); }
.pcard .role { color: var(--steel); font-size: .82rem; }
.pcard .stat { display: flex; gap: 18px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-l); }
.pcard .stat .n { font-family: var(--font-head); font-weight: 800; font-size: 1.3rem; }
.pcard .stat .l { font-size: .72rem; color: var(--steel); text-transform: uppercase; letter-spacing: .08em; }

@media (max-width: 1080px) { .kpis { grid-template-columns: repeat(2,1fr); } .cols2, .disp, .route-wrap { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; } .side nav { flex-direction: row; flex-wrap: wrap; } }

/* ---------- contacts: filters, stage, tags ---------- */
.filters { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters .search { flex: 1; min-width: 200px; border: 1.5px solid var(--line-l); border-radius: 9px; padding: 10px 13px; font: inherit; font-size: .92rem; background: var(--white); }
.filters .search:focus { outline: none; border-color: var(--ink); }
.tbl .sub2 { color: var(--steel); font-size: .78rem; margin-top: 2px; }
.tbl .nowrap, td.nowrap { white-space: nowrap; }
.stage { font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 4px 9px; border-radius: 99px; }
.stage.active { background: #eaf2ec; color: var(--st-assigned); }
.stage.lead { background: #f6efe0; color: var(--st-requested); }
.stage.past { background: var(--paper-2); color: var(--steel); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: .7rem; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--paper-2); color: var(--graphite); border: 1px solid var(--line-l); white-space: nowrap; }
.due-soon { color: var(--st-requested); font-weight: 700; }

/* ---------- drawer tabs + comms ---------- */
.drawer-tabs { display: flex; margin: 20px 0 14px; width: 100%; }
.drawer-tabs button { flex: 1; }
.comm { border: 1px solid var(--line-l); border-radius: 10px; padding: 12px 13px; margin-bottom: 9px; background: var(--white); }
.comm-h { display: flex; align-items: center; gap: 8px; font-size: .78rem; }
.comm-ch { font-weight: 700; }
.comm-when { margin-left: auto; color: var(--steel); }
.comm-st { font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 7px; border-radius: 99px; }
.comm-st.sent { background: #eaf2ec; color: var(--st-assigned); }
.comm-st.queued { background: #f6efe0; color: var(--st-requested); }
.comm-st.scheduled { background: var(--paper-2); color: var(--steel); }
.comm-subj { font-weight: 700; font-size: .88rem; margin-top: 8px; }
.comm-body { font-size: .85rem; color: var(--graphite); line-height: 1.45; margin-top: 4px; white-space: pre-wrap; }
.comm-fn { font-size: .72rem; color: var(--steel); margin-top: 8px; }

/* ---------- messages view ---------- */
.msg-prev { font-size: .82rem; color: var(--graphite); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src { font-size: .78rem; color: var(--steel); }
.btn.mini { padding: .4em .8em; font-size: .78rem; }
.panel h3 .seg { display: inline-flex; }
.panel h3 .seg button { padding: 5px 11px; }

/* ---------- funnels ---------- */
.sub-lead { color: var(--graphite); max-width: 60ch; line-height: 1.5; margin: 0 0 20px; }
.funnels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.fcard { background: var(--white); border: 1px solid var(--line-l); border-radius: 12px; padding: 18px; opacity: .72; transition: .18s; }
.fcard.on { opacity: 1; border-color: var(--graphite); }
.fc-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.fc-n { font-family: var(--font-head); font-weight: 800; font-size: 1.1rem; }
.fc-t { font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--steel); font-weight: 700; margin-top: 3px; }
.fc-d { color: var(--graphite); font-size: .86rem; line-height: 1.45; margin: 12px 0 14px; }
.fsteps { display: flex; flex-direction: column; }
.fstep { display: flex; align-items: flex-start; gap: 10px; }
.fstep > div { line-height: 1.3; }
.fstep .fdot { width: 11px; height: 11px; border-radius: 50%; flex: none; margin-top: 3px; }
.fstep .fdot.email { background: var(--st-scheduled); } .fstep .fdot.sms { background: var(--st-assigned); }
.fs-n { font-weight: 700; font-size: .88rem; } .fs-m { font-size: .76rem; color: var(--steel); margin-top: 1px; }
.fline { width: 1px; height: 14px; background: var(--mist); margin: 4px 0 4px 5px; }
.fc-f { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-l); }

/* toggle (shared) */
.toggle { position: relative; width: 44px; height: 26px; border-radius: 99px; background: var(--mist); border: 0; cursor: pointer; transition: .2s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle.on { background: var(--st-assigned); } .toggle.on::after { transform: translateX(18px); }
