:root {
  --ink: #17312d;
  --muted: #647a75;
  --line: #dce7e4;
  --surface: #ffffff;
  --soft: #f3f8f6;
  --accent: #0b6b5e;
  --accent-strong: #07564b;
  --accent-light: #dff3ed;
  --gold: #d89826;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 16px 44px rgba(27, 73, 65, 0.1);
  --radius: 18px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: #edf5f2;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 10% -10%, #d8eee8 0, transparent 34%), #edf5f2; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
:focus-visible { outline: 3px solid rgba(11, 107, 94, .28); outline-offset: 2px; }

.skip-link { position: fixed; left: 16px; top: -60px; z-index: 99; background: var(--ink); color: white; padding: 10px 16px; border-radius: 8px; }
.skip-link:focus { top: 12px; }

.app-header { height: 74px; padding: 0 max(24px, calc((100vw - 1440px) / 2)); display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.92); border-bottom: 1px solid rgba(170,197,190,.55); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--accent); box-shadow: 0 8px 20px rgba(11,107,94,.22); }
.brand-mark svg { width: 25px; fill: white; }
.brand strong { display: block; font-size: 18px; letter-spacing: .04em; }
.brand span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.account-name { max-width: 180px; overflow: hidden; color: var(--muted); font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.step-chip { border-radius: 999px; padding: 7px 11px; font-size: 12px; font-weight: 700; background: var(--soft); color: var(--muted); border: 1px solid var(--line); }

.page-shell { width: min(1440px, calc(100% - 48px)); margin: 28px auto 60px; }

.workspace-grid { display: grid; grid-template-columns: minmax(420px, .85fr) minmax(420px, 1.15fr); gap: 20px; align-items: stretch; }
.panel { background: var(--surface); border: 1px solid rgba(191,211,206,.75); border-radius: var(--radius); box-shadow: var(--shadow); }
.create-panel, .task-panel { padding: 26px; min-height: 560px; }
.task-panel { display: flex; flex-direction: column; }
.panel-heading, .detail-header, .results-toolbar, .dialog-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: clamp(24px, 2vw, 31px); }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
.section-intro, .dialog-intro { margin: 14px 0 24px; color: var(--muted); line-height: 1.65; font-size: 14px; }

