:root {
  color-scheme: light;
  --bg: #111111;
  --bg-soft: #1a1a1a;
  --surface: #f6f0e6;
  --surface-strong: #fffaf0;
  --surface-muted: #ebe2d4;
  --text: #171717;
  --text-inverse: #f7f0e6;
  --muted: #6e6a62;
  --muted-inverse: #bbb3a7;
  --line: #d6cbb9;
  --line-dark: #33302b;
  --gold: #b8924a;
  --gold-dark: #7d622f;
  --danger: #9b332b;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(17, 17, 17, 0.96), rgba(34, 32, 29, 0.94)),
    var(--bg);
  color: var(--text);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Noto Sans CJK SC",
    Arial,
    sans-serif;
}

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

.app-shell {
  width: min(1220px, calc(100% - 44px));
  margin: 0 auto;
  padding: 58px 0;
}

.intro {
  position: relative;
  max-width: 820px;
  margin-bottom: 34px;
  padding-left: 22px;
  color: var(--text-inverse);
}

.intro::before {
  position: absolute;
  left: 0;
  top: 4px;
  width: 3px;
  height: calc(100% - 8px);
  background: var(--gold);
  content: "";
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 14px;
  font-size: clamp(32px, 4.8vw, 56px);
  line-height: 1.12;
  font-weight: 700;
}

.intro-text {
  margin-bottom: 0;
  color: var(--muted-inverse);
  font-size: 16px;
  line-height: 1.8;
}

.auth-panel {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid rgba(184, 146, 74, 0.42);
  background: rgba(17, 17, 17, 0.94);
  color: var(--text-inverse);
}

.auth-panel:not(.is-authenticated) {
  display: flex;
}

.auth-panel.is-authenticated {
  display: flex;
}

.auth-panel.is-authenticated .auth-form input,
.auth-panel.is-authenticated .auth-form button[type="submit"] {
  display: none;
}

.auth-panel:not(.is-authenticated) #logoutButton {
  display: none;
}

.auth-panel strong,
.auth-panel span {
  display: block;
}

.auth-panel span {
  margin-top: 4px;
  color: var(--muted-inverse);
  font-size: 13px;
}

.auth-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-form input {
  min-width: 220px;
  border-color: rgba(184, 146, 74, 0.45);
  background: #111;
  color: #fff;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.9fr);
  gap: 24px;
  align-items: start;
}

.form-panel,
.records-panel {
  border: 1px solid rgba(214, 203, 185, 0.8);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-panel {
  padding: 30px;
}

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

label,
.radio-group,
.followup-entry {
  display: grid;
  gap: 8px;
}

label span,
legend {
  color: var(--gold-dark);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

input,
select {
  height: 46px;
  padding: 0 14px;
}

textarea {
  min-height: 136px;
  padding: 13px 14px;
  resize: vertical;
  line-height: 1.65;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(184, 146, 74, 0.18);
  background: #fffdf8;
}

.full-row {
  grid-column: 1 / -1;
}

.radio-group {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.followup-entry {
  margin: 0;
  padding: 18px;
  border: 1px solid rgba(184, 146, 74, 0.34);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.55);
}

.followup-entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.radio-group legend {
  grid-column: 1 / -1;
  padding: 0;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
}

.radio-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--gold-dark);
}

.radio-option span {
  color: var(--text);
  font-weight: 500;
}

.actions,
.export-actions,
.backup-actions,
.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions {
  margin-top: 24px;
}

button {
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  transition:
    transform 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
}

button[type="submit"] {
  background: #151515;
  color: var(--text-inverse);
}

button[type="submit"]:hover {
  background: #000;
  border-color: var(--gold);
}

.secondary {
  background: var(--gold);
  color: #16120b;
}

.secondary:hover {
  background: #c7a45e;
}

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.ghost:hover {
  border-color: var(--gold);
  color: var(--gold-dark);
}

.status {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--gold-dark);
  font-size: 14px;
}

.records-panel {
  padding: 24px;
}

.records-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.records-heading h2 {
  margin: 0;
  font-size: 20px;
}

#recordCount {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.records-tools {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.36);
}

.search-field {
  gap: 7px;
}

.export-actions button,
.backup-actions button {
  flex: 1;
}

