/* Home, Attendance and the day view */

/* ---------- Home ---------- */
.hm-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: var(--s-4); align-items: start; }
.hm-card .card-b.flush { padding: 0; }
.hm-att { list-style: none; margin: 0; padding: 0; }
.hm-att li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); min-height: 56px; }
.hm-att li:first-child { border-top: 0; }
.hm-att-t { flex: 1; min-width: 0; color: var(--text); }
.hm-att .btn { flex: none; }
.hm-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-faint); }
.hm-dot.t-info { background: var(--info); }
.hm-dot.t-danger { background: var(--danger); }
.hm-dot.t-warning { background: #D98B00; }
.hm-dot.t-success { background: var(--success); }
.hm-chart-box { position: relative; }
.hm-chart { display: block; width: 100%; height: auto; }
.hm-chart text { font-family: var(--font); }
.hm-gl { stroke: var(--border); stroke-width: 1; }
.hm-ax { font-size: 12px; fill: var(--text-muted); }
.hm-axd { fill: var(--text-2); font-weight: var(--fw-medium); }
.hm-sv { font-size: 12px; font-weight: var(--fw-semibold); fill: var(--text); pointer-events: none; font-variant-numeric: tabular-nums; }
.hm-sv.on-dark { fill: #fff; }
.hm-hit { fill: transparent; cursor: default; }
.hm-hit:hover { fill: rgba(15, 23, 42, .04); }
.wk-P { fill: var(--success); background: var(--success); }
.wk-HD { fill: #6FBF94; background: #6FBF94; }
.wk-INC { fill: #B97400; background: #B97400; }
.wk-NS { fill: url(#hm-hatch); background: repeating-linear-gradient(45deg, #F5D08A 0 2px, var(--warning-soft) 2px 5px); }
.wk-A { fill: var(--danger); background: var(--danger); }
.wk-L { fill: var(--purple); background: var(--purple); }
.wk-other { fill: var(--border-strong); background: var(--border-strong); }
.hm-hatch-bg { fill: var(--warning-soft); }
.hm-hatch-fg { fill: #E2A93B; }
.hm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: var(--fs-xs); color: var(--text-muted); }
.hm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.hm-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.hm-tip { position: absolute; z-index: 5; min-width: 170px; padding: 8px 10px; background: var(--text); color: #fff; border-radius: var(--r-sm); box-shadow: var(--shadow-md); font-size: var(--fs-xs); line-height: 18px; pointer-events: none; display: flex; flex-direction: column; gap: 2px; }
.hm-tip[hidden] { display: none; }
.hm-tip b { font-weight: var(--fw-semibold); margin-bottom: 2px; }
.hm-tip span { display: flex; align-items: center; gap: 6px; }
.hm-tip em { font-style: normal; margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; font-weight: var(--fw-semibold); }

/* ---------- Attendance ---------- */
.at-step { display: inline-flex; }
.at-sub { display: block; font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }
.at-muted { color: var(--text-muted); }
.at-flags { display: inline-flex; gap: 4px; align-items: center; }
.at-flag { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-2); }
.at-flag svg { width: 14px; height: 14px; }
.at-flag.f-clock, .at-flag.f-noloc { background: var(--warning-soft); color: var(--warning); }
.at-need { margin-bottom: var(--s-4); }
.at-need .card-h { min-height: 48px; padding: 10px 20px; }
.at-need .card-h h3 .ui-tab-n { background: var(--warning-soft); color: var(--warning); }
.at-need .ui-card-f { justify-content: flex-start; padding: 6px 12px; }
.at-mapcard { overflow: hidden; }
.at-mapgrid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 520px; }
.at-map { height: calc(100vh - 360px); min-height: 520px; width: 100%; background: var(--surface-2); }
.at-side { border-left: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.at-side-h { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); color: var(--text-muted); }
.at-side-l { overflow-y: auto; flex: 1; max-height: calc(100vh - 400px); min-height: 480px; }
.at-side-i { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.at-side-i:hover { background: var(--surface-2); }
.at-side-i.none { cursor: default; }
.at-side-i.none:hover { background: none; }
.at-side-n { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 18px; }
.at-side-n b { font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.at-side-n small { font-size: var(--fs-xs); color: var(--text-muted); }
.at-legend, .dy-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-muted); }
.at-legend span, .dy-legend span { display: inline-flex; align-items: center; gap: 6px; }
.at-pin { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px 0 7px; border-radius: var(--r-pill); background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-md); font-size: 12px; font-weight: var(--fw-semibold); white-space: nowrap; cursor: pointer; }
.at-pin::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.at-pin.live { border-color: var(--success); }
.at-pin.live::before { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.at-pin.stale { border-color: #D98B00; }
.at-pin.stale::before { background: #D98B00; }
.at-pin.out { color: var(--text-muted); }
.at-pin-k { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--text-faint); }
.at-pin-k.live { background: var(--success); }
.at-pin-k.stale { background: #D98B00; }

/* ---------- Day view ---------- */
.dy-step { display: inline-flex; }
.dy-card { margin-bottom: var(--s-4); }
.dy-card .card-b { padding: 20px; }
.dy-sum { display: flex; gap: 20px; align-items: flex-start; }
.dy-photo { width: 72px; height: 72px; border-radius: var(--r-md); object-fit: cover; border: 1px solid var(--border); background: var(--surface-3); cursor: zoom-in; flex: none; }
.dy-facts { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; }
.dy-f { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dy-f .l { font-size: var(--fs-sm); color: var(--text-muted); }
.dy-f .v { font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: 28px; font-variant-numeric: tabular-nums; }
.dy-f .s { font-size: var(--fs-sm); color: var(--text-2); overflow-wrap: anywhere; }
.dy-rows { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.dy-rows > div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; }
.dy-rows dt { color: var(--text-muted); font-size: var(--fs-sm); line-height: 20px; }
.dy-rows dd { margin: 0; line-height: 20px; }
.dy-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.dy-line { margin-top: 14px; color: var(--text-muted); font-size: var(--fs-sm); }
.dy-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; max-width: 520px; }
.dy-form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.dy-kpis { margin-bottom: var(--s-4); }
.dy-routecard { overflow: hidden; margin-bottom: var(--s-4); }
.dy-routegrid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.dy-map { height: 460px; width: 100%; background: var(--surface-2); }
.dy-tl { list-style: none; margin: 0; padding: 8px 0; border-left: 1px solid var(--border); max-height: 460px; overflow-y: auto; }
.dy-tl li { position: relative; }
.dy-tl li + li::before { content: ''; position: absolute; left: 27px; top: -6px; height: 12px; border-left: 1px dashed var(--border-strong); }
.dy-tl button { display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 8px 16px; border: 0; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.dy-tl button:disabled { cursor: default; }
.dy-tl button:not(:disabled):hover, .dy-tl li.on button { background: var(--surface-2); }
.dy-tl-m { width: 22px; height: 22px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: var(--fw-semibold); color: #fff; background: var(--text-faint); margin-top: -1px; }
.dy-tl .k-in .dy-tl-m { background: var(--success); }
.dy-tl .k-out .dy-tl-m { background: var(--text); }
.dy-tl .k-stop .dy-tl-m { background: var(--primary); }
.dy-tl .k-gap .dy-tl-m { background: var(--warning-soft); box-shadow: inset 0 0 0 2px #D98B00; }
.dy-tl .k-mode .dy-tl-m { background: var(--surface-3); box-shadow: inset 0 0 0 2px var(--border-strong); }
.dy-tl .k-last .dy-tl-m { background: var(--surface); box-shadow: inset 0 0 0 3px var(--primary); }
.dy-tl-t { display: flex; flex-direction: column; min-width: 0; line-height: 18px; }
.dy-tl-t b { font-weight: var(--fw-medium); font-size: var(--fs-sm); }
.dy-tl-t small { font-size: var(--fs-xs); color: var(--text-muted); overflow-wrap: anywhere; }
.dy-tl .k-gap .dy-tl-t b { color: var(--warning); }
.dy-lg { width: 12px; height: 12px; border-radius: 50%; display: inline-block; background: var(--text-faint); }
.dy-lg.k-in { background: var(--success); }
.dy-lg.k-out { background: var(--text); }
.dy-lg.k-stop { background: var(--primary); }
.dy-lg.k-gap { background: var(--warning-soft); box-shadow: inset 0 0 0 2px #D98B00; transform: rotate(45deg); border-radius: 2px; width: 10px; height: 10px; }
.dy-lg.k-last { background: var(--surface); box-shadow: inset 0 0 0 3px var(--primary); }
.dy-mk { position: absolute; left: 0; top: 0; transform: translate(calc(-50% + var(--dx, 0px)), -50%); display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: var(--r-pill); color: #fff; font-size: 11px; font-weight: var(--fw-semibold); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(15, 23, 42, .35); white-space: nowrap; }
.dy-mk.k-in { background: var(--success); }
.dy-mk.k-out { background: var(--text); }
.dy-mk.k-stop { background: var(--primary); }
.dy-mk.k-mode { width: 12px; min-width: 12px; height: 12px; padding: 0; background: var(--surface); border: 2px solid var(--text-2); }
.dy-mk.k-gap { width: 14px; min-width: 14px; height: 14px; padding: 0; border-radius: 3px; background: var(--warning-soft); border: 2px solid #D98B00; transform: translate(-50%, -50%) rotate(45deg); }
.dy-mk.k-last { width: 18px; min-width: 18px; height: 18px; padding: 0; background: var(--surface); border: 4px solid var(--primary); }
.leaflet-overlay-pane path.dy-line-route { stroke: var(--primary); }
.leaflet-overlay-pane path.dy-pt { fill: var(--primary); }
.dy-disc { margin-bottom: var(--s-3); overflow: hidden; }
.dy-disc > summary { display: flex; align-items: center; gap: 8px; padding: 14px 20px; cursor: pointer; font-weight: var(--fw-semibold); list-style: none; }
.dy-disc > summary::-webkit-details-marker { display: none; }
.dy-disc > summary::before { content: ''; width: 7px; height: 7px; border-right: 1.6px solid var(--text-muted); border-bottom: 1.6px solid var(--text-muted); transform: rotate(-45deg); transition: transform 120ms var(--ease); margin-right: 4px; }
.dy-disc[open] > summary::before { transform: rotate(45deg); }
.dy-disc > summary:hover { background: var(--surface-2); }
.dy-disc-b { border-top: 1px solid var(--border); }
.dy-disc-b .ui-dt { border: 0; border-radius: 0; box-shadow: none; }
.dy-disc-bar { display: flex; justify-content: flex-end; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.dy-sub-h { padding: 12px 16px 8px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); border-top: 1px solid var(--border); }
.dy-kv { padding: 16px 20px; }

/* ---------- smaller screens ---------- */
@media (max-width: 1100px) {
  .hm-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .at-mapgrid, .dy-routegrid { grid-template-columns: minmax(0, 1fr); }
  .at-side { border-left: 0; border-top: 1px solid var(--border); }
  .at-side-l { min-height: 0; max-height: 320px; }
  .at-map { height: 420px; min-height: 0; }
  .dy-map { height: 360px; }
  .dy-tl { border-left: 0; border-top: 1px solid var(--border); max-height: none; }
}
@media (max-width: 719px) {
  .hm-att li { padding: 12px 16px; flex-wrap: wrap; }
  .dy-sum { flex-direction: column; gap: 14px; }
  .dy-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dy-form-row { grid-template-columns: minmax(0, 1fr); }
  .dy-rows > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .dy-map { height: 300px; }
}
.at-nm { font-weight: var(--fw-medium); }
.dy-none { color: var(--text-2); font-size: var(--fs-md); }
.dy-none + .dy-rows { margin-top: 14px; }
.ui-kpis.dy-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