.field { margin-bottom: 19px; }
.field label, .district-filter span { display: block; margin-bottom: 8px; color: #2f4843; font-weight: 700; font-size: 13px; }
.field-label { display: block; margin-bottom: 8px; color: #2f4843; font-weight: 700; font-size: 13px; }
.field input, .field textarea, .field select, .district-filter select { width: 100%; border: 1px solid #bfcfcb; border-radius: 11px; background: white; padding: 12px 13px; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.field textarea { min-height: 116px; resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus, .district-filter select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11,107,94,.1); outline: none; }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--danger); }
.field select:disabled { background: #f2f5f4; color: #82908d; cursor: not-allowed; }
.field-hint { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.field-error { min-height: 17px; margin: 4px 0 0; color: var(--danger); font-size: 12px; }
.compact-field { max-width: 300px; }
.limit-field { max-width: 550px; }
.limit-choice { display: flex !important; align-items: flex-start; gap: 10px; padding: 12px 13px; border: 1px solid #bfcfcb; border-radius: 11px; background: var(--soft); cursor: pointer; }
.limit-choice input { flex: 0 0 auto; width: 18px !important; height: 18px; margin: 1px 0 0; padding: 0 !important; accent-color: var(--accent); }
.limit-choice span { display: grid; gap: 3px; }
.limit-choice strong { font-size: 13px; }
.limit-choice small { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.45; }
.custom-limit { max-width: 300px; margin-top: 12px; }
.region-fieldset { min-width: 0; margin: 0 0 19px; padding: 0; border: 0; }
.region-fieldset legend { margin-bottom: 8px; color: #2f4843; font-weight: 700; font-size: 13px; }
.region-select-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.region-select-grid .field { margin-bottom: 0; }
.optional-label { color: var(--muted); font-size: 11px; font-weight: 500; }
.scope-summary { margin: 10px 0 0; padding: 9px 11px; border-radius: 9px; background: #eef7f4; color: #315a52; font-size: 12px; line-height: 1.45; }
.number-control { display: flex; align-items: center; }
.number-control input { border-radius: 11px 0 0 11px; }
.number-control span { align-self: stretch; min-width: 48px; display: grid; place-items: center; border: 1px solid #bfcfcb; border-left: 0; border-radius: 0 11px 11px 0; background: var(--soft); color: var(--muted); }
.danger-check { display: flex; align-items: flex-start; gap: 10px; margin: 5px 0 2px; color: #425d57; font-size: 13px; line-height: 1.55; }
.danger-check input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--accent); }

.button { min-height: 42px; border: 1px solid transparent; border-radius: 11px; padding: 10px 16px; font-weight: 750; transition: transform .12s, background .15s, border-color .15s; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button.primary { background: var(--accent); color: white; box-shadow: 0 8px 18px rgba(11,107,94,.18); }
.button.primary:hover:not(:disabled) { background: var(--accent-strong); }
.button.ghost { background: white; color: var(--ink); border-color: #c7d5d1; }
.button.ghost:hover:not(:disabled) { background: var(--soft); border-color: #9eb8b1; }
.button.danger { background: var(--danger-soft); color: var(--danger); border-color: #f2c4bf; }
.button.full { width: 100%; margin-top: 16px; min-height: 48px; }
.button.small { min-height: 36px; padding: 7px 12px; font-size: 12px; }
.button.loading .button-label { opacity: .75; }
.button-spinner { display: none; width: 15px; height: 15px; margin-left: 8px; border: 2px solid rgba(255,255,255,.45); border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
.button.loading .button-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-button { min-width: 38px; min-height: 38px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); font-size: 20px; }
.icon-button:hover { background: var(--soft); }

.task-list { display: grid; align-content: start; gap: 11px; margin-top: 20px; flex: 1 1 auto; }
.task-card { position: relative; width: 100%; min-width: 0; border: 1px solid var(--line); background: #fbfdfc; border-radius: 13px; color: inherit; transition: border .15s, box-shadow .15s, transform .15s; }
.task-card:hover { border-color: #9fc2b9; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(32,71,63,.08); }
.task-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(11,107,94,.11); }
.task-card:focus-within { border-color: var(--accent); }
.task-card-main { display: block; width: 100%; min-width: 0; padding: 15px; border: 0; border-radius: inherit; background: transparent; color: inherit; text-align: left; }
.task-card-main:focus-visible { outline-offset: 3px; }
.task-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.task-card-top strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-card strong { font-size: 14px; }
.task-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-card small { display: block; margin-top: 8px; padding-right: 60px; color: #82938f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-card-delete { position: absolute; right: 12px; bottom: 10px; min-width: 46px; min-height: 30px; padding: 4px 9px; border: 1px solid #efc3be; border-radius: 8px; background: #fff7f6; color: var(--danger); font-size: 11px; font-weight: 750; }
.task-card-delete:hover:not(:disabled) { background: var(--danger-soft); border-color: #e49e96; }
.task-list-pagination { display: flex; flex: 0 0 auto; justify-content: center; align-items: center; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.task-page-info { min-width: 128px; color: var(--muted); font-size: 12px; text-align: center; }
.status-pill { flex: 0 0 auto; border-radius: 999px; padding: 5px 9px; background: #eef3f2; color: #60736f; font-size: 11px; font-weight: 800; }
.status-pill.completed { background: #e2f5e9; color: #207744; }
.status-pill.running, .status-pill.queued, .status-pill.cancelling { background: #e6f1fb; color: #26648e; }
.status-pill.failed { background: var(--danger-soft); color: var(--danger); }
.status-pill.cancelled { background: #f0f1f2; color: #666d70; }
.empty-state { min-height: 340px; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 30px; }
.empty-state strong { display: block; color: var(--ink); margin-bottom: 8px; }
.empty-state-icon { width: 52px; height: 52px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--soft); border: 1px solid var(--line); border-radius: 16px; font-size: 23px; }

.detail-panel { margin-top: 20px; padding: 26px; }
.hidden { display: none !important; }
.detail-meta { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.detail-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.progress-area { margin-top: 24px; padding: 16px 18px; border-radius: 13px; background: var(--soft); border: 1px solid var(--line); }
.progress-copy { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.progress-copy span { color: var(--muted); }
.progress-track { height: 7px; margin-top: 12px; overflow: hidden; border-radius: 999px; background: #dce8e5; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s; }
.progress-track.indeterminate span { width: 38%; animation: indeterminate 1.4s ease-in-out infinite; }
@keyframes indeterminate { 0% { transform: translateX(-110%); } 100% { transform: translateX(300%); } }
.task-error { margin: 10px 0 0; color: var(--danger); font-size: 13px; }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(110px, 1fr)); gap: 10px; margin-top: 18px; }
.stat { min-height: 82px; padding: 14px; background: #fbfdfc; border: 1px solid var(--line); border-radius: 12px; }
.stat strong { display: block; font-size: 22px; }
.stat span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.results-section { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 22px; }
.results-toolbar { align-items: flex-end; margin-bottom: 14px; }
.results-toolbar p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.district-filter { min-width: 190px; }
.district-filter select { padding: 9px 11px; }
.table-scroll { overflow: auto; border: 1px solid var(--line); border-radius: 13px; }
table { width: 100%; min-width: 1050px; border-collapse: collapse; font-size: 12px; }
th { position: sticky; top: 0; z-index: 1; background: #edf6f3; color: #39514c; text-align: left; font-weight: 800; }
th, td { padding: 12px 13px; border-bottom: 1px solid #e3ecea; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafdfc; }
td { max-width: 280px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 14px; color: var(--muted); font-size: 12px; }

.dialog { width: min(620px, calc(100% - 30px)); max-height: calc(100vh - 40px); overflow: auto; border: 0; border-radius: 18px; padding: 25px; box-shadow: 0 26px 90px rgba(11,38,33,.28); color: var(--ink); }
.dialog::backdrop { background: rgba(16,40,35,.45); backdrop-filter: blur(3px); }
.key-state { padding: 13px 14px; margin-bottom: 18px; border-radius: 11px; background: var(--soft); border: 1px solid var(--line); color: #3e5953; font-size: 13px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 0; border-top: 1px solid var(--line); }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row small { margin-top: 4px; color: var(--muted); }
.toggle-row input { width: 42px; height: 23px; accent-color: var(--accent); }
.danger-check { margin: 15px 0; color: var(--danger); }
.form-message { min-height: 22px; color: var(--muted); font-size: 13px; }
.form-message.error { color: var(--danger); }
.form-message.success { color: #207744; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.account-security { margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--line); }
.settings-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.account-security > .field-hint { margin-bottom: 18px; }
.account-security .field { margin-bottom: 14px; }
.details-dialog { width: min(780px, calc(100% - 30px)); }
.poi-details { display: grid; grid-template-columns: 150px 1fr; gap: 0; margin-top: 20px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.poi-details dt, .poi-details dd { margin: 0; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.poi-details dt { background: var(--soft); font-weight: 750; color: #405953; }
.poi-details dd { white-space: pre-wrap; word-break: break-word; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 80; max-width: min(420px, calc(100% - 44px)); padding: 13px 16px; border-radius: 11px; background: var(--ink); color: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .create-panel, .task-panel { min-width: 0; min-height: auto; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 680px) {
  .app-header { height: auto; min-height: 70px; padding: 12px 16px; align-items: flex-start; }
  .brand span { display: none; }
  .header-actions { align-items: flex-end; flex-direction: column-reverse; gap: 6px; }
  .account-name { display: none; }
  .header-actions .button { min-height: 36px; padding: 7px 11px; font-size: 12px; }
  .page-shell { width: calc(100% - 24px); margin-top: 14px; }
  .create-panel, .task-panel, .detail-panel { padding: 18px; border-radius: 15px; }
  .panel-heading, .detail-header, .results-toolbar { flex-direction: column; }
  .detail-actions { width: 100%; justify-content: flex-start; }
  .detail-actions .button { flex: 1 1 135px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .region-select-grid { grid-template-columns: 1fr; gap: 12px; }
  .region-select-grid .field, .region-select-grid select { min-width: 0; }
  .task-card-delete { min-height: 36px; }
  .district-filter { width: 100%; }
  .dialog { padding: 18px; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
  .poi-details { grid-template-columns: 1fr; }
  .poi-details dt { border-bottom: 0; padding-bottom: 4px; }
  .poi-details dd { padding-top: 4px; }
}

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-shell { width: min(440px, 100%); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brand-mark { flex: 0 0 auto; }
.login-brand strong { display: block; font-size: 20px; }
.login-brand span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.login-card { padding: 30px; background: var(--surface); border: 1px solid rgba(191,211,206,.8); border-radius: var(--radius); box-shadow: var(--shadow); }
.login-card h1 { font-size: 26px; }
.login-card .section-intro { margin-bottom: 22px; }
.login-card .button.full { margin-top: 4px; }
.login-footnote { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; text-align: center; }

@media (max-width: 480px) {
  .login-page { align-items: start; padding: 42px 14px 24px; }
  .login-card { padding: 22px 18px; border-radius: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
