:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #647084;
  --line: #dce2ea;
  --blue: #2463eb;
  --green: #12805c;
  --amber: #b7791f;
  --red: #c2413a;
  --cyan: #087f95;
  --nav: #111827;
  --radius: 8px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef2f7 0%, #f6f8fb 52%, #eef8f5 100%);
}

.login-panel {
  width: min(920px, 100%);
  min-height: 460px;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 28px;
  align-items: center;
  padding: 44px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 70px rgba(23, 32, 51, 0.12);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-panel h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1.16;
}

.login-copy {
  max-width: 560px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.9;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fbfcfe;
}

.login-form button,
.small-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--blue);
  font-weight: 700;
}

.small-button {
  min-height: 32px;
  padding: 0 12px;
}

.tiny-button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.tiny-button:hover {
  border-color: #b7c7e5;
  background: #eef5ff;
}

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

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px;
  background: var(--nav);
  color: #fff;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #06291e;
  background: #65d6ad;
  font-weight: 900;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: #9ca3af;
}

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

.nav button,
.ghost-button {
  min-height: 42px;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  color: #d1d5db;
  background: transparent;
  text-align: left;
}

.nav button span {
  width: 22px;
  color: #8fb1ff;
  text-align: center;
}

.nav button.active,
.nav button:hover,
.ghost-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.ghost-button {
  margin-top: auto;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.topbar h2 {
  margin: 0;
  font-size: 24px;
}

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

.user-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #0f5132;
  background: #dff6ea;
  font-size: 12px;
  font-weight: 800;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.section-head h3 {
  margin: 0 0 6px;
  font-size: 22px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

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

.metric-card,
.panel,
.item-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-card {
  padding: 16px;
}

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

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h4 {
  margin: 0;
  font-size: 16px;
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

.module-list,
.compact-list,
.risk-list,
.timeline,
.rule-list,
.task-board,
.confirmation-list,
.table-like {
  display: grid;
  gap: 10px;
}

.action-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

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

.module-row,
.compact-row,
.risk-row,
.timeline-row,
.rule-row,
.task-row,
.confirmation-row,
.requirement-row {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.module-row-head,
.risk-row-head,
.rule-row-head,
.task-row-head,
.requirement-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.module-row strong,
.risk-row strong,
.rule-row strong,
.task-row strong,
.requirement-row strong {
  font-size: 14px;
}

.muted {
  color: var(--muted);
}

.progress {
  height: 7px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: #234;
  background: #eef2f7;
  font-size: 12px;
  font-weight: 700;
}

.tag.green {
  color: #0f5132;
  background: #ddf4e8;
}

.tag.amber {
  color: #704300;
  background: #fff3d6;
}

.tag.red {
  color: #842029;
  background: #fde1df;
}

.tag.blue {
  color: #173c89;
  background: #e1ebff;
}

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

.item-card {
  padding: 16px;
}

.item-card h4 {
  margin: 0 0 8px;
}

.item-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.doc-layout,
.prompt-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  min-height: 620px;
}

.doc-list {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.doc-list button {
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  background: #f7f9fc;
  text-align: left;
}

.doc-item {
  display: grid;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eef2f7;
}

.doc-list button.active,
.doc-list button:hover {
  border-color: #b7c7e5;
  background: #eef5ff;
}

.doc-list strong {
  display: block;
  margin-bottom: 6px;
}

.doc-list small {
  color: var(--muted);
}

.doc-reader {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.doc-reader-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.doc-reader h4 {
  margin: 10px 0 0;
  font-size: 20px;
}

.markdown-body {
  max-width: 980px;
  padding-top: 12px;
  color: #263244;
  line-height: 1.8;
  white-space: pre-wrap;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 22px 0 8px;
  line-height: 1.3;
}

.markdown-body ul {
  padding-left: 20px;
}

.prompt-output {
  width: 100%;
  min-height: 560px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fbfcfe;
  line-height: 1.7;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 6px;
  color: #fff;
  background: #172033;
  box-shadow: 0 16px 50px rgba(23, 32, 51, 0.2);
  z-index: 20;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.46);
  z-index: 50;
}

.modal-panel {
  width: min(940px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  padding: 18px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 80px rgba(17, 24, 39, 0.28);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.edit-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding-top: 16px;
}

.form-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-field.wide,
.form-field.tall {
  grid-column: 1 / -1;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fbfcfe;
}

.form-field textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.6;
}

.form-field.tall textarea {
  min-height: 260px;
}

.checkline {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 600;
}

.checkline input {
  width: auto;
  min-height: auto;
}

.modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

.ghost-light {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .metric-grid,
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-column,
  .doc-layout,
  .prompt-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .login-panel,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 24px;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .workspace {
    padding: 16px;
  }

  .metric-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

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