/* ADVANSYS Field Service demo. Tokens and components follow docs/mockups/base.css. */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --navy:#13294b; --blue:#1f5fd6; --blue-soft:#e8f0fe; --blue-faint:#f2f6fe; --line:#e2e8f0; --muted:#64748b;
  --green:#15803d; --green-soft:#e9f1ec; --green-muted:#e9f1ec; --green-muted-line:#d3e3d8; --slate-soft:#dfe5ee; --slate-line:#cbd5e1; --amber:#b45309; --amber-soft:#fef3c7;
  --red:#b91c1c; --red-soft:#fee2e2; --bg:#f6f8fb; --ink:#0f172a; --input:#cbd5e1;
}
html { -webkit-text-size-adjust: 100%; }
body { font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; font-size: 14px; font-feature-settings: "calt" 0; } /* calt off: Inter draws "2x" as "2×" */
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* components */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; border-radius:8px; font-weight:600; font-size:14px; padding:9px 14px; border:1px solid transparent; cursor:pointer; background:none; min-height:40px; white-space:nowrap; }
.btn-primary { background:var(--blue); color:#fff; }
.btn-ghost { background:#fff; border-color:var(--line); color:var(--ink); }
.btn-green { background:var(--green); color:#fff; }
.btn-red { background:var(--red); color:#fff; }
.btn:disabled { opacity:.45; cursor:not-allowed; }
.btn:focus-visible, .chip:focus-within, .in:focus, .ta:focus { outline:2px solid #93c5fd; outline-offset:1px; }
.btn-lg { min-height:52px; font-size:16px; font-weight:700; }
.pill { display:inline-block; font-size:11px; font-weight:600; padding:3px 8px; border-radius:999px; letter-spacing:.02em; white-space:nowrap; }
.pill-blue { background:var(--blue-soft); color:var(--blue); }
.pill-green { background:var(--green-soft); color:var(--green); }
.pill-amber { background:var(--amber-soft); color:var(--amber); }
.pill-gray { background:#f1f5f9; color:#475569; }
.pill-red { background:var(--red-soft); color:var(--red); }
.card { background:#fff; border:1px solid var(--line); border-radius:12px; }
.muted { color:var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.in { border:1px solid var(--input); border-radius:8px; padding:9px 11px; font-size:14px; background:#fff; width:100%; min-height:40px; }
select.in { appearance:none; -webkit-appearance:none; padding-right:30px; background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2364748b'/%3E%3C/svg%3E") no-repeat right 11px center; }
.lbl { font-size:12px; font-weight:700; color:#334155; text-transform:uppercase; letter-spacing:.05em; margin:16px 0 8px; }
.field-lbl { font-size:11.5px; font-weight:600; color:var(--muted); margin-bottom:4px; display:block; }
.dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:7px; }
.flash { background:var(--green-soft); color:var(--green); border:1px solid var(--green-muted-line); border-radius:10px; padding:10px 14px; font-weight:600; font-size:13px; }
h2.title { font-size:21px; font-weight:800; }
.flash-warn { background:var(--amber-soft); color:var(--amber); border-color:#fde68a; }
.row-between { display:flex; justify-content:space-between; align-items:center; gap:10px; }

/* chrome: desktop top bar */
.topbar { background:var(--navy); color:#fff; display:flex; align-items:center; gap:28px; padding:0 28px; height:58px; position:sticky; top:0; z-index:1000; }
.brand { font-weight:800; letter-spacing:.04em; font-size:17px; white-space:nowrap; }
.brand small { font-weight:500; opacity:.7; letter-spacing:0; margin-left:6px; font-size:15px; }
.nav { display:flex; height:100%; }
.nav a { color:#cbd5e1; font-size:14px; font-weight:500; margin-right:22px; display:flex; align-items:center; border-bottom:2px solid transparent; padding-top:2px; }
.nav a:hover { color:#fff; }
.nav a.on { color:#fff; border-bottom-color:#60a5fa; }
.user { margin-left:auto; font-size:13px; color:#cbd5e1; display:flex; align-items:center; gap:10px; white-space:nowrap; }
.user a:hover { color:#fff; }
.avatar { width:30px; height:30px; border-radius:50%; background:#3b82f6; color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:12px; }
.main { padding:22px 28px 28px; max-width:1400px; margin:0 auto; width:100%; }

/* chrome: phone */
.apphead { background:var(--navy); color:#fff; padding:14px 18px 16px; padding-top:calc(14px + env(safe-area-inset-top)); display:none; }
.apphead .t { font-size:19px; font-weight:700; }
.apphead .s { font-size:12px; opacity:.75; margin-top:2px; }
.apphead .back { font-size:13px; opacity:.8; display:inline-block; margin-bottom:4px; }
.tabbar { display:none; }
.desk-only { }
.phone-only { display:none; }

@media (max-width: 899px) {
  body { height:100dvh; overflow:hidden; }
  .shell { display:flex; flex-direction:column; height:100dvh; }
  .topbar, .desk-only { display:none !important; }
  .phone-only { display:revert; }
  .apphead { display:block; flex:none; }
  .apphead .row-between { align-items:flex-start; }
  .main { padding:12px 14px 20px; flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; }
  .main.flush { padding:0; overflow:hidden; position:relative; }
  .tabbar { flex:none; height:62px; padding-bottom:env(safe-area-inset-bottom); box-sizing:content-box; background:#fff; border-top:1px solid var(--line); display:flex; justify-content:space-around; align-items:stretch; font-size:11px; color:var(--muted); font-weight:600; }
  .tabbar a { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; }
  .tabbar svg { width:22px; height:22px; }
  .tabbar .on { color:var(--blue); }
  .btn { min-height:44px; }
}

/* login */
.login-wrap { min-height:100dvh; display:flex; align-items:center; justify-content:center; padding:24px 16px; background:var(--navy); }
.login-card { width:100%; max-width:400px; padding:28px 26px; }
.login-logo { text-align:center; margin-bottom:22px; }
.login-logo .b { font-weight:800; letter-spacing:.08em; font-size:28px; color:var(--navy); }
.login-logo .s { color:var(--muted); font-size:14px; margin-top:2px; }
.login-card form > div { margin-bottom:14px; }
.err { color:var(--red); font-size:13px; font-weight:600; }

/* jobs */
.seg { display:flex; background:#fff; border-radius:10px; border:1px solid var(--line); padding:3px; }
.seg a { flex:1; text-align:center; font-size:12.5px; font-weight:600; padding:8px 6px; border-radius:8px; color:var(--muted); }
.seg a.on { background:var(--blue-soft); color:var(--blue); }
.seg button { flex:1; border:0; background:none; cursor:pointer; text-align:center; font-size:12.5px; font-weight:600; padding:8px 14px; border-radius:8px; color:var(--muted); white-space:nowrap; }
.seg button.on { background:var(--blue-soft); color:var(--blue); }
.list { display:flex; flex-direction:column; gap:10px; margin-top:12px; }
.cust { padding:13px 14px; }
.cust .n { font-weight:700; font-size:15px; }
.cust .a { font-size:12px; color:var(--muted); margin-top:2px; }
.cust .row { display:flex; justify-content:space-between; align-items:center; margin-top:10px; gap:8px; }
.dist { font-size:13px; font-weight:600; color:var(--blue); }
.near { border:2px solid var(--blue); }
.jobs-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(320px, 1fr)); gap:12px; margin-top:14px; }
@media (max-width: 899px) { .jobs-grid { grid-template-columns:1fr; gap:10px; margin-top:12px; } }
.cust .tk { font-size:12.5px; margin-top:8px; display:flex; flex-direction:column; gap:4px; }
.cust .tk a { color:#334155; }
.cust .tk a:hover { color:var(--blue); }

/* route */
.route-desk { display:grid; grid-template-columns:1fr 380px; gap:16px; margin-top:14px; height:calc(100vh - 58px - 120px); min-height:480px; }
.map { width:100%; height:100%; border-radius:12px; border:1px solid var(--line); background:#eef0ea; }
.stops { overflow-y:auto; display:flex; flex-direction:column; gap:10px; }
.stop { padding:14px 16px; }
.stop { transition:border-color .2s, box-shadow .2s; }
.stop.selected { border-color:var(--blue); box-shadow:0 0 0 1px var(--blue); }
.stop-h { display:flex; gap:12px; align-items:center; }
.num { width:30px; height:30px; border-radius:50%; background:var(--blue); color:#fff; font-weight:800; display:flex; align-items:center; justify-content:center; flex:none; font-size:14px; }
.stop-btns { display:flex; gap:8px; margin-top:12px; }
.stop-btns > * { flex:1; }
.stop-btns form { display:flex; }
.stop-btns form .btn { flex:1; }
.num-marker span { display:flex; width:32px; height:32px; border-radius:50%; background:var(--blue); color:#fff; font-weight:800; font-size:14px; align-items:center; justify-content:center; border:3px solid #fff; box-shadow:0 2px 6px rgba(15,23,42,.35); font-family:Inter, sans-serif; }
.me-marker span { display:block; width:16px; height:16px; border-radius:50%; background:#2563eb; border:3px solid #fff; box-shadow:0 0 0 7px rgba(37,99,235,.22); }
@media (max-width: 899px) {
  .route-desk { display:block; height:100%; margin:0; min-height:0; }
  .route-desk .map { border-radius:0; border:0; }
  .stops { position:absolute; left:0; right:0; bottom:0; max-height:46%; background:#fff; border-radius:20px 20px 0 0; box-shadow:0 -6px 20px rgba(0,0,0,.1); padding:10px 14px 14px; z-index:1001; gap:8px; }
  .stops .grab { width:40px; height:4px; background:var(--input); border-radius:4px; margin:0 auto 4px; flex:none; }
  .stops .stop { border-radius:12px; padding:12px 14px; }
}

/* ticket */
.timer { text-align:center; padding:16px 0 10px; }
.timer .big { font-size:44px; font-weight:800; letter-spacing:-.02em; color:var(--navy); font-variant-numeric:tabular-nums; }
.timer .big small { font-size:20px; color:var(--muted); font-weight:700; }
.timer .big.range { font-size:28px; white-space:nowrap; padding:6px 0 4px; }
.task-row { display:flex; align-items:center; gap:6px; border-bottom:1px solid #f1f5f9; }
.task-row:last-of-type { border:0; }
.task { flex:1; display:flex; gap:12px; align-items:flex-start; padding:12px 0; font-size:14px; cursor:pointer; min-height:44px; }
.task-del { width:30px; height:30px; border:0; border-radius:6px; background:none; color:#cbd5e1; font-size:18px; line-height:1; cursor:pointer; flex:none; }
.task-del:hover, .task-del:focus-visible { color:var(--red); background:var(--red-soft); outline:none; }
@media (hover: none) { .task-del { color:#94a3b8; } }
.task input { position:absolute; opacity:0; pointer-events:none; }
.box { width:22px; height:22px; border-radius:5px; border:2px solid var(--input); flex:none; display:flex; align-items:center; justify-content:center; color:#fff; font-size:13px; font-weight:800; }
.task input:checked + .box { background:var(--green); border-color:var(--green); }
.task input:checked + .box::after { content:"✓"; }
.task input:checked ~ .tt { color:var(--muted); text-decoration:line-through; }
.task input:focus-visible + .box { outline:2px solid #93c5fd; outline-offset:2px; }
.ticket-head { align-items:flex-end; margin-bottom:4px; }
.add-task { display:flex; gap:8px; margin-top:10px; }
.add-task .in { flex:1; }
.new-ticket { max-width:760px; }
.new-ticket textarea { resize:vertical; line-height:1.5; }
.nt-grid { display:grid; grid-template-columns:minmax(0,1.4fr) minmax(0,1fr) minmax(0,1fr); gap:10px; }
@media (max-width: 899px) { .nt-grid { grid-template-columns:minmax(0,1fr) minmax(0,1fr); } .nt-grid > :first-child { grid-column:span 2; } .ticket-head { margin-bottom:10px; } }
.ticket-grid { display:grid; grid-template-columns:380px 1fr; gap:16px; margin-top:14px; align-items:start; }
@media (max-width: 899px) {
  .ticket-grid { display:block; margin-top:0; }
  .clock-card { position:sticky; top:-12px; z-index:5; box-shadow:0 6px 14px rgba(15,23,42,.06); }
}

/* builder */
.builder { display:grid; grid-template-columns:1fr 470px; gap:20px; margin-top:14px; align-items:start; }
.timegrid { display:grid; grid-template-columns:1.1fr 1.2fr .8fr .8fr .9fr; gap:10px; }
.chips { display:flex; flex-wrap:wrap; gap:7px; }
.chip { position:relative; font-size:12.5px; font-weight:600; padding:8px 11px; border-radius:7px; border:1px solid var(--input); background:#fff; color:#334155; cursor:pointer; user-select:none; }
.chip input { position:absolute; opacity:0; pointer-events:none; }
.chip:has(input:checked) { background:var(--blue); border-color:var(--blue); color:#fff; }
.mods { display:flex; flex-wrap:wrap; gap:8px 18px; align-items:center; }
.chk { display:inline-flex; align-items:center; gap:7px; font-size:13.5px; font-weight:500; cursor:pointer; min-height:32px; }
.chk input { width:17px; height:17px; accent-color:var(--blue); }
.mod-text { display:flex; gap:8px; align-items:center; margin-top:8px; }
.mod-text .in { max-width:420px; }
.mod-lbl { font-size:13px; font-weight:600; min-width:72px; }
.mod-text .act-time { width:84px; flex:none; text-align:center; }
.mod-text .act-why { flex:1; max-width:none; }
@media (max-width: 899px) {
  .mod-text { flex-wrap:wrap; }
  .mod-text .act-why { flex-basis:100%; }
}
.wi { display:grid; grid-template-columns:160px 1fr 34px; gap:10px; margin-bottom:10px; align-items:start; }
.wi .letter { position:absolute; left:11px; top:10px; font-weight:700; color:var(--muted); font-size:13.5px; pointer-events:none; }
.wi .ta-wrap { position:relative; }
.ta { min-height:64px; line-height:1.45; font-size:13.5px; resize:vertical; padding-left:32px; display:block; }
.x { width:34px; height:40px; border:1px solid var(--line); border-radius:8px; background:#fff; color:var(--muted); cursor:pointer; font-size:18px; line-height:1; }
.x:hover { color:var(--red); border-color:#fecaca; }
.phrase-wrap { position:relative; }
.linkbtn { background:none; border:0; font-weight:600; color:var(--blue); cursor:pointer; font-size:13px; text-transform:none; letter-spacing:0; padding:4px 0; }
.dd { position:absolute; right:0; top:28px; width:340px; max-width:calc(100vw - 28px); max-height:340px; overflow-y:auto; background:#fff; border:1px solid var(--input); border-radius:10px; box-shadow:0 12px 30px rgba(15,23,42,.18); padding:6px; z-index:50; text-transform:none; letter-spacing:0; }
.dd .h { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); padding:6px 10px; }
.dd button { display:block; width:100%; text-align:left; background:none; border:0; font-size:13px; font-weight:500; padding:8px 10px; border-radius:6px; cursor:pointer; color:var(--ink); white-space:pre-wrap; }
.dd button:hover, .dd button:focus { background:var(--blue-soft); color:var(--blue); outline:none; }
.preview { background:#0f1b31; color:#e2e8f0; border-radius:10px; padding:16px 18px; font-size:13px; line-height:1.6; min-height:90px; white-space:pre-wrap; word-break:break-word; }
.preview .k { color:#7dd3fc; font-weight:600; }
textarea.preview { width:100%; border:0; resize:vertical; min-height:180px; font:inherit; font-size:13px; outline:2px solid var(--amber); }
#checks:empty { display:none; }
.rule { display:flex; gap:9px; font-size:13px; padding:5px 0; color:#334155; }
.ok { color:var(--green); font-weight:800; }
.bad { color:var(--red); font-weight:800; }
.preview-card { padding:18px 20px; position:sticky; top:80px; }
@media (max-width: 1100px) { .builder { grid-template-columns:1fr; } .preview-card { position:static; } }
@media (max-width: 899px) {
  .timegrid { grid-template-columns:1fr 1fr; }
  .timegrid .span2 { grid-column:span 2; }
  .wi { grid-template-columns:1fr 34px; }
  .wi .ta-wrap { grid-column:1 / span 2; }
  .builder { margin-top:0; gap:12px; }
  .save-bar { position:sticky; bottom:-20px; background:#fff; padding:10px 0 4px; }
}

/* dashboard */
.kpis { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-top:16px; }
.kpi { padding:16px 18px; }
.kpi .v { font-size:30px; font-weight:800; margin-top:4px; color:var(--navy); }
.kpi .l { font-size:13px; color:var(--muted); font-weight:600; }
.two { display:grid; grid-template-columns:1.25fr 1fr; gap:16px; margin-top:16px; }
.ct { font-weight:800; font-size:15px; padding:16px 18px 10px; }
table.t { width:100%; border-collapse:collapse; font-size:13.5px; }
table.t th { text-align:left; font-size:11.5px; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; font-weight:700; padding:8px 18px; border-bottom:1px solid var(--line); }
table.t td { padding:11px 18px; border-bottom:1px solid #f1f5f9; }
table.t tr:last-child td { border-bottom:0; }
table.t a:hover { color:var(--blue); }
/* zebra rows: .zebra is striped by app.js (skips rows hidden by search); .stripes is plain CSS */
table.t.zebra tbody tr.alt td, table.t.stripes tbody tr:nth-child(even) td { background:var(--blue-faint); }
table.t.zebra tbody tr:hover td, table.t.stripes tbody tr:hover td { background:var(--blue-soft); }
.ticket-tools { display:flex; gap:10px; }
.new-ticket-btn { width:100%; margin-bottom:10px; }
@media (max-width: 899px) { .phone-only.new-ticket-btn { display:flex; } }
.table-scroll { overflow-y:auto; -webkit-overflow-scrolling:touch; }
.table-scroll.scrolling thead th { position:sticky; top:0; z-index:1; background:#fff; box-shadow:inset 0 -1px 0 var(--line); }
.ticket-tools input { flex:0 1 360px; min-width:0; }
.ticket-tools .day-filter { flex:none; }
.ticket-tools select { margin-left:auto; }
.ticket-tools select { width:auto; min-width:150px; }
@media (max-width: 899px) {
  .ticket-tools { flex-wrap:wrap; }
  .ticket-tools input { flex:1 1 0; }
  .ticket-tools select { min-width:0; flex:none; margin-left:0; }
  .ticket-tools .day-filter { order:3; flex:1 1 100%; }
  .in { font-size:16px; } /* 16px stops iPhone Safari zooming on focus */
}
.bar { height:10px; border-radius:6px; background:var(--blue); margin-top:5px; min-width:4px; }
@media (max-width: 899px) {
  .kpis { grid-template-columns:1fr 1fr; gap:10px; margin-top:12px; }
  .kpi .v { font-size:24px; }
  .two { grid-template-columns:1fr; }
  table.t th, table.t td { padding:10px 12px; }
}

/* report */
.filters { display:flex; gap:10px; align-items:end; margin-top:14px; flex-wrap:wrap; }
.filters .in { width:auto; font-size:13.5px; }
.block { margin-top:16px; }
.bh { display:flex; justify-content:space-between; align-items:center; padding:14px 20px; border-bottom:1px solid var(--slate-line); gap:10px; background:var(--slate-soft); }
.bh .pill { background:#fff; color:var(--navy); }
table.t.green-head th, .table-scroll.scrolling table.t.green-head thead th { background:var(--green-muted); color:var(--navy); border-bottom-color:var(--green-muted-line); }
.bh .n { font-weight:800; font-size:16px; color:var(--navy); }
.rec { padding:12px 20px; border-bottom:1px solid #f1f5f9; font-size:13px; line-height:1.55; }
.rec:last-child { border:0; }
.rec .h { font-weight:700; color:var(--navy); }
.ticket-ref { font-size:12px; font-weight:600; color:var(--blue); margin-left:4px; white-space:nowrap; }
.ticket-ref:hover { text-decoration:underline; }
.block { overflow:hidden; }
details.menu { position:relative; }
details.menu summary { list-style:none; }
details.menu summary::-webkit-details-marker { display:none; }
details.menu .dd { top:46px; width:200px; }
details.menu .dd a { display:block; font-size:13px; padding:9px 10px; border-radius:6px; }
details.menu .dd a:hover { background:var(--blue-soft); color:var(--blue); }
@media (max-width: 899px) { .rec, .bh { padding-left:14px; padding-right:14px; } .filters > * { flex:1 1 140px; } }

/* client */
.client-grid { display:grid; grid-template-columns:360px 1fr; gap:16px; margin-top:14px; align-items:start; }
.small-map { height:220px; border-radius:10px; border:1px solid var(--line); margin-top:12px; }
.sec { padding:16px 18px; }
.sec + .sec { margin-top:14px; }
.sec h3 { font-size:15px; font-weight:800; margin-bottom:8px; }
.li { padding:10px 0; border-bottom:1px solid #f1f5f9; font-size:13.5px; }
.li:last-child { border:0; }
@media (max-width: 899px) { .client-grid { grid-template-columns:1fr; margin-top:0; } }

/* me / settings */
.me-list a, .me-list button { display:flex; justify-content:space-between; align-items:center; width:100%; padding:14px 16px; border-bottom:1px solid #f1f5f9; font-weight:600; background:none; border-left:0; border-right:0; border-top:0; cursor:pointer; text-align:left; font-size:14px; }
.me-list > :last-child { border-bottom:0; }
.tags { display:flex; flex-wrap:wrap; gap:6px; }
