:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #12151e;
  --surface-2: #1a1e2e;
  --line: rgba(255,255,255,.08);
  --text: #e8ecf4;
  --muted: #8a93aa;
  --accent: #7c6ef7;
  --accent-strong: #695bdc;
  --success: #34c98a;
  --warning: #f59e0b;
  --danger: #f56565;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(124,110,247,.12), transparent 60%), var(--bg); color: var(--text); line-height: 1.55; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }
button, a, input, select, summary { outline-offset: 3px; }
:focus-visible { outline: 3px solid var(--accent); }

.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 20; padding: .6rem 1rem; background: white; color: black; }
.skip-link:focus { top: 1rem; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex: 0 0 220px; flex-direction: column; width: 220px; height: 100vh; padding: 20px 12px; border-right: 1px solid var(--line); background: var(--surface); }
.sidebar-brand { padding: 4px 10px 20px; color: var(--text); font-size: 16px; font-weight: 700; line-height: 1.4; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-nav { display: flex; flex: 1; flex-direction: column; gap: 6px; }
.nav-item { padding: 11px 14px; border: 1px solid transparent; border-radius: 10px; color: var(--muted); font-size: 14px; }
.nav-item:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-item.active { color: var(--text); border-color: rgba(124,110,247,.35); background: rgba(124,110,247,.15); font-weight: 600; }
.sidebar-logout { margin-top: 12px; }
.logout-button { width: 100%; }
.content-column { flex: 1; min-width: 0; }
.http-warning { padding: .65rem clamp(1rem, 3vw, 2.5rem); color: #ffe4b5; background: #422f12; border-bottom: 1px solid #795820; font-size: .9rem; }
.main-content { width: 100%; padding: 16px; overflow: auto; }
.login-shell { min-height: 100vh; }
.login-content { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 2rem 0 4rem; }
.page-heading, .section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.page-heading { margin-bottom: 1.4rem; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .2rem; font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: 1.15rem; }
.eyebrow { margin: 0 0 .25rem; color: var(--accent); font-size: .78rem; text-transform: uppercase; letter-spacing: .15em; font-weight: 800; }
.muted, small { color: var(--muted); }

.login-card { width: min(440px, 100%); margin: clamp(2rem, 9vh, 7rem) auto; padding: clamp(1.5rem, 5vw, 2.5rem); border: 1px solid var(--line); border-radius: 1rem; background: rgba(17,26,40,.96); box-shadow: 0 28px 80px rgba(0,0,0,.35); }
.stacked-form, .settings-form { display: grid; gap: 1rem; }
label { display: grid; gap: .4rem; color: #d9e5f7; font-weight: 650; }
input, select { width: 100%; min-height: 2.75rem; padding: .58rem .72rem; border: 1px solid var(--line); border-radius: .5rem; color: var(--text); background: #0b1320; }
input[type="checkbox"] { width: 1.1rem; min-height: 1.1rem; accent-color: var(--accent); }
.primary-button, .secondary-button { min-height: 2.75rem; padding: .65rem 1rem; border: 1px solid transparent; border-radius: .55rem; font-weight: 800; cursor: pointer; }
.primary-button { color: #06101d; background: var(--accent); }
.primary-button:hover { background: #84baff; }
.secondary-button { color: var(--text); border-color: var(--line); background: var(--surface-2); }
.danger-button { background: var(--danger); }

.alert { display: flex; flex-wrap: wrap; gap: .4rem .8rem; margin-bottom: 1.25rem; padding: .85rem 1rem; border: 1px solid; border-radius: .65rem; }
.alert.error { color: #ffd9de; border-color: #7a3540; background: #351923; }
.alert.warning { color: #ffe7bc; border-color: #7b5c28; background: #352817; }
.alert.success { color: #caffea; border-color: #29684f; background: #163429; }
.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.status-card, .panel, .history-card { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.status-card { display: grid; align-content: start; gap: .5rem; min-height: 8.2rem; padding: 1rem; }
.status-card span { color: var(--muted); font-size: .85rem; }
.status-card strong { overflow-wrap: anywhere; }
.healthy { color: var(--success); }
.panel { margin: 1rem 0; padding: 1.1rem; }
.page-panel { min-height: calc(100vh - 32px); margin: 0; padding: 20px; }
.subpanel { margin-top: 1rem; padding: 1.1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.toolbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .65rem; }
.auto-toggle-form { margin: 0; }
.auto-toggle-button { display: inline-flex; align-items: center; gap: .55rem; min-height: 2.75rem; padding: .65rem 1rem; border: 1px solid var(--line); border-radius: .55rem; color: var(--text); background: var(--surface-2); cursor: pointer; font-weight: 700; }
.toggle-dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--muted); }
.auto-toggle-button.is-on { border-color: rgba(52,201,138,.45); }
.auto-toggle-button.is-on .toggle-dot { background: var(--success); box-shadow: 0 0 8px rgba(52,201,138,.65); }
.auto-toggle-button.is-off { color: var(--muted); }
.section-heading { margin-bottom: .85rem; }
.section-heading h2 { margin: 0; }
.plan-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
.plan-grid article { display: grid; gap: .25rem; padding: .85rem; border-radius: .55rem; background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .75rem; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.empty { color: var(--muted); text-align: center; }
.status-pill { display: inline-block; padding: .18rem .55rem; border-radius: 99px; background: var(--surface-2); white-space: nowrap; }
.status-success { color: var(--success); background: #163429; }
.status-failed { color: #ffb6c0; background: #351923; }
.status-skipped { color: var(--warning); background: #352817; }

.form-section h2 { padding-bottom: .7rem; border-bottom: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.four-columns { grid-template-columns: repeat(4, 1fr); }
.checkbox-row { display: flex; align-items: center; }
.toggle-card { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.toggle-row { display: flex; align-items: flex-start; gap: 10px; }
.toggle-row input { width: auto; margin-top: 3px; }
.toggle-text { display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.toggle-text small { color: var(--muted); font-weight: 400; }
fieldset { margin: 0 0 1rem; padding: .75rem; border: 1px solid var(--line); border-radius: .55rem; }
legend { padding: 0 .35rem; color: var(--muted); }
.weekday-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .5rem; }
.weekday-grid label { display: flex; align-items: center; gap: .35rem; font-weight: 500; }
.advanced summary { cursor: pointer; font-weight: 800; }
.advanced[open] summary { margin-bottom: 1rem; }
.form-actions { display: flex; justify-content: flex-end; }

.filter-bar { display: grid; grid-template-columns: repeat(5, 1fr) auto; align-items: end; gap: .75rem; margin-bottom: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface); }
.history-list { display: grid; gap: .8rem; }
.history-card { overflow: hidden; }
.history-summary { display: grid; grid-template-columns: 1.1fr 1fr auto 2fr; align-items: center; gap: 1rem; padding: 1rem; }
.history-summary > div { display: grid; }
.history-summary p { margin: 0; }
.history-card details { border-top: 1px solid var(--line); }
.history-card summary { padding: .7rem 1rem; cursor: pointer; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin: 0; padding: 0 1rem 1rem; }
.detail-grid div { min-width: 0; padding: .7rem; border-radius: .45rem; background: var(--surface-2); }
.detail-grid dt { color: var(--muted); font-size: .8rem; }
.detail-grid dd { margin: .2rem 0 0; overflow-wrap: anywhere; }
.log-list { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.log-row { display: flex; align-items: center; min-height: 104px; padding: 22px 16px; border-bottom: 1px solid var(--line); }
.log-row:last-child { border-bottom: 0; }
.log-row p { margin: 0; overflow-wrap: anywhere; }
.log-success strong { color: var(--success); }
.log-failed strong { color: var(--danger); }
.log-skipped strong { color: var(--warning); }
.log-empty { margin: 0; padding: 2rem; }

@media (max-width: 850px) {
  .status-grid, .plan-grid { grid-template-columns: repeat(2, 1fr); }
  .four-columns, .filter-bar { grid-template-columns: repeat(2, 1fr); }
  .history-summary { grid-template-columns: 1fr auto; }
  .history-summary p { grid-column: 1 / -1; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: .8rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-brand { padding-bottom: .8rem; }
  .sidebar-nav { flex-flow: row wrap; }
  .nav-item { flex: 1 1 7rem; text-align: center; }
  .sidebar-logout { margin-top: .5rem; }
  .main-content { padding: 10px; }
  .page-panel { min-height: auto; }
}

@media (max-width: 560px) {
  .login-content { width: min(100% - 1rem, 1180px); padding-top: 1rem; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .toolbar-actions { justify-content: stretch; }
  .toolbar-actions form, .toolbar-actions button { width: 100%; }
  .status-grid, .plan-grid, .form-grid, .four-columns, .filter-bar, .detail-grid { grid-template-columns: 1fr; }
  .weekday-grid { grid-template-columns: repeat(2, 1fr); }
  .history-summary { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
