/* Tirpin Monitor web */
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.brand { font-weight: 700; font-size: 21px; letter-spacing: -.02em; color: var(--text); display: inline-flex; align-items: center; gap: 10px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand:hover { text-decoration: none; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang button { border: 0; background: transparent; padding: 5px 11px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.lang button.on { background: var(--accent-soft); color: var(--text); }

/* login */
.login { height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; }
.login-side { background: linear-gradient(165deg, var(--accent-soft), var(--bg) 75%); padding: 40px 56px 0; overflow: hidden; display: flex; flex-direction: column; }
.login-side h1 { font-size: clamp(30px, 3.4vw, 44px); line-height: 1.08; letter-spacing: -.03em; margin: 64px 0 12px; max-width: 16ch; }
.login-side p { color: var(--muted); font-size: 18px; max-width: 42ch; margin: 0; }
.login-shot { width: 300px; margin: 40px auto 0; border: 8px solid #1b1e25; border-bottom: 0; border-radius: 32px 32px 0 0; box-shadow: var(--shadow); }
.login-form { padding: 32px 40px; display: flex; flex-direction: column; overflow-y: auto; }
.login-top { display: flex; justify-content: flex-end; align-items: center; }
.login-form form { width: 100%; max-width: 400px; margin: auto; padding: 24px 0; }
.login-form h2 { font-size: 30px; letter-spacing: -.02em; margin: 0 0 6px; }
.field { display: grid; gap: 6px; margin-top: 16px; }
.field label { font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea {
  height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px; width: 100%;
}
.field textarea { height: 80px; padding: 10px 14px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.field small { font-size: 13px; }
.err { color: var(--danger); min-height: 22px; margin: 10px 0 4px; font-size: 15px; }
.wide { width: 100%; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 14px 0; width: 100%; font-weight: 500; }

/* shell */
.main { height: 100dvh; display: flex; flex-direction: column; }
.top { height: 64px; flex: none; display: flex; align-items: center; gap: 28px; padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 8px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 600; white-space: nowrap; position: relative; }
.tabs button.on { background: var(--accent-soft); color: var(--text); }
.tabs .badge { margin-left: 6px; background: var(--danger); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 6px; }
.top-right { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.view { flex: 1; min-height: 0; overflow: auto; }

/* map view */
.mapview { display: grid; grid-template-columns: 380px 1fr; height: 100%; }
.side { border-right: 1px solid var(--line); background: var(--bg); overflow-y: auto; display: flex; flex-direction: column; }
.side-head { padding: 16px 16px 8px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 14px; cursor: pointer; font-weight: 500; }
.chip.on { background: var(--accent-soft); border-color: transparent; }
.search { margin-top: 10px; width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; }
.list { padding: 4px 12px 16px; display: grid; gap: 8px; }
.tcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; text-align: left; width: 100%; }
.tcard:hover { border-color: var(--accent); }
.tcard .row1 { display: flex; align-items: center; gap: 8px; }
.tcard .plate { font-weight: 700; font-size: 17px; }
.tcard .drv { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tcard .row2 { margin-top: 4px; }
.tcard .row3 { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: 2px; gap: 8px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.st-moving { color: var(--moving); } .st-stopped { color: var(--parked); } .st-offline, .st-never { color: var(--offline); }
.warn { color: var(--danger); }
.mapbox { position: relative; min-height: 300px; }
#map { position: absolute; inset: 0; }
.leaflet-container { font: inherit; background: var(--surface-2); }
.pin { background: var(--surface); color: var(--text); border: 2px solid var(--c); border-radius: 999px; padding: 3px 10px 3px 8px; font-weight: 700; font-size: 13px;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 2px 8px rgb(0 0 0 / .2); transform: translate(-50%, -100%); position: absolute; }
.pin::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.pin.sel { background: var(--c); color: #fff; }
.pin.sel::before { background: #fff; }
.dot { width: 22px; height: 22px; border-radius: 50%; background: var(--c); color: #fff; border: 2px solid #fff; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; transform: translate(-50%, -50%); position: absolute; box-shadow: 0 1px 4px rgb(0 0 0 / .3); }
html[data-dark] .leaflet-tile-pane { filter: grayscale(1) invert(.88) brightness(.95) contrast(.9) hue-rotate(180deg); }

/* truck detail */
.detail { padding: 14px 16px 24px; }
.back { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px 0; font-weight: 600; }
.detail h2 { margin: 8px 0 0; font-size: 26px; letter-spacing: -.02em; }
.daynav { display: flex; align-items: center; gap: 6px; margin: 14px 0 10px; }
.daynav input { flex: 1; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; }
.iconbtn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 18px; line-height: 1; }
.iconbtn[disabled] { opacity: .4; cursor: default; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat small { color: var(--muted); font-size: 12px; display: block; }
.stat b { font-size: 18px; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-top: 14px; }
.subtabs button { border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.subtabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.lines > div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.lines small { color: var(--muted); display: block; }
.replay { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.replay input { flex: 1; accent-color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty b { display: block; color: var(--text); font-size: 18px; margin-bottom: 4px; }

/* pages */
.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 48px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 30px; letter-spacing: -.02em; margin: 0; flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tblwrap { overflow-x: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters input, .filters select { height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.kpi small { color: var(--muted); display: block; }
.kpi b { font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.alert-row { display: grid; grid-template-columns: 12px 1fr auto; gap: 14px; align-items: start; padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.alert-row:hover { background: var(--surface-2); }
.alert-row i { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; background: var(--c); }
.alert-row b { margin-right: 8px; }
.alert-row .type { color: var(--c); font-weight: 600; font-size: 14px; }
.alert-row time { color: var(--muted); font-size: 14px; white-space: nowrap; }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings h2 { font-size: 19px; margin: 0 0 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.zonemap { height: 320px; border-radius: 12px; overflow: hidden; margin: 12px 0; position: relative; }
.zonemap > div { position: absolute; inset: 0; }
.chat { display: flex; flex-direction: column; height: 60vh; max-height: 520px; }
.chat .msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px; }
.bubble { max-width: 75%; padding: 9px 13px; border-radius: 14px; background: var(--surface-2); align-self: flex-start; }
.bubble.me { background: var(--accent); color: var(--accent-ink); align-self: flex-end; }
.bubble small { display: block; font-size: 12px; opacity: .75; margin-top: 2px; }
.chat form { display: flex; gap: 8px; margin-top: 10px; }
.chat input { flex: 1; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; }
.code { font-size: 40px; font-weight: 700; letter-spacing: .12em; margin: 6px 0; }
.codebox { background: var(--accent-soft); border-radius: 14px; padding: 16px 18px; margin-bottom: 8px; }

/* modal, toast */
.modal { position: fixed; inset: 0; background: rgb(10 14 22 / .5); display: grid; place-items: center; padding: 16px; z-index: 1000; }
.modal-box { background: var(--bg); border-radius: 18px; width: 100%; max-width: 620px; max-height: 92dvh; overflow-y: auto; padding: 24px; box-shadow: var(--shadow); }
.modal-box h2 { margin: 0 0 4px; font-size: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 1100; font-weight: 500; }
.skel { background: var(--surface-2); border-radius: 12px; height: 74px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

@media (max-width: 960px) {
  .login { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .mapview { grid-template-columns: 1fr; grid-template-rows: 46vh auto; height: auto; }
  .mapbox { grid-row: 1; min-height: 46vh; }
  .side { grid-row: 2; border-right: 0; }
  .settings, .form-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .top { gap: 12px; padding: 0 12px; }
  .top .brand span { display: none; }
}
@media (max-width: 600px) {
  .top { flex-wrap: wrap; height: auto; padding: 10px 12px; }
  .tabs { order: 3; width: 100%; }
  .page { padding: 20px 16px 40px; }
  .login-form { padding: 20px 16px; }
}
@media print {
  .top, .filters, .page-head .btn { display: none !important; }
}

/* theme switch */
.theme-toggle { width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center; font-size: 18px; }
.theme-toggle .ph-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ph-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .ph-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ph-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .ph-moon { display: none; }
}
.login-top { gap: 10px; }
