@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap");

/* AFOGPS components. Values come from tokens.css; nothing here declares a token. */
html, body { margin: 0; background: var(--bg-100); color: var(--ink-100); font-family: var(--font-sans); font-size: 13px; line-height: 20px; -webkit-font-smoothing: antialiased; }
* { box-sizing: border-box; }
.ag-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ag-muted { color: var(--ink-300); }
.ag-sub { color: var(--ink-200); }
.ag-label { font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-300); }
.ag-row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.ag-stack { display: flex; flex-direction: column; gap: var(--space-3); }
:focus-visible { outline: 2px solid var(--accent-500); outline-offset: 1px; }

/* Icon */
.ag-ic { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* Button */
.ag-btn { display: inline-flex; align-items: center; gap: 6px; height: var(--control-h); padding: 0 12px; border-radius: var(--radius-md); border: 1px solid transparent; font: 500 13px/1 var(--font-sans); cursor: pointer; white-space: nowrap; }
.ag-btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.ag-btn-primary { background: var(--accent-fill); color: var(--on-accent); }
.ag-btn-primary:hover { filter: brightness(1.08); }
.ag-btn-secondary { background: var(--bg-300); color: var(--ink-100); border-color: var(--line-200); }
.ag-btn-secondary:hover { background: var(--bg-400); }
.ag-btn-ghost { background: transparent; color: var(--ink-200); }
.ag-btn-ghost:hover { background: var(--bg-300); color: var(--ink-100); }
.ag-btn-danger { background: transparent; color: var(--status-offline); border-color: var(--status-offline); }
.ag-btn-icon { width: var(--control-h); padding: 0; justify-content: center; }
.ag-btn:disabled { opacity: .45; cursor: not-allowed; }

/* Fields */
.ag-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ag-field > span:first-child { font-size: 12px; line-height: 16px; color: var(--ink-200); }
.ag-input { display: flex; align-items: center; height: var(--control-h); background: var(--bg-300); border: 1px solid var(--line-200); border-radius: var(--radius-md); padding: 0 10px; gap: 6px; }
.ag-input:focus-within { border-color: var(--accent-500); box-shadow: 0 0 0 1px var(--accent-500); }
.ag-input input, .ag-input select { flex: 1; min-width: 0; height: 100%; background: transparent; border: 0; outline: 0; color: var(--ink-100); font: 400 13px/20px var(--font-sans); padding: 0; appearance: none; }
.ag-input select { cursor: pointer; }
.ag-input select option { background: var(--bg-200); color: var(--ink-100); }
.ag-input input::placeholder { color: var(--ink-300); }
.ag-input.is-mono input { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ag-input .ag-suffix { color: var(--ink-300); font-size: 12px; }
.ag-hint { font-size: 12px; line-height: 16px; color: var(--ink-300); }
.ag-field.is-error .ag-input { border-color: var(--status-offline); }
.ag-field.is-error .ag-hint { color: var(--status-offline); }

/* Segmented */
.ag-seg { display: inline-flex; border: 1px solid var(--line-200); border-radius: var(--radius-md); overflow: hidden; height: var(--control-h); }
.ag-seg button { border: 0; background: transparent; color: var(--ink-200); padding: 0 10px; font: 500 12px/1 var(--font-sans); cursor: pointer; border-left: 1px solid var(--line-100); display: inline-flex; align-items: center; gap: 6px; }
.ag-seg button:first-child { border-left: 0; }
.ag-seg button.is-on { background: var(--accent-tint); color: var(--accent-500); }
.ag-seg .ag-count { font-family: var(--font-mono); color: var(--ink-300); }

/* Status tag */
.ag-tag { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 6px; border-radius: var(--radius-sm); font: 500 11px/1 var(--font-sans); white-space: nowrap; }
.ag-tag svg { width: 8px; height: 8px; flex: none; }
.ag-st-work { color: var(--status-work); background: var(--status-work-tint); }
.ag-st-onsite { color: var(--status-onsite); background: var(--status-onsite-tint); }
.ag-st-private { color: var(--status-private); background: var(--status-private-tint); }
.ag-st-idle { color: var(--status-idle); background: var(--status-idle-tint); }
.ag-st-offline { color: var(--status-offline); background: var(--status-offline-tint); }

/* Metric strip */
.ag-metrics { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line-100); border-radius: var(--radius-md); background: var(--bg-200); }
.ag-metric { padding: 12px 16px; border-left: 1px solid var(--line-100); min-width: 0; }
.ag-metric:first-child { border-left: 0; }
.ag-metric .v { font: 500 24px/28px var(--font-mono); letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.ag-metric .v small { font-size: 13px; color: var(--ink-200); margin-left: 4px; letter-spacing: 0; }
.ag-metric .d { font: 400 12px/16px var(--font-mono); color: var(--ink-300); margin-top: 2px; }
.ag-metric .d b { font-weight: 500; }
.ag-metric .d .up { color: var(--status-onsite); } .ag-metric .d .down { color: var(--status-offline); } .ag-metric .d .warn { color: var(--status-private); }

/* Table */
.ag-table { width: 100%; border-collapse: collapse; background: var(--bg-200); font-size: 13px; }
.ag-table th { text-align: left; font: 500 11px/16px var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-300); padding: 8px 12px; border-bottom: 1px solid var(--line-100); white-space: nowrap; position: sticky; top: 0; background: var(--bg-200); }
.ag-table td { height: var(--row-h); padding: 0 12px; border-bottom: 1px solid var(--line-100); white-space: nowrap; }
.ag-table tr:hover td { background: var(--bg-300); }
.ag-table tr.is-sel td { background: var(--bg-400); }
.ag-table .r { text-align: right; }
.ag-table .m { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Employee row */
.ag-emp { display: grid; grid-template-columns: 28px 1fr auto; gap: 2px 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line-100); cursor: pointer; }
.ag-emp:hover { background: var(--bg-300); }
.ag-emp.is-sel { background: var(--bg-400); box-shadow: inset 2px 0 0 var(--accent-500); }
.ag-emp .ini { grid-row: span 2; width: 28px; height: 28px; border-radius: var(--radius-md); background: var(--bg-400); color: var(--ink-200); display: grid; place-items: center; font: 500 11px/1 var(--font-mono); }
.ag-emp .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-emp .pl { color: var(--ink-200); font-size: 12px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-emp .mt { font: 400 11px/16px var(--font-mono); color: var(--ink-300); text-align: right; white-space: nowrap; }

/* Map */
.ag-map { position: relative; overflow: hidden; background: var(--map-land); cursor: crosshair; user-select: none; }
.ag-map > svg.base { position: absolute; inset: 0; width: 100%; height: 100%; }
.ag-map .water { fill: var(--map-water); } .ag-map .block { fill: var(--map-block); } .ag-map .park { fill: var(--map-park); }
.ag-map .road { stroke: var(--map-road); fill: none; } .ag-map .major { stroke: var(--map-road-major); fill: none; }
.ag-map .mlabel { fill: var(--map-label); font: 500 10px var(--font-sans); letter-spacing: .08em; text-transform: uppercase; }
.ag-map .trk-work { stroke: var(--track-work); stroke-width: 3; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.ag-map .trk-private { stroke: var(--track-private); stroke-width: 3; fill: none; stroke-dasharray: 6 4; stroke-linejoin: round; }
.ag-map .fence { fill: var(--status-onsite-tint); fill-opacity: .5; stroke: var(--geofence); stroke-width: 1; stroke-dasharray: 3 3; }
.ag-map .stop { fill: var(--bg-200); stroke: var(--status-idle); stroke-width: 1.5; }
.ag-map-ctl { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 1px; background: var(--line-100); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-float); }
.ag-map-ctl button { width: 32px; height: 32px; border: 0; background: var(--bg-200); color: var(--ink-200); display: grid; place-items: center; cursor: pointer; }
.ag-map-ctl button:hover { color: var(--ink-100); background: var(--bg-300); }
.ag-map-coord { position: absolute; left: 12px; bottom: 12px; background: var(--bg-200); box-shadow: var(--shadow-float); border-radius: var(--radius-md); padding: 4px 8px; font: 400 11px/16px var(--font-mono); color: var(--ink-200); }
.ag-map-scale { position: absolute; right: 12px; bottom: 12px; font: 400 11px/16px var(--font-mono); color: var(--ink-200); display: flex; align-items: center; gap: 6px; }
.ag-map-scale i { display: block; width: 64px; height: 5px; border: 1px solid var(--ink-300); border-top: 0; }

/* Pins */
.ag-pin { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 6px; pointer-events: auto; cursor: pointer; }
.ag-pin .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-200); border: 2px solid currentColor; position: relative; }
.ag-pin .dot svg { width: 10px; height: 10px; }
.ag-pin .hd { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.ag-pin .hd::before { content: ""; position: absolute; left: -4px; top: -20px; border: 4px solid transparent; border-bottom: 6px solid currentColor; }
.ag-pin .lb { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); background: var(--bg-200); color: var(--ink-100); box-shadow: var(--shadow-float); border-radius: var(--radius-sm); padding: 1px 6px; font: 500 11px/16px var(--font-sans); white-space: nowrap; }
.ag-pin .lb span { font-family: var(--font-mono); color: var(--ink-300); font-weight: 400; margin-left: 6px; }
.ag-pin.is-sel .dot { box-shadow: 0 0 0 4px var(--accent-tint), 0 0 0 5px var(--accent-500); }
.ag-pin.client .dot { border-radius: var(--radius-sm); width: 16px; height: 16px; border-width: 1.5px; color: var(--ink-200); }
.ag-pin.client.visited .dot { color: var(--status-onsite); background: var(--status-onsite-tint); }
.ag-pin.client.plan .dot { color: var(--accent-500); }
.ag-pin.client .lb { left: 14px; font-weight: 400; color: var(--ink-200); }
.ag-pin.cluster .dot { width: 30px; height: 30px; background: var(--bg-300); border-color: var(--line-200); color: var(--ink-100); font: 500 11px/1 var(--font-mono); }
.ag-pin.drop .dot { width: 28px; height: 28px; border-radius: 0; border: 0; background: none; color: var(--accent-500); }

