:root {
  --red: #991c22;
  --red-dark: #791419;
  --red-soft: #fff6f5;
  --ink: #241917;
  --text: #3a2a27;
  --muted: #8a7772;
  --line: rgba(66, 39, 36, 0.08);
  --bg: #fcfbfa;
  --card: #ffffff;
  --soft: #f7f2ef;
  --shadow: 0 14px 34px rgba(66, 39, 36, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.5;
}

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

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

button {
  cursor: pointer;
}

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(66, 39, 36, 0.04);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 14px 10px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
}

.logo {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(66, 39, 36, 0.06);
}

.logo-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-text,
.login-brand > div {
  min-width: 0;
}

.brand-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-subtitle {
  display: none;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.user-pill {
  max-width: 112px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(153, 28, 34, 0.12);
  color: var(--red-dark);
  background: var(--red-soft);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
  color: var(--text);
  padding: 5px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.nav a,
.nav button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 7px 10px;
  font-size: 13px;
}

.nav a.active {
  border-color: rgba(153, 28, 34, 0.16);
  background: var(--red-soft);
  color: var(--red-dark);
  font-weight: 700;
}

.main {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 14px 28px;
  flex: 1;
}

.footer {
  padding: 18px 14px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 14px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.login-title {
  margin: 0;
  color: var(--ink);
  font-size: 19px;
  line-height: 1.28;
  letter-spacing: 0;
}

.login-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.page-head h1 {
  margin: 0;
  color: var(--ink);
  font-size: 21px;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 15px;
  box-shadow: var(--shadow);
}

.section-title {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 16px;
}

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

.small {
  font-size: 12px;
}

.stack {
  display: grid;
  gap: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  min-height: 92px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  margin-top: 6px;
  color: var(--red);
  font-size: 29px;
  font-weight: 800;
}

.stat-note {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.filter-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.filter-grid,
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

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

.number-grid .field {
  min-width: 0;
}

.number-grid input {
  min-width: 0;
  padding-left: 9px;
  padding-right: 9px;
}

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

.field label,
.field-label {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.field-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

.field textarea {
  min-height: 108px;
  resize: vertical;
}

.field textarea[rows="1"] {
  min-height: 42px;
}

.field textarea[rows="2"] {
  min-height: 72px;
}

.field textarea[rows="10"] {
  min-height: 220px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(153, 28, 34, 0.42);
  box-shadow: 0 0 0 3px rgba(153, 28, 34, 0.08);
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  background: #faf7f5;
  color: var(--muted);
}

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

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.check-pill input {
  accent-color: var(--red);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--red);
  border-radius: 13px;
  background: linear-gradient(180deg, var(--red), var(--red-dark));
  color: #fff;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(153, 28, 34, 0.12);
}

.btn.secondary {
  border-color: var(--line);
  background: var(--soft);
  color: var(--text);
  box-shadow: none;
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--red);
  box-shadow: none;
}

.btn.danger {
  border-color: var(--red-dark);
  background: var(--red-dark);
}

.btn.danger-soft {
  border-color: rgba(153, 28, 34, 0.24);
  background: var(--red-soft);
  color: var(--red-dark);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

.btn.compact {
  min-height: 30px;
  padding: 5px 9px;
}

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

.mobile-card-list {
  display: grid;
}

.desktop-table-wrap {
  display: none;
  padding: 0;
  overflow: hidden;
}

.desktop-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.desktop-table th,
.desktop-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  color: var(--text);
  font-size: 13px;
}

.desktop-table th {
  background: #fbf8f6;
  color: var(--muted);
  font-weight: 700;
}

.desktop-table tr:last-child td {
  border-bottom: 0;
}

.table-title {
  color: var(--ink);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-card,
.report-card,
.user-card,
.material-card {
  display: grid;
  gap: 12px;
}

.content-card-head,
.report-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.content-title,
.report-title {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
}

.meta-item {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.meta-label {
  color: var(--muted);
  flex: 0 0 auto;
}

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

.inline-actions {
  align-items: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(36, 25, 23, 0.34);
}

.modal-card {
  width: min(92vw, 380px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 18px 46px rgba(36, 25, 23, 0.16);
}

.modal-card h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.35;
}

.modal-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

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

.tag,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid rgba(153, 28, 34, 0.12);
  background: var(--red-soft);
  color: var(--red-dark);
  font-size: 12px;
}

.empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
}

.two-col,
.summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.summary-card h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 15px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}

.pre-line {
  white-space: pre-line;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 50;
  transform: translateX(-50%) translateY(18px);
  max-width: min(92vw, 420px);
  border-radius: 14px;
  background: rgba(36, 25, 23, 0.94);
  color: #fff;
  padding: 10px 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.desktop-reset {
  display: none;
}

@media (min-width: 641px) {
  .brand-title {
    font-size: 18px;
  }

  .brand-subtitle {
    display: block;
  }

  .user-pill {
    max-width: 180px;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .filter-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .search-row {
    grid-template-columns: 1fr auto auto;
  }

  .desktop-reset {
    display: inline-flex;
  }

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

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

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

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

  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 860px) {
  .mobile-card-list {
    display: none;
  }

  .desktop-table-wrap {
    display: block;
  }
}

@media (min-width: 1100px) {
  .number-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .logo {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 12px;
  }

  .main {
    padding-top: 12px;
  }

  .page-head {
    display: grid;
  }

  .head-actions {
    justify-content: flex-start;
  }

  .top-actions {
    gap: 5px;
  }

  .logout-btn {
    padding: 5px 7px;
  }

  .content-card .btn,
  .report-card .btn {
    width: 100%;
  }

  .card {
    padding: 14px;
  }
}
