:root {
  --bg: #f5f2e8;
  --panel: #fffdf6;
  --ink: #171717;
  --muted: #6c675b;
  --line: #e5dcc9;
  --green: #9ad337;
  --green-dark: #5e8f12;
  --yellow: #f6d51f;
  --danger: #d93f32;
  --shadow: 0 18px 45px rgba(34, 29, 17, .12);
  --radius: 24px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top left, #fff9d9 0, #fff9d9 240px, transparent 241px), var(--bg);
  color: var(--ink);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 34px;
}
.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #111;
  font-weight: 900;
  margin-bottom: 18px;
}
.login-card h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.03em; }
.login-card p { margin: 0 0 24px; color: var(--muted); }
.form-row { margin-bottom: 16px; }
label { display: block; margin-bottom: 8px; font-weight: 700; font-size: 14px; }
input[type="text"], input[type="password"], input[type="number"], input[type="file"], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  outline: none;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, textarea:focus, select:focus { border-color: var(--green-dark); box-shadow: 0 0 0 3px rgba(154, 211, 55, .2); }
.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary { background: #111; color: #fff; }
.btn-green { background: var(--green); color: #111; }
.btn-yellow { background: var(--yellow); color: #111; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-light { background: #fff; border: 1px solid var(--line); }
.btn-full { width: 100%; }
.layout { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar {
  background: #111;
  color: #fff;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.side-logo .mark { width: 44px; height: 44px; border-radius: 50%; background: var(--green); color: #111; display: grid; place-items: center; font-weight: 900; }
.side-logo strong { display: block; line-height: 1.2; }
.side-logo span { color: #aaa; font-size: 12px; }
.nav a { display: block; padding: 13px 14px; border-radius: 14px; color: #d6d6d6; margin-bottom: 6px; }
.nav a.active, .nav a:hover { background: #272727; color: #fff; }
.main { padding: 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.topbar h1 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: 0 8px 20px rgba(34,29,17,.06); }
.metric span { color: var(--muted); font-size: 14px; }
.metric strong { display: block; margin-top: 8px; font-size: 34px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(34,29,17,.08); overflow: hidden; margin-bottom: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 20px; }
.panel-body { padding: 22px; }
.route-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.route-card { background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 18px; }
.route-card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.route-title { display:flex; align-items:center; gap:10px; }
.route-badge { width: 42px; height: 42px; border-radius: 50%; background: #111; color: var(--yellow); display: grid; place-items: center; font-size: 24px; font-weight: 900; }
.status { padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.status.on { background: rgba(154,211,55,.25); color: var(--green-dark); }
.status.off { background: rgba(217,63,50,.12); color: var(--danger); }
.switch-row { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.switch-row input { width: auto; }
.file-preview { margin-top: 12px; border-radius: 16px; border: 1px solid var(--line); overflow: hidden; background: #f7f7f7; }
.file-preview img { width: 100%; display: block; max-height: 220px; object-fit: contain; }
.inline-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.alert { padding: 12px 14px; border-radius: 14px; margin-bottom: 16px; font-weight: 700; }
.alert.ok { background: rgba(154,211,55,.24); color: var(--green-dark); }
.alert.err { background: rgba(217,63,50,.12); color: var(--danger); }
.table-wrap { overflow:auto; }
table { width:100%; border-collapse: collapse; background:#fff; }
th, td { text-align:left; padding: 13px 12px; border-bottom:1px solid var(--line); font-size:14px; }
th { color: var(--muted); font-size:12px; text-transform: uppercase; letter-spacing:.04em; }
.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; background:#f1ede0; padding: 2px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.footer-note { color: var(--muted); font-size: 13px; margin-top: 22px; }
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height:auto; }
  .cards, .route-grid { grid-template-columns: 1fr; }
  .main { padding: 18px; }
}
.hint {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}


/* v3 compact admin improvements */
.main { padding: 22px; }
.topbar { margin-bottom: 18px; }
.topbar h1 { font-size: 24px; }
.topbar p { font-size: 13px; }
.route-grid { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.route-card { padding: 16px; border-radius: 18px; box-shadow: 0 6px 18px rgba(34,29,17,.05); }
.route-card .form-row { margin-bottom: 10px; }
.route-card label { margin-bottom: 6px; font-size: 13px; }
.route-card input[type="text"], .route-card input[type="number"], .route-card input[type="file"], .route-card textarea { padding: 10px 12px; border-radius: 12px; }
.route-card textarea { min-height: 64px; }
.form-grid { display: grid; gap: 12px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.file-preview img { max-height: 170px; }
.inline-actions { margin-top: 10px; }
.hint { font-size: 12px; margin: 0 0 10px; }
.api-card-grid { margin-bottom: 18px; }
.api-meta { margin-bottom: 10px; }
.json-box { margin: 0; padding: 16px; background: #111; color: #d8f5c5; border-radius: 16px; overflow: auto; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; line-height: 1.6; }
.api-two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.subhead { font-weight: 800; margin-bottom: 10px; }
@media (max-width: 980px) { .api-two-col, .form-grid-2 { grid-template-columns: 1fr; } }

/* v4 operation-focused route management */
.compact-panel .panel-head { align-items: flex-start; }
.panel-desc { margin: 6px 0 0; font-size: 13px; }
.route-ops-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.route-ops-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: 0 6px 18px rgba(34,29,17,.05); }
.ops-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.toggle-line { display: flex; align-items: center; gap: 9px; padding: 10px 12px; background: #fbf7ea; border: 1px solid var(--line); border-radius: 14px; font-weight: 800; cursor: pointer; margin-bottom: 12px; }
.toggle-line input { width: auto; }
.compact-toggle { margin-top: -2px; }
.ops-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.route-ops-card .form-row { margin-bottom: 10px; }
.route-ops-card label { font-size: 12px; margin-bottom: 6px; }
.route-ops-card input[type="number"], .route-ops-card input[type="file"] { padding: 9px 10px; border-radius: 12px; }
.mini-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.fixed-hint { background: #f7f1df; border-radius: 12px; padding: 9px 10px; margin: -2px 0 12px; }
.mini-warning { color: var(--danger); background: rgba(217,63,50,.09); border-radius: 12px; padding: 9px 10px; font-size: 12px; line-height: 1.5; }
.upload-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; margin-top: 4px; }
.map-detail { margin-top: 10px; font-size: 12px; color: var(--muted); }
.map-detail summary { cursor: pointer; font-weight: 800; color: var(--green-dark); }
.code-wrap { word-break: break-all; margin-top: 8px; padding: 8px 10px; background: #f1ede0; border-radius: 10px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.compact-actions { margin-top: 12px; }
.compact-actions .btn { padding: 10px 16px; }
@media (max-width: 720px) { .ops-fields, .upload-row { grid-template-columns: 1fr; } }


/* v5 route management: compact card layout */
.route-manager-panel { overflow: visible; }
.route-manager-head { padding: 18px 20px; }
.route-manager-head h2 { font-size: 20px; }
.route-manager-body { padding: 14px; }
.route-ops-grid-v5 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 12px;
  align-items: stretch;
}
.route-mini-card {
  background: #fffef8;
  border: 1px solid #e7ddc8;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 8px 18px rgba(34,29,17,.055);
  min-width: 0;
}
.mini-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.compact-route-title { gap: 8px; min-width: 0; }
.small-badge {
  width: 38px;
  height: 38px;
  font-size: 22px;
  flex: 0 0 38px;
}
.mini-meta { font-size: 12px; margin-top: 1px; }
.enable-pill,
.auto-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #eadfc8;
  background: #faf5e7;
  border-radius: 13px;
  padding: 8px 10px;
  font-weight: 800;
  font-size: 13px;
  margin: 8px 0;
  min-height: 38px;
}
.enable-pill input,
.auto-pill input { width: auto; margin: 0; }
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0;
}
.mini-field label,
.map-compact label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin: 0 0 5px;
}
.mini-field input[type="number"] {
  height: 38px;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 14px;
}
.tiny-help { color: var(--muted); font-size: 11px; margin-top: 3px; }
.locked-note {
  background: #f7f1df;
  color: #6c675b;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
  margin: 8px 0;
}
.map-compact {
  border: 1px dashed #dccdaf;
  border-radius: 14px;
  padding: 10px;
  margin-top: 8px;
  background: #fffaf0;
}
.map-compact-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}
.file-compact,
.route-mini-card input[type="file"] {
  width: 100%;
  padding: 8px;
  border-radius: 11px;
  font-size: 12px;
}
.tiny-warning {
  margin-top: 7px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(217,63,50,.08);
  color: #b53128;
  font-size: 11px;
  line-height: 1.45;
}
.compact-detail { margin-top: 7px; }
.compact-detail summary { font-size: 12px; }
.compact-detail .code-wrap { font-size: 11px; max-height: 80px; overflow: auto; }
.mini-actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mini-actions .btn {
  width: 100%;
  padding: 9px 12px;
  min-height: 38px;
  font-size: 13px;
}
.route-mini-card .status {
  padding: 5px 8px;
  font-size: 11px;
  white-space: nowrap;
}
@media (min-width: 1280px) {
  .route-ops-grid-v5 { grid-template-columns: repeat(4, minmax(230px, 1fr)); }
}
@media (max-width: 1100px) {
  .route-ops-grid-v5 { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
}
@media (max-width: 720px) {
  .route-ops-grid-v5,
  .stats-grid,
  .mini-actions { grid-template-columns: 1fr; }
}

/* v8 polished route management layout */
.route-manager-panel {
  background: #fffcf3;
  border-radius: 24px;
}
.route-manager-head {
  padding: 18px 22px;
  align-items: center;
  background: linear-gradient(180deg, #fffdf8 0%, #fffaf0 100%);
}
.route-manager-head h2 { font-size: 22px; letter-spacing: -.02em; }
.route-manager-head .btn { min-width: 132px; }
.route-manager-body { padding: 20px; }
.route-ops-grid-v8 {
  display: grid;
  grid-template-columns: repeat(2, minmax(340px, 1fr));
  gap: 16px;
  align-items: start;
}
.route-op-card {
  position: relative;
  background: #fff;
  border: 1px solid #e6dbc6;
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 10px 26px rgba(34, 29, 17, .06);
  min-width: 0;
}
.route-op-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(90deg, var(--green), var(--yellow));
  opacity: .95;
}
.route-op-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.route-op-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.route-badge-sm {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  font-size: 24px;
}
.route-op-name strong {
  display: block;
  font-size: 17px;
  line-height: 1.2;
}
.route-op-name span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}
.route-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #f7f3e8;
  border: 1px solid #eadfc8;
  border-radius: 14px;
  cursor: pointer;
}
.route-switch input { width: auto; margin: 0; }
.route-switch span { font-size: 14px; font-weight: 900; }
.route-input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.op-field {
  margin: 0;
}
.op-field span,
.map-upload-top strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 900;
}
.op-field input[type="number"] {
  height: 42px;
  padding: 8px 12px;
  border-radius: 14px;
  background: #fffefa;
}
.op-field em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}
.auto-close-box {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: #f3ffe4;
  border: 1px solid rgba(154, 211, 55, .45);
  border-radius: 14px;
  color: #31480f;
  font-size: 13px;
  font-weight: 800;
}
.auto-close-box.disabled {
  background: #f7f1df;
  border-color: #eadfc8;
  color: var(--muted);
  font-weight: 700;
}
.auto-close-box label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  width: 100%;
  cursor: pointer;
}
.auto-close-box input { width: auto; margin: 0; }
.map-upload-box {
  padding: 12px;
  background: #fff9ec;
  border: 1px dashed #dbc9aa;
  border-radius: 16px;
  margin-bottom: 12px;
}
.map-upload-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.map-upload-top strong { margin-bottom: 0; }
.file-clean {
  height: 42px;
  padding: 8px 10px !important;
  border-radius: 13px !important;
  background: #fff !important;
  font-size: 12px !important;
}
.upload-help {
  margin: 8px 0 0;
  padding: 8px 10px;
  background: rgba(217, 63, 50, .08);
  color: #b53128;
  border-radius: 11px;
  font-size: 12px;
  line-height: 1.45;
}
.map-url-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.map-url-detail summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--green-dark);
}
.map-url-detail .code-wrap {
  margin-top: 8px;
  max-height: 78px;
  overflow: auto;
  font-size: 11px;
}
.route-card-actions {
  display: grid;
  grid-template-columns: 1.2fr .9fr;
  gap: 10px;
}
.route-card-actions .btn {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
}
@media (min-width: 1500px) {
  .route-ops-grid-v8 { grid-template-columns: repeat(4, minmax(280px, 1fr)); }
}
@media (max-width: 1180px) {
  .route-ops-grid-v8 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .route-manager-body { padding: 14px; }
  .route-input-grid,
  .route-card-actions { grid-template-columns: 1fr; }
  .route-op-card { padding: 14px; }
}


/* v10 font upload */
.font-upload-form { max-width: 640px; }
.font-status-box { margin-top: 18px; padding: 16px; border-radius: 16px; background: #fffef8; border: 1px solid var(--line); }
.font-status-box p { margin: 0 0 10px; }

/* v11 editable text fields */
.text-edit-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0 12px;
  padding: 10px;
  border: 1px solid #eadfc8;
  border-radius: 14px;
  background: #fffaf0;
}
.text-edit-box .op-field {
  margin: 0;
}
.text-edit-box .op-field:nth-child(4) {
  grid-column: 1 / -1;
}
.text-edit-box textarea {
  min-height: 52px;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid #dfd1b7;
  border-radius: 12px;
  font: inherit;
  line-height: 1.45;
  background: #fff;
}
@media (max-width: 720px) {
  .text-edit-box { grid-template-columns: 1fr; }
  .text-edit-box .op-field:nth-child(4) { grid-column: auto; }
}
