:root {
  --bg: #f5f3ee;
  --surface: #fffdf8;
  --surface-2: #ffffff;
  --ink: #24231f;
  --muted: #706b61;
  --line: #e4ded2;
  --teal: #176f69;
  --teal-soft: #e4f1ef;
  --gold: #9a6b22;
  --red: #a64a43;
  --green: #287a4b;
  --shadow: 0 20px 60px rgba(37, 31, 19, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1040px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

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

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background: var(--bg);
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  display: grid;
  width: min(420px, 100%);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.login-card input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}

.login-card button {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.app[hidden] {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #fbf8f1;
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #1f4f4b;
  color: #fffaf0;
  font-weight: 800;
}

.brand strong {
  display: block;
}

.brand span,
.eyebrow,
.section-toolbar p,
.api-box label,
td small,
.panel-head span,
.top-actions span {
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  justify-content: flex-start;
  padding: 10px 12px;
  text-align: left;
}

.nav button.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.api-box {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.api-box input,
.settings-panel input,
.settings-panel select,
.settings-panel textarea,
.drawer input,
.drawer select,
.drawer textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

.api-box input {
  padding: 9px 10px;
}

.main {
  padding: 26px;
}

.topline,
.section-toolbar,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topline {
  margin-bottom: 20px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: 28px;
}

h2 {
  font-size: 19px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-actions button,
.section-toolbar button,
.api-box button,
.drawer .save-btn {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.page {
  display: none;
}

.page.active {
  display: grid;
  gap: 18px;
}

.status-banner {
  border: 1px solid #d8caa9;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff7dd;
  color: #745119;
}

.status-banner.ok {
  border-color: #b8dcc7;
  background: #edf8f1;
  color: var(--green);
}

.status-banner.fail {
  border-color: #e5b8b4;
  background: #fff0ee;
  color: var(--red);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(37, 31, 19, 0.05);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin: 10px 0 4px;
  font-size: 28px;
}

.metric em {
  color: var(--teal);
  font-size: 12px;
  font-style: normal;
}

.work-grid,
.daily-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 14px;
}

.activity-studio {
  display: grid;
  grid-template-columns: minmax(360px, 0.78fr) minmax(520px, 1.22fr);
  gap: 16px;
  align-items: stretch;
}

.activity-input-panel {
  display: grid;
  gap: 14px;
}

#activity-raw-content {
  width: 100%;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  color: var(--ink);
  line-height: 1.7;
  resize: vertical;
}

.studio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.studio-actions button:first-child,
.studio-actions button:nth-child(2) {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.activity-page-preview {
  display: flex;
  min-height: 640px;
  overflow: hidden;
  border: 1px solid #e0d4bf;
  border-radius: 8px;
  padding: 22px;
  background: #ede5d7;
  box-shadow: 0 16px 48px rgba(37, 31, 19, 0.08);
}

.preview-empty {
  display: grid;
  width: 100%;
  min-height: 520px;
  place-content: center;
  gap: 10px;
  text-align: center;
}

.preview-empty span {
  color: var(--muted);
  font-size: 13px;
}

.preview-empty strong {
  color: var(--ink);
  font-size: 24px;
}

.activity-phone-shell {
  width: min(390px, 100%);
  max-height: 720px;
  margin: auto;
  overflow: auto;
  border: 9px solid #171a1f;
  border-radius: 34px;
  background: #f6f7f9;
  box-shadow: 0 24px 72px rgba(23, 26, 31, 0.22);
}

.activity-phone-top {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 22px;
  background: #171a1f;
}

.activity-phone-top::after {
  display: block;
  width: 74px;
  height: 4px;
  margin: 7px auto 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.34);
  content: "";
}

.activity-preview-hero {
  position: relative;
  display: grid;
  gap: 13px;
  min-height: 260px;
  padding: 26px 22px 34px;
  background:
    radial-gradient(circle at 84% 14%, rgba(216, 59, 45, 0.28), transparent 34%),
    linear-gradient(145deg, #1d3735 0%, #172d2b 58%, #111817 100%);
  color: #fffaf0;
}

.activity-preview-hero span {
  width: fit-content;
  border: 1px solid rgba(255, 250, 240, 0.28);
  border-radius: 6px;
  padding: 6px 9px;
  background: rgba(255, 250, 240, 0.08);
  color: #f4d8bd;
  font-size: 13px;
}

.activity-preview-hero h2 {
  max-width: 340px;
  font-size: 27px;
  line-height: 1.2;
  text-wrap: balance;
}

.activity-preview-hero p {
  max-width: 340px;
  color: rgba(255, 250, 240, 0.82);
  font-size: 14px;
  line-height: 1.75;
}

.activity-preview-value {
  margin: -20px 16px 14px;
  border: 1px solid #eadfcc;
  border-radius: 12px;
  padding: 14px;
  background: #fffaf0;
  color: #1d3735;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.65;
}

.activity-preview-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0 16px 14px;
  overflow: hidden;
  border: 1px solid #e7e9ee;
  border-radius: 12px;
  background: #e7e9ee;
}

.activity-preview-facts div {
  min-height: 72px;
  padding: 11px 12px;
  background: #fff;
}

.activity-preview-facts span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.activity-preview-facts strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14px;
}

.activity-preview-section {
  margin: 0 16px 14px;
  border: 1px solid #e7e9ee;
  border-radius: 12px;
  padding: 17px;
  background: #fff;
}

.activity-preview-section.priority {
  background: #fffdf8;
}

.activity-preview-section h3 {
  margin-bottom: 12px;
  color: #d83b2d;
  font-size: 15px;
}

.activity-preview-section ul,
.activity-preview-section ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: #3f454f;
  font-size: 14px;
  line-height: 1.65;
}

.activity-preview-note {
  display: grid;
  gap: 8px;
  margin: 0 16px 18px;
  border-radius: 12px;
  padding: 15px;
  background: #171a1f;
  color: #fff;
}

.activity-preview-note strong {
  color: #f4d8bd;
  font-size: 13px;
}

.activity-preview-note span {
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  line-height: 1.6;
}

.panel,
.table-wrap,
.daily-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(37, 31, 19, 0.05);
}

