:root {
  color-scheme: light;
  --bg: #f5f4f1;
  --paper: #ffffff;
  --ink: #1f2933;
  --muted: #637083;
  --line: #d9ded7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warm: #9a5b13;
  --risk: #9f2d20;
  --soft: #e8f3f0;
  --shadow: 0 18px 50px rgba(31, 41, 51, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

a {
  color: var(--accent-dark);
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 30px clamp(18px, 4vw, 56px);
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.94), rgba(29, 78, 216, 0.74)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='120' viewBox='0 0 180 120'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.16' stroke-width='2'%3E%3Cpath d='M18 24h58v72H18zM92 24h70v16H92zM92 54h70M92 72h70M92 90h48'/%3E%3Cpath d='M34 44h26M34 60h26M34 76h18'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover, 360px 240px;
  color: white;
}

.topbar h1 {
  margin: 2px 0 6px;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.2;
  letter-spacing: 0;
}

.subtitle,
.eyebrow {
  margin: 0;
}

.subtitle {
  color: rgba(255, 255, 255, 0.86);
}

.eyebrow {
  color: var(--warm);
  font-size: 13px;
  font-weight: 700;
}

.topbar .eyebrow {
  color: rgba(255, 255, 255, 0.82);
}

.actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.actions {
  justify-content: flex-end;
  max-width: 640px;
}

.cloud-login {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cloud-login input {
  width: 190px;
  min-height: 42px;
  border-color: rgba(255, 255, 255, 0.55);
}

.cloud-status {
  flex-basis: 100%;
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 13px;
  text-align: right;
}

.cloud-status.ok {
  color: #d9f99d;
}

.cloud-status.warn {
  color: #fde68a;
}

.cloud-status.error {
  color: #fecaca;
}

button,
.file-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.primary {
  background: #f7c948;
  color: #222;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}

.secondary {
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent-dark);
  border-color: rgba(15, 118, 110, 0.2);
}

.panel .secondary {
  background: #f8fbfa;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 26px;
  max-width: 1380px;
  margin: 0 auto;
  padding: 26px clamp(14px, 3vw, 36px) 48px;
}

.sidebar {
  position: sticky;
  top: 18px;
  align-self: start;
  display: grid;
  gap: 7px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sidebar a {
  display: block;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 14px;
  text-decoration: none;
}

.sidebar a:hover {
  background: var(--soft);
  color: var(--accent-dark);
}

.content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.notice,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.notice {
  padding: 14px 18px;
  border-left: 5px solid var(--accent);
}

.panel {
  padding: clamp(18px, 3vw, 28px);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

h2,
h3 {
  margin: 0;
  line-height: 1.3;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(22px, 3vw, 30px);
}

h3 {
  font-size: 18px;
}

.form-grid,
.two-col,
.risk-grid,
.template-list {
  display: grid;
  gap: 16px;
}

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

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

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

.risk-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: #2d3748;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid #cdd5df;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  font-weight: 500;
}

textarea {
  min-height: 116px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.15);
}

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

.checklist label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfa;
  font-weight: 600;
}

.checklist input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--accent);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  background: #eef5f4;
  color: #26343f;
  font-size: 14px;
}

td input,
td textarea {
  min-width: 120px;
  border-color: transparent;
  padding: 7px;
}

td textarea {
  min-height: 70px;
}

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

.delete-row {
  background: #fff1f0;
  color: var(--risk);
  border-color: #fac8c3;
}

.risk-grid article {
  border-left: 4px solid var(--accent);
  padding: 12px 14px;
  background: #fbfbfa;
  border-radius: 8px;
}

.risk-grid article:nth-child(2) {
  border-left-color: var(--warm);
}

.risk-grid article:nth-child(3) {
  border-left-color: #1d4ed8;
}

.risk-grid p {
  margin: 8px 0 0;
  color: var(--muted);
}

.template {
  display: grid;
  gap: 10px;
}

.template textarea {
  min-height: 330px;
  font-family:
    "Songti SC", "SimSun", "STSong", "Times New Roman", serif;
  line-height: 1.75;
}

.source-list {
  margin: 0;
  padding-left: 20px;
}

.source-list li + li {
  margin-top: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  background: #102a43;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(16, 42, 67, 0.25);
}

body.printing-section .printable {
  display: none;
}

body.printing-section .printable.print-focus {
  display: block;
}

@media (max-width: 960px) {
  .topbar,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

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

  .sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid,
  .two-col,
  .risk-grid,
  .template-list,
  .checklist {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4;
    margin: 14mm;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  .no-print,
  .sidebar,
  .actions,
  .notice,
  #sources {
    display: none !important;
  }

  .topbar {
    display: block;
    padding: 0 0 10mm;
    background: #fff !important;
    color: #000;
  }

  .topbar .eyebrow,
  .subtitle {
    color: #000;
  }

  .layout {
    display: block;
    max-width: none;
    padding: 0;
  }

  .content {
    display: block;
  }

  .panel {
    break-inside: avoid;
    box-shadow: none;
    border: 0;
    border-radius: 0;
    padding: 0 0 12mm;
  }

  .section-head {
    display: block;
    border-bottom: 1px solid #000;
    padding-bottom: 3mm;
    margin-bottom: 5mm;
  }

  .form-grid,
  .two-col,
  .risk-grid,
  .template-list,
  .checklist {
    grid-template-columns: 1fr 1fr;
  }

  input,
  textarea {
    border: 0;
    border-bottom: 1px solid #777;
    border-radius: 0;
    padding: 3px 0;
    min-height: auto;
  }

  textarea {
    white-space: pre-wrap;
    min-height: 80px;
  }

  .template textarea {
    min-height: 280px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
  }

  table {
    min-width: 0;
    font-size: 10pt;
  }

  th,
  td {
    border: 1px solid #000;
    padding: 4px;
  }

  td input,
  td textarea {
    border: 0;
    padding: 0;
  }

  a {
    color: #000;
    text-decoration: none;
  }
}
