:root {
  --navy: #10263b;
  --navy-2: #18344d;
  --blue: #1769e0;
  --blue-soft: #eaf2ff;
  --green: #138a5b;
  --green-soft: #e0f5ea;
  --amber: #9a6500;
  --amber-soft: #fff0c9;
  --red: #c63d4a;
  --red-soft: #ffe6e9;
  --ink: #172534;
  --muted: #718195;
  --line: #dbe3eb;
  --surface: #ffffff;
  --canvas: #f2f5f8;
  --sidebar-width: 220px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--canvas); font-size: 14px; letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); z-index: 30;
  display: flex; flex-direction: column; background: var(--navy); color: #d7e4ef;
}
.brand { height: 76px; padding: 0 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 7px; background: #2c7be5; color: white; font-weight: 800; font-size: 16px; }
.brand-mark.large { width: 48px; height: 48px; font-size: 22px; }
.brand strong { display: block; color: #fff; font-size: 15px; }
.brand span { display: block; margin-top: 3px; color: #8fa6ba; font-size: 11px; }
.nav { padding: 18px 10px; display: grid; gap: 5px; }
.nav-item { height: 44px; width: 100%; border: 0; border-radius: 6px; display: flex; align-items: center; gap: 12px; padding: 0 12px; color: #b7c8d7; background: transparent; text-align: left; font-weight: 600; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 5px; background: rgba(255,255,255,.09); font-size: 11px; }
.sidebar-footer { margin-top: auto; padding: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.user-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; color: #fff; font-weight: 600; }
.user-avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #34516c; }
.logout-button { width: 100%; height: 34px; border: 1px solid rgba(255,255,255,.16); border-radius: 5px; background: transparent; color: #b9cad8; }
.logout-button:hover { color: #fff; border-color: rgba(255,255,255,.35); }

.page { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { height: 76px; display: flex; align-items: center; gap: 14px; padding: 0 30px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 20px; line-height: 1.25; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.activity { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: #aeb9c5; }
.activity.running .activity-dot { background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.menu-button { display: none; width: 38px; height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 6px; font-size: 20px; }
.main-content { max-width: 1680px; margin: 0 auto; padding: 22px 26px 36px; }
.view { display: none; }
.view.active { display: block; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface); margin-bottom: 18px; }
.metric { min-height: 108px; padding: 19px 22px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin: 5px 0 2px; font-size: 27px; line-height: 1.1; }
.metric strong.metric-status { font-size: 21px; }
.metric small { font-size: 11px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(360px, .78fr) minmax(560px, 1.42fr); gap: 18px; margin-bottom: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.panel-heading { min-height: 68px; padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading h2 { margin: 0; font-size: 16px; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.heading-actions .secondary-button,
.heading-actions .danger-button { width: auto; }
.danger-button { min-height: 40px; border-radius: 6px; padding: 0 16px; font-weight: 700; border: 1px solid #c44755; background: #fff; color: var(--red); }
.danger-button:hover { background: var(--red-soft); }
.danger-button:disabled { opacity: .45; cursor: not-allowed; }
.danger-text { color: var(--red); }
.check-col { width: 42px; padding-left: 14px; padding-right: 0; }
.is-expired { color: var(--red); font-weight: 700; }
.row-actions { white-space: nowrap; }
.status-chip { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-chip.ready, .status-chip.success { color: var(--green); background: var(--green-soft); }
.status-chip.running { color: #175cb7; background: var(--blue-soft); }
.status-chip.partial { color: var(--amber); background: var(--amber-soft); }
.status-chip.failed, .status-chip.interrupted { color: var(--red); background: var(--red-soft); }
.status-chip.queued { color: #5f6e7d; background: #eef1f4; }
.launch-panel form { padding: 16px 18px 20px; }
.segment { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 17px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segment-button { height: 40px; border: 0; background: #fff; color: var(--muted); }
.segment-button + .segment-button { border-left: 1px solid var(--line); }
.segment-button.active { background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label span { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 650; }
input, select { width: 100%; height: 40px; border: 1px solid #cbd6e1; border-radius: 6px; padding: 0 11px; color: var(--ink); background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,224,.12); }
input:disabled, select:disabled { background: #f3f5f7; color: #738092; }
.settings-form { display: grid; gap: 14px; padding: 18px; }
.settings-form .form-grid { margin: 0; }
.settings-actions { display: grid; gap: 8px; }
.settings-save { width: auto; min-width: 160px; }
.settings-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.check-row input { width: 16px; height: 16px; padding: 0; box-shadow: none; }
.pool-panel .chain-grid { border-top: 0; grid-template-columns: repeat(4, 1fr); }
.pool-links { display: grid; gap: 12px; padding: 16px 18px 8px; }
.pool-links label { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.pool-links label span { grid-column: 1 / -1; }
.pool-hint { padding: 0 18px 16px; }
.runtime-strip { display: grid; grid-template-columns: repeat(3, 1fr); margin: 15px 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.runtime-strip div { min-width: 0; padding: 10px; border-right: 1px solid var(--line); }
.runtime-strip div:last-child { border-right: 0; }
.runtime-strip span, .runtime-strip strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runtime-strip span { color: var(--muted); font-size: 10px; margin-bottom: 3px; }
.runtime-strip strong { font-size: 11px; }
.primary-button, .secondary-button { min-height: 40px; border-radius: 6px; padding: 0 16px; font-weight: 700; }
.primary-button { width: 100%; border: 1px solid var(--blue); background: var(--blue); color: #fff; }
.primary-button:hover { background: #105dc9; }
.primary-button:disabled { opacity: .55; cursor: not-allowed; }
.secondary-button { border: 1px solid #b9c7d5; background: #fff; color: #2f455a; }
.secondary-button:hover { border-color: var(--blue); color: var(--blue); }
.text-button { border: 0; background: transparent; color: var(--blue); font-weight: 700; padding: 6px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { height: 47px; padding: 0 16px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th { height: 43px; color: #526478; background: #f7f9fb; font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable:hover { background: #f7faff; cursor: pointer; }
.empty-cell { height: 120px; text-align: center; color: var(--muted); }
.chain-panel .panel-heading { min-height: 62px; }
.chain-grid { display: grid; grid-template-columns: repeat(5, 1fr); }
.chain-grid > div { min-height: 62px; padding: 13px 16px; border-right: 1px solid var(--line); }
.chain-grid > div:last-child { border-right: 0; }
.chain-grid span, .chain-grid strong { display: block; }
.chain-grid span { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.chain-grid strong { color: var(--green); font-size: 12px; }
.page-panel { min-height: 460px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.setting-panel { min-height: 220px; padding: 24px; }
.setting-kicker { color: var(--muted); font-size: 12px; }
.setting-panel h2 { margin: 14px 0 6px; font-size: 22px; }
.setting-panel p { margin: 0 0 24px; color: var(--muted); }
.file-list { padding: 0 18px; }
.file-row { min-height: 64px; display: grid; grid-template-columns: minmax(220px, 1fr) 100px 170px 110px; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); }
.file-row:last-child { border-bottom: 0; }
.file-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.file-meta { color: var(--muted); font-size: 12px; }
.download-link { color: var(--blue); text-decoration: none; font-weight: 700; text-align: right; }

.task-dialog { width: min(640px, calc(100vw - 32px)); max-height: 80vh; padding: 0; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); box-shadow: 0 18px 50px rgba(21,36,50,.22); }
.account-dialog { width: min(920px, calc(100vw - 24px)); max-height: 88vh; padding: 0; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); box-shadow: 0 18px 50px rgba(21,36,50,.22); overflow: auto; }
.task-dialog::backdrop, .account-dialog::backdrop { background: rgba(11,28,43,.48); }
.dialog-heading { padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font-size: 17px; }
.dialog-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.dialog-heading button { width: 32px; height: 32px; border: 0; background: #f0f3f6; border-radius: 50%; font-size: 20px; color: #526273; }
.dialog-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.dialog-stats div { padding: 14px; border-right: 1px solid var(--line); }
.dialog-stats div:last-child { border-right: 0; }
.dialog-stats span, .dialog-stats strong { display: block; }
.dialog-stats span { color: var(--muted); font-size: 10px; margin-bottom: 4px; }
.log-list { max-height: 420px; overflow: auto; padding: 14px 20px 20px; }
.log-entry { padding: 9px 11px; margin-top: 7px; border-left: 3px solid #adc2d8; background: #f5f7f9; font-size: 12px; }
.account-form { padding: 0 20px 20px; display: grid; gap: 18px; }
.account-form h3 { margin: 0 0 10px; font-size: 14px; }
.account-form textarea { width: 100%; min-height: 72px; border: 1px solid #cbd6e1; border-radius: 6px; padding: 10px 11px; color: var(--ink); background: #fff; outline: none; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.account-form textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,224,.12); }
.perm-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.perm-actions { display: flex; gap: 8px; }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.perm-group { border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: #f8fafc; }
.perm-group h4 { margin: 0 0 4px; font-size: 13px; }
.perm-group p { margin: 0 0 10px; color: var(--muted); font-size: 11px; }
.perm-group .check-row { margin: 6px 0; font-size: 12px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.account-actions .primary-button, .account-actions .secondary-button, .account-actions .danger-button { width: auto; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 80; min-width: 240px; max-width: min(400px, calc(100vw - 44px)); padding: 12px 15px; border-radius: 6px; background: #172b3d; color: #fff; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #a92938; }
.sidebar-scrim { display: none; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #edf2f6; }
.login-shell { width: min(880px, 100%); min-height: 520px; display: grid; grid-template-columns: .9fr 1.1fr; overflow: hidden; border: 1px solid #d4dee7; border-radius: 8px; background: #fff; box-shadow: 0 18px 48px rgba(19,42,62,.12); }
.login-brand { padding: 56px 44px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; background: var(--navy); color: #fff; }
.login-brand h1 { margin: 22px 0 6px; font-size: 32px; }
.login-brand p { margin: 0; color: #a9bed0; font-size: 15px; }
.login-status { margin-top: 54px; padding-top: 22px; width: 100%; border-top: 1px solid rgba(255,255,255,.12); color: #b9cbd9; font-size: 12px; }
.login-status span { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: #36c584; }
.login-form-panel { display: grid; place-items: center; padding: 50px; }
.login-form { width: min(330px, 100%); display: grid; gap: 20px; }
.login-form h2 { margin: 6px 0 0; font-size: 24px; }
.eyebrow { color: var(--blue); font-weight: 800; font-size: 11px; text-transform: uppercase; }
.login-error { margin: 0; padding: 10px 12px; border-radius: 5px; background: var(--red-soft); color: var(--red); font-size: 12px; }

@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .chain-grid { grid-template-columns: repeat(3, 1fr); }
  .chain-grid > div:nth-child(3) { border-right: 0; }
  .chain-grid > div:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 20; background: rgba(10,25,38,.42); }
  .sidebar-scrim.show { display: block; }
  .page { margin-left: 0; }
  .topbar { height: 68px; padding: 0 16px; }
  .topbar h1 { font-size: 17px; }
  .topbar p { display: none; }
  .menu-button { display: grid; place-items: center; }
  .activity span:last-child { display: none; }
  .main-content { padding: 14px 12px 26px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 94px; padding: 15px; }
  .metric strong { font-size: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .perm-grid { grid-template-columns: 1fr; }
  .runtime-strip { grid-template-columns: 1fr; }
  .runtime-strip div { border-right: 0; border-bottom: 1px solid var(--line); }
  .runtime-strip div:last-child { border-bottom: 0; }
  .chain-grid { grid-template-columns: 1fr 1fr; }
  .chain-grid > div { border-bottom: 1px solid var(--line); }
  .chain-grid > div:nth-child(odd) { border-right: 1px solid var(--line); }
  .chain-grid > div:nth-child(even) { border-right: 0; }
  .settings-grid { grid-template-columns: 1fr; }
  .panel-heading { align-items: flex-start; }
  .file-row { grid-template-columns: 1fr auto; padding: 12px 0; }
  .file-row .file-meta:nth-child(3) { display: none; }
  .login-page { padding: 0; }
  .login-shell { min-height: 100vh; grid-template-columns: 1fr; border: 0; border-radius: 0; }
  .login-brand { min-height: 210px; padding: 34px 28px; }
  .login-brand h1 { margin-top: 14px; font-size: 26px; }
  .login-status { margin-top: 24px; padding-top: 14px; }
  .login-form-panel { padding: 38px 28px; align-items: start; }
}