.panel,
.daily-card {
  padding: 16px;
}

.panel p,
.daily-card p,
.daily-card li {
  color: var(--muted);
  line-height: 1.7;
}

.task-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.task-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  text-align: left;
}

.section-toolbar {
  align-items: flex-end;
}

.section-toolbar p {
  margin-top: 6px;
  line-height: 1.6;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #faf7ef;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

td {
  font-size: 14px;
  overflow-wrap: anywhere;
}

td strong {
  display: block;
  margin-bottom: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

.pill.warn {
  background: #fff0d2;
  color: #8a5a0b;
}

.pill.red {
  background: #f8e4e2;
  color: var(--red);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions button {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 13px;
}

.row-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--teal);
  font-size: 13px;
  text-decoration: none;
}

.news-layout {
  display: grid;
  gap: 14px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  background: rgba(30, 27, 21, 0.34);
}

.drawer-backdrop[hidden] {
  display: none;
}

.drawer {
  width: min(520px, 100vw);
  height: 100vh;
  overflow: auto;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

#editor-form {
  display: grid;
  gap: 13px;
}

#editor-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.drawer input,
.drawer select {
  min-height: 40px;
  padding: 8px 10px;
}

.drawer textarea {
  min-height: 96px;
  padding: 10px;
  resize: vertical;
}

.drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.daily-card {
  display: grid;
  gap: 12px;
}

.daily-card ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.settings-panel {
  display: grid;
  gap: 13px;
}

.settings-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.settings-panel input,
.settings-panel select {
  min-height: 40px;
  padding: 8px 10px;
}

.settings-panel textarea {
  min-height: 84px;
  padding: 10px;
  resize: vertical;
}

.model-panel {
  grid-column: 1 / -1;
}

.settings-note,
.model-card {
  display: flex;
}

.settings-note {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #d8caa9;
  border-radius: 7px;
  padding: 10px 12px;
  background: #fff7dd;
}

.model-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.model-card {
  flex-direction: column;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

.model-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.model-card-head h3 {
  font-size: 16px;
}

.model-card-head span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.model-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.model-card input {
  min-height: 38px;
  padding: 8px 10px;
}

.model-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.model-card-actions button {
  min-height: 30px;
  padding: 4px 9px;
}

.model-card-actions button:first-child {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.settings-note strong {
  color: #745119;
  font-size: 13px;
}

.settings-note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-note-actions button {
  min-height: 30px;
  padding: 4px 9px;
  background: #fff;
}

.model-test-result.ok {
  border-color: #b8dcc7;
  background: #edf8f1;
  color: var(--green);
}

.model-test-result.fail {
  border-color: #e5b8b4;
  background: #fff0ee;
  color: var(--red);
}

.settings-inline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.runtime-panel {
  grid-column: 1 / -1;
}

.runtime-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.runtime-list div {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
}

.runtime-list span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.runtime-list strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 1180px) {
  body {
    min-width: 900px;
  }

  .metric-grid,
  .metric-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .work-grid,
  .daily-layout,
  .activity-studio {
    grid-template-columns: 1fr;
  }

  .settings-grid,
  .model-card-grid,
  .settings-inline,
  .runtime-list {
    grid-template-columns: 1fr;
  }
}
