:root {
  color-scheme: dark;
  --ink: #f5f5f7;
  --ink-2: #e5e5e9;
  --muted: #b4b4bf;
  --line: #414149;
  --surface: #24252b;
  --canvas: #18191d;
  --accent: #d92736;
  --accent-dark: #ff858d;
  --danger: #ff858d;
  --warning: #e69222;
  --success: #26965c;
  --sidebar: 288px;
  --shadow: 0 18px 50px rgba(0,0,0,.22);
  --radius: 18px;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-family: "Montserrat", "Segoe UI", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.sr-only { position: absolute!important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; width: var(--sidebar); padding: 28px 18px 18px; display: flex; flex-direction: column; overflow-y: auto; background: #131417; color: #fff; border-right: 1px solid var(--line); }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 0 0 26px; }
.brand-link { display: block; max-width: 100%; text-decoration: none; }
.brand-image { display: inline-flex; vertical-align: middle; width: 243px; max-width: 100%; aspect-ratio: 243 / 54;  border-radius: 6px; overflow: hidden; }
.brand-image img { display: block; width: 100%; height: auto; object-fit: contain; }
.brand-wordmark { display: inline-block; max-width: 100%; padding-left: 12px; border-left: 4px solid var(--accent); color: #fff; font-size: 22px; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.brand strong { display: block; font-size: 13px; line-height: 1.3; }
.brand small, .user-meta small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.nav { display: grid; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; color: #c4c4cd; text-decoration: none; font-size: 13px; font-weight: 650; border-radius: 8px; transition: .2s ease; }
.nav a span { width: 21px; font-size: 19px; text-align: center; color: #a4a4b0; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav a.active { color: #fff; background: linear-gradient(90deg,rgba(217,39,54,.23),rgba(217,39,54,.08)); box-shadow: inset 3px 0 var(--accent); }
.nav a.active span { color: #ff858d; }
.nav-caption { padding: 22px 12px 8px; color: #a4a4b0; font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.sidebar-user { margin-top: auto; padding: 14px 8px 0; display: flex; align-items: center; gap: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #b7202e; font-size: 13px; font-weight: 800; }
.user-meta { min-width: 0; flex: 1; }
.user-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.icon-button { width: 36px; height: 36px; border: 0; color: inherit; background: transparent; cursor: pointer; font-size: 20px; border-radius: 8px; }
.icon-button:hover { background: rgba(255,255,255,.08); }
.main { margin-left: var(--sidebar); min-height: 100vh; padding: 30px clamp(20px,3vw,46px) 46px; }
.mobile-header, .sidebar-backdrop { display: none; }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 24px; }
.page-header h1 { margin: 6px 0 10px; font-size: clamp(27px,3vw,38px); line-height: 1.12; letter-spacing: -.035em; }
.page-header p { margin: 0; max-width: 720px; color: var(--muted); font-size: 14px; }
.eyebrow { color: var(--accent-dark); font-size: 10px; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.stat-row { display: flex; gap: 10px; }
.stat { min-width: 96px; padding: 12px 15px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.stat strong { display: block; font-size: 22px; line-height: 1; }
.stat span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.stat-danger strong { color: var(--danger); }
.flash { position: relative; z-index: 100; margin: 0 0 18px; padding: 13px 16px; border: 1px solid; color: var(--ink); background: var(--surface); font-size: 13px; box-shadow: 0 8px 30px rgba(13,24,35,.07); }
.flash-success { color: #17673e; border-color: #b9dfc9; background: #effaf4; }
.flash-error { color: #9e2530; border-color: #f0bdc2; background: #fff1f2; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 9px; text-decoration: none; font-size: 12px; font-weight: 800; cursor: pointer; transition: transform .15s ease,background .15s ease,border-color .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--accent); box-shadow: 0 8px 22px rgba(217,39,54,.18); }
.button-primary:hover { background: #bc1e2c; }
.button-dark { color: #fff; background: #b7202e; }
.button-dark:hover { background: #981b26; }
.button-ghost { color: var(--ink-2); background: #303138; border-color: #575762; }
.button-ghost:hover { background: #3b3c45; }
.button-danger { color: #a71d2a; background: #fff2f3; border-color: #f1c4c8; }
.button-wide { width: 100%; }
.button-small { min-height: 34px; padding: 0 12px; font-size: 11px; }
.filter-panel { margin-bottom: 14px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.filter-grid { display: grid; grid-template-columns: minmax(220px,1.8fr) repeat(4,minmax(125px,1fr)) auto auto; gap: 8px; }
input,select,textarea { width: 100%; min-width: 0; color: var(--ink); background: #1c1d22; border: 1px solid #656570; border-radius: 8px; outline: 0; transition: border .15s,box-shadow .15s; }
input::placeholder,textarea::placeholder { color: #ababba; opacity: 1; }
input,select { min-height: 42px; padding: 0 12px; }
textarea { padding: 12px; resize: vertical; }
input:focus,select:focus,textarea:focus { border-color: #ff858d; box-shadow: 0 0 0 3px rgba(217,39,54,.24); }
.search-field { position: relative; }
.search-field input { padding-right: 38px; }
.search-field b { position: absolute; top: 10px; right: 13px; color: var(--muted); font-size: 20px; }
.map-workspace { height: calc(100vh - 215px); min-height: 590px; display: grid; grid-template-columns: minmax(0,1fr) 350px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.map-panel { position: relative; min-width: 0; }
.map-canvas { width: 100%; height: 100%; min-height: 460px; background: #2b2c32; color: #202126; color-scheme: light; }
.map-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--muted); text-align: center; background: linear-gradient(135deg,#202126,#303139); }
.map-loading b { color: var(--ink); font-size: 15px; }
.map-loading small { font-size: 11px; }
.spinner { width: 34px; height: 34px; border: 3px solid #565661; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.map-message { max-width: 390px; margin: 16px; padding: 24px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); text-align: center; }
.map-message h3 { margin: 0 0 7px; }
.map-message p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.map-legend { position: absolute; left: 14px; bottom: 14px; z-index: 5; display: flex; gap: 12px; padding: 9px 12px; color: #536371; background: rgba(255,255,255,.94); border: 1px solid rgba(197,210,219,.9); box-shadow: 0 7px 25px rgba(13,24,35,.11); font-size: 9px; font-weight: 700; }
.map-legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot-planned { background: #168dc2; }.dot-progress { background: #e69222; }.dot-overdue { background: #dc3545; }.dot-completed { background: #26965c; }
.visit-list-panel { min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: #212228; }
.map-panel,.visit-list-panel { min-height:0; }
.visit-list-panel { overflow:hidden; }
.visit-list-panel > .panel-heading { flex:0 0 auto; }
.visit-list { flex:1 1 auto; }
.map-message .button { margin-top:16px; }
.panel-heading { min-height: 77px; padding: 16px 18px 13px; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #292a31; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 2px 0 0; font-size: 19px; letter-spacing: -.03em; }
.count-badge { display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; color: #fff; background: #b7202e; border-radius: 8px; font-size: 11px; font-weight: 850; }
.visit-list { min-height: 0; overflow: auto; }
.visit-card { width: 100%; display: block; padding: 16px 18px; color: inherit; background: transparent; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; transition: background .15s; overflow-wrap: anywhere; }
.visit-card:hover,.visit-card.active { background: #303139; box-shadow: inset 3px 0 var(--accent); }
.visit-card-top { display: flex; justify-content: space-between; gap: 10px; }
.visit-card-title { font-size: 12px; font-weight: 850; line-height: 1.35; }
.visit-card-time { color: var(--ink); font-size: 10px; font-weight: 850; white-space: nowrap; }
.visit-card-company { margin: 7px 0 5px; color: #dedee5; font-size: 11px; font-weight: 700; }
.visit-card-address { display: flex; gap: 5px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.visit-card-footer { margin-top: 11px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.engineer-tag { display: inline-flex; align-items: center; gap: 5px; color: #c4c4ce; font-size: 9px; font-weight: 750; }
.engineer-tag:before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.status-chip { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; color: #536371; background: #edf2f5; border: 1px solid #d9e2e8; font-size: 9px; font-weight: 850; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.status-planned { color: #08729a; background: #e8f7fd; border-color: #b9e3f2; }
.status-in_progress,.status-running { color: #a55d00; background: #fff4df; border-color: #edd49d; }
.status-overdue,.status-failed,.status-cancelled { color: #a92531; background: #fff0f1; border-color: #efc2c6; }
.status-completed,.status-success,.status-sent,.status-active { color: #197344; background: #ebf8f1; border-color: #bce1cc; }
.status-deferred { color: #6b5aa0; background: #f3efff; border-color: #d9cdf7; }
.status-muted,.status-queued { color: #667586; background: #f0f3f5; }
.list-skeleton { height: 118px; margin: 1px 0; background: linear-gradient(100deg,#25262c 20%,#363740 35%,#25262c 50%); background-size: 300% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position-x: -100%; } }
.empty-list { padding: 50px 24px; color: var(--muted); text-align: center; font-size: 12px; line-height: 1.6; }
.map-marker { position: relative; width: 34px; height: 42px; display: grid; place-items: center; color: #fff; background: #168dc2; border: 3px solid #fff; border-radius: 50% 50% 50% 7px; transform: rotate(-45deg); box-shadow: 0 7px 18px rgba(13,24,35,.28); cursor: pointer; }
.map-marker span { transform: rotate(45deg); font-size: 10px; font-weight: 900; }
.map-marker.status-overdue { background: #dc3545; }.map-marker.status-in_progress { background: #e69222; }.map-marker.status-completed { background: #26965c; }.map-marker.status-deferred { background: #7562af; }.map-marker.status-cancelled { background: #7c8993; }
.cluster-marker { width: 43px; height: 43px; display: grid; place-items: center; color: #fff; background: var(--accent); border: 4px solid rgba(255,255,255,.9); border-radius: 50%; box-shadow: 0 7px 22px rgba(13,24,35,.28); font-size: 11px; font-weight: 900; cursor: pointer; }
.detail-sheet { position: fixed; z-index: 80; top: 0; right: 0; width: min(470px,100%); height: 100vh; padding: 28px; overflow: auto; background: var(--surface); box-shadow: -20px 0 60px rgba(0,0,0,.4); transform: translateX(105%); transition: transform .26s ease; }
.detail-open .detail-sheet { transform: translateX(0); }
.detail-backdrop { position: fixed; z-index: 70; inset: 0; pointer-events: none; opacity: 0; background: rgba(5,14,21,.42); transition: opacity .2s; }
.detail-open .detail-backdrop { pointer-events: auto; opacity: 1; }
.detail-close { position: absolute; top: 18px; right: 18px; width: 44px; height: 44px; border: 1px solid #656570; color: var(--ink); background: #303138; border-radius: 50%; font-size: 22px; cursor: pointer; }
.detail-header { padding: 20px 48px 20px 0; border-bottom: 1px solid var(--line); }
.detail-header h2 { margin: 8px 0 6px; font-size: 24px; line-height: 1.15; letter-spacing: -.035em; }
.detail-header p { margin: 0; color: var(--muted); font-size: 12px; }
.detail-section { padding: 19px 0; border-bottom: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 12px; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.detail-item small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.detail-item b,.detail-item span { display: block; font-size: 12px; line-height: 1.45; }
.detail-item-wide { grid-column: 1/-1; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 20px; }
.admin-card { min-width: 0; margin-bottom: 18px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 0 0 3px; font-size: 18px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.settings-grid,.user-form,.edit-visit-form { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.field { display: block; min-width: 0; }
.field > span { display: block; margin-bottom: 6px; color: #dedee5; font-size: 12px; font-weight: 750; }
.field > small { display: block; margin-top: 6px; color: var(--muted); font-family: ui-monospace,SFMono-Regular,Consolas,monospace; font-size: 10px; overflow-wrap: anywhere; }
.field-wide { grid-column: 1/-1; }
.switch-row { min-height: 67px; padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #1c1d22; border: 1px solid var(--line); border-radius: 8px; }
.switch-row span b,.switch-row span small { display: block; }
.switch-row span b { font-size: 11px; }.switch-row span small { margin-top: 3px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.switch-row input { position: absolute; opacity: 0; width: 1px; }
.switch-row i { position: relative; width: 40px; height: 22px; flex: none; background: #696975; border-radius: 12px; cursor: pointer; transition: .2s; }
.switch-row i:after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.switch-row input:checked + i { background: var(--accent); }.switch-row input:checked + i:after { transform: translateX(18px); }
.sticky-actions { position: sticky; bottom: 12px; z-index: 10; padding: 12px; display: flex; justify-content: end; background: rgba(36,37,43,.95); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(10px); box-shadow: 0 12px 36px rgba(0,0,0,.2); }
.test-grid { display: flex; flex-wrap: wrap; gap: 8px; }
details summary { cursor: pointer; list-style: none; } details summary::-webkit-details-marker { display: none; }
.create-user summary,.user-card summary { display: flex; align-items: center; gap: 12px; }
.create-user summary { justify-content: space-between; }.create-user summary b,.create-user summary small { display: block; }.create-user summary small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.create-user[open] summary,.user-card[open] summary { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 42px; font-size: 11px; font-weight: 700; }
.check-row input { width: 17px; min-height: 17px; accent-color: var(--accent); }
.form-actions { display: flex; align-items: end; gap: 8px; }
.user-cards { display: grid; gap: 10px; }
.user-card { margin-bottom: 0; }
.user-summary { min-width: 0; flex: 1; }.user-summary b,.user-summary small { display: block; }.user-summary small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.danger-action { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.admin-search { max-width: 680px; margin-bottom: 18px; display: flex; gap: 8px; }
.data-table-wrap { width: 100%; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.data-table th { padding: 10px 12px; color: #c4c4ce; background: #1c1d22; border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.data-table td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tbody tr:hover { background: #2c2d35; }
.data-table td b,.data-table td small { display: block; }.data-table td small { margin-top: 4px; max-width: 390px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.data-table code { max-width: 360px; display: block; overflow-wrap: anywhere; font-size: 9px; }
.empty-cell { padding: 40px!important; color: var(--muted); text-align: center; }
.back-link { color: var(--accent-dark); font-size: 11px; font-weight: 800; text-decoration: none; }
.source-banner { margin-bottom: 20px; padding: 15px; background: #352328; border-left: 3px solid var(--accent); }
.source-banner span,.source-banner b,.source-banner small { display: block; }.source-banner span { color: var(--accent-dark); font-size: 9px; font-weight: 850; text-transform: uppercase; }.source-banner b { margin: 5px 0; font-size: 12px; }.source-banner small { color: var(--muted); font-size: 10px; }
.empty-page { min-height: 70vh; display: grid; place-content: center; justify-items: center; text-align: center; }.empty-page h1 { margin: 16px 0 6px; }.empty-page p { color: var(--muted); }.empty-icon { width: 56px; height: 56px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 50%; font-size: 28px; font-weight: 900; }
.auth-main { min-height: 100vh; }
.login-shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0,1.2fr) minmax(380px,.8fr); }
.login-visual { position: relative; min-width: 0; min-height: 660px; overflow: hidden; padding: clamp(32px,5vw,80px); display: flex; flex-direction: column; justify-content: space-between; gap: 80px; color: #fff; background-color: #16171b; background-image: linear-gradient(135deg,#303138,#16171b 70%); background-size: cover; background-position: center; }
/* banner.png is optional and always resolves relative to this stylesheet. */
.login-visual.has-login-banner { background-image: linear-gradient(180deg,rgba(14,15,18,.24),rgba(14,15,18,.55) 45%,rgba(14,15,18,.94)),url("banner.png"); }
.login-visual:after { content: ''; position: absolute; bottom: 0; left: 0; width: 110px; height: 5px; background: var(--accent); }
.login-brand,.login-message { position: relative; z-index: 1; }
.login-message { max-width: 720px; }
.login-visual .eyebrow { color: #fff; font-weight: 700; }
.login-visual .eyebrow:before { content: ''; display: inline-block; width: 26px; height: 3px; margin-right: 10px; background: #ff5764; vertical-align: middle; }
.login-visual h1 { margin: 18px 0 22px; font-size: clamp(38px,4.8vw,76px); line-height: 1.04; letter-spacing: -.04em; overflow-wrap: anywhere; }
.login-visual p { max-width: 490px; margin: 0; color: #e0e0e7; font-size: 15px; line-height: 1.8; }
.login-card { min-width: 0; padding: clamp(32px,5vw,80px); display: flex; flex-direction: column; justify-content: center; background: #202126; border-left: 1px solid var(--line); }
.login-form-brand { max-width: 100%; margin-bottom: 48px; }
.login-card h2 { margin: 0 0 12px; font-size: clamp(25px,2.2vw,34px); line-height: 1.2; letter-spacing: -.035em; }
.login-card > p { margin: 0 0 32px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.stack-form { display: grid; gap: 20px; }
.stack-form label { min-width: 0; }
.stack-form label span { display: block; margin-bottom: 8px; color: #dedee5; font-size: 12px; font-weight: 700; }
.stack-form input { height: 50px; }
.stack-form .button { min-height: 50px; margin-top: 5px; font-size: 14px; }
.security-note { margin-top: 28px; color: var(--muted); text-align: center; font-size: 9px; line-height: 1.8; text-transform: uppercase; letter-spacing: .09em; }
.auth-main > .flash { margin: 0; }
@media (min-width: 961px) {
  .map-workspace { grid-template-rows:minmax(0,1fr); }
  .map-panel > .map-canvas { position:absolute; inset:0; min-height:0; }
}
@media (max-width: 1280px) {
  .filter-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .map-workspace { grid-template-columns: minmax(0,1fr) 320px; }
  .settings-grid,.user-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 960px) {
  .mobile-header { position: sticky; top: 0; z-index: 45; height: 64px; padding: 0 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; color: #fff; background: #131417; border-bottom: 1px solid var(--line); }
  .mobile-brand { min-width: 0; max-width: 190px; text-decoration: none; }
  .mobile-brand .brand-image { width: 170px; }
  .mobile-brand .brand-wordmark { font-size: 15px; }
  .mobile-header .icon-button { flex: none; }
  .sidebar { transform: translateX(-105%); transition: transform .22s ease; }.menu-open .sidebar { transform: translateX(0); }.sidebar-backdrop { position: fixed; z-index: 49; inset: 0; display: block; pointer-events: none; opacity: 0; background: rgba(5,13,20,.45); transition: opacity .2s; }.menu-open .sidebar-backdrop { pointer-events:auto; opacity:1; }
  .main { margin-left: 0; padding: 22px 18px 35px; }.page-header { align-items: start; }.page-header h1 { font-size: 30px; }
  .map-workspace { height: auto; min-height: 0; grid-template-columns: 1fr; }.map-canvas { height: 55vh; min-height: 430px; }.visit-list-panel { max-height: 520px; border: 0; border-top: 1px solid var(--line); }
  .filter-grid { grid-template-columns: 1fr 1fr 1fr auto; }.filter-grid .search-field { grid-column: 1/-1; }.filter-grid label:nth-of-type(5) { display:block; }
  .map-page-header { align-items: end; }.stat-row { flex-wrap: wrap; }.stat { min-width: 80px; }
  .login-shell { grid-template-columns: minmax(0,1fr); }
  .login-visual { min-height: 320px; padding: 32px max(28px,calc((100vw - 600px)/2)); gap: 44px; background-position: center 40%; }
  .login-visual h1 { font-size: 42px; }
  .login-card { min-height: 0; width: 100%; padding: 40px max(28px,calc((100vw - 600px)/2)) 48px; border-left: 0; }
  .login-form-brand { margin-bottom: 28px; }
}
@media (max-width: 640px) {
  .main { padding: 18px 12px 30px; }.page-header { display:block; margin-bottom:18px; }.page-header p { font-size:12px;line-height:1.5; }.page-header > form { margin-top:14px; }.map-page-header .stat-row { margin-top:14px; }.stat { flex:1; padding:10px; }.stat strong { font-size:18px; }
  .filter-panel { padding:8px; }.filter-grid { grid-template-columns: 1fr 1fr; }.filter-grid .search-field { grid-column:1/-1; }.filter-grid .button { min-height:44px; }
  .map-canvas { height: 48vh; min-height: 360px; }.map-legend { left:8px;right:8px;bottom:8px;flex-wrap:wrap;justify-content:center;gap:7px 12px; }.visit-list-panel { max-height: 52vh; }
  .detail-sheet { top:auto;bottom:0;height:min(86vh,760px);width:100%;padding:22px 18px;border-radius:18px 18px 0 0;transform:translateY(105%); }.detail-open .detail-sheet { transform:translateY(0); }.detail-grid { grid-template-columns:1fr; }.detail-item-wide { grid-column:auto; }
  .admin-card { padding:16px; }.settings-grid,.user-form,.edit-visit-form { grid-template-columns:1fr; }.field-wide { grid-column:auto; }.sticky-actions { bottom:6px; }.sticky-actions .button { width:100%; }.test-grid { display:grid;grid-template-columns:1fr 1fr; }.test-grid .button { width:100%;padding:0 8px; }
  .user-card summary { align-items:flex-start;flex-wrap:wrap; }.user-card .status-chip { margin-left:46px; }.admin-search { display:grid;grid-template-columns:1fr auto; }.data-table { min-width:760px; }
  .login-visual { min-height: 280px; padding: 26px 22px 32px; gap: 36px; }
  .login-visual h1 { margin: 14px 0; font-size: 34px; }
  .login-visual p { font-size: 12px; line-height: 1.7; }
  .login-card { padding: 32px 22px; }
  .login-card h2 { font-size: 27px; }
}

/* v1.1: all filters remain available on narrow screens. */
.filter-grid { grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); }
.filter-grid label { display:block; min-width:0; }
.load-status { margin:0 0 12px; color:var(--muted); font-size:13px; line-height:1.6; }
.stage-badge { display:inline-block; max-width:100%; margin-top:9px; padding:5px 8px; color:var(--stage-color,#087eaa); background:#f2f2f5; border-left:3px solid var(--stage-color,#087eaa); border-radius:0 4px 4px 0; font-size:12px; line-height:1.4; }
.map-marker { background:var(--marker-color,#087eaa); }
.visit-card-company,.visit-card-title { font-size:14px; }
.visit-card-address,.visit-card-footer { font-size:12px; line-height:1.5; }
.visit-card-top { flex-wrap:wrap; }
.coordinate-warning { display:block; color:#efba76; margin-top:8px; }
.detail-item { margin:12px 0; overflow-wrap:anywhere; }
.detail-item b { white-space:pre-wrap; font-weight:500; font-size:14px; }
.field-code { color:var(--muted); }
.task-detail { padding:12px; margin:10px 0; border:1px solid var(--line); border-radius:10px; }
.task-detail .button { margin:5px 5px 0 0; }
.task-detail h4 { margin:0 0 8px; }
.metadata-list { display:grid; grid-template-columns:minmax(120px,1fr) 2fr; gap:8px; }
.metadata-list dd { margin:0; }
.admin-card p { line-height:1.6; overflow-wrap:anywhere; }
.admin-card code { overflow-wrap:anywhere; }
.table-wrap { overflow:auto; }
.table-wrap table { border-collapse:collapse; width:100%; font-size:13px; }
.table-wrap td,.table-wrap th { padding:12px; border-bottom:1px solid var(--line); text-align:left; vertical-align:top; }
.table-wrap td small { display:block; margin-top:6px; }
.paid-confirm { display:flex; align-items:center; gap:8px; min-width:200px; margin-bottom:8px; font-size:12px; }
.paid-confirm input { width:18px; min-height:18px; }
.muted { color:var(--muted); }
button:focus-visible,a:focus-visible,summary:focus-visible { outline:3px solid #ff858d; outline-offset:3px; }
.switch-row input:focus-visible + i { outline:3px solid #ff858d; outline-offset:3px; }
.button:disabled { cursor:not-allowed; opacity:.6; transform:none; }
.visit-list,.detail-sheet { scrollbar-color:#686874 #24252b; scrollbar-width:thin; }
.detail-sheet[aria-hidden="true"] { visibility:hidden; }
.detail-sheet[aria-hidden="false"] { visibility:visible; }
.card-fields-editor { padding:20px; border:1px solid var(--line); border-radius:10px; background:#1c1d22; }
.card-fields-heading { display:flex; justify-content:space-between; align-items:flex-start; gap:20px; }
.card-fields-heading h3 { margin:0 0 8px; font-size:16px; }
.card-fields-heading p,.card-fields-editor > p { font-size:12px; line-height:1.7; }
.card-fields-heading .button { flex:none; }
.card-field-row { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto; align-items:end; gap:12px; padding:16px 0; border-top:1px solid var(--line); }
.card-field-actions { display:flex; gap:6px; }
.card-field-actions .button { min-width:42px; padding:0 12px; }
.debug-fields > summary { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:44px; font-size:13px; font-weight:700; }
.debug-toggle { flex:none; color:var(--accent-dark); font-size:12px; }
.debug-fields-body { max-height:55vh; overflow:auto; padding-right:8px; }
.debug-fields-body > p { font-size:12px; line-height:1.6; }
.sync-progress[hidden] { display:none; }
.sync-progress-heading { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.sync-progress-heading h2 { margin:0; font-size:20px; }
.sync-progress-heading strong { font-size:24px; color:var(--accent-dark); white-space:nowrap; }
.sync-progress progress { display:block; width:100%; height:12px; border:0; border-radius:20px; overflow:hidden; accent-color:var(--accent); background:#414149; }
.sync-progress progress::-webkit-progress-bar { background:#414149; border-radius:20px; }
.sync-progress progress::-webkit-progress-value { background:var(--accent); border-radius:20px; transition:width .25s; }
.sync-progress progress::-moz-progress-bar { background:var(--accent); }
.sync-counts { display:flex; flex-wrap:wrap; gap:12px 24px; margin-top:18px; font-size:12px; }
.sync-progress[data-result="failed"] [data-sync-stage] { color:var(--danger); }
.sync-progress[data-result="success"] [data-sync-stage] { color:#7bdba5; }
@media(max-width:1280px) {
  .card-field-row { grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
  .card-field-actions { grid-column:1/-1; justify-content:flex-end; }
}
@media(max-width:640px) {
  .filter-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  input,select,textarea { font-size:16px; }
  .test-grid { grid-template-columns:1fr; }
  .metadata-list { grid-template-columns:1fr; }
  .detail-sheet { height:88dvh; }
  .icon-button { width:44px; height:44px; }
  .card-fields-editor { padding:14px; }
  .card-fields-heading { flex-direction:column; gap:8px; margin-bottom:16px; }
  .card-fields-heading .button { width:100%; }
  .card-field-row { grid-template-columns:minmax(0,1fr); }
  .card-field-actions .button { min-height:44px; }
}
@media(prefers-reduced-motion:reduce) {
  *,*::before,*::after { animation:none!important; transition:none!important; scroll-behavior:auto!important; }
}