.backup-actions {
  padding-top: 12px;
  border-top: 1px solid rgba(214, 203, 185, 0.72);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.records-list {
  display: grid;
  gap: 12px;
  max-height: 650px;
  overflow: auto;
  padding-right: 4px;
}

.dashboard-panel {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid rgba(184, 146, 74, 0.26);
  background: #f7f1e7;
}

.export-center-panel {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid rgba(184, 146, 74, 0.26);
  background: #f7f1e7;
}

.dashboard-heading,
.dashboard-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-heading {
  margin-bottom: 16px;
}

.dashboard-heading h3 {
  margin: 4px 0;
  color: var(--ink);
  font-size: 20px;
}

.dashboard-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-actions .is-active {
  border-color: var(--gold);
  color: var(--ink);
  background: rgba(184, 146, 74, 0.16);
}

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

.metric-card {
  padding: 14px;
  border: 1px solid rgba(23, 23, 23, 0.1);
  background: #fffaf2;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

.metric-card.danger strong {
  color: #9f2a20;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

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

.dashboard-box,
.dashboard-table-wrap {
  padding: 14px;
  border: 1px solid rgba(23, 23, 23, 0.1);
  background: #fffaf2;
}

.dashboard-box h4,
.dashboard-table-wrap h4 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 15px;
}

.stats-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stats-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.stats-list strong {
  color: var(--ink);
}

.reminder-list {
  display: grid;
  gap: 10px;
}

.reminder-item {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(23, 23, 23, 0.08);
}

.reminder-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.reminder-item strong {
  color: var(--ink);
}

.reminder-item span,
.reminder-item small {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-table-wrap {
  margin-top: 14px;
  overflow-x: auto;
}

.dashboard-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: 12px;
}

.dashboard-table th,
.dashboard-table td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(23, 23, 23, 0.08);
  text-align: left;
  vertical-align: top;
}

.dashboard-table th {
  color: var(--ink);
  background: rgba(184, 146, 74, 0.12);
}

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

.export-range-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(23, 23, 23, 0.1);
  background: #fffaf2;
}

.export-range-box h4 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 15px;
}

.export-range-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.export-range-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.export-range-fields input {
  min-height: 40px;
}

.record-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 16px;
}

.record-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.record-card h3 {
  margin: 6px 0 0;
  color: #111;
  font-size: 17px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-right: 6px;
  padding: 0 10px;
  border: 1px solid rgba(184, 146, 74, 0.42);
  border-radius: 999px;
  background: rgba(184, 146, 74, 0.12);
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 700;
}

.status-badge.quiet {
  border-color: rgba(23, 23, 23, 0.14);
  background: rgba(23, 23, 23, 0.06);
  color: var(--muted);
}

.status-badge.alert {
  border-color: rgba(155, 51, 43, 0.28);
  background: rgba(155, 51, 43, 0.1);
  color: var(--danger);
}

.status-badge.archived {
  border-color: rgba(23, 23, 23, 0.18);
  background: rgba(23, 23, 23, 0.09);
  color: #2f2f2f;
}

.text-button {
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--gold-dark);
  font-size: 13px;
}

.text-button:hover {
  color: #111;
  transform: none;
}

.text-button.danger {
  color: var(--danger);
}

.record-card dl {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 7px 10px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.record-card dt {
  color: var(--gold-dark);
  font-weight: 700;
}

.record-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.followup-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.followup-list li {
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(214, 203, 185, 0.64);
}

.followup-list li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.followup-list strong {
  display: block;
  margin-bottom: 2px;
  color: var(--gold-dark);
  font-size: 12px;
}

.followup-list span {
  display: block;
}

.followup-list small,
.latest-followup small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.latest-followup {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-left: 3px solid var(--gold);
  background: rgba(184, 146, 74, 0.08);
}

.latest-followup strong {
  color: var(--gold-dark);
  font-size: 12px;
}

.empty {
  margin: 0;
  padding: 36px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.data-note {
  margin: 22px 0 0;
  color: var(--muted-inverse);
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
}

@media (max-width: 940px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 28px, 1220px);
    padding: 36px 0;
  }

  .intro {
    padding-left: 16px;
  }

  .form-panel,
  .records-panel {
    padding: 20px;
  }

  .dashboard-heading,
  .dashboard-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-metrics,
  .dashboard-grid,
  .dashboard-grid.two,
  .export-center-grid,
  .export-range-fields {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .followup-entry-grid {
    grid-template-columns: 1fr;
  }

  .actions button,
  .export-actions button,
  .backup-actions button {
    width: 100%;
  }

  .record-topline {
    display: grid;
  }
}
