:root {
  color-scheme: light;
  --canvas: #f5f6f7;
  --surface: #ffffff;
  --surface-soft: #f0f3f3;
  --ink: #18201f;
  --muted: #687372;
  --line: #dce2e1;
  --line-strong: #bdc8c6;
  --teal: #087f72;
  --teal-dark: #05665d;
  --teal-soft: #e2f3f0;
  --coral: #d9583b;
  --coral-soft: #fff0eb;
  --amber: #b7791f;
  --amber-soft: #fff7df;
  --green: #247a4b;
  --green-soft: #e7f4eb;
  --focus: #78bdb5;
  --sidebar: #18211f;
  --sidebar-muted: #9eaaa7;
  --radius-sm: 4px;
  --radius-md: 7px;
  --shadow-sm: 0 1px 2px rgb(18 34 30 / 6%);
  --shadow-lg: 0 22px 60px rgb(10 27 24 / 16%);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 24px;
  --text-display: 44px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --fast: 160ms;
  --normal: 320ms;
  font-family: "Noto Sans SC", "Microsoft YaHei UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: var(--text-md); line-height: 1.55; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button, input, select { min-height: 42px; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: var(--space-1); font-size: var(--text-xl); line-height: 1.25; }
h2 { margin-bottom: var(--space-1); font-size: var(--text-xl); line-height: 1.3; }
h3 { display: inline; margin: 0; font-size: var(--text-lg); }
.muted, .hint { color: var(--muted); }
.hint { margin: var(--space-1) 0 0; font-size: var(--text-sm); }
.page-kicker, .visual-kicker { margin-bottom: var(--space-1); color: var(--teal); font-size: var(--text-xs); font-weight: 800; letter-spacing: 0; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(420px, .8fr); background: var(--surface); }
.auth-visual { position: relative; display: flex; min-height: 100vh; align-items: flex-end; overflow: hidden; padding: var(--space-10); color: #fff; background: var(--sidebar) url("/static/login-network.png") center / cover no-repeat; isolation: isolate; }
.auth-visual::after { position: absolute; inset: 0; z-index: -1; content: ""; background: rgb(7 18 16 / 42%); }
.visual-content { max-width: 580px; animation: rise-in 700ms var(--ease) both; }
.visual-content h1 { margin: var(--space-5) 0 var(--space-2); font-size: var(--text-display); }
.visual-content > p:last-child { margin-bottom: 0; color: #dce9e6; font-size: var(--text-lg); }
.visual-kicker { color: #93d8ce; }
.brand-symbol { display: inline-grid; width: 48px; height: 48px; place-items: center; border: 1px solid rgb(255 255 255 / 38%); border-radius: var(--radius-md); background: rgb(255 255 255 / 10%); color: #fff; font-size: var(--text-lg); font-weight: 900; }
.brand-symbol.small { width: 38px; height: 38px; border-color: #3a4946; background: #26322f; }
.visual-status { position: absolute; top: var(--space-10); right: var(--space-10); display: flex; align-items: center; gap: var(--space-2); color: #d6e6e2; font-size: var(--text-xs); font-weight: 700; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #58c7b7; box-shadow: 0 0 0 5px rgb(88 199 183 / 14%); animation: pulse 2.4s ease-in-out infinite; }

.auth-panel { display: grid; min-height: 100vh; align-content: center; padding: clamp(28px, 6vw, 80px); background: var(--surface); }
.auth-form-wrap { width: min(430px, 100%); min-width: 0; margin-inline: auto; animation: fade-in 500ms var(--ease) 120ms both; }
.auth-panel h2 { margin-bottom: var(--space-2); font-size: 30px; }
.product-mark { margin-bottom: var(--space-4); color: var(--teal); font-size: var(--text-sm); font-weight: 800; }
.auth-footnote { align-self: end; margin: var(--space-10) auto 0; color: var(--muted); font-size: var(--text-xs); }
.field { display: grid; min-width: 0; gap: var(--space-2); }
.auth-panel .field + .field { margin-top: var(--space-5); }
label { color: #34403e; font-size: var(--text-sm); font-weight: 700; }
input, select { width: 100%; min-width: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; color: var(--ink); padding: 9px 11px; transition: border-color var(--fast), box-shadow var(--fast), background var(--fast); }
input:hover, select:hover { border-color: #899895; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.input-action { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); }
.error-text { margin: var(--space-4) 0 0; color: var(--coral); }

.button { min-width: 42px; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 9px 14px; cursor: pointer; background: #fff; color: var(--ink); font-size: var(--text-sm); font-weight: 750; transition: transform var(--fast) var(--ease), background var(--fast), border-color var(--fast), color var(--fast), box-shadow var(--fast); }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button.primary { background: var(--teal); color: #fff; box-shadow: 0 7px 18px rgb(8 127 114 / 16%); }
.button.primary:hover:not(:disabled) { background: var(--teal-dark); }
.button.secondary { border-color: var(--line-strong); }
.button.secondary:hover:not(:disabled) { border-color: #8c9c99; background: var(--surface-soft); }
.button.danger { border-color: #efb6a8; background: var(--coral-soft); color: #a43821; }
.button.danger:hover:not(:disabled) { border-color: var(--coral); background: #ffe5dd; }
.button.compact { padding-inline: 10px; }
.button.full { width: 100%; margin-top: var(--space-6); }

#app-view { display: grid; min-height: 100vh; grid-template-columns: 238px minmax(0, 1fr); grid-template-rows: 88px minmax(0, 1fr); }
.topbar { z-index: 5; grid-column: 2; display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); border-bottom: 1px solid var(--line); padding: var(--space-4) clamp(22px, 4vw, 52px); background: rgb(255 255 255 / 94%); backdrop-filter: blur(12px); }
.topbar h1 { font-size: 21px; }
.topbar p { margin-bottom: 0; }
.top-actions, .toolbar-actions { display: flex; align-items: center; gap: var(--space-2); }
.user-label { max-width: 180px; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }

.tabs { position: sticky; top: 0; z-index: 10; grid-column: 1; grid-row: 1 / span 2; display: flex; height: 100vh; flex-direction: column; gap: var(--space-2); padding: var(--space-5) var(--space-3); background: var(--sidebar); color: #fff; }
.sidebar-brand { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-8); padding: 0 var(--space-2); }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand span { color: var(--sidebar-muted); font-size: 10px; }
.tab { position: relative; min-height: 46px; border: 0; border-radius: var(--radius-sm); background: transparent; color: #c8d0ce; cursor: pointer; padding: 0 var(--space-4); text-align: left; font-size: var(--text-sm); font-weight: 750; transition: color var(--fast), background var(--fast), transform var(--fast); }
.tab::before { position: absolute; left: 0; width: 3px; height: 0; border-radius: 0 3px 3px 0; content: ""; background: #58c7b7; transition: height var(--normal) var(--ease); }
.tab:hover { background: #222d2a; color: #fff; transform: translateX(2px); }
.tab.active { background: #293532; color: #fff; }
.tab.active::before { height: 24px; }
.sidebar-foot { display: flex; align-items: center; gap: var(--space-2); margin-top: auto; padding: var(--space-3); color: var(--sidebar-muted); font-size: 10px; font-weight: 700; }

.tab-panel { grid-column: 2; grid-row: 2; width: min(1160px, calc(100% - 44px)); margin: var(--space-6) auto var(--space-10); animation: panel-in var(--normal) var(--ease) both; }
.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-6); margin-bottom: var(--space-5); }
.page-intro h2 { margin: 0; font-size: 28px; }
.page-intro > p { max-width: 420px; margin: 0; color: var(--muted); text-align: right; }

.section-band { border: 1px solid var(--line); border-bottom: 0; padding: var(--space-6); background: var(--surface); box-shadow: var(--shadow-sm); }
.section-band:first-of-type { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.section-band:last-child { border-bottom: 1px solid var(--line); border-radius: 0 0 var(--radius-md) var(--radius-md); }
.section-heading, .status-toolbar, .command-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); }
.section-heading p, .status-toolbar p { margin-bottom: 0; color: var(--muted); }
.step-index { display: inline-block; min-width: 28px; margin-right: var(--space-2); color: var(--teal); font-size: var(--text-xs); font-weight: 900; }
.form-grid, .upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); margin-top: var(--space-5); }
.connection-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented { display: grid; min-width: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); margin: var(--space-4) 0 0; border: 0; padding: 0; }
.segmented label { display: flex; min-height: 46px; align-items: center; gap: var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); font-weight: 600; transition: border-color var(--fast), background var(--fast); }
.segmented label:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-dark); }
.segmented input { width: auto; min-height: auto; accent-color: var(--teal); }
.proxy-select-row { margin-top: var(--space-4); }
.file-list { min-height: 52px; max-height: 180px; overflow: auto; margin: var(--space-4) 0; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-8); background: #fafbfb; }
.file-list:empty::before { display: block; content: "等待选择文件"; color: var(--muted); }
.file-list li + li { margin-top: var(--space-2); }
.status-message { margin: 0; color: var(--muted); }

.status-toolbar { border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-5) var(--space-6); background: var(--surface); box-shadow: var(--shadow-sm); }
.connection-statuses { display: flex; min-width: 0; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) 0; }
.connection-status { display: flex; min-width: 190px; align-items: center; justify-content: space-between; gap: var(--space-3); border-left: 3px solid var(--green); padding: var(--space-2) var(--space-3); background: var(--green-soft); font-size: var(--text-sm); }
.connection-status span { color: var(--muted); overflow-wrap: anywhere; }
.connection-status.failed { flex: 1 1 320px; border-left-color: var(--coral); background: var(--coral-soft); }
.connection-status.failed span { color: #9d3b27; }
.connection-status.empty { border-left-color: var(--line-strong); background: var(--surface-soft); color: var(--muted); }
.number-input { width: 72px; }
.status-metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-2); margin: var(--space-3) 0; }
.metric-button { display: grid; min-height: 76px; align-content: center; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; transition: transform var(--fast) var(--ease), border-color var(--fast), box-shadow var(--fast); }
.metric-button:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 8px 20px rgb(18 34 30 / 8%); }
.metric-button strong { font-size: 22px; }
.metric-button span { color: var(--muted); font-size: var(--text-xs); }
.metric-button[data-status="active"] strong { color: var(--green); }
.metric-button[data-status="error"] strong { color: var(--coral); }
.metric-button[data-status="rate_limited"] strong, .metric-button[data-status="temp_unschedulable"] strong { color: var(--amber); }
.selection-bar { position: sticky; top: 100px; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); border: 1px solid #b6d6d1; border-radius: var(--radius-sm); margin-bottom: var(--space-3); padding: var(--space-3) var(--space-5); background: #eff9f7; box-shadow: var(--shadow-sm); animation: bar-in var(--normal) var(--ease) both; }
.selection-bar .muted { margin-left: var(--space-3); }
.status-groups { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); }
.status-group { border-bottom: 1px solid var(--line); }
.status-group:last-child { border-bottom: 0; }
.status-group summary { cursor: pointer; list-style-position: inside; padding: var(--space-5) var(--space-6); font-size: var(--text-lg); font-weight: 850; transition: background var(--fast), color var(--fast); }
.status-group summary:hover { background: var(--surface-soft); }
.status-group[open] summary { background: #f0f7f6; color: var(--teal-dark); }
.account-list { overflow: hidden; border-top: 1px solid var(--line); animation: reveal var(--normal) var(--ease) both; }
.account-row { display: grid; width: 100%; min-height: 56px; grid-template-columns: 68px minmax(180px, 1fr) 110px 110px 110px minmax(180px, 1fr); align-items: center; gap: var(--space-3); border: 0; border-bottom: 1px solid #e9edec; padding: var(--space-2) var(--space-6) var(--space-2) var(--space-10); background: #fff; color: var(--ink); cursor: pointer; text-align: left; transition: background var(--fast), box-shadow var(--fast); }
.account-row:last-child { border-bottom: 0; }
.account-row:hover { background: #f6f9f8; }
.account-row.selected { background: #e6f4f1; box-shadow: inset 4px 0 var(--teal); }
.account-name { overflow-wrap: anywhere; font-weight: 750; }
.connection-badge { overflow: hidden; color: var(--teal-dark); font-size: var(--text-sm); font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.empty-row { margin: 0; padding: var(--space-5) var(--space-10); color: var(--muted); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius-md) var(--radius-md); background: var(--surface); }
table { width: 100%; min-width: 900px; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: var(--space-3) var(--space-4); text-align: left; vertical-align: top; }
th { background: var(--surface-soft); color: var(--muted); font-size: var(--text-xs); }
tbody tr { transition: background var(--fast); }
tbody tr:hover { background: #f7f9f8; }
.toast { position: fixed; right: var(--space-6); bottom: var(--space-6); z-index: 30; max-width: min(420px, calc(100% - 48px)); border-left: 4px solid #58c7b7; border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); background: #18211f; color: #fff; box-shadow: var(--shadow-lg); animation: toast-in var(--normal) var(--ease) both; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes panel-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bar-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes reveal { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: .65; } 50% { opacity: 1; } }

@media (max-width: 1040px) {
  #app-view { grid-template-columns: 205px minmax(0, 1fr); }
  .status-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .account-row { grid-template-columns: 68px minmax(160px, 1fr) 110px 110px minmax(160px, 1fr); }
  .account-row span:nth-child(5) { display: none; }
}

@media (max-width: 760px) {
  body { padding-bottom: 70px; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { min-height: 220px; align-items: flex-end; padding: var(--space-6); background-position: center 45%; }
  .visual-content h1 { margin-top: var(--space-3); font-size: 32px; }
  .visual-content > p:last-child, .visual-status { display: none; }
  .brand-symbol { width: 40px; height: 40px; }
  .auth-panel { min-height: calc(100vh - 220px); padding: var(--space-8) var(--space-5); }
  .auth-panel h2 { font-size: var(--text-xl); }
  #app-view { display: block; min-height: calc(100vh - 70px); }
  .topbar { position: sticky; top: 0; padding: var(--space-3) var(--space-4); }
  .topbar h1 { font-size: var(--text-lg); }
  .page-kicker, .user-label { display: none; }
  .tabs { position: fixed; inset: auto 0 0 0; z-index: 20; display: grid; width: 100%; height: 66px; grid-template-columns: repeat(3, 1fr); gap: 0; padding: 0 max(var(--space-2), env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--space-2), env(safe-area-inset-left)); border-top: 1px solid #34413e; }
  .sidebar-brand, .sidebar-foot { display: none; }
  .tab { min-height: 58px; border-radius: 0; padding: var(--space-2); text-align: center; font-size: var(--text-xs); }
  .tab::before { inset: 0 auto auto 50%; width: 24px; height: 3px; transform: translateX(-50%); }
  .tab.active::before { height: 3px; }
  .tab:hover { transform: none; }
  .tab-panel { width: calc(100% - 24px); margin: var(--space-4) auto var(--space-6); }
  .page-intro { align-items: flex-start; flex-direction: column; gap: var(--space-1); }
  .page-intro h2 { font-size: var(--text-xl); }
  .page-intro > p { text-align: left; }
  .section-band { padding: var(--space-5) var(--space-4); }
  .section-heading, .status-toolbar, .command-row, .selection-bar { align-items: stretch; flex-direction: column; }
  .top-actions, .toolbar-actions { flex-wrap: wrap; }
  .form-grid, .upload-grid, .segmented { grid-template-columns: 1fr; }
  .status-toolbar { padding: var(--space-4); }
  .status-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-button { min-height: 68px; }
  .selection-bar { top: 77px; }
  .selection-bar .muted { display: block; margin: var(--space-1) 0 0; }
  .status-group summary { padding: var(--space-4); }
  .account-row { min-height: 76px; grid-template-columns: 58px minmax(0, 1fr); gap: var(--space-1) var(--space-2); padding: var(--space-3) var(--space-4); }
  .account-row span:nth-child(3), .account-row span:nth-child(4), .account-row span:nth-child(5) { display: inline; grid-column: 2; color: var(--muted); font-size: var(--text-xs); }
  .account-row span:nth-child(6) { grid-column: 2; overflow-wrap: anywhere; }
  .empty-row { padding: var(--space-5); }
  .toast { right: var(--space-3); bottom: 78px; max-width: calc(100% - 24px); }
}

@media (max-width: 380px) {
  .top-actions .button { padding-inline: 10px; }
  .toolbar-actions { align-items: stretch; }
  .toolbar-actions .button { flex: 1 1 auto; }
  .status-metrics { grid-template-columns: 1fr 1fr; }
}

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