:root{
  --brand:#1683c9; --brand-dark:#0f5fa0; --ink:#1f2a37; --muted:#6b7280;
  --line:#e5e7eb; --bg:#f4f6f9; --link:#1683c9; --navy:#0c1119;
  --steel-lo:#0c1119; --steel-hi:#121b2b; --sidebar-ink:#c7cfdb; --sidebar-muted:#8b95a6;
  --green:#2ea44f; --red:#e23b34; --amber:#f59e0b; --blue:#3b82f6;
  --green-bg:#dcf5dd; --green-bd:#7fce8a; --red-bg:#fde3e1; --red-bd:#f0a8a2;
  --blue-bg:#dbeafe; --blue-bd:#93c5fd; --amber-bg:#fef3c7; --amber-bd:#fcd34d;
  --row-h:78px; --col-w:96px; --label-w:240px;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;font-family:-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;color:var(--ink);background:var(--bg)}
.app{display:flex;height:100vh;overflow:hidden}

/* Sidebar */
.sidebar{width:212px;background:linear-gradient(180deg,var(--steel-lo),var(--steel-hi));border-right:1px solid #1e2634;flex-shrink:0;display:flex;flex-direction:column;padding:16px 0;overflow:auto}
.logo{display:flex;align-items:center;gap:10px;padding:0 18px 16px;cursor:pointer}
.logo .wm{font-weight:800;letter-spacing:3px;font-size:19px;line-height:1;background:linear-gradient(180deg,#f2f5f9,#aeb8c6);-webkit-background-clip:text;background-clip:text;color:transparent}
.logo .tag{font-size:8px;letter-spacing:1.5px;color:var(--brand);font-weight:600;margin-top:3px}
.nav{display:flex;flex-direction:column;gap:1px}
.nav a{display:flex;align-items:center;gap:12px;padding:9px 20px;color:var(--sidebar-ink);text-decoration:none;font-size:14.5px;border-left:3px solid transparent;cursor:pointer}
.nav a .ic{width:20px;text-align:center;opacity:.85}
.nav a:hover{background:rgba(255,255,255,.06)}
.nav a.active{color:#fff;background:rgba(22,131,201,.22);border-left-color:var(--brand);font-weight:600}
.nav .sub{display:none;flex-direction:column}
.nav .sub.open{display:flex}
.nav .sub a{padding:7px 20px 7px 52px;font-size:13.5px;color:var(--sidebar-muted)}
.nav .sub a.active{color:#fff;background:rgba(22,131,201,.16);font-weight:600}

.main{flex:1;display:flex;flex-direction:column;min-width:0}
.topbar{display:flex;align-items:center;gap:14px;padding:16px 24px;border-bottom:1px solid var(--line);background:#fff;flex-shrink:0}
.topbar h1{font-size:21px;margin:0;font-weight:700;flex:1}
.search{display:flex;align-items:center;gap:8px;background:#fff;border:1px solid var(--line);border-radius:8px;padding:8px 12px;width:260px;color:var(--muted)}
.search input{border:0;outline:0;font-size:14px;width:100%}
.content{flex:1;overflow:auto;padding:22px 24px 48px}

.btn{border:0;border-radius:8px;padding:9px 15px;font-size:14px;font-weight:600;cursor:pointer;display:inline-flex;align-items:center;gap:7px;text-decoration:none}
.btn.primary{background:var(--brand);color:#fff}.btn.primary:hover{background:var(--brand-dark)}
.btn.ghost{background:#fff;border:1px solid var(--line);color:var(--ink)}.btn.ghost:hover{background:#f3f6fb}
.btn.green{background:var(--green);color:#fff}.btn.red{background:var(--red);color:#fff}
.link{color:var(--link);text-decoration:none;cursor:pointer}.link:hover{text-decoration:underline}
.crumb{font-size:13.5px;color:var(--muted);margin-bottom:14px}
.crumb a{color:var(--link);cursor:pointer}

.panel{background:#fff;border:1px solid var(--line);border-radius:10px;margin-bottom:18px}
.panel .ph{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--line)}
.panel .ph h3{margin:0;font-size:16px}
.panel .pb{padding:18px 20px}

table{width:100%;border-collapse:collapse;background:#fff}
thead th{text-align:left;font-size:11.5px;font-weight:700;color:var(--muted);letter-spacing:.5px;padding:13px 18px;border-bottom:1px solid var(--line)}
tbody td{padding:14px 18px;font-size:14px;border-bottom:1px solid #f0f2f5;vertical-align:middle}
tbody tr:hover{background:#f3f8ff}
.name a{font-weight:600}
.right{text-align:right}
.actions .link{margin-left:14px;font-size:13.5px}

.chip{display:inline-block;background:#eef4fc;color:var(--brand);border-radius:6px;padding:3px 9px;font-size:12.5px;font-weight:600}
.badge{display:inline-block;padding:3px 10px;border-radius:99px;font-size:12px;font-weight:600}
.badge.active{background:var(--green-bg);color:#176b27}
.badge.inactive{background:#eef1f5;color:#6b7280}
.badge.tech{background:var(--blue-bg);color:#1e487f}
.badge.sales{background:#ede9fe;color:#6d28d9}
.badge.helper{background:#fef3c7;color:#92600b}
.countpill{background:#eef4fc;color:var(--brand);border-radius:99px;padding:4px 12px;font-size:12.5px;font-weight:700}

.avatar{width:38px;height:38px;border-radius:50%;background:var(--brand);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:13px;flex-shrink:0}
.avatar.gray{background:#cbd5e1}

/* Filters / forms */
.filters{display:flex;align-items:flex-end;gap:14px;flex-wrap:wrap;padding:18px 20px}
.fg{display:flex;flex-direction:column;gap:5px}
.fg label{font-size:12px;font-weight:600;color:var(--muted)}
.fg input,.fg select,.fg textarea{border:1px solid var(--line);border-radius:7px;padding:9px 11px;font-size:14px;outline:0;font-family:inherit}
.fg input:focus,.fg select:focus,.fg textarea:focus{border-color:var(--brand)}
.fg textarea{resize:vertical;min-height:64px;line-height:1.4}
.formgrid{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.formgrid .full{grid-column:1/3}

/* Stat cards */
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-bottom:20px}
.stat{background:#fff;border:1px solid var(--line);border-radius:10px;padding:18px}
.stat .n{font-size:30px;font-weight:800}
.stat .l{font-size:13px;color:var(--muted);margin-top:3px}
.stat .ic{font-size:20px;opacity:.6;float:right}

/* Modal */
.modal-bg{position:fixed;inset:0;background:rgba(15,23,42,.45);display:none;align-items:center;justify-content:center;z-index:60}
.modal-bg.open{display:flex}
.modal{background:#fff;border-radius:14px;width:520px;max-width:94vw;max-height:90vh;overflow:auto;padding:22px 24px;box-shadow:0 18px 48px rgba(0,0,0,.25)}
.modal h2{margin:0 0 16px;font-size:18px}
.modal .actions{display:flex;justify-content:flex-end;gap:10px;margin-top:18px}

/* Toast */
.toast{position:fixed;bottom:24px;left:50%;transform:translateX(-50%) translateY(12px);background:#1f2a37;color:#fff;padding:12px 20px;border-radius:10px;font-size:14px;opacity:0;transition:.25s;z-index:80;pointer-events:none}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}

/* Drawer */
.drawer{position:fixed;top:0;right:0;height:100vh;width:380px;background:#fff;box-shadow:-6px 0 24px rgba(0,0,0,.12);transform:translateX(100%);transition:transform .22s ease;z-index:50;display:flex;flex-direction:column}
.drawer.open{transform:translateX(0)}
.drawer header{padding:18px 20px;border-bottom:1px solid var(--line);display:flex;align-items:flex-start;gap:10px}
.drawer header h2{margin:0;font-size:17px;flex:1}
.drawer .x{border:0;background:transparent;font-size:22px;cursor:pointer;color:var(--muted);line-height:1}
.drawer .body{padding:18px 20px;overflow:auto;flex:1}
.field{margin-bottom:16px}
.field label{display:block;font-size:11.5px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.4px;margin-bottom:5px}
.field .v{font-size:14.5px}
.statusrow{display:flex;gap:8px;flex-wrap:wrap}
.statusrow button{border:1px solid var(--line);background:#fff;border-radius:99px;padding:6px 12px;font-size:13px;cursor:pointer}
.statusrow button.sel{border-color:var(--brand);background:#eef4fc;color:var(--brand);font-weight:600}

.empty{padding:40px;text-align:center;color:var(--muted)}

/* ===== Mobile technician view (Anvil field app) ===== */
.tv{position:fixed;inset:0;background:var(--bg);display:flex;flex-direction:column;overflow:hidden}
.tv-scroll{flex:1;overflow:auto;-webkit-overflow-scrolling:touch;padding-bottom:96px}
@media(min-width:520px){ .tv{left:50%;transform:translateX(-50%);width:460px;box-shadow:0 0 0 1px var(--line)} }
.tvh{background:linear-gradient(135deg,#0f4f99,#1d74d0);color:#fff;padding:16px 18px 20px}
.tvh .top{display:flex;align-items:center;gap:10px;font-size:15px;font-weight:600;justify-content:center;position:relative}
.tvh .back{position:absolute;left:0;font-size:24px;cursor:pointer;line-height:1}
.tvh h1{font-size:22px;margin:10px 0 2px;font-weight:800;line-height:1.15}
.tvh .meta{font-size:14px;opacity:.9;margin-top:4px}
.tvh .svc{font-size:14px;opacity:.85;margin-top:6px}
.tvh .addr{display:flex;justify-content:space-between;align-items:flex-end;margin-top:16px;font-size:13.5px}
.tvh .addr a{color:#fff;font-weight:700;text-decoration:none;white-space:nowrap}
.tv-greet{padding:18px 18px 6px}
.tv-greet h1{margin:0;font-size:22px}
.tv-greet .sub{color:var(--muted);font-size:13.5px;margin-top:2px}
.tv-sec{font-size:12px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.5px;margin:16px 18px 8px}
.tv-card{background:#fff;border:1px solid var(--line);border-radius:14px;margin:0 14px 11px;padding:14px;position:relative;border-left:4px solid var(--blue)}
.tv-card.red{border-left-color:var(--red)} .tv-card.amber{border-left-color:var(--amber)} .tv-card.green{border-left-color:var(--green)}
.tv-card .t{font-size:12.5px;font-weight:700;color:var(--brand)}
.tv-card .c{font-weight:700;font-size:16px;margin:3px 0}
.tv-card .d{font-size:13.5px;color:var(--muted)}
.tv-card .chev{position:absolute;right:14px;top:50%;transform:translateY(-50%);color:#cbd5e1;font-size:22px}
.tv-grid{display:grid;grid-template-columns:repeat(3,1fr);background:#fff;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}
.tv-grid .cell{padding:16px 6px;text-align:center;border-right:1px solid #f0f2f5;border-bottom:1px solid #f0f2f5;cursor:pointer}
.tv-grid .cell .n{font-size:22px;font-weight:800}
.tv-grid .cell .l{font-size:12px;color:var(--brand);margin-top:2px}
.tv-block{background:#fff;border:1px solid var(--line);border-radius:14px;margin:12px 14px;padding:14px}
.tv-block h3{margin:0 0 6px;font-size:15px}
.tv-block .kv{display:flex;justify-content:space-between;font-size:14px;padding:6px 0;border-bottom:1px solid #f3f4f6}
.tv-block .kv:last-child{border-bottom:0}.tv-block .kv .k{color:var(--muted)}
.tv-soft{display:flex;align-items:center;gap:10px;width:calc(100% - 28px);margin:0 14px 10px;border:1px solid var(--line);background:#fff;border-radius:12px;padding:13px 14px;font-size:14.5px;font-weight:600;color:var(--ink);cursor:pointer;text-decoration:none}
.tv-status{display:flex;gap:8px;flex-wrap:wrap}
.tv-status button{border:1px solid var(--line);background:#fff;border-radius:99px;padding:8px 14px;font-size:13.5px;cursor:pointer}
.tv-status button.sel{border-color:var(--brand);background:#eef4fc;color:var(--brand);font-weight:700}
.tv-cta{display:block;width:calc(100% - 28px);margin:14px;border:0;border-radius:12px;padding:15px;font-size:16px;font-weight:700;color:#fff;background:var(--brand);cursor:pointer;text-align:center}
.tv-clock{position:absolute;left:0;right:0;bottom:0;background:#16a34a;color:#fff;padding:12px 16px;display:flex;align-items:center;gap:12px;z-index:5}
.tv-clock.off{background:#334155}
.tv-clock .lbl{font-size:12.5px;opacity:.9}
.tv-clock .timer{font-size:20px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1}
.tv-clock button{margin-left:auto;border:0;background:#fff;color:#16a34a;font-weight:700;border-radius:10px;padding:11px 16px;font-size:14px;cursor:pointer}
.tv-clock.off button{color:#334155}
.tv-pill{display:inline-block;padding:3px 10px;border-radius:99px;font-size:11.5px;font-weight:700}
.tv-pill.red{background:#fde3e1;color:#9b271f}.tv-pill.amber{background:#fef3c7;color:#92600b}
.tv-pill.blue{background:#dbeafe;color:#1e487f}.tv-pill.green{background:#dcf5dd;color:#176b27}.tv-pill.gray{background:#eef1f5;color:#4b5563}
.tv-banner{background:#fffbe9;border:1px solid #f3e9c2;color:#6b5b14;font-size:12.5px;padding:9px 14px;margin:12px 14px 0;border-radius:10px}
