:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #64706b;
  --line: #dce3df;
  --accent: #0f766e;
  --accent-dark: #0b5751;
  --warn: #a15c07;
  --danger: #b42318;
  --ok: #15803d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sidebar {
  background: #101815;
  color: #eef5f1;
  padding: 16px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: #d8f3dc;
  color: #0b3d2e;
  font-weight: 800;
  border-radius: 8px;
}

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

.brand h1 {
  font-size: 17px;
}

.brand p, .eyebrow {
  color: #9fb0a8;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 5px;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

.nav-btn {
  text-align: left;
  background: transparent;
  color: #cbd8d1;
}

.nav-group {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.nav-group-title {
  color: #8fa39a;
  font-size: 12px;
  font-weight: 800;
  padding: 10px 12px 4px;
}

.nav-sub-btn {
  margin-left: 12px;
  padding-left: 16px;
  border-left: 2px solid #31443c;
  color: #d8e4de;
}

.nav-btn.active,
.nav-btn:hover {
  background: #20302a;
  color: white;
}

.nav-sub-btn.active,
.nav-sub-btn:hover {
  border-left-color: #d8f3dc;
}

main {
  padding: 24px;
  min-width: 0;
}

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

.topbar h2 {
  font-size: 26px;
}

.actions, .form-actions, .row-actions, .filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary {
  background: var(--accent);
  color: white;
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary {
  background: #e7eeea;
  color: #21302b;
}

.secondary.active {
  background: #cfe5df;
  color: #0b5751;
  font-weight: 700;
}

.danger {
  background: #fee2e2;
  color: #991b1b;
}

.danger:hover {
  background: #fecaca;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.stat, .notice, .form-grid, .table-wrap, .item, .filters, .local-upload-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat {
  padding: 14px;
}

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

.stat strong {
  font-size: 24px;
}

.notice {
  padding: 12px 14px;
  color: var(--muted);
  margin-bottom: 16px;
}

.view {
  display: none;
  scroll-margin-top: 16px;
}

.view.active {
  display: block;
  margin-bottom: 18px;
}

.view.focused {
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.18);
  border-radius: 10px;
}

.form-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.local-upload-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.local-upload-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

.upload-feedback {
  min-height: 44px;
  align-content: center;
  padding: 10px 12px;
  border: 1px dashed #c6d7d1;
  border-radius: 8px;
  background: #f8fbfa;
  color: #42524c;
  font-size: 13px;
}

.filters {
  padding: 12px;
  margin-bottom: 12px;
}

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

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font: inherit;
  color: var(--ink);
  background: white;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font: inherit;
  color: var(--ink);
  background: white;
  resize: vertical;
}

.span-2 {
  grid-column: span 2;
}

.form-actions {
  align-items: end;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  background: #fbfcfb;
}

.content-list {
  display: grid;
  gap: 12px;
}

.raw-tabs {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.raw-tab {
  flex: 0 0 260px;
  display: grid;
  gap: 4px;
  text-align: left;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  border-radius: 8px;
  padding: 11px 12px;
}

.raw-tab strong {
  font-size: 15px;
}

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

.raw-tab.active {
  border-color: #8fbfb4;
  background: #e9f5f1;
  color: #0b5751;
}

.raw-active-panel {
  min-width: 0;
}

.raw-group {
  display: grid;
  align-content: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  padding: 12px;
  min-width: 0;
}

.raw-group-head {
  display: grid;
  gap: 10px;
  padding: 4px 2px 8px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fbfa;
}

.raw-group-head h3 {
  font-size: 18px;
}

.raw-group-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.raw-group .item {
  padding: 12px;
}

.raw-group .item-head {
  display: grid;
  gap: 8px;
}

.raw-group .body-text {
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.raw-empty {
  border: 1px dashed #c9d6d1;
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: #ffffff;
}

.item {
  padding: 16px;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.item h3 {
  font-size: 17px;
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.code-chip {
  display: inline-flex;
  width: fit-content;
  margin: 6px 0 4px;
  border-radius: 6px;
  border: 1px solid #b7d4cc;
  background: #e6f4f0;
  color: #0b5751;
  padding: 4px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
}

.body-text {
  white-space: pre-wrap;
  color: #25342f;
  margin: 10px 0;
}

.title-suggestions {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  margin: 10px 0 12px;
}

.title-suggestions ol {
  margin: 0;
  padding-left: 20px;
}

.title-suggestions li {
  margin: 4px 0;
  color: #22312c;
}

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

.chip {
  border-radius: 999px;
  background: #eef4f1;
  color: #42524c;
  padding: 4px 9px;
  font-size: 12px;
}

.chip.ok {
  background: #e6f6ea;
  color: var(--ok);
}

.chip.warn {
  background: #fff4df;
  color: var(--warn);
}

.chip.danger {
  background: #fff0ef;
  color: var(--danger);
}

.section-title {
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.department-note {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #edf7f4;
  border: 1px solid #cfe5df;
  border-radius: 8px;
  color: #23443d;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.department-note span {
  color: #4f625b;
}

.planning-card .section-title:first-child {
  margin-top: 0;
}

.score-box {
  min-width: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  background: #f7faf8;
}

.score-box span,
.score-box em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.score-box strong {
  display: block;
  color: var(--accent-dark);
  font-size: 22px;
  line-height: 1.2;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.analysis-field {
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.analysis-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.analysis-field p {
  color: #24332e;
}

.reusable-summary {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.metric {
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

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

.metric strong {
  font-size: 20px;
}

.work-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

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

.work-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.work-card strong {
  color: var(--ink);
  font-size: 28px;
}

.work-card.ok strong {
  color: var(--ok);
}

.work-card.warn strong {
  color: var(--warn);
}

.work-card.danger strong {
  color: var(--danger);
}

.work-card.wide {
  grid-column: span 3;
}

.work-card.wide strong {
  font-size: 22px;
}

.work-log-card {
  margin-top: 12px;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

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

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

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

@media (max-width: 560px) {
  main {
    padding: 14px;
  }

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

  .item-head {
    flex-direction: column;
  }

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

  .work-detail-grid {
    grid-template-columns: 1fr;
  }

  .work-card.wide {
    grid-column: span 1;
  }
}
