:root {
  --ink: #1f2933;
  --muted: #667085;
  --line: #d9dee5;
  --canvas: #f7f8fa;
  --surface: #ffffff;
  --blue: #2563eb;
  --blue-soft: #eaf0ff;
  --green: #16803c;
  --green-soft: #e9f7ed;
  --amber: #9a5b00;
  --amber-soft: #fff5dd;
  --red: #bf3030;
  --red-soft: #fff0f0;
  --radius: 7px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.sidebar { background: #20272e; color: #e5e7eb; padding: 22px 14px 16px; display: flex; flex-direction: column; border-right: 1px solid #11161b; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 0 8px 28px; }
.brand-mark, .login-mark { width: 30px; height: 30px; display: grid; place-items: center; background: #2aa876; color: white; border-radius: 6px; font-weight: 800; }
.nav-list { display: grid; gap: 4px; }
.nav-link { padding: 10px 12px; border-radius: 5px; color: #b6c0ca; font-size: 14px; }
.nav-link:hover { background: #2b343d; color: white; }
.nav-link.active { background: #31475f; color: white; font-weight: 650; }
.logout-form { margin-top: auto; padding: 14px 8px 0; }
.text-button { border: 0; background: none; color: #b6c0ca; padding: 6px 0; cursor: pointer; }
.text-button:hover { color: white; }

.main-content { width: min(1220px, 100%); margin: 0 auto; padding: 42px clamp(22px, 4vw, 64px) 72px; }
.page-header { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding-bottom: 30px; }
.page-header.compact { padding-bottom: 24px; }
.page-header h1 { margin: 4px 0 8px; font-size: 29px; line-height: 1.2; letter-spacing: 0; }
.page-header p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.eyebrow { color: var(--blue); margin: 0; font-size: 11px; font-weight: 750; letter-spacing: 0.08em; }

.primary-button, .secondary-button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; padding: 0 15px; font-size: 14px; font-weight: 650; cursor: pointer; border: 1px solid transparent; white-space: nowrap; }
.primary-button { background: var(--blue); color: white; }
.primary-button:hover { background: #1d4ed8; }
.secondary-button { color: #344054; background: white; border-color: #cdd5df; }
.secondary-button:hover { background: #f8fafc; border-color: #98a2b3; }
.full-width { width: 100%; }
.text-link { color: var(--blue); font-size: 14px; font-weight: 650; }
.text-link:hover { text-decoration: underline; }

.status-band { display: flex; align-items: center; justify-content: space-between; gap: 24px; background: #eff6ff; border: 1px solid #c7ddff; padding: 16px 18px; margin-bottom: 24px; border-radius: var(--radius); }
.status-band div { display: grid; gap: 3px; }
.status-band strong { font-size: 16px; color: #1d4ed8; }
.status-band p { margin: 0; color: #475467; font-size: 13px; line-height: 1.5; }
.status-label { color: var(--muted); font-size: 12px; }
.apply-band { display: flex; align-items: center; justify-content: space-between; gap: 24px; background: #eef8f1; border: 1px solid #c5e7cf; padding: 16px 18px; margin-bottom: 24px; border-radius: var(--radius); }
.apply-band div { display: grid; gap: 3px; }
.apply-band strong { font-size: 15px; color: #166534; }
.apply-band p { margin: 0; color: #475467; font-size: 12px; }
.apply-band.is-error { background: var(--red-soft); border-color: #f3c3c3; }
.apply-band.is-error strong { color: var(--red); }
.primary-button:disabled { background: #8ca4c9; cursor: not-allowed; }

.subject-list { border-top: 1px solid var(--line); }
.subject-row { min-height: 112px; display: grid; grid-template-columns: minmax(270px, 1.4fr) minmax(190px, 0.8fr) auto; align-items: center; gap: 24px; padding: 20px 4px; border-bottom: 1px solid var(--line); }
.subject-row.is-active { background: #fbfdff; }
.subject-ident { display: flex; gap: 14px; align-items: center; min-width: 0; }
.subject-avatar { flex: 0 0 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #eaf0ff; color: #2458c5; font-weight: 750; }
.subject-title-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.subject-title-row h2 { margin: 0; font-size: 17px; }
.subject-ident p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 700; }
.badge.blue { color: #1849a9; background: var(--blue-soft); }
.badge.green { color: #107235; background: var(--green-soft); }
.badge.gray { color: #475467; background: #eef1f5; }
.subject-statuses { display: flex; flex-wrap: wrap; gap: 7px; }
.config-state { color: #7a4c00; background: var(--amber-soft); border-radius: 999px; padding: 4px 8px; font-size: 11px; }
.config-state.ready { color: var(--green); background: var(--green-soft); }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }

.lower-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 44px; padding-top: 44px; }
.info-section { border-top: 1px solid var(--line); padding-top: 18px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2 { margin: 0 0 5px; font-size: 17px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.key-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
.key-values div { display: grid; gap: 5px; }
.key-values dt { color: var(--muted); font-size: 12px; }
.key-values dd { margin: 0; font-size: 15px; font-weight: 650; }
.activity-preview { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.activity-preview li { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; }
.activity-preview time { color: var(--muted); white-space: nowrap; }
.muted { color: var(--muted) !important; }

.settings-form { display: grid; gap: 32px; }
.narrow-form { max-width: 680px; }
.form-section { border-top: 1px solid var(--line); padding-top: 20px; }
.form-grid { display: grid; gap: 16px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 650; }
.field.full { grid-column: 1 / -1; }
.field input, .field textarea { width: 100%; border: 1px solid #cdd5df; background: white; color: var(--ink); border-radius: 6px; padding: 9px 10px; font-size: 14px; line-height: 1.45; font-weight: 400; outline: none; }
.field input { min-height: 40px; }
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.field input[readonly] { background: #f2f4f7; color: #667085; }
.secret-note { color: var(--muted); font-size: 11px; font-weight: 400; }
.toggle-row { display: inline-flex; align-items: center; gap: 9px; margin: 0 0 16px; color: #344054; font-size: 14px; cursor: pointer; }
.toggle-row input { accent-color: var(--blue); width: 16px; height: 16px; }
.inline-toggles { display: flex; flex-wrap: wrap; gap: 22px; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 22px; }
.flash-stack { display: grid; gap: 10px; margin: 0 0 20px; }
.flash { border-radius: 6px; padding: 10px 12px; font-size: 14px; }
.flash.success { color: #0f5d2a; background: var(--green-soft); border: 1px solid #bee7ca; }
.flash.error { color: #9f2424; background: var(--red-soft); border: 1px solid #f3c3c3; }
.activity-table-wrap { overflow-x: auto; }
.activity-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.activity-table th, .activity-table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.activity-table th { color: var(--muted); font-size: 12px; font-weight: 650; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #edf2f0; }
.login-panel { width: min(100%, 390px); background: var(--surface); border: 1px solid #d8e0dc; border-radius: 8px; padding: 36px; box-shadow: 0 18px 50px rgba(31, 41, 51, 0.09); }
.login-mark { width: 42px; height: 42px; margin-bottom: 24px; font-size: 18px; }
.login-panel h1 { margin: 5px 0 8px; font-size: 25px; }
.login-copy { margin: 0 0 26px; color: var(--muted); font-size: 14px; }
.login-form { display: grid; gap: 17px; }
.login-form label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 650; }
.login-form input { min-height: 42px; border: 1px solid #cdd5df; border-radius: 6px; padding: 9px 10px; outline: none; }
.login-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; padding: 14px 18px; flex-direction: row; align-items: center; gap: 18px; overflow-x: auto; }
  .brand { padding: 0; white-space: nowrap; }
  .nav-list { display: flex; gap: 4px; }
  .nav-link { white-space: nowrap; }
  .logout-form { margin: 0 0 0 auto; padding: 0; white-space: nowrap; }
  .main-content { padding-top: 30px; }
  .subject-row { grid-template-columns: 1fr; gap: 14px; }
  .row-actions { justify-content: flex-start; }
  .lower-grid { grid-template-columns: 1fr; gap: 34px; }
}

@media (max-width: 640px) {
  .page-header, .status-band, .apply-band { align-items: flex-start; flex-direction: column; }
  .page-header h1 { font-size: 25px; }
  .two-columns, .three-columns { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .subject-statuses { gap: 6px; }
  .form-actions { justify-content: stretch; }
  .form-actions > * { flex: 1; }
  .login-panel { padding: 28px 22px; }
}
