@charset "UTF-8";
/* ==========================================================================
   CIOT 車聯網 — 共用樣式（電腦版儀表板、登入、軌跡查詢、軌跡結果、單車地圖）
   設計重點：大字、高對比（文字對比約 7:1 以上）、觸控目標 ≥ 44px
   ========================================================================== */

:root {
    --app-height: 100vh;
    --font-ui: "Microsoft JhengHei UI", "Microsoft JhengHei", "Noto Sans TC", "PingFang TC", "Heiti TC", "Segoe UI", sans-serif;

    /* 配色 */
    --bg: #eef2f6;
    --surface: #ffffff;
    --surface-2: #f5f7fa;
    --border: #d3dce6;
    --border-strong: #b7c4d3;
    --text: #14212e;
    --muted: #46566a;
    --primary: #0b5cad;
    --primary-strong: #084a8c;
    --primary-soft: #e3eefa;
    --nav: #10263f;
    --nav-2: #1a3f66;
    --nav-text: #f4f8fc;
    --nav-muted: #c3d3e6;
    --brand: #f2a516;
    --addr-bg: #fff6e0;
    --addr-border: #efd398;
    --addr-text: #6b4100;
    --green: #0f7a4f;
    --green-soft: #def3e9;
    --amber: #9a5500;
    --amber-soft: #fdefd6;
    --red: #b42318;
    --red-soft: #fde7e5;
    --slate: #475569;
    --slate-soft: #e9edf2;

    --shadow-sm: 0 1px 3px rgba(16, 38, 63, 0.10);
    --shadow-md: 0 6px 18px rgba(16, 38, 63, 0.12);
    --shadow-lg: 0 18px 44px rgba(16, 38, 63, 0.22);
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

/* ---------- 基礎 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 17px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

@media (min-width: 1280px) {
    html { font-size: 18px; }
}

body {
    margin: 0;
    font-family: var(--font-ui);
    font-weight: 500;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}

[hidden] { display: none !important; }

/* ASP.NET 自動產生的隱藏欄位容器，不參與版面 */
.aspNetHidden { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
input, button { touch-action: manipulation; }

:focus-visible {
    outline: 3px solid #f2a516;
    outline-offset: 2px;
}

/* 共用按鈕 */
.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
    min-height: 48px;
    padding: 0.55rem 1.3rem;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.primary-button {
    border: 2px solid var(--primary);
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(11, 92, 173, 0.28);
}

.primary-button:hover { background: var(--primary-strong); border-color: var(--primary-strong); }

.secondary-button {
    border: 2px solid var(--border-strong);
    background: var(--surface);
    color: var(--primary-strong);
}

.secondary-button:hover { border-color: var(--primary); background: var(--primary-soft); }

.error-msg {
    display: block;
    min-height: 1.5em;
    color: var(--red);
    font-weight: 700;
    font-size: 1rem;
}

/* 時間狀態顏色（列表與明細共用） */
.time-fresh, .gps-time-live { color: var(--green) !important; }
.time-warning { color: var(--amber) !important; }
.time-danger, .gps-time-last, .gps-time-unfixed { color: var(--red) !important; }
.time-stale { color: var(--muted) !important; }

/* Leaflet 地圖控制項加大，方便點按與閱讀 */
.leaflet-container { font-family: var(--font-ui); }
.leaflet-control-zoom a {
    width: 40px !important;
    height: 40px !important;
    line-height: 38px !important;
    font-size: 24px !important;
    color: var(--nav) !important;
}
.leaflet-tooltip {
    padding: 4px 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    border-radius: 8px;
}
.leaflet-popup-content {
    margin: 12px 16px;
    font-size: 16px;
    line-height: 1.6;
}

/* ==========================================================================
   登入頁
   ========================================================================== */
.page-login {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background:
        radial-gradient(circle at 85% 10%, rgba(242, 165, 22, 0.20), transparent 32%),
        linear-gradient(165deg, var(--nav) 0%, var(--nav-2) 48%, var(--bg) 48.2%, var(--bg) 100%);
}

.login-card {
    width: min(460px, 100%);
    padding: 36px 32px 30px;
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 1.9rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    color: var(--nav);
}

.login-brand::before {
    content: "";
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: #fff url("../image/logo.png") center / cover no-repeat;
    box-shadow: 0 4px 14px rgba(16, 38, 63, 0.25);
}

.login-note {
    margin: 12px 0 26px;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.6;
}

.login-form {
    display: grid;
    gap: 18px;
}

.form-label {
    display: grid;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
}

.form-control {
    width: 100%;
    min-height: 56px;
    padding: 0 16px;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
}

.form-control::placeholder { color: #7a8899; font-weight: 500; }

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(11, 92, 173, 0.18);
}

.login-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
}

.login-row input[type="checkbox"] {
    width: 24px;
    height: 24px;
    margin: 0;
    accent-color: var(--primary);
}

.login-row label { cursor: pointer; padding: 6px 0; }

.login-form .primary-button {
    width: 100%;
    min-height: 58px;
    margin-top: 4px;
    font-size: 1.25rem;
    letter-spacing: 0.3em;
}

@media (max-width: 420px) {
    .login-card { padding: 28px 20px 24px; border-radius: 18px; }
    .login-brand { font-size: 1.6rem; }
    .login-brand::before { width: 52px; height: 52px; }
}

/* ==========================================================================
   電腦版儀表板（Desktop.aspx）
   ========================================================================== */
html:has(.desktop-dashboard),
.desktop-dashboard {
    height: 100%;
}

.desktop-dashboard {
    margin: 0;
    overflow: hidden;
    background: var(--bg);
}

.desktop-dashboard > form {
    height: 100%;
    display: grid;
    grid-template-rows: 72px minmax(0, 1fr);
}

.desktop-dashboard > form > .app-header { grid-row: 1; }
.desktop-dashboard > form > .dashboard-main { grid-row: 2; }

/* 頁首 */
.desktop-dashboard .app-header {
    position: relative;
    z-index: 1000;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    padding: 0 20px;
    background: linear-gradient(100deg, var(--nav) 0%, var(--nav-2) 100%);
    color: var(--nav-text);
    box-shadow: 0 3px 12px rgba(16, 38, 63, 0.25);
}

.desktop-dashboard .brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.desktop-dashboard .brand-mark {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    overflow: hidden;
    border-radius: 13px;
    background: #fff url("../image/logo.png") center / cover no-repeat;
    color: transparent;
    font-size: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.desktop-dashboard .brand-block strong,
.desktop-dashboard .brand-block small {
    display: block;
    white-space: nowrap;
}

.desktop-dashboard .brand-block strong {
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: 0.06em;
}

.desktop-dashboard .brand-block small {
    color: var(--nav-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.desktop-dashboard .main-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.desktop-dashboard .main-nav::-webkit-scrollbar { display: none; }

.desktop-dashboard .nav-button {
    flex: 0 0 auto;
    min-height: 46px;
    padding: 0 18px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--nav-text);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.desktop-dashboard .nav-button:not(:disabled):not(.active):hover {
    background: rgba(255, 255, 255, 0.12);
}

.desktop-dashboard .nav-button.active {
    background: #ffffff;
    color: var(--nav);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
}

.desktop-dashboard .nav-button:disabled {
    color: rgba(244, 248, 252, 0.45);
}

.desktop-dashboard #reportQueryButton:not(:disabled) {
    border-color: var(--brand);
    color: #ffd27a;
}

.desktop-dashboard #reportQueryButton:not(:disabled):hover {
    background: var(--brand);
    color: var(--nav);
}

.desktop-dashboard .account-tools {
    display: flex;
    align-items: center;
    gap: 12px;
}

.desktop-dashboard .account-name {
    max-width: 14em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.05rem;
    font-weight: 800;
}

.desktop-dashboard .logout-button {
    min-height: 44px;
    padding: 0 18px;
    border: 2px solid rgba(255, 255, 255, 0.55);
    border-radius: 12px;
    background: transparent;
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
}

.desktop-dashboard .logout-button:hover { background: rgba(255, 255, 255, 0.14); }

/* 主要版面：左列表 + 右地圖 */
.desktop-dashboard .dashboard-main {
    display: grid;
    grid-template-columns: clamp(300px, 23vw, 380px) minmax(0, 1fr);
    min-height: 0;
}

.desktop-dashboard .vehicle-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    padding: 12px 10px 10px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 10px rgba(16, 38, 63, 0.06);
    z-index: 2;
}

.desktop-dashboard .panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.desktop-dashboard .eyebrow {
    display: block;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.desktop-dashboard .panel-heading h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 900;
    line-height: 1.25;
}

.desktop-dashboard .icon-button {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 1.5rem;
    font-weight: 900;
}

.desktop-dashboard .icon-button:hover:not(:disabled) { border-color: var(--primary); }
.desktop-dashboard .icon-button:disabled { opacity: 0.55; }
.desktop-dashboard .icon-button.loading { animation: ciot-spin 0.9s linear infinite; }

@keyframes ciot-spin { to { transform: rotate(360deg); } }

/* 篩選列：與車輛卡片對齊的三欄 */
.desktop-dashboard .vehicle-filter-grid,
.desktop-dashboard .vehicle-card {
    grid-template-columns: 38px 4em minmax(0, 1fr);
    column-gap: 6px;
}

.desktop-dashboard .vehicle-filter-grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    display: grid;
    row-gap: 4px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.desktop-dashboard .vehicle-filter-grid .filter-icon-spacer { display: none; }

.desktop-dashboard .filter-sort {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 34px;
    padding: 0 5px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 1rem;
    font-weight: 800;
    text-align: left;
}

.desktop-dashboard .filter-sort:hover { background: var(--slate-soft); }
.desktop-dashboard .filter-sort.active { color: var(--primary-strong); background: var(--primary-soft); }
.desktop-dashboard .sort-arrow { font-size: 0.8rem; }

.desktop-dashboard .vehicle-filter-grid input {
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 0 5px;
    border: 2px solid var(--border-strong);
    border-radius: 10px;
    background: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.desktop-dashboard .vehicle-filter-grid input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(11, 92, 173, 0.18);
}

.desktop-dashboard .list-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 4px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--muted);
}

