:root {
  color-scheme: light;
  --canvas: #f3f5fa;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --ink: #182033;
  --muted: #687086;
  --line: #e3e7ef;
  --brand: #5b63d9;
  --brand-dark: #4249b5;
  --success: #17875d;
  --warning: #b46b0b;
  --danger: #c53e4c;
  --shadow: 0 18px 46px rgba(31, 42, 76, .09);
  --radius-lg: 22px;
  --radius-md: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
a { color: var(--brand-dark); text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(91, 99, 217, .28); outline-offset: 2px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 22px; background: #20253a; color: #fff; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; margin-bottom: 38px; }
.brand-mark, .login-logo { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(135deg, #7b83f0, #4c54c7); color: #fff; font-weight: 800; box-shadow: 0 10px 30px rgba(91, 99, 217, .35); }
.brand strong, .brand small { display: block; }
.brand small { color: #aeb5d0; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.nav { display: grid; gap: 8px; }
.nav a { color: #bfc5dc; padding: 12px 14px; border-radius: 11px; transition: .18s ease; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.10); color: #fff; }
.logout-form { margin-top: auto; }
.main-content { min-width: 0; width: 100%; max-width: 1400px; padding: 42px clamp(24px, 4vw, 64px); }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 3vw, 38px); letter-spacing: -.035em; }
h2 { font-size: 20px; letter-spacing: -.02em; }
.eyebrow { margin-bottom: 7px; color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
.muted, small { color: var(--muted); }

.panel, .stat-card { background: var(--surface); border: 1px solid rgba(220,225,236,.85); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card { padding: 20px; display: flex; align-items: center; gap: 14px; }
.stat-card p { margin: 0 0 5px; color: var(--muted); font-size: 13px; }
.stat-card strong { font-size: 17px; }
.stat-icon { flex: 0 0 auto; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: #eef0ff; color: var(--brand); font-weight: 800; }
.stat-icon.success, .status-dot.success { background: #e8f7f0; color: var(--success); }
.stat-icon.warning { background: #fff5e5; color: var(--warning); }
.stat-icon.failed, .stat-icon.timeout { background: #fff0f1; color: var(--danger); }
.stat-icon.running { animation: pulse 1.5s infinite; }

.dashboard-grid, .content-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); gap: 18px; }
.panel { padding: 24px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-heading h2 { margin-bottom: 0; }
.config-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.config-summary div { padding: 14px; background: var(--surface-soft); border-radius: 12px; }
.config-summary span, .config-summary strong { display: block; }
.config-summary span { color: var(--muted); font-size: 12px; margin-bottom: 6px; }

.button { min-height: 42px; padding: 10px 16px; border: 0; border-radius: 11px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--brand); color: #fff; box-shadow: 0 8px 22px rgba(91, 99, 217, .24); }
.button-primary:hover { background: var(--brand-dark); }
.button-secondary { background: #edf0ff; color: var(--brand-dark); }
.button-danger { background: var(--danger); color: #fff; }
.button-ghost { width: 100%; background: rgba(255,255,255,.08); color: #d7daea; }
.button-wide { width: 100%; }
.run-now-form, .page-actions { display: flex; align-items: end; gap: 10px; }
.run-now-form label { color: var(--muted); font-size: 12px; font-weight: 700; }
.run-now-form input { width: 96px; }

.run-list { display: grid; }
.run-row { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 12px; padding: 12px 2px; border-top: 1px solid var(--line); color: var(--ink); }
.run-row:first-child { border-top: 0; }
.run-row small { display: block; margin-top: 3px; }
.run-duration { color: var(--muted); font-size: 13px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #a9b0c2; }
.status-dot.success { background: var(--success); }
.status-dot.failed, .status-dot.timeout { background: var(--danger); }
.status-dot.running { background: var(--brand); }
.status-dot.partial_success { background: var(--warning); }

.stack { display: grid; gap: 18px; }
.field { display: grid; gap: 8px; }
.field label { font-weight: 700; font-size: 14px; }
input, textarea, select { width: 100%; min-height: 44px; padding: 11px 13px; border: 1px solid #d8ddea; border-radius: 11px; color: var(--ink); background: #fff; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); outline: 3px solid rgba(91,99,217,.12); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row.single { grid-template-columns: 1fr; }
.secret-details { border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.secret-details summary { cursor: pointer; font-weight: 700; }
.secret-details summary span { margin-left: 8px; color: var(--muted); font-weight: 400; font-size: 12px; }
.secret-grid { display: grid; gap: 10px; margin-top: 14px; }
.form-actions { display: flex; justify-content: flex-end; }
.config-status dl { margin: 0; }
.config-status dl div { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.config-status dt { color: var(--muted); }
.config-status dd { margin: 0; text-align: right; font-weight: 700; }
.schedule-section { margin-top: 18px; }
.schedule-panel { max-width: 760px; }
.switch-row, .schedule-overview { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.switch { position: relative; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { display: block; width: 52px; height: 30px; padding: 3px; border-radius: 999px; background: #cfd4df; cursor: pointer; transition: .2s ease; }
.switch span::after { content: ""; display: block; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 3px 10px rgba(0,0,0,.16); transition: .2s ease; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(22px); }
.schedule-overview { margin-top: 18px; }
.schedule-overview h2 { margin-bottom: 5px; }
.schedule-meta { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.schedule-meta strong { color: var(--ink); font-size: 15px; }

.table-panel { overflow: hidden; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 18px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: var(--surface-soft); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.status-badge { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px; background: #edf0f5; color: #596174; font-size: 12px; font-weight: 800; }
.status-badge.success { background: #e8f7f0; color: var(--success); }
.status-badge.failed, .status-badge.timeout { background: #fff0f1; color: var(--danger); }
.status-badge.running { background: #eef0ff; color: var(--brand-dark); }
.status-badge.partial_success { background: #fff5e5; color: var(--warning); }
.status-badge.large { padding: 9px 14px; font-size: 14px; }

.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metric span, .metric strong { display: block; }
.metric span { color: var(--muted); font-size: 13px; margin-bottom: 7px; }
.metric strong { font-size: 22px; }
.log-view { max-height: 560px; overflow: auto; background: #151a28; color: #d9deed; border-radius: 14px; padding: 16px; font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; }
.log-line { display: grid; grid-template-columns: 120px 1fr; gap: 14px; }
.log-line time { color: #818aa6; }
.live-indicator { color: var(--brand); font-size: 12px; font-weight: 800; }

.alert { margin-bottom: 16px; padding: 13px 15px; border-radius: 12px; background: #edf0ff; color: var(--brand-dark); }
.alert-error { background: #fff0f1; color: #9f2634; }
.alert-success { background: #e8f7f0; color: #116a49; }
.alert-warning { background: #fff5e5; color: #8c5208; }
.empty-state { padding: 34px 16px; text-align: center; color: var(--muted); }
.empty-state span { font-size: 34px; color: var(--brand); }
.empty-state.compact { padding: 20px 8px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #e5e7ff 0, transparent 35%), var(--canvas); }
.login-card { width: min(430px, 100%); padding: 36px; border-radius: 26px; background: rgba(255,255,255,.94); border: 1px solid rgba(255,255,255,.75); box-shadow: 0 28px 80px rgba(37,47,84,.14); }
.login-logo { margin-bottom: 26px; }

@keyframes pulse { 50% { opacity: .45; transform: scale(.92); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 1000px) {
  .stats-grid, .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 18px; flex-direction: row; align-items: center; gap: 16px; }
  .brand { margin: 0; }
  .brand small, .brand strong { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .nav { display: flex; gap: 4px; flex: 1; }
  .nav a { padding: 9px 10px; font-size: 13px; }
  .logout-form { margin: 0; }
  .logout-form .button { width: auto; font-size: 0; padding: 9px; }
  .logout-form .button::after { content: "退出"; font-size: 12px; }
  .main-content { padding: 28px 16px; }
  .page-header { align-items: flex-end; }
  .stats-grid, .detail-grid { grid-template-columns: 1fr 1fr; }
  .config-summary, .form-row { grid-template-columns: 1fr; }
  .table-panel { background: transparent; border: 0; box-shadow: none; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tr { margin-bottom: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
  td { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border: 0; }
  td::before { content: attr(data-label); color: var(--muted); }
  .log-line { grid-template-columns: 1fr; gap: 2px; margin-bottom: 8px; }
}
@media (max-width: 480px) {
  .stats-grid, .detail-grid { grid-template-columns: 1fr; }
  .page-header { display: grid; }
  .login-card { padding: 28px 22px; }
}
