:root {
  --primary: #245987;
  --primary-strong: #17446f;
  --primary-soft: #eaf2f8;
  --accent: #2e74b5;
  --surface: #ffffff;
  --surface-muted: #f5f7fa;
  --background: #eef2f6;
  --text: #202b36;
  --muted: #667085;
  --border: #d6dee7;
  --danger: #b42318;
  --success: #1f6f4a;
  --warning: #8a6116;
  --shadow: 0 12px 34px rgb(31 77 120 / 9%);
  --radius: 12px;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--background);
  font-size: 16px;
  line-height: 1.55;
}

button, input { font: inherit; }

button { cursor: pointer; }

button:disabled { cursor: not-allowed; opacity: 0.48; }

:focus-visible {
  outline: 3px solid rgb(46 116 181 / 35%);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  color: white;
  background: var(--primary-strong);
  border-radius: 8px;
}

.skip-link:focus { top: 12px; }

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgb(36 89 135 / 8%), transparent 50%),
    var(--background);
}

.login-card {
  width: min(100%, 420px);
  padding: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 24px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.eyebrow, .section-kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

h1 { margin-bottom: 8px; font-size: clamp(24px, 3vw, 32px); line-height: 1.25; }

h2 { margin-bottom: 6px; font-size: 20px; line-height: 1.35; }

.login-copy, .helper { color: var(--muted); }

.login-copy { margin-bottom: 28px; }

label { display: block; margin-bottom: 8px; font-weight: 650; }

input {
  width: 100%;
  min-height: 46px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid #bfcbd7;
  border-radius: 8px;
  color: var(--text);
  background: white;
}

input:hover { border-color: #91a8bc; }

input:focus { border-color: var(--accent); }

.button {
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.button.primary { color: white; background: var(--primary); }
.button.primary:hover:not(:disabled) { background: var(--primary-strong); }
.button.ghost { color: var(--primary); background: white; border-color: var(--border); }
.button.ghost:hover:not(:disabled) { background: var(--primary-soft); border-color: #a8bfd3; }
.button.danger { color: var(--danger); background: white; border-color: #efc5c0; }
.button.danger:hover { background: #fff3f2; }
.button.small { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.button.full { width: 100%; }

.field-error { min-height: 24px; margin: -8px 0 10px; color: var(--danger); font-size: 14px; }

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(20px, 5vw, 64px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar h1 { margin: 0; font-size: 24px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.user-chip, .status-badge, .count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}

.user-chip { color: var(--muted); background: var(--surface-muted); }

.content {
  width: min(1180px, calc(100% - 40px));
  margin: 28px auto 64px;
}

.schedule-panel, .platform-panel, .keyword-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 18px rgb(31 77 120 / 5%);
}

.schedule-panel { padding: 24px; margin-bottom: 20px; }

.section-heading, .keyword-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.section-heading.compact { padding: 20px 20px 10px; }

.helper { margin-bottom: 0; font-size: 14px; }

.schedule-summary { display: flex; align-items: center; gap: 12px; font-variant-numeric: tabular-nums; }
.status-badge { color: var(--primary-strong); background: var(--primary-soft); }
.status-badge.high { color: var(--warning); background: #fff5dc; }
.count-badge { color: var(--primary); background: var(--primary-soft); }

.month-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(58px, 1fr));
  gap: 8px;
  margin-top: 20px;
}

.month-option { position: relative; }
.month-option input { position: absolute; opacity: 0; pointer-events: none; }
.month-option label {
  min-height: 48px;
  display: grid;
  place-items: center;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #445566;
  background: white;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.month-option label:hover { border-color: #91a8bc; background: var(--surface-muted); }
.month-option input:focus-visible + label { outline: 3px solid rgb(46 116 181 / 35%); outline-offset: 2px; }
.month-option input:checked + label { border-color: var(--primary); color: white; background: var(--primary); }

.section-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 20px; }
.section-actions .field-error { margin: 0 auto 0 0; }

.keyword-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; }
.platform-panel { align-self: start; overflow: hidden; }
.platform-list { padding: 8px; }
.platform-item {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
}
.platform-item:hover { background: var(--surface-muted); }
.platform-item.active { border-color: #bfd3e5; color: var(--primary-strong); background: var(--primary-soft); }
.platform-meta { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.platform-count { color: var(--muted); font-variant-numeric: tabular-nums; }

.keyword-panel { min-height: 520px; padding: 24px; }
.keyword-header { padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.keyword-form { display: flex; align-items: flex-end; gap: 12px; padding: 20px 0 8px; }
.input-group { flex: 1; }
.input-group input { margin-bottom: 0; }
.form-actions { display: flex; gap: 8px; }

.keyword-list { display: grid; gap: 8px; margin-top: 12px; }
.keyword-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.keyword-text { overflow-wrap: anywhere; }
.row-actions { display: flex; flex: none; gap: 8px; }

.empty-state {
  padding: 56px 20px;
  border: 1px dashed #bfcbd7;
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(380px, calc(100vw - 40px));
  padding: 12px 16px;
  border-radius: 8px;
  color: white;
  background: #263238;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .month-grid { grid-template-columns: repeat(6, 1fr); }
  .keyword-layout { grid-template-columns: 1fr; }
  .platform-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
}

@media (max-width: 600px) {
  .login-card { padding: 28px 22px; }
  .topbar { align-items: flex-start; padding: 16px 20px; }
  .topbar-actions { flex-direction: column; align-items: flex-end; }
  .content { width: min(100% - 24px, 1180px); margin-top: 12px; }
  .schedule-panel, .keyword-panel { padding: 18px; }
  .section-heading, .keyword-header { flex-direction: column; }
  .schedule-summary { width: 100%; justify-content: space-between; }
  .month-grid { grid-template-columns: repeat(4, 1fr); }
  .platform-list { grid-template-columns: repeat(2, 1fr); }
  .keyword-form { align-items: stretch; flex-direction: column; }
  .form-actions .button { flex: 1; }
  .keyword-row { align-items: flex-start; flex-direction: column; }
  .row-actions { width: 100%; }
  .row-actions .button { flex: 1; }
  .section-actions { align-items: stretch; flex-direction: column; }
}

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