/* Client placer */
.ag-placer { width: 340px; background: var(--bg-200); border-radius: var(--radius-lg); box-shadow: var(--shadow-float); }
.ag-placer header { padding: 12px 16px 10px; border-bottom: 1px solid var(--line-100); }
.ag-placer header .t { font-weight: 600; font-size: 15px; line-height: 22px; display: flex; justify-content: space-between; align-items: center; }
.ag-placer .co { display: flex; gap: 8px; align-items: center; margin-top: 4px; font: 400 12px/16px var(--font-mono); color: var(--ink-200); }
.ag-placer .bd { padding: 12px 16px; display: grid; gap: 10px; }
.ag-placer .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ag-placer footer { padding: 10px 16px 12px; border-top: 1px solid var(--line-100); display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Day track */
.ag-day { font-family: var(--font-mono); }
.ag-day .bar { position: relative; height: 18px; background: var(--bg-300); border-radius: var(--radius-sm); overflow: hidden; }
.ag-day .sg { position: absolute; top: 0; bottom: 0; }
.ag-day .sg-work { background: var(--status-work); }
.ag-day .sg-onsite { background: var(--status-onsite); }
.ag-day .sg-private { background: repeating-linear-gradient(135deg, var(--status-private) 0 4px, var(--status-private-tint) 4px 6px); }
.ag-day .sg-idle { background: var(--status-idle-tint); box-shadow: inset 0 0 0 1px var(--status-idle); }
.ag-day .sg-offline { background: repeating-linear-gradient(90deg, var(--status-offline) 0 2px, transparent 2px 5px); }
.ag-day .ev { position: absolute; top: -5px; bottom: -5px; width: 1px; background: var(--ink-100); }
.ag-day .ev::after { content: ""; position: absolute; top: -3px; left: -3px; width: 7px; height: 3px; background: var(--ink-100); }
.ag-day .wrap { position: relative; padding-top: 6px; }
.ag-day .ax { position: relative; height: 16px; margin-top: 4px; font-size: 11px; color: var(--ink-300); }
.ag-day .ax span { position: absolute; transform: translateX(-50%); }
.ag-day .shift { position: absolute; top: 0; height: 2px; background: var(--accent-500); }
.ag-day .lg { display: flex; gap: 14px; margin-top: 8px; font: 400 12px/16px var(--font-sans); color: var(--ink-200); flex-wrap: wrap; }
.ag-day .lg i { display: inline-block; width: 12px; height: 8px; margin-right: 6px; vertical-align: 0; border-radius: 1px; }
.ag-day .lg b { font: 500 12px/16px var(--font-mono); color: var(--ink-100); margin-left: 4px; }

/* Event log */
.ag-log { list-style: none; margin: 0; padding: 0; }
.ag-log li { display: grid; grid-template-columns: 52px 18px 1fr; gap: 0 8px; padding: 6px 0; position: relative; }
.ag-log li::before { content: ""; position: absolute; left: 68px; top: 24px; bottom: -6px; width: 1px; background: var(--line-100); }
.ag-log li:last-child::before { display: none; }
.ag-log .tm { font: 400 12px/18px var(--font-mono); color: var(--ink-200); }
.ag-log .mk { width: 18px; height: 18px; display: grid; place-items: center; }
.ag-log .mk svg { width: 14px; height: 14px; }
.ag-log .tt { font-weight: 500; line-height: 18px; }
.ag-log .dt { color: var(--ink-200); font-size: 12px; line-height: 16px; }
.ag-log .mt { color: var(--ink-300); font: 400 11px/16px var(--font-mono); margin-top: 2px; }
.ag-log .k-gps-on .mk, .ag-log .k-depart .mk { color: var(--status-work); }
.ag-log .k-arrive .mk, .ag-log .k-leave .mk { color: var(--status-onsite); }
.ag-log .k-private .mk { color: var(--status-private); }
.ag-log .k-stop .mk { color: var(--status-idle); }
.ag-log .k-gps-off .mk, .ag-log .k-alert .mk { color: var(--status-offline); }
.ag-log .k-alert .tt { color: var(--status-offline); }

/* Nav rail */
.ag-rail { width: var(--rail-w); background: var(--bg-000); border-right: 1px solid var(--line-100); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 2px; height: 100%; }
.ag-rail .brand { font: 600 11px/1 var(--font-mono); color: var(--ink-100); letter-spacing: .04em; margin: 4px 0 14px; }
.ag-rail .brand b { color: var(--accent-500); font-weight: 600; }
.ag-rail a { width: 56px; padding: 7px 0 5px; border-radius: var(--radius-md); display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-300); text-decoration: none; font: 500 10px/12px var(--font-sans); cursor: pointer; }
.ag-rail a:hover { color: var(--ink-100); background: var(--bg-200); }
.ag-rail a.is-on { color: var(--accent-500); background: var(--accent-tint); }
.ag-rail .sp { flex: 1; }

