:root {
  --ink: #17201f;
  --muted: #69726f;
  --line: #d9dfdc;
  --surface: #ffffff;
  --canvas: #f3f5f3;
  --green: #176b52;
  --green-dark: #10523f;
  --blue: #245b8f;
  --orange: #ae5b20;
  --danger: #a5372c;
  --shadow: 0 12px 40px rgba(23, 32, 31, .09);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.page-shell { width: min(980px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 64px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px 0; }
.login-panel {
  width: min(430px, 100%);
  padding: 38px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 28px;
  color: #fff;
  background: var(--green);
  border-radius: 6px;
  font-size: 21px;
  font-weight: 700;
}
.eyebrow { margin: 0 0 7px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
h1, h2, p { margin-top: 0; }
.login-panel h1 { margin-bottom: 30px; font-size: 30px; line-height: 1.2; }
.login-form label, .week-picker label, .form-toolbar label { display: block; color: var(--muted); font-size: 13px; font-weight: 650; }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 8px; }
input[type="password"], input[type="date"] {
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bfc8c4;
  border-radius: 6px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 82, .12); }
.primary-button, .secondary-button, .quiet-button, .link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
.primary-button { color: #fff; background: var(--green); }
.primary-button:hover { background: var(--green-dark); }
.secondary-button { color: var(--ink); background: #fff; border-color: #bfc8c4; }
.secondary-button:hover { background: #eef1ef; }
.quiet-button { min-height: 38px; padding: 0 14px; color: inherit; background: transparent; border-color: rgba(255,255,255,.46); }

.topbar { color: #fff; background: var(--green); border-bottom: 4px solid #e3b643; }
.topbar-blue { background: var(--blue); }
.topbar-orange { background: var(--orange); }
.topbar-gray, .topbar-admin { background: #394442; }
.topbar-inner { width: min(980px, calc(100% - 32px)); min-height: 112px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.topbar h1 { margin: 0; font-size: 25px; line-height: 1.25; }
.topbar .eyebrow { color: rgba(255,255,255,.72); }

.notices { margin-bottom: 18px; }
.notice { padding: 12px 14px; border: 1px solid; border-radius: 6px; font-size: 14px; }
.notice-success { color: #155e47; background: #e8f4ef; border-color: #b6d8ca; }
.notice-error { color: #842b23; background: #faecea; border-color: #e8beb9; }
.report-form { display: grid; gap: 18px; }
.form-toolbar { display: flex; align-items: center; gap: 12px; padding: 4px 0 8px; }
.form-toolbar label { margin-right: -3px; }
.form-toolbar input { width: 156px; }
.saved-at { margin-left: auto; color: var(--muted); font-size: 12px; }
.field-section { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.field-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.field-heading > div { display: flex; align-items: baseline; gap: 10px; }
.field-heading h2 { margin: 0; font-size: 18px; }
.step-number, .char-count { color: var(--muted); font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
textarea {
  display: block;
  width: 100%;
  min-height: 180px;
  padding: 15px;
  resize: vertical;
  color: var(--ink);
  background: #fbfcfb;
  border: 1px solid #c8d0cc;
  border-radius: 5px;
  outline: none;
  line-height: 1.75;
}
textarea::placeholder { color: #929a97; }
.sticky-actions { display: flex; justify-content: flex-end; padding-top: 2px; }
.wide-button { min-width: 180px; }
.history-panel { margin-top: 18px; padding: 16px 18px; color: var(--muted); background: #e9eeeb; border-radius: 6px; font-size: 13px; }
.history-panel summary { color: var(--ink); font-weight: 700; cursor: pointer; }
.history-panel summary span { color: var(--muted); font-weight: 500; }
.history-panel ol { margin: 14px 0 0; padding-left: 22px; }
.history-panel li { margin: 7px 0; }

.admin-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 2px 0 22px; border-bottom: 1px solid var(--line); }
.week-picker { display: flex; align-items: flex-end; gap: 9px; }
.week-picker label { align-self: center; }
.week-links { display: flex; gap: 5px; overflow-x: auto; }
.week-links a { padding: 7px 9px; color: var(--muted); border-radius: 4px; font-size: 12px; text-decoration: none; white-space: nowrap; }
.week-links a.active { color: #fff; background: #485451; }
.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 24px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--line); }
.status-item { display: flex; align-items: flex-start; gap: 10px; min-width: 0; padding: 18px 15px; background: #fff; }
.status-dot { flex: 0 0 auto; width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--green); }
.status-blue .status-dot { background: var(--blue); }
.status-orange .status-dot { background: var(--orange); }
.status-gray .status-dot { background: #6c7472; }
.status-item h2 { margin-bottom: 6px; font-size: 14px; }
.status-item p { margin: 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.generate-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 0; }
.generation-title { display: flex; align-items: center; gap: 10px; }
.generate-bar h2 { margin-bottom: 5px; font-size: 20px; }
.generation-title h2 { margin-bottom: 0; }
.generate-bar p { margin: 0; color: var(--muted); font-size: 12px; }
.mode-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border: 1px solid #c9d0cd; border-radius: 4px; color: #5c6562; background: #fff; font-size: 11px; font-weight: 700; }
.mode-llm { color: #155e47; background: #e8f4ef; border-color: #b6d8ca; }
.checks { margin-bottom: 18px; padding: 17px 20px; color: #714117; background: #fff5e8; border-left: 4px solid #d88b35; }
.checks h2 { margin-bottom: 9px; font-size: 15px; }
.checks ul { margin: 0; padding-left: 20px; font-size: 13px; }
.checks li + li { margin-top: 5px; }
.editor-form textarea { min-height: 560px; background: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.75; }
.editor-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.error-panel { text-align: center; }
.error-code { margin-bottom: 12px; color: var(--orange); font-size: 42px; font-weight: 800; }
.error-panel h1 { margin-bottom: 28px; font-size: 20px; }

@media (max-width: 760px) {
  .page-shell, .topbar-inner { width: min(100% - 24px, 980px); }
  .page-shell { padding-top: 18px; padding-bottom: 96px; }
  .login-shell { width: 100%; padding: 0; }
  .login-panel { width: 100%; min-height: 100vh; padding: max(34px, env(safe-area-inset-top)) 24px 28px; border: 0; border-radius: 0; box-shadow: none; }
  .login-panel h1 { font-size: 28px; }
  .password-row { grid-template-columns: 1fr; }
  .password-row .primary-button { width: 100%; }
  .topbar-inner { min-height: 96px; }
  .topbar h1 { max-width: 260px; font-size: 21px; }
  .form-toolbar { flex-wrap: wrap; }
  .saved-at { width: 100%; margin-left: 0; }
  .field-section { padding: 18px 14px; }
  textarea { padding: 13px; font-size: 16px; }
  .sticky-actions { position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); }
  .wide-button { width: 100%; }
  .admin-toolbar { align-items: stretch; flex-direction: column; }
  .week-picker { width: 100%; }
  .week-picker input { flex: 1; }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
  .generate-bar { align-items: flex-start; }
  .editor-form textarea { min-height: 480px; }
  .editor-actions { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 400px) {
  .status-grid { grid-template-columns: 1fr; }
  .generate-bar { flex-direction: column; }
  .generate-bar form, .generate-bar button { width: 100%; }
}
