:root {
  color-scheme: dark;
  --bg: #07110f;
  --surface: rgba(13, 29, 25, .88);
  --line: rgba(180, 231, 212, .15);
  --line-strong: rgba(118, 240, 188, .34);
  --text: #eefbf6;
  --muted: #8ca69d;
  --mint: #76f0bc;
  --mint-strong: #36d995;
  --danger: #ff8b8b;
  --warning: #ffd49a;
  --shadow: 0 20px 55px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ambient { position: fixed; width: 520px; height: 520px; border-radius: 50%; filter: blur(120px); opacity: .12; pointer-events: none; }
.ambient-a { background: #36d995; top: -260px; right: -140px; }
.ambient-b { background: #397dff; bottom: -340px; left: -180px; opacity: .07; }
.shell { width: min(1680px, calc(100% - 32px)); margin: 0 auto; padding: 18px 0 80px; position: relative; z-index: 1; }
.glass { background: linear-gradient(145deg, rgba(17, 38, 32, .94), rgba(10, 25, 21, .86)); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(18px); }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 20px; }
.plain-button { padding: 0; border: 0; color: inherit; background: none; }
.brand { display: flex; align-items: center; gap: 11px; text-align: left; }
.brand:hover { transform: none; }
.brand-mark { display: block; flex: none; width: 44px; height: 44px; border: 1px solid rgba(255, 129, 45, .42); border-radius: 12px; overflow: hidden; background: #071328; box-shadow: 0 0 18px rgba(255, 105, 26, .12); }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 14px; }
.brand-copy small { color: var(--muted); font-size: 11px; }
.status-pill { border: 1px solid var(--line); background: rgba(8, 22, 18, .55); padding: 8px 12px; border-radius: 999px; color: #b4cbc2; font-size: 11px; display: flex; align-items: center; gap: 7px; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 12px var(--mint); }

.login-wrap { min-height: calc(100vh - 120px); display: grid; place-items: center; padding-bottom: 80px; }
.login-card { width: min(620px, 100%); padding: clamp(28px, 5vw, 50px); border-radius: 24px; }
.login-logo { display: block; width: 82px; height: 82px; margin: 0 0 20px; border: 1px solid rgba(255, 129, 45, .36); border-radius: 20px; object-fit: cover; image-rendering: pixelated; box-shadow: 0 12px 30px rgba(0, 0, 0, .24); }
.eyebrow { margin: 0 0 7px; color: var(--mint); font-weight: 850; font-size: 10px; letter-spacing: .12em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 3.7vw, 44px); line-height: 1.05; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 18px; letter-spacing: -.015em; }
.muted { color: var(--muted); line-height: 1.6; }
form label { display: block; margin: 22px 0 7px; font-size: 12px; color: #b9cec6; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid var(--line); background: rgba(4, 15, 12, .78); color: var(--text); border-radius: 9px; padding: 10px 11px; outline: none; transition: border-color .18s, box-shadow .18s; }
input:focus, textarea:focus, select:focus { border-color: rgba(118, 240, 188, .65); box-shadow: 0 0 0 3px rgba(118, 240, 188, .08); }
input:disabled { color: #9db1aa; opacity: .72; }
.login-fields { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 12px 10px; margin-top: 24px; }
.login-fields label { margin: 0; }
.login-submit { width: 100%; margin-top: 16px; }
button { border: 0; border-radius: 9px; padding: 10px 15px; font-weight: 800; transition: transform .16s, opacity .16s, background .16s; }
button:hover { transform: translateY(-1px); }
button:disabled { opacity: .55; cursor: wait; transform: none; }
.primary { color: #062117; background: linear-gradient(135deg, var(--mint), var(--mint-strong)); }
.secondary { color: var(--mint); background: rgba(118, 240, 188, .08); border: 1px solid var(--line-strong); }
.ghost { color: #bfd5cd; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.danger-text, .remove-row { color: var(--danger); }
.form-error { min-height: 18px; margin: 8px 0 0; color: var(--danger); font-size: 11px; }

.dashboard, .editor-view { animation: enter .28s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
.page-heading, .editor-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 14px 0 20px; }
.page-heading h1, .editor-heading h1 { margin: 0; }
.heading-note { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.heading-actions, .editor-actions { display: flex; gap: 7px; align-items: center; }
.user-badge { color: var(--mint); white-space: nowrap; font-size: 10px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 10px; background: rgba(118, 240, 188, .06); }
.panel { border-radius: 16px; padding: 18px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.panel-title .eyebrow { margin-bottom: 5px; }
.panel-help { color: var(--muted); margin: 6px 0 0; font-size: 10px; }
.compact-title { margin-bottom: 12px; }

/* 运营列表以信息完整度为优先，固定布局且不产生横向滚动。 */
.table-panel { padding: 20px; min-height: 500px; border-color: rgba(118, 240, 188, .2); }
.list-title { align-items: flex-end; }
.table-tools { display: flex; align-items: center; gap: 9px; }
.table-tools input { width: 280px; padding: 9px 10px; }
.sort-control { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); white-space: nowrap; font-size: 9px; }
.sort-control select { width: 154px; padding: 9px 10px; }
.count-badge { color: var(--muted); white-space: nowrap; font-size: 10px; border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; }
.table-wrap { width: 100%; overflow: visible; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.col-app { width: 24%; }
.col-summary { width: 43%; }
.col-remark { width: 14%; }
.col-time { width: 11%; }
.col-actions { width: 8%; }
th { text-align: left; color: #789087; font-size: 10px; letter-spacing: .05em; padding: 10px 9px; border-bottom: 1px solid var(--line); }
td { padding: 14px 9px; border-bottom: 1px solid rgba(180, 231, 212, .09); color: #cce0d8; font-size: 11px; vertical-align: top; overflow-wrap: anywhere; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(118, 240, 188, .025); }
.app-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.app-title-row > strong { color: var(--text); font: 750 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.list-status-switch, .switch-field { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.list-status-switch { flex: none; color: #a8c0b7; font-size: 9px; }
.list-status-switch > input, .switch-field > input { position: absolute; opacity: 0; pointer-events: none; }
.switch { flex: none; width: 38px; height: 22px; border-radius: 999px; padding: 3px; background: #33443e; transition: .18s; }
.switch::after { content: ""; display: block; width: 16px; height: 16px; border-radius: 50%; background: #c2d0cb; transition: .18s; }
.list-status-switch input:checked + .switch, .switch-field input:checked + .switch { background: var(--mint-strong); }
.list-status-switch input:checked + .switch::after, .switch-field input:checked + .switch::after { transform: translateX(16px); background: #052017; }
.compact-switch { width: 32px; height: 18px; padding: 2px; }
.compact-switch::after { width: 14px; height: 14px; }
.list-status-switch input:checked + .compact-switch::after { transform: translateX(14px); }
.stat-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.stat-chips span { padding: 4px 6px; border-radius: 5px; background: rgba(255, 255, 255, .045); color: #9fb6ad; font-size: 9px; }
.stat-chips .dau-chip { color: var(--mint); background: rgba(54, 217, 149, .08); }
.config-preview { display: grid; gap: 6px; }
.summary-count { color: var(--muted); font-size: 9px; }
.summary-url-row { display: grid; gap: 4px; padding: 7px 8px; border: 1px solid rgba(180, 231, 212, .1); border-radius: 7px; background: rgba(4, 18, 14, .35); }
.summary-url-row strong { color: #e0f1eb; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-url-row > div { display: flex; flex-wrap: wrap; gap: 4px 8px; color: #8fa79e; font-size: 9px; }
.config-more { margin-top: 1px; }
.config-more summary { width: max-content; color: var(--mint); cursor: pointer; font-size: 10px; padding: 4px 0; }
.more-url-list { display: grid; gap: 6px; margin-top: 5px; }
.remark-cell { color: #b9cdc5; line-height: 1.55; }
.time-cell { color: #97ada5; line-height: 1.55; }
.muted-cell { color: var(--muted); }
.row-actions { display: grid; gap: 5px; }
.row-actions button { width: 100%; padding: 7px 8px; border-radius: 7px; font-size: 9px; color: #c4ddd3; background: rgba(255, 255, 255, .045); border: 1px solid var(--line); }
.row-actions .delete { color: var(--danger); }
.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; }
.col-user { width: 22%; }
.col-role { width: 11%; }
.col-status { width: 11%; }
.col-creator { width: 13%; }
.admin-users-table .col-time { width: 15%; }
.admin-users-table .col-actions { width: 13%; }
.person-title { display: grid; gap: 3px; }
.person-title strong { color: var(--text); font-size: 12px; }
.person-title small { color: var(--muted); font: 10px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.role-badge, .status-badge { display: inline-flex; width: max-content; padding: 4px 7px; border-radius: 999px; border: 1px solid var(--line); color: #b9cec6; font-size: 9px; }
.role-badge.super { color: var(--warning); border-color: rgba(255, 212, 154, .3); background: rgba(255, 212, 154, .07); }
.role-badge.external { color: #9dc4ff; border-color: rgba(99, 158, 255, .3); background: rgba(99, 158, 255, .08); }
.status-badge.enabled { color: var(--mint); border-color: rgba(118, 240, 188, .25); background: rgba(118, 240, 188, .06); }
.status-badge.disabled { color: var(--danger); border-color: rgba(255, 139, 139, .22); background: rgba(255, 139, 139, .06); }
.admin-user-form { margin-top: 10px; }
.admin-user-fields { grid-template-columns: repeat(4, minmax(150px, 1fr)) auto; }
.form-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 16px; }

.editor-heading { align-items: flex-end; }
.editor-subtitle { margin: 8px 0 0; font-size: 12px; }
.back-button { color: #a9c1b8; background: none; padding: 0; margin-bottom: 15px; font-size: 11px; }
.back-button:hover { color: var(--mint); transform: translateX(-2px); }
.editor-warning { color: var(--warning); border: 1px solid rgba(255, 196, 112, .25); background: rgba(130, 84, 20, .16); padding: 10px 12px; border-radius: 9px; font-size: 11px; }
.save-result { margin-bottom: 10px; padding: 10px 12px; border-radius: 9px; font-size: 11px; border: 1px solid var(--line); }
.save-result.success { color: var(--mint); background: rgba(54, 217, 149, .08); border-color: rgba(54, 217, 149, .28); }
.save-result.error { color: var(--danger); background: rgba(255, 139, 139, .07); border-color: rgba(255, 139, 139, .25); }
.save-result.pending { color: #c8d8d2; background: rgba(255, 255, 255, .04); }
.editor-workspace { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(390px, .65fr); gap: 10px; align-items: start; }
.editor-column { min-width: 0; }
.editor-stack { display: grid; gap: 10px; }
.editor-panel { box-shadow: 0 12px 35px rgba(0, 0, 0, .18); }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.operations-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.settings-grid { grid-template-columns: 1.2fr repeat(4, 1fr); }
.field { display: grid; gap: 6px; }
.field > span { color: #a9c1b8; font-size: 10px; font-weight: 700; }
.span-2 { grid-column: span 2; }
.switch-field { min-height: 39px; color: #bdd2ca; font-size: 10px; }
.emphasized-switch { padding: 0 4px; color: var(--mint); font-weight: 750; }
.section-heading { align-items: flex-end; }
.dynamic-rows { display: grid; gap: 6px; }
.config-grid-head, .dynamic-row { display: grid; gap: 6px; align-items: center; }
.config-grid-head { color: #718b81; font-size: 9px; letter-spacing: .03em; padding: 0 3px 5px; }
.url-grid { grid-template-columns: minmax(170px, 2fr) 55px 55px 66px 66px 75px minmax(80px, .8fr) 49px; }
.customer-url-grid { grid-template-columns: minmax(280px, 2fr) 90px 54px; }
.package-grid { grid-template-columns: minmax(240px, 1fr) 90px 49px; }
.touch-grid { grid-template-columns: minmax(180px, .7fr) minmax(0, 1.3fr); align-items: end; }
.touch-mode-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; }
.country-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto auto; gap: 8px; align-items: center; margin-bottom: 10px; }
.country-toolbar input { padding: 9px 10px; }
.country-toolbar button { padding: 9px 11px; font-size: 9px; }
.country-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; max-height: 280px; overflow-y: auto; padding: 7px; border: 1px solid var(--line); border-radius: 9px; background: rgba(4, 18, 14, .35); transition: opacity .18s; }
.country-options.filter-disabled { opacity: .55; }
.country-option { display: flex; align-items: center; gap: 7px; min-width: 0; margin: 0; padding: 7px; border-radius: 7px; cursor: pointer; background: rgba(255, 255, 255, .025); }
.country-option:hover { background: rgba(118, 240, 188, .07); }
.country-option input { width: 14px; height: 14px; flex: none; accent-color: var(--mint-strong); }
.country-option span { display: grid; min-width: 0; }
.country-option strong { overflow: hidden; color: #cce0d8; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.country-option small { color: var(--muted); font-size: 8px; }
.dynamic-row { padding: 7px; border: 1px solid rgba(180, 231, 212, .09); border-radius: 9px; background: rgba(4, 18, 14, .35); }
.dynamic-row input { min-width: 0; padding: 8px 7px; border-radius: 7px; font-size: 10px; }
.remove-row { padding: 8px 5px; border: 1px solid rgba(255, 139, 139, .15); border-radius: 7px; background: rgba(255, 139, 139, .06); font-size: 9px; }
.json-panel { position: sticky; top: 10px; min-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.json-title { align-items: flex-start; }
.sync-state { flex: none; padding: 5px 7px; border-radius: 6px; color: var(--muted); background: rgba(255, 255, 255, .04); font-size: 9px; }
.sync-state.success { color: var(--mint); background: rgba(54, 217, 149, .08); }
.sync-state.error { color: var(--danger); background: rgba(255, 139, 139, .08); }
#jsonInput { flex: 1; min-height: calc(100vh - 175px); resize: vertical; font: 10px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2; }
.editor-footer { position: sticky; z-index: 7; bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 10px; padding: 10px 13px; border-radius: 11px; }
.editor-footer > span { color: var(--muted); font-size: 10px; }
.editor-footer > span.success { color: var(--mint); }
.editor-footer > span.error { color: var(--danger); }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 30; background: #10271f; border: 1px solid rgba(118, 240, 188, .28); box-shadow: var(--shadow); border-radius: 10px; padding: 10px 13px; color: #dff9ee; transform: translateY(70px); opacity: 0; transition: .22s ease; font-size: 11px; }
.toast.show { transform: translateY(0); opacity: 1; }
.owner-badge { width: max-content; max-width: 100%; margin-top: 7px; padding: 4px 7px; border-radius: 999px; color: #9dc4ff; background: rgba(99, 158, 255, .08); border: 1px solid rgba(99, 158, 255, .2); font-size: 9px; overflow-wrap: anywhere; }
.external-mode .admin-only, .external-mode #jsonEditor { display: none; }
.external-mode .editor-workspace { grid-template-columns: minmax(0, 1fr); }

@media (max-width: 1180px) {
  .editor-workspace { grid-template-columns: 1fr; }
  .json-panel { position: static; min-height: 520px; }
  #jsonInput { min-height: 430px; }
  .settings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .country-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .shell { width: min(100% - 20px, 1680px); padding-top: 12px; }
  .status-pill { display: none; }
  .login-fields { grid-template-columns: 1fr; gap: 7px; }
  .login-fields label { margin-top: 8px; }
  .page-heading, .editor-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions, .top-actions { width: 100%; flex-wrap: wrap; }
  .heading-actions button, .top-actions button { flex: 1; }
  .panel { padding: 14px; }
  .list-title { align-items: stretch; flex-direction: column; }
  .table-tools { width: 100%; }
  .table-tools { flex-wrap: wrap; }
  .table-tools input { width: 100%; }
  .sort-control { flex: 1; }
  .sort-control select { width: 100%; }
  table, tbody, tr, td { display: block; width: 100%; }
  colgroup, thead { display: none; }
  tbody { display: grid; gap: 10px; }
  tbody tr { padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
  td { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 9px; padding: 8px 0; border-bottom: 1px solid rgba(180, 231, 212, .08); }
  td::before { content: attr(data-label); color: #718b81; font-size: 9px; }
  td:last-child { border-bottom: 0; }
  .row-actions { display: flex; }
  .row-actions button { width: auto; flex: 1; }
  .form-grid, .operations-grid, .settings-grid, .admin-user-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: span 2; }
  .url-editor-panel { overflow-x: auto; }
  .url-grid { min-width: 830px; }
  .customer-url-grid { min-width: 620px; }
  .touch-grid, .touch-mode-fields { grid-template-columns: 1fr; }
  .country-toolbar { grid-template-columns: 1fr 1fr; }
  .country-toolbar input { grid-column: span 2; }
  .country-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .form-grid, .operations-grid, .settings-grid, .admin-user-fields { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  td { grid-template-columns: 1fr; }
  .editor-footer { align-items: stretch; flex-direction: column; }
  .editor-actions { width: 100%; }
  .editor-actions button { flex: 1; }
}