/* Panels & screen chrome */
.ag-panel { background: var(--bg-200); border: 1px solid var(--line-100); border-radius: var(--radius-md); }
.ag-panel > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line-100); }
.ag-panel > header h3 { margin: 0; font: 600 15px/22px var(--font-sans); }
.ag-topbar { height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line-100); background: var(--bg-200); }
.ag-topbar h1 { margin: 0; font: 600 15px/22px var(--font-sans); }
.ag-crumbs { color: var(--ink-300); font-size: 12px; }
.ag-float { position: absolute; background: var(--bg-200); border-radius: var(--radius-lg); box-shadow: var(--shadow-float); }
.ag-hbar { height: 8px; display: flex; background: var(--bg-300); border-radius: 1px; overflow: hidden; min-width: 120px; }
.ag-hbar i { display: block; height: 100%; }
.ag-hbar .w { background: var(--status-work); } .ag-hbar .o { background: var(--status-onsite); } .ag-hbar .p { background: var(--status-private); } .ag-hbar .s { background: var(--status-idle); }
.ag-sched { display: grid; grid-template-columns: 36px repeat(24, 1fr); gap: 2px; font: 400 10px/14px var(--font-mono); color: var(--ink-300); }
.ag-sched .c { height: 18px; background: var(--bg-300); border-radius: 1px; }
.ag-sched .c.on { background: var(--accent-tint); box-shadow: inset 0 0 0 1px var(--accent-500); }
.ag-switch { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-100); }
.ag-switch:last-child { border-bottom: 0; }
.ag-switch .sw { flex: none; width: 30px; height: 18px; border-radius: 9px; background: var(--bg-400); border: 1px solid var(--line-200); position: relative; margin-top: 1px; cursor: pointer; }
.ag-switch .sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink-200); }
.ag-switch .sw.on { background: var(--accent-fill); border-color: var(--accent-fill); }
.ag-switch .sw.on::after { left: 14px; background: var(--on-accent); }
.ag-switch .tx b { display: block; font-weight: 500; }
.ag-switch .tx span { color: var(--ink-200); font-size: 12px; line-height: 16px; }
.ag-pin.drop .dot svg { width: 28px; height: 28px; }
.ag-day .ax span:first-child { transform: none; }
.ag-day .ax span:last-child { transform: translateX(-100%); }
