:root {
  --bg: #f5f7f7;
  --bg-quiet: #e8eeec;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #f6f8f7;
  --surface-tint: #eff6f1;
  --line: #dbe3df;
  --line-strong: #bdc9c3;
  --text: #18231f;
  --text-soft: #33423d;
  --muted: #6f7a73;
  --muted-strong: #4e5c55;
  --green: #177350;
  --green-dark: #0f533a;
  --green-soft: #e5f2ea;
  --blue: #2c6f9f;
  --blue-soft: #e8f1f7;
  --amber: #b36a16;
  --amber-soft: #fff1d8;
  --red: #b83d3d;
  --red-soft: #fae8e7;
  --brown-soft: #eeece7;
  --sidebar: #17231f;
  --sidebar-2: #20322b;
  --shadow-sm: 0 1px 2px rgba(24, 35, 31, 0.06), 0 8px 22px rgba(24, 35, 31, 0.06);
  --shadow-md: 0 18px 44px rgba(24, 35, 31, 0.1);
  --ring: 0 0 0 4px rgba(23, 115, 80, 0.13);
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.35) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
  color: var(--text);
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  overflow-y: auto;
  color: #f7fbf8;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 44%),
    var(--sidebar);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #f6f9f6;
  color: #17231f;
  border-radius: 8px;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: inset 0 -2px 0 rgba(23, 35, 31, 0.12);
}

.brand h1,
.brand p,
.section-head h2,
.topbar h2,
.view-title h3,
.panel h4 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.2;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.project-switcher {
  padding-top: 6px;
}

.section-head,
.panel-head,
.topbar,
.view-title,
.topbar-actions,
.form-actions {
  display: flex;
  align-items: center;
}

.section-head,
.panel-head,
.topbar,
.view-title {
  justify-content: space-between;
  gap: 16px;
}

.section-head h2 {
  color: rgba(247, 251, 248, 0.65);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 8px;
  font-size: 22px;
  line-height: 1;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.project-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.project-item {
  position: relative;
  width: 100%;
  min-height: 150px;
  padding: 16px;
  text-align: left;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.project-item::before {
  content: "";
  position: absolute;
  top: 13px;
  bottom: 13px;
  left: 8px;
  width: 3px;
  border-radius: 999px;
  background: var(--green);
}

.project-item:hover {
  border-color: #b9d7c5;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.project-item.is-active {
  color: var(--text);
  background: #f7faf8;
  border-color: #b9d7c5;
}

.project-item.is-active::before {
  background: var(--green);
}

.project-item strong {
  display: block;
  margin-bottom: 7px;
  font-size: 16px;
  line-height: 1.35;
}

.project-item span {
  display: block;
  color: currentColor;
  opacity: 0.72;
  font-size: 12px;
  line-height: 1.45;
}

.project-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 12px;
}

.project-card-meta span {
  display: inline-flex;
  width: auto;
  min-height: 24px;
  align-items: center;
  padding: 0 9px;
  color: var(--green-dark);
  background: var(--green-soft);
  border-radius: 999px;
  font-weight: 850;
  opacity: 1;
}

.project-item small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.main {
  min-width: 0;
  max-width: 1580px;
  width: 100%;
  margin: 0 auto;
  padding: 26px;
}

.is-hidden {
  display: none !important;
}

.home-view {
  gap: 18px;
}

.home-hero {
  min-height: 190px;
  display: grid;
  align-content: space-between;
  gap: 24px;
  padding: 22px;
  color: #f7fbf8;
  background:
    linear-gradient(135deg, rgba(23, 35, 31, 0.96), rgba(32, 50, 43, 0.92)),
    var(--sidebar);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

.home-hero .brand h1,
.home-hero .brand p {
  color: #f7fbf8;
}

.home-copy {
  max-width: 850px;
}

.home-copy .eyebrow {
  color: rgba(247, 251, 248, 0.72);
}

.home-copy h2 {
  margin: 0;
  max-width: 760px;
  font-size: 28px;
  line-height: 1.22;
}

.home-copy p:last-child {
  max-width: 760px;
  margin: 10px 0 0;
  color: rgba(247, 251, 248, 0.76);
  font-size: 14px;
  line-height: 1.65;
}

.home-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.home-actions h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.home-actions p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.topbar {
  min-height: 82px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(219, 227, 223, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px);
}

.topbar h2 {
  color: #101916;
  font-size: 23px;
  line-height: 1.25;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 850;
}

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

.topbar-actions,
.form-actions {
  gap: 10px;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 38px;
  border-radius: 8px;
  font-weight: 800;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.primary-button,
.secondary-button {
  border: 1px solid transparent;
  padding: 0 15px;
}

.primary-button {
  color: #fff;
  background: var(--green);
  box-shadow: 0 8px 18px rgba(23, 115, 80, 0.18);
}

.primary-button:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 83, 58, 0.22);
}

.secondary-button {
  color: var(--text-soft);
  background: #f8faf9;
  border-color: var(--line);
}

.secondary-button:hover {
  color: var(--green-dark);
  background: var(--green-soft);
  border-color: #b9d7c5;
  transform: translateY(-1px);
}

.danger-button {
  min-height: 38px;
  padding: 0 15px;
  color: #fff;
  background: var(--red);
  border: 1px solid var(--red);
  border-radius: 8px;
  font-weight: 850;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.danger-button:hover {
  background: #962f2f;
  border-color: #962f2f;
  box-shadow: 0 12px 24px rgba(184, 61, 61, 0.2);
  transform: translateY(-1px);
}

.text-button {
  min-height: auto;
  padding: 0;
  color: var(--green-dark);
  background: transparent;
  border: 0;
}

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

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
  padding: 8px;
  background: rgba(245, 247, 247, 0.86);
  border: 1px solid rgba(219, 227, 223, 0.78);
  border-radius: 8px;
  backdrop-filter: blur(14px);
}

.tab,
.segmented-control button {
  min-height: 36px;
  padding: 0 14px;
  color: var(--muted-strong);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
}

.tab:hover,
.segmented-control button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(219, 227, 223, 0.96);
}

