:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #657080;
  --line: #dce2e8;
  --primary: #1f7a6d;
  --primary-weak: #e2f3ef;
  --accent: #9a5b20;
  --danger: #b54040;
  --shadow: 0 12px 30px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f5;
}

.login-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-copy,
.login-hint p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.auth-panel {
  display: none;
  gap: 12px;
}

.auth-panel.active {
  display: grid;
}

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

.auth-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
}

.login-hint {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.login-hint:empty {
  display: none;
}

.login-hint.error {
  color: #9f1d1d;
  border-color: #efb5b5;
  background: #fff6f6;
}

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

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background: #17202a;
  color: #fff;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.sidebar .eyebrow {
  color: #a9bac7;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

.field,
.filters label,
.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.role-card {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #e8eef3;
  line-height: 1.5;
}

.login-note {
  margin: 8px 0 0;
  color: #c6d3dc;
  font-size: 12px;
}

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

.nav-btn,
button {
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}

.nav-btn {
  text-align: left;
  background: rgba(255, 255, 255, 0.1);
}

.nav-btn.active {
  background: #fff;
  color: #17202a;
}

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

.nav-sub-list {
  display: grid;
  gap: 6px;
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
}

.nav-sub-btn {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #d7e2ea;
  text-align: left;
  font-size: 13px;
}

.nav-sub-btn.active {
  background: var(--primary-weak);
  color: var(--primary);
}

.ghost-btn {
  background: var(--primary-weak);
  color: var(--primary);
}

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

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

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

.mode-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--primary-weak);
  color: var(--primary);
  font-size: 13px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.view {
  display: none;
}

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

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