.desktop-dashboard #vehicleCount { color: var(--text); font-weight: 800; }

.desktop-dashboard .countdown-button {
    min-height: 40px;
    padding: 0 14px;
    border: 2px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.98rem;
    font-weight: 700;
}

.desktop-dashboard .countdown-button b { color: var(--primary); font-size: 1.1rem; }
.desktop-dashboard .countdown-button.paused { background: var(--amber-soft); border-color: #e9c27a; color: var(--amber); }
.desktop-dashboard .countdown-button.paused b { color: var(--amber); }
.desktop-dashboard .countdown-button:disabled { opacity: 0.7; }

/* 車輛列表 */
.desktop-dashboard .vehicle-list {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-right: -6px;
    padding: 2px 6px 8px 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.desktop-dashboard .vehicle-card {
    display: grid;
    align-items: center;
    flex: 0 0 auto;
    width: 100%;
    min-height: 50px;
    padding: 3px 6px;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    text-align: left;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.desktop-dashboard .vehicle-card:hover { background: var(--primary-soft); }

.desktop-dashboard .vehicle-card.selected {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: inset 5px 0 0 var(--primary);
}

.desktop-dashboard .vehicle-card-icon {
    display: block;
    width: 38px;
    height: 38px;
    object-fit: contain;
}

.desktop-dashboard .vehicle-card-number {
    font-size: 0.98rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: var(--primary-strong);
    overflow-wrap: anywhere;
}

.desktop-dashboard .vehicle-card-name {
    font-size: 1.04rem;
    font-weight: 800;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.desktop-dashboard .loading-state {
    padding: 28px 12px;
    text-align: center;
    color: var(--muted);
    font-size: 1.05rem;
    font-weight: 700;
}

/* 地圖與車輛明細 */
.desktop-dashboard .map-panel {
    position: relative;
    min-width: 0;
    min-height: 0;
}

.desktop-dashboard #map {
    position: absolute;
    inset: 0;
    background: #dfe6ee;
}

.desktop-dashboard .vehicle-detail {
    position: absolute;
    z-index: 700;
    top: 16px;
    left: 16px;
    width: clamp(340px, 28vw, 440px);
    max-height: calc(100% - 32px);
    overflow-y: auto;
    padding: 18px 20px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-lg);
}

.desktop-dashboard .detail-empty {
    display: none;
    padding: 6px 2px;
    color: var(--muted);
    font-size: 1.15rem;
    font-weight: 800;
}

.desktop-dashboard .vehicle-detail.is-empty { width: auto; }
.desktop-dashboard .vehicle-detail.is-empty .detail-empty { display: block; }
.desktop-dashboard .vehicle-detail.is-empty .detail-content { display: none; }

.desktop-dashboard .detail-topline h2 {
    margin: 0;
    font-size: 1.65rem;
    font-weight: 900;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.desktop-dashboard .detail-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-top: 6px;
    font-weight: 700;
}

.desktop-dashboard #detailNumber {
    padding: 2px 10px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 1.05rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.desktop-dashboard #detailVersion { color: var(--muted); font-size: 0.95rem; }

.desktop-dashboard .detail-grid {
    display: grid;
    margin: 14px 0 0;
    border-top: 1px solid var(--border);
}

.desktop-dashboard .detail-grid > div {
    display: grid;
    grid-template-columns: 5.6em minmax(0, 1fr);
    gap: 10px;
    align-items: baseline;
    padding: 7px 2px;
    border-bottom: 1px solid #e6ebf1;
}

.desktop-dashboard .detail-grid dt {
    color: var(--muted);
    font-size: 1rem;
    font-weight: 700;
}

.desktop-dashboard .detail-grid dd {
    margin: 0;
    font-size: 1.12rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.desktop-dashboard .detail-state-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
}

.desktop-dashboard .detail-state-row > span {
    color: var(--muted);
    font-size: 1rem;
    font-weight: 700;
}

.desktop-dashboard .detail-address {
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px solid var(--addr-border);
    border-radius: var(--radius-md);
    background: var(--addr-bg);
}

.desktop-dashboard .detail-address strong {
    display: block;
    color: var(--addr-text);
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

/* ---------- 車輛資訊卡：緊湊版（讓地圖露出更多） ---------- */
.desktop-dashboard .vehicle-detail {
    top: 10px;
    left: 10px;
    width: max-content;                        /* 寬度依內容決定，右側不留多餘空白 */
    min-width: 280px;
    max-width: min(460px, calc(100% - 20px));
    max-height: calc(100% - 20px);
    padding: 8px 10px 10px;
    border-radius: 14px;
}

.desktop-dashboard .detail-topline h2 { font-size: 1.4rem; line-height: 1.2; }
.desktop-dashboard .detail-meta-row { margin-top: 3px; gap: 4px 10px; }
.desktop-dashboard #detailNumber { padding: 0 8px; font-size: 1rem; }
.desktop-dashboard #detailVersion { font-size: 0.9rem; }

/* 短欄位左右兩欄並排；定位狀態、時間、參數設定這類長內容佔整行 */
.desktop-dashboard .detail-grid {
    grid-template-columns: auto auto;
    justify-content: start;
    column-gap: 14px;
    margin-top: 6px;
}

/* 標題與地址不撐寬卡片，跟著表格寬度自動換行 */
.desktop-dashboard .detail-topline,
.desktop-dashboard .detail-address {
    width: 0;
    min-width: 100%;
}

/* 每一格的欄名都用同一個寬度，左欄與右欄的值各自上下對齊 */
.desktop-dashboard .detail-grid > div {
    grid-template-columns: 3.8em minmax(0, 1fr);
    gap: 4px;
    padding: 3px 0;
}

.desktop-dashboard .detail-grid > div:has(#detailGpsState),
.desktop-dashboard .detail-grid > div:has(#detailGpsDate),
.desktop-dashboard .detail-grid > div:has(#detailReceiveDate),
.desktop-dashboard .detail-grid > div:has(#detailParameterSetting) {
    grid-column: 1 / -1;
    grid-template-columns: 3.8em minmax(0, 1fr);
}

.desktop-dashboard .detail-grid dt { font-size: 0.88rem; white-space: nowrap; }
.desktop-dashboard .detail-grid dd { font-size: 1.04rem; line-height: 1.4; }

.desktop-dashboard .detail-state-row { margin-top: 6px; }
.desktop-dashboard .detail-state-row > span { font-size: 0.92rem; }
.desktop-dashboard .detail-state-row .state-badge { padding: 1px 12px; font-size: 1rem; }

.desktop-dashboard .detail-address { margin-top: 6px; padding: 6px 10px; border-radius: 10px; }
.desktop-dashboard .detail-address strong { font-size: 1.05rem; line-height: 1.4; }

@media (max-width: 900px) {
    .desktop-dashboard .vehicle-detail { width: min(320px, calc(100% - 20px)); }
}

/* 車輛狀態標籤 */
.state-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 999px;
    background: var(--slate-soft);
    color: var(--slate);
    font-size: 1.1rem;
    font-weight: 900;
    letter-spacing: 0.06em;
}

.state-badge::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
}

.state-badge.moving { background: var(--green-soft); color: var(--green); }
.state-badge.parked { background: var(--amber-soft); color: var(--amber); }
.state-badge.off { background: var(--slate-soft); color: var(--slate); }

/* 更新狀態提示（由 refresh-request.js 建立） */
.desktop-dashboard #ciotRefreshStatus {
    right: 70px !important;
    bottom: 14px !important;
    padding: 6px 14px !important;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96) !important;
    box-shadow: var(--shadow-md);
    font-size: 14px !important;
    font-weight: 700;
}

/* 報表查詢視窗 */
.desktop-dashboard .report-dialog {
    position: fixed;
    inset: 0;
    z-index: 4500;
    display: grid;
    padding: 20px;
    background: rgba(10, 22, 38, 0.6);
}

.desktop-dashboard .report-dialog-card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1500px;
    height: 100%;
    margin: 0 auto;
    padding-top: 58px;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: var(--nav);
    box-shadow: var(--shadow-lg);
}

.desktop-dashboard .report-dialog-card::before {
    content: "報表查詢・行車軌跡";
    position: absolute;
    top: 0;
    left: 20px;
    height: 58px;
    display: flex;
    align-items: center;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.desktop-dashboard .report-frame {
    flex: 1;
    width: 100%;
    border: 0;
    background: var(--bg);
}

.desktop-dashboard .report-close-button {
    position: absolute;
    z-index: 2;
    top: 8px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    background: transparent;
    color: #fff;
    font-size: 1.7rem;
    line-height: 1;
}

.desktop-dashboard .report-close-button:hover { background: rgba(255, 255, 255, 0.15); }

/* 較窄的電腦視窗 */
@media (max-width: 1180px) {
    .desktop-dashboard .app-header { gap: 12px; padding: 0 14px; }
    .desktop-dashboard .brand-block small { display: none; }
    .desktop-dashboard .nav-button { padding: 0 12px; font-size: 1rem; }
    .desktop-dashboard .main-nav { justify-content: flex-start; }
}

@media (max-width: 900px) {
    .desktop-dashboard .brand-block strong { display: none; }
    .desktop-dashboard .account-name { display: none; }
    .desktop-dashboard .dashboard-main { grid-template-columns: 280px minmax(0, 1fr); }
    .desktop-dashboard .vehicle-detail { top: 12px; left: 12px; width: min(330px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 14px 16px; }

    /* 窄視窗：編號與名稱上下排列，避免名稱被擠成一字一行 */
    .desktop-dashboard .vehicle-filter-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .desktop-dashboard .filter-icon-spacer { display: none; }
    .desktop-dashboard .vehicle-card {
        grid-template-columns: 44px minmax(0, 1fr);
        grid-template-areas: "icon num" "icon name";
        row-gap: 0;
    }
    .desktop-dashboard .vehicle-card-icon { grid-area: icon; width: 42px; height: 42px; }
    .desktop-dashboard .vehicle-card-number { grid-area: num; font-size: 0.95rem; }
    .desktop-dashboard .vehicle-card-name { grid-area: name; }
}

/* ==========================================================================
   內頁共用（軌跡查詢 Trajectory、軌跡結果 trmap、單車地圖 map、訊息 message）
   ========================================================================== */
body.detail-page {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: var(--bg);
}

.detail-panel {
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 20px;
    background: linear-gradient(100deg, var(--nav) 0%, var(--nav-2) 100%);
    color: var(--nav-text);
}

.detail-title-block { flex: 1 1 auto; min-width: 0; }

.detail-title {
    font-size: 1.45rem;
    font-weight: 900;
    line-height: 1.35;
    letter-spacing: 0.03em;
    overflow-wrap: anywhere;
}

.detail-subtitle {
    margin-top: 4px;
    color: var(--nav-muted);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
}

.detail-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 10px;
}

.detail-header .secondary-button {
    border-color: rgba(255, 255, 255, 0.75);
    background: #fff;
    color: var(--nav);
}

.detail-header .secondary-button:hover { background: var(--primary-soft); }

.detail-body {
    display: grid;
    gap: 16px;
    padding: 20px;
}

.detail-card {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.info-text { font-size: 1.15rem; font-weight: 700; line-height: 1.8; }

.detail-note {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.6;
}

/* 軌跡查詢表單 */
.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
}

.field-group { display: grid; gap: 8px; }

.field-label {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
}

.field-control {
    width: 100%;
    min-height: 56px;
    padding: 0 14px;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.field-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(11, 92, 173, 0.18);
}

.field-actions { margin-top: 18px; }

.field-actions .primary-button {
    width: 100%;
    min-height: 58px;
    font-size: 1.25rem;
}

/* 地址橫幅 */
.address-banner {
    padding: 12px 16px;
    border: 1px solid var(--addr-border);
    border-radius: var(--radius-md);
    background: var(--addr-bg);
    color: var(--addr-text);
    font-size: 1.12rem;
    font-weight: 800;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.address-cell-loading { color: var(--muted) !important; }
.hiddenColumn { display: none; }

/* ---------- 單車地圖 map.aspx ---------- */
.map-detail-panel { max-width: 1280px; }

.detail-stack { gap: 14px; }

.map-card { padding: 6px; }

.map-compact-page .detail-map {
    height: clamp(300px, 55vh, 640px);
    height: clamp(300px, 55dvh, 640px);
    border-radius: 12px;
}

.map-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}

.metric-pill {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 1.08rem;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.meta-pill,
.countdown-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 5em;
    padding: 0 14px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 999px;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
}

/* ---------- 軌跡結果 trmap.aspx ---------- */
body.trajectory-fixed-page {
    height: 100vh;
    height: var(--app-height);
    min-height: 0;
    padding: 0;
    overflow: hidden;
}

.trajectory-fixed-page > form { height: 100%; }

.trajectory-fixed-page .trajectory-result-panel {
    display: flex;
    flex-direction: column;
    max-width: none;
    height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: var(--bg);
}

.trajectory-fixed-page .detail-header { padding: 10px 18px; }

.trajectory-fixed-page .detail-title {
    font-size: 1.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trajectory-result-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(360px, 32vw, 500px);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
        "map nav"
        "map list";
    gap: 12px;
    padding: 12px;
}

.trajectory-map-shell {
    grid-area: map;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.trajectory-fixed-page .map-card-tight {
    position: relative;
    flex: 1 1 auto;
    min-height: 260px;
    padding: 0;
    overflow: hidden;
}

.trajectory-fixed-page .detail-map {
    position: absolute;
    inset: 0;
    height: auto !important;
}

.touch-track-nav {
    grid-area: nav;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.touch-track-nav button {
    flex: 1;
    min-height: 50px;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--primary-strong);
    font-size: 1.05rem;
    font-weight: 800;
}

.touch-track-nav button:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
.touch-track-nav button:disabled { opacity: 0.45; }

.touch-track-nav span {
    flex: 0 0 auto;
    min-width: 5.5em;
    text-align: center;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.trajectory-list-shell {
    grid-area: list;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 2px 4px 8px 2px;
}

.trajectory-list-shell:focus { outline: none; }
.trajectory-list-shell:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 12px; }

.trajectory-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.trajectory-row { cursor: pointer; }

.trajectory-card-cell {
    padding: 8px 12px;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.12s ease, background-color 0.12s ease;
}

.trajectory-row:hover .trajectory-card-cell { border-color: #b9cfe8; }

.trajectory-row.selected-row .trajectory-card-cell {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: inset 5px 0 0 var(--primary);
}

.trajectory-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 18px;
}

.trajectory-line + .trajectory-line { margin-top: 1px; }

.trajectory-item {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    font-size: 1.08rem;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.trajectory-label {
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 700;
}

.trajectory-address {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed var(--addr-border);
    color: var(--addr-text);
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

/* ==========================================================================
   手機 / 平板（內頁）
   ========================================================================== */
@media (max-width: 900px), (pointer: coarse) and (max-width: 1100px) {
    .trajectory-result-body {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto minmax(0, 1fr);
        grid-template-areas:
            "map"
            "nav"
            "list";
        gap: 10px;
        padding: 10px;
    }

    .trajectory-fixed-page .map-card-tight {
        flex: 0 0 auto;
        height: clamp(200px, 34vh, 380px);
        height: clamp(200px, 34dvh, 380px);
        min-height: 0;
    }

    .trajectory-fixed-page .address-banner {
        max-height: 4.8em;
        overflow-y: auto;
        padding: 8px 12px;
        font-size: 1.02rem;
    }
}

@media (max-width: 640px) {
    body.detail-page:not(.trajectory-fixed-page) { padding: 0; }

    .detail-page:not(.trajectory-fixed-page) .detail-panel {
        min-height: 100vh;
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .detail-header {
        padding: 12px 14px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .detail-title { font-size: 1.25rem; }
    .detail-subtitle { font-size: 0.95rem; }
    .detail-body { padding: 14px; gap: 12px; }
    .detail-card { padding: 14px; }
    .field-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }

    .detail-actions .detail-button,
    .detail-actions .secondary-button {
        min-height: 46px;
        padding: 0 14px;
        font-size: 1rem;
    }

    .trajectory-fixed-page .detail-header { padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
    .trajectory-fixed-page .detail-title { font-size: 1.15rem; }
    .trajectory-item { font-size: 1.02rem; }
    .trajectory-line { gap: 2px 14px; }

    .map-compact-page .detail-map { height: clamp(260px, 50dvh, 520px); }
    .map-action-row { gap: 8px; }
}

/* 橫向的手機（高度很矮）：整頁可捲動，避免地圖與列表都被壓扁 */
@media (max-height: 520px) and (pointer: coarse) {
    body.trajectory-fixed-page { height: auto; overflow: auto; }
    .trajectory-fixed-page > form,
    .trajectory-fixed-page .trajectory-result-panel { height: auto; }
    .trajectory-fixed-page .map-card-tight { height: 70vh; }
    .trajectory-list-shell { height: 70vh; flex: none; }
}

/* 報表視窗開啟時，隱藏右下角的更新狀態提示 */
body:has(.report-dialog:not([hidden])) #ciotRefreshStatus { display: none !important; }