.tab.is-active,
.segmented-control button.is-active {
  color: #fff;
  background: var(--sidebar-2);
  border-color: var(--sidebar-2);
  box-shadow: 0 8px 18px rgba(32, 50, 43, 0.16);
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 18px;
}

.view-title {
  min-height: 48px;
}

.view-title h3 {
  font-size: 25px;
  line-height: 1.2;
}

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

.metric-card,
.panel,
.alert-item,
.todo-item,
.record-item {
  background: var(--surface-raised);
  border: 1px solid rgba(219, 227, 223, 0.96);
  border-radius: 8px;
}

.metric-card {
  position: relative;
  min-height: 136px;
  padding: 17px;
  display: grid;
  align-content: space-between;
  gap: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.metric-card::after {
  content: "";
  position: absolute;
  top: 17px;
  right: 17px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 5px var(--green-soft);
}

.metric-card:nth-child(2)::after {
  background: var(--blue);
  box-shadow: 0 0 0 5px var(--blue-soft);
}

.metric-card:nth-child(3)::after {
  background: var(--amber);
  box-shadow: 0 0 0 5px var(--amber-soft);
}

.metric-card:nth-child(4)::after {
  background: var(--red);
  box-shadow: 0 0 0 5px var(--red-soft);
}

.metric-card p {
  margin: 0 28px 8px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.metric-card strong {
  display: block;
  color: #101916;
  font-size: 30px;
  line-height: 1.05;
}

.metric-card small {
  color: var(--muted);
  line-height: 1.45;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  background: #e4ebe7;
  border-radius: 999px;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

.progress-bar.is-over {
  background: var(--red);
}

.dashboard-grid,
.split-layout,
.draft-layout {
  display: grid;
  gap: 18px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.16fr) minmax(330px, 0.84fr);
}

.split-layout {
  grid-template-columns: minmax(420px, 0.95fr) minmax(0, 1.05fr);
  align-items: start;
}

.draft-layout {
  grid-template-columns: minmax(0, 1fr) 330px;
  align-items: start;
}

.panel {
  padding: 17px;
  box-shadow: var(--shadow-sm);
}

.panel-head {
  min-height: 32px;
}

.panel h4 {
  color: #111a17;
  font-size: 16px;
  line-height: 1.25;
}

.danger-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: #fffafa;
  border-color: #efcecb;
}

.danger-panel h4 {
  color: var(--red);
  margin: 0 0 6px;
}

.danger-panel p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.count-badge,
.status-badge,
.type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.count-badge {
  color: var(--green-dark);
  background: var(--green-soft);
}

.status-badge {
  color: var(--blue);
  background: var(--blue-soft);
}

.status-badge.is-danger {
  color: var(--red);
  background: var(--red-soft);
}

.status-badge.is-warning {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-badge.is-success {
  color: var(--green-dark);
  background: var(--green-soft);
}

.type-badge {
  color: #72542f;
  background: var(--brown-soft);
}

.alert-stack,
.todo-list,
.record-list,
.basis-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.alert-item,
.todo-item,
.record-item {
  position: relative;
  padding: 14px;
  background: #ffffff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.alert-item:hover,
.todo-item:hover,
.record-item:hover {
  border-color: #cfc6b6;
  box-shadow: 0 10px 26px rgba(24, 35, 31, 0.07);
}

.alert-item {
  padding-left: 16px;
}

.alert-item::before {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 8px;
  width: 3px;
  border-radius: 999px;
  background: var(--amber);
}

.alert-item.is-danger::before {
  background: var(--red);
}

.alert-item.is-success::before {
  background: var(--green);
}

.todo-item {
  background: var(--surface);
}

.alert-item h5,
.todo-item h5,
.record-item h5 {
  margin: 0 0 6px;
  color: #111a17;
  font-size: 14px;
  line-height: 1.35;
}

.alert-item p,
.todo-item p,
.record-item p,
.basis-list p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.58;
}

.alert-item button,
.todo-item button,
.record-item button {
  margin-top: 11px;
}

.timeline {
  display: grid;
  gap: 0;
  margin-top: 16px;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 18px;
  padding: 0 0 18px;
}

.timeline-item + .timeline-item {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.timeline-date {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.timeline-content {
  position: relative;
  padding-left: 17px;
}

.timeline-content::before {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 5px var(--green-soft);
}

.timeline-content strong {
  display: block;
  margin-bottom: 6px;
  color: #111a17;
  font-size: 14px;
}

.timeline-content p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.form-panel {
  display: grid;
  gap: 15px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

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

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

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  padding: 10px 11px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
  min-height: auto;
  resize: vertical;
  line-height: 1.6;
}

select {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted-strong) 50%),
    linear-gradient(135deg, var(--muted-strong) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 17px,
    calc(100% - 13px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input:hover,
textarea:hover,
select:hover {
  border-color: #b7ad9b;
}

input:focus,
textarea:focus,
select:focus {
  background: #fff;
  border-color: var(--green);
  box-shadow: var(--ring);
}

.checkbox-label {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: end;
}

.checkbox-label input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  accent-color: var(--green);
}

.record-item {
  display: grid;
  gap: 9px;
}

.record-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.segmented-control {
  display: flex;
  gap: 5px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented-control button {
  min-height: 30px;
  border-radius: 6px;
}

.draft-editor {
  min-height: 540px;
  margin-top: 14px;
  color: #1f2925;
  background: #ffffff;
  white-space: pre-wrap;
  line-height: 1.68;
}

.draft-controls {
  margin-top: 14px;
}

.mail-preview {
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  white-space: normal;
}

.mail-preview:focus {
  border-color: var(--green);
  box-shadow: var(--ring);
}

.mail-preview table {
  width: 900px;
  max-width: 900px;
}

.basis-list .basis-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.basis-list .basis-item:last-child {
  border-bottom: 0;
}

.basis-item strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text-soft);
  font-size: 13px;
}

.empty-state {
  padding: 22px 18px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed #c9c0af;
  border-radius: 8px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 360px;
  padding: 13px 15px;
  color: #fff;
  background: var(--sidebar-2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

  .dashboard-grid,
  .split-layout,
  .draft-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  body {
    background-size: 28px 28px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

  .project-list {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  }

  .main {
    padding: 16px;
  }

  .topbar,
  .view-title,
  .panel-head,
  .danger-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .form-actions,
  .home-actions {
    width: 100%;
  }

  .primary-button,
  .secondary-button,
  .danger-button {
    flex: 1;
  }

  .tabs {
    position: static;
  }

  .metric-grid,
  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (max-width: 520px) {
  .topbar-actions,
  .form-actions,
  .home-actions,
  .record-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .primary-button,
  .secondary-button,
  .danger-button {
    width: 100%;
  }

  .record-topline {
    flex-direction: column;
  }
}