.workspace-intro {
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.workspace-intro p,
.task-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

.metric,
article,
.detail-card,
.task-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.compact-metric strong {
  font-size: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

article {
  padding: 16px;
}

.split,
.task-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.table {
  display: grid;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  overflow-x: auto;
}

.table-row {
  display: grid;
  grid-template-columns: var(--columns, repeat(var(--cols), minmax(0, 1fr)));
  border-bottom: 1px solid var(--line);
}

.table-row:last-child {
  border-bottom: 0;
}

.table-cell {
  padding: 9px;
  min-width: 0;
  word-break: break-word;
}

.table-link {
  padding: 6px 8px;
  background: var(--primary-weak);
  color: var(--primary);
}

.table-head {
  background: #eef2f5;
  color: var(--muted);
  font-size: 12px;
}

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

.section-heading,
.form-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.form-header p,
.subtle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.task-card {
  padding: 12px;
  cursor: pointer;
}

.task-search-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.task-search-panel input {
  min-width: 0;
}

.task-search-panel button {
  min-height: 38px;
  padding: 0 12px;
}

.task-search-panel .subtle {
  grid-column: 1 / -1;
}

.task-card.active {
  border-color: var(--primary);
  background: var(--primary-weak);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #eef2f5;
  color: var(--muted);
  font-size: 12px;
}

.status-active {
  background: var(--primary-weak);
  color: var(--primary);
}

.status-pending_review {
  background: #fff6d9;
  color: #8a5a00;
}

.status-rejected,
.status-disabled {
  background: #fff0f0;
  color: var(--danger);
}

.detail-card {
  padding: 16px;
}

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

.detail-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

.actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.notice {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--muted);
  line-height: 1.5;
}

.round-list {
  display: grid;
  gap: 8px;
}

.round-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.round-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

.log-panel {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.log-panel summary {
  cursor: pointer;
  padding: 10px 12px;
  color: var(--primary);
  font-weight: 600;
}

.log-panel .table {
  margin: 0;
  border-width: 1px 0 0;
  border-radius: 0;
}

.log-collapsed {
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fbfcfd;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.task-form {
  align-items: start;
}

.form-progress {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.form-progress strong,
.form-progress span {
  display: block;
}

.form-progress span,
.form-progress p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.form-progress.done {
  border-color: #abd7cc;
  background: #f1fbf8;
}

.form-progress.warning {
  border-color: #eadfbf;
  background: #fffaf0;
}

.form-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.form-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.form-section-heading strong,
.form-section-heading span {
  display: block;
}

.form-section-heading span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.form-section-heading em {
  flex: 0 0 auto;
  min-width: 74px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f5;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  text-align: center;
}

.form-section-heading em.done {
  background: var(--primary-weak);
  color: var(--primary);
}

.form-section-heading em.warning {
  background: #fff6d9;
  color: #8a5a00;
}

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

.field-muted {
  opacity: 0.72;
}

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

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

.pending-list {
  margin: 0;
  padding: 16px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.role-guide-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.role-guide-card.current {
  border-color: var(--primary);
  background: #fbfefd;
}

.permission-list,
.test-path-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.account-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.account-table select {
  min-width: 130px;
}

.account-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.management-board {
  display: grid;
  gap: 12px;
}

.management-panel {
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.management-panel-heading {
  padding: 12px 16px;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
}

.management-panel-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.image-preview {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.form-image-preview {
  display: grid;
  gap: 12px;
  align-items: stretch;
  min-height: 92px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
}

.image-paste-zone {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.image-paste-zone:focus {
  outline: 2px solid rgba(45, 108, 223, 0.22);
  border-color: var(--primary);
}

.image-paste-zone strong {
  color: var(--text);
}

.image-paste-zone span {
  font-size: 13px;
}

.form-image-preview.empty {
  display: flex;
  min-height: 44px;
  align-items: center;
}

.form-image-preview strong {
  display: block;
  color: var(--text);
}

.form-image-preview p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.image-preview-button {
  width: fit-content;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.image-preview img,
.form-image-preview img {
  width: min(420px, 100%);
  max-height: 320px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.form-image-preview img {
  width: 92px;
  height: 72px;
}

.image-preview p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.attachment-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

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

.attachment-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.attachment-card strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-card p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.attachment-card .image-preview-button {
  width: 74px;
}

.attachment-card img {
  width: 74px;
  height: 58px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.attachment-count {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.image-remove-btn {
  white-space: nowrap;
}

.image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 32, 42, 0.72);
}

.image-preview-dialog {
  display: grid;
  gap: 10px;
  width: min(880px, 100%);
  max-height: 92vh;
  padding: 16px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.image-preview-dialog img {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.image-preview-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.image-preview-close {
  justify-self: end;
}

.management-panel-body {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
}

.board-note,
.diagnostic-date-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.board-note span,
.diagnostic-date-row span {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid #eadfbf;
  border-radius: 6px;
  background: #fff6d9;
  color: #18446d;
}

.bottleneck-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.bottleneck-card {
  display: grid;
  gap: 6px;
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
  text-align: left;
}

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

.bottleneck-card strong {
  color: var(--text);
  font-size: 24px;
}

.bottleneck-card.active,
.bottleneck-card:hover {
  border-color: var(--primary);
  background: var(--primary-weak);
}

.diagnostic-section-title {
  color: #18446d;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.management-table {
  width: 100%;
  max-width: 100%;
}

.management-board .management-table,
.drilldown-panel .table {
  overflow: visible;
}

.management-board .management-table .table-head,
.drilldown-panel .table-head {
  display: none;
}

.management-board .management-table .table-row,
.drilldown-panel .table-row {
  min-width: 0;
}

.management-board .management-table .table-row:not(.table-head),
.drilldown-panel .table-row:not(.table-head) {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  padding: 10px;
  background: #fff;
}

.management-board .management-table .table-row:not(.table-head):not(:last-child),
.drilldown-panel .table-row:not(.table-head):not(:last-child) {
  border-bottom: 8px solid #eef2f5;
}

.management-table .table-cell,
.drilldown-panel .table-cell {
  min-height: 0;
  display: grid;
  gap: 4px;
  align-content: start;
  justify-content: stretch;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  text-align: left;
}

.management-table .table-cell::before,
.drilldown-panel .table-cell::before {
  content: attr(data-label);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.management-table .table-cell:empty,
.drilldown-panel .table-cell:empty {
  display: none;
}

.management-table .table-link,
.drilldown-panel .table-link {
  width: fit-content;
}

.compact-assignment-table {
  overflow-x: auto;
}

.management-board .compact-assignment-table .table-head {
  display: grid;
}

.management-board .compact-assignment-table .table-row {
  min-width: 980px;
}

.management-board .compact-assignment-table .table-row:not(.table-head) {
  grid-template-columns: var(--columns, repeat(var(--cols), minmax(0, 1fr)));
  gap: 0;
  padding: 0;
  background: #fff;
}

.management-board .compact-assignment-table .table-row:not(.table-head):not(:last-child) {
  border-bottom: 1px solid var(--line);
}

.compact-assignment-table .table-cell {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 13px;
}

.compact-assignment-table .table-head .table-cell {
  color: #fff;
  background: #1f557f;
  font-weight: 700;
}

.compact-assignment-table .table-cell::before {
  content: none;
}

.compact-assignment-table .table-cell:last-child {
  border-right: 0;
}

.compact-assignment-table .table-row:not(.table-head) {
  cursor: pointer;
}

.compact-assignment-table .table-row:not(.table-head):hover,
.compact-assignment-table .table-row.selected {
  background: #eef8f5;
}

.assignment-detail-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.assignment-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.assignment-detail-grid .detail-item:last-child {
  grid-column: 1 / -1;
}

.grouped-table .group-head,
.grouped-table .field-head {
  display: none;
}

.diagnostic-metrics {
  margin-top: 0;
  margin-bottom: 0;
}

.diagnostic-metrics .metric {
  box-shadow: none;
  border-radius: 0;
  text-align: center;
  background: #f7f9fb;
}

.diagnostic-metrics .metric strong {
  color: #18446d;
  font-size: 26px;
}

.person-link {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.drilldown-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  max-width: 100%;
  overflow: hidden;
}

.drilldown-table {
  max-width: 100%;
}

.drilldown-panel .summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
}

.drilldown-table .table-cell {
  line-height: 1.4;
}

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

.accent,
.danger {
  background: var(--danger);
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .app-shell,
  .split,
  .task-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .filters,
  .task-search-panel,
  .metric-grid,
  .form-grid,
  .form-section-grid,
  .bottleneck-summary,
  .register-form,
  .account-form {
    grid-template-columns: 1fr;
  }

  .auth-actions {
    flex-direction: column;
    align-items: stretch;
  }

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

.accent {
  background: var(--accent);
}

@media (max-width: 900px) {
  .app-shell,
  .split,
  .task-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .filters,
  .task-search-panel,
  .metric-grid,
  .form-grid,
  .form-section-grid,
  .bottleneck-summary,
  .account-form {
    grid-template-columns: 1fr;
  }
}
