:root {
  color-scheme: light;
  --bg: #f3f3f3;
  --panel: #ffffff;
  --panel-soft: #fafafa;
  --ink: #1f1f1f;
  --muted: #616161;
  --line: #e5e5e5;
  --line-strong: #d1d1d1;
  --blue: #0067c0;
  --green: #16845b;
  --amber: #b56b18;
  --red: #c7443e;
  --cyan: #007d8a;
  --sidebar-bg: #202020;
  --sidebar-hover: #2d2d2d;
  --sidebar-active: #333333;
  --sidebar-text: #f5f5f5;
  --sidebar-muted: #bdbdbd;
  --control-bg: rgba(255, 255, 255, 0.72);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #202020;
  --panel: #2b2b2b;
  --panel-soft: #242424;
  --ink: #f3f3f3;
  --muted: #c8c8c8;
  --line: #3a3a3a;
  --line-strong: #4a4a4a;
  --blue: #60cdff;
  --green: #6ccb9c;
  --amber: #f0b35a;
  --red: #ff8a84;
  --cyan: #63d8e4;
  --sidebar-bg: #171717;
  --sidebar-hover: #2c2c2c;
  --sidebar-active: #343434;
  --sidebar-text: #f3f3f3;
  --sidebar-muted: #b8b8b8;
  --control-bg: rgba(43, 43, 43, 0.78);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  min-width: 0;
  overflow-x: hidden;
}

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

button {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
  max-width: 100%;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--sidebar-bg);
}

.login-stack {
  display: grid;
  width: min(820px, 100%);
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}

.login-card {
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid #273646;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.28);
}

.login-card h1,
.login-card h2,
.login-card p {
  margin: 0;
}

.login-card p {
  color: var(--muted);
}

.form-error {
  min-height: 20px;
  color: var(--red);
  overflow-wrap: anywhere;
}

.ghost-button {
  background: var(--panel-soft);
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

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

.app-shell.sidebar-collapsed {
  grid-template-columns: 35px minmax(0, 1fr);
}

.sidebar {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 18px 14px;
  min-width: 0;
  min-height: 100vh;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 4px 18px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #eaf3ff;
  color: #005fb8;
  font-weight: 800;
  flex: 0 0 42px;
}

.sidebar-brand-toggle {
  cursor: pointer;
}

.sidebar-brand-toggle:hover {
  border-color: #7aa7ff;
}

.brand-mark svg,
.icon-svg,
.nav-icon svg,
.sidebar-toggle svg,
.back-button svg,
.theme-mode-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark svg {
  width: 25px;
  height: 25px;
  stroke-width: 2.2;
}

.brand-copy {
  min-width: 0;
  transition: opacity 160ms ease, width 160ms ease;
}

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

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

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

.view-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.view-nav-items {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 0;
  overflow: auto;
  flex: 1 1 auto;
}

.view-nav button,
.developer-mode-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-color: transparent;
  background: transparent;
  color: var(--sidebar-muted);
  padding: 0 10px;
  overflow: hidden;
}

.developer-mode-btn {
  margin-top: auto;
}

.view-nav button.active,
.view-nav button:hover,
.developer-mode-btn:hover {
  background: var(--sidebar-active);
  color: var(--sidebar-text);
  border-color: transparent;
}

.nav-icon {
  display: grid;
  place-items: center;
  flex: 0 0 20px;
}

.view-nav button span:last-child,
.developer-mode-btn span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 160ms ease, width 160ms ease;
}

.sidebar-footer {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.app-shell.sidebar-collapsed .sidebar {
  padding: 0 0 8px;
}

.app-shell.sidebar-collapsed .sidebar-head {
  display: grid;
  width: 16px;
  justify-self: center;
  justify-items: center;
  gap: 0;
  padding: 0 0 10px;
}

.app-shell.sidebar-collapsed .brand {
  justify-content: center;
}

.app-shell.sidebar-collapsed .brand-copy,
.app-shell.sidebar-collapsed .view-nav button span:last-child,
.app-shell.sidebar-collapsed .developer-mode-btn span:last-child {
  width: 0;
  opacity: 0;
  pointer-events: none;
}

.app-shell.sidebar-collapsed .view-nav button,
.app-shell.sidebar-collapsed .developer-mode-btn {
  justify-content: center;
  width: 35px;
  min-height: 20px;
  height: 20px;
  padding: 0;
  gap: 0;
  border-radius: 3px;
}

.app-shell.sidebar-collapsed .view-nav,
.app-shell.sidebar-collapsed .view-nav-items,
.app-shell.sidebar-collapsed .sidebar-footer {
  width: 35px;
  justify-self: center;
  gap: 20px;
  justify-items: center;
}

.app-shell.sidebar-collapsed .view-nav {
  padding-top: 100px;
}

.app-shell.sidebar-collapsed .view-nav-items {
  flex: 0 0 auto;
}

.app-shell.sidebar-collapsed .developer-mode-btn {
  margin-top: 0;
}

.app-shell.sidebar-collapsed .sidebar-footer {
  align-self: end;
  margin-top: 10px;
  padding-top: 10px;
}

.app-shell.sidebar-collapsed .brand-mark {
  width: 16px;
  height: 16px;
  min-height: 16px;
  flex-basis: 16px;
  border-radius: 2px;
  background: transparent;
  color: var(--sidebar-muted);
}

.app-shell.sidebar-collapsed .brand-mark svg,
.app-shell.sidebar-collapsed .nav-icon svg {
  width: 16px;
  height: 16px;
}

.app-shell.sidebar-collapsed .nav-icon {
  flex-basis: 16px;
}

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

.list-view {
  display: grid;
  grid-template-rows: auto auto auto minmax(360px, 1fr) auto;
  gap: 14px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.topbar-title {
  min-width: 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

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

.topbar p,
.section-title p {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

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

.theme-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border-radius: 6px;
  background: var(--control-bg);
  backdrop-filter: blur(18px);
}

.theme-mode-icon {
  display: grid;
  place-items: center;
}

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

.metric {
  display: grid;
  min-height: auto;
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.metric:hover,
.metric:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 18px 45px rgba(30, 40, 55, 0.12);
  transform: translateY(-1px);
}

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

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(6, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.search-toolbar {
  grid-template-columns: minmax(260px, 480px) auto;
}

.toolbar-action-buttons {
  display: flex;
  gap: 8px;
  align-items: end;
  min-width: 0;
}

.toolbar-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 104px;
  white-space: nowrap;
}

.toolbar-icon-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

label span {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
  min-width: 0;
}

textarea {
  min-height: 78px;
  padding: 8px 10px;
  resize: vertical;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

.table-panel,
.detail-panel,
.audit-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

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

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 280px);
}

.table-wrap.filter-popover-open {
  min-height: 280px;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
}

th.filterable-column {
  overflow: visible;
}

th.filter-open {
  z-index: 8;
}

.th-content {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  line-height: 1;
  min-width: 0;
}

.th-content > span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.column-filter-btn {
  display: inline-grid;
  flex: 0 0 24px;
  place-items: center;
  width: 24px;
  min-height: 24px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.column-filter-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.column-filter-btn:hover,
.column-filter-btn:focus-visible,
.column-filter-btn.active {
  border-color: var(--line-strong);
  background: var(--control-bg);
  color: var(--blue);
}

.column-filter-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 8px;
  z-index: 30;
  display: grid;
  width: 220px;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
}

.dispatch-date-filter {
  width: 260px;
}

.dispatch-date-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.column-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.column-filter-actions button {
  min-height: 30px;
  padding: 0 10px;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #eef5ff;
}

.address-cell {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: #eef2f7;
  color: #324255;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.status-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status-done {
  background: #e5f5ee;
  color: var(--green);
}

.status-active {
  background: #eaf0ff;
  color: var(--blue);
}

.status-warn {
  background: #fff3df;
  color: var(--amber);
}

.status-danger {
  background: #fdeceb;
  color: var(--red);
}

.detail-panel {
  padding: 14px;
  overflow: auto;
}

.project-detail-view {
  display: grid;
  gap: 14px;
  min-width: 0;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.project-detail-hero {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 8px;
  min-height: 36px;
}

.project-detail-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.project-detail-title > div {
  min-width: 0;
}

.project-detail-title h2,
.project-detail-title p,
.eyebrow {
  margin: 0;
}

.project-detail-title h2 {
  font-size: 30px;
  line-height: 1.15;
}

.project-detail-title p:last-child {
  margin-top: 6px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

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

.project-detail-summary div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.project-detail-summary dt,
.project-detail-summary dd {
  margin: 0;
}

.project-detail-summary dt {
  color: var(--muted);
  font-size: 12px;
}

.project-detail-summary dd {
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 14px;
  align-items: start;
  min-height: 0;
}

.project-detail-layout.single-column {
  grid-template-columns: minmax(0, 1fr);
}

.project-detail-main,
.project-detail-aside {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  max-height: calc(100vh - 260px);
  overflow: auto;
}

.project-detail-main {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.project-detail-main .detail-section {
  padding: 16px;
}

.project-detail-main .detail-section:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.project-detail-aside {
  padding: 16px;
}

.empty-detail {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
}

.detail-head {
  display: grid;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

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

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

.detail-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.detail-section:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.detail-section h4 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #3c4654;
}

.field-grid {
  display: grid;
  gap: 8px;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(86px, 0.38fr) minmax(0, 1fr);
  gap: 8px;
}

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

.field-row span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.edit-grid {
  display: grid;
  gap: 8px;
}

.save-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.audit-panel {
  padding: 14px;
}

.audit-view {
  display: grid;
  gap: 14px;
  min-width: 0;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.change-log-view {
  display: grid;
  gap: 14px;
  min-width: 0;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.audit-hero,
.change-log-hero {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.audit-title h2,
.audit-title p,
.change-log-title h2,
.change-log-title p {
  margin: 0;
}

.audit-title h2,
.change-log-title h2 {
  font-size: 28px;
  line-height: 1.18;
}

.audit-title p:last-child,
.change-log-title p:last-child {
  margin-top: 6px;
  color: var(--muted);
}

.change-log-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(160px, 0.8fr) repeat(3, minmax(130px, 0.7fr));
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.change-log-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.change-log-item {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.change-log-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.change-log-item h4,
.change-log-item p {
  margin: 0;
}

.change-log-item h4 {
  overflow-wrap: anywhere;
}

.change-log-item time,
.change-log-context {
  color: var(--muted);
  font-size: 12px;
}

.change-log-item time {
  flex: 0 0 auto;
  white-space: nowrap;
}

.change-list {
  display: grid;
  gap: 6px;
}

.change-row {
  display: grid;
  grid-template-columns: minmax(100px, 0.5fr) minmax(0, 1fr) 22px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

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

.change-before,
.change-after {
  min-width: 0;
  overflow-wrap: anywhere;
}

.change-arrow {
  color: var(--muted);
  text-align: center;
}

.empty-value {
  color: var(--muted);
  font-style: italic;
}

.audit-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  margin: 0;
}

.audit-stats div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.audit-stats dt,
.audit-stats dd {
  margin: 0;
}

.audit-stats dt {
  color: var(--muted);
  font-size: 12px;
}

.audit-stats dd {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 800;
}

.audit-board {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
  min-height: 0;
}

.audit-lane,
.audit-history {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.audit-lane .audit-list {
  max-height: calc(100vh - 390px);
  overflow: auto;
}

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

.audit-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.audit-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.audit-item.test-audit {
  border-color: #e4b24d;
  background: #fffaf0;
}

.audit-item h4,
.audit-item p {
  margin: 0;
}

.audit-item h4 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.audit-item p {
  color: var(--muted);
}

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

.audit-meta div {
  min-width: 0;
}

.audit-meta dt,
.audit-meta dd {
  margin: 0;
}

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

.audit-meta dd {
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-reason {
  margin-top: 10px !important;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fff3df;
  color: var(--amber) !important;
}

.compact-empty {
  min-height: 120px;
}

.audit-timeline {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  margin-top: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.timeline-item p,
.timeline-item strong {
  margin: 0;
}

.timeline-item p,
.timeline-item span {
  color: var(--muted);
}

.timeline-item > div:nth-child(2) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.test-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  background: #ffe3a1;
  color: #7b4b00;
  font-size: 12px;
  font-weight: 700;
}

.audit-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.audit-actions button:first-child {
  border-color: #9ad7bd;
  color: var(--green);
}

.audit-actions button:last-child {
  border-color: #efb1ad;
  color: var(--red);
}

dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(20, 30, 42, 0.25);
}

dialog::backdrop {
  background: rgba(10, 16, 24, 0.38);
}

:root[data-theme="dark"] .login-card {
  border-color: var(--line);
}

:root[data-theme="dark"] tbody tr:hover,
:root[data-theme="dark"] tbody tr.selected {
  background: #26364a;
}

:root[data-theme="dark"] .status-pill {
  background: #3a3a3a;
  color: #e8e8e8;
}

:root[data-theme="dark"] .status-done {
  background: #19382b;
  color: var(--green);
}

:root[data-theme="dark"] .status-active {
  background: #17324a;
  color: var(--blue);
}

:root[data-theme="dark"] .status-warn {
  background: #3d321f;
  color: var(--amber);
}

:root[data-theme="dark"] .status-danger {
  background: #442522;
  color: var(--red);
}

:root[data-theme="dark"] .project-detail-summary div,
:root[data-theme="dark"] .audit-stats div {
  background: var(--panel-soft);
}

:root[data-theme="dark"] .audit-item.test-audit,
:root[data-theme="dark"] .pending-user {
  border-color: #7a6128;
  background: #332916;
}

:root[data-theme="dark"] .audit-reason {
  background: #332916;
  color: var(--amber) !important;
}

dialog form {
  display: grid;
  gap: 12px;
}

#userDialog {
  width: min(1040px, calc(100vw - 28px));
}

.developer-console {
  display: grid;
  gap: 14px;
}

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

.dev-summary div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.dev-summary span,
.dev-user-button small,
.dev-editor-head p,
.dev-role-line {
  color: var(--muted);
}

.dev-summary strong {
  display: block;
  margin-top: 2px;
  font-size: 22px;
}

.dev-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.dev-user-list {
  display: grid;
  align-content: start;
  gap: 6px;
  max-height: 520px;
  overflow: auto;
}

.dev-user-button {
  display: grid;
  gap: 2px;
  justify-items: start;
  width: 100%;
  height: auto;
  min-height: 52px;
  padding: 8px 10px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
}

.dev-user-button.active,
.dev-user-button:hover {
  border-color: var(--blue);
  background: var(--panel-soft);
}

.dev-user-button span,
.dev-user-button small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dev-editor,
.dev-create {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.dev-editor {
  display: grid;
  gap: 10px;
}

.dev-editor-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.dev-editor-head h4,
.dev-editor-head p,
.dev-role-line {
  margin: 0;
}

.dev-create summary {
  cursor: pointer;
  font-weight: 700;
}

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

.dev-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.user-edit-grid {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) repeat(2, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.pending-user {
  border-color: #e4b24d;
  background: #fffaf0;
}

.user-actions {
  display: flex;
  min-width: 150px;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.user-item h4,
.user-item p {
  margin: 0;
}

.user-item h4 span {
  color: var(--muted);
  font-weight: 400;
}

.user-item p {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  min-height: auto;
  width: 16px;
  height: 16px;
}

.checkbox-row span {
  color: var(--ink);
  font-size: 14px;
}

.dialog-head,
menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.dialog-head h3 {
  margin: 0;
}

.icon-button {
  width: 34px;
  padding: 0;
}

@media (max-width: 1120px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .app-shell.sidebar-collapsed .sidebar {
    position: static;
    padding: 18px 14px;
    min-height: auto;
    grid-template-rows: minmax(0, 1fr);
  }

  .app-shell.sidebar-collapsed .brand {
    justify-content: flex-start;
  }

  .app-shell.sidebar-collapsed .brand-copy,
  .app-shell.sidebar-collapsed .view-nav button span:last-child,
  .app-shell.sidebar-collapsed .developer-mode-btn span:last-child {
    width: auto;
    opacity: 1;
    pointer-events: auto;
  }

  .app-shell.sidebar-collapsed .view-nav button,
  .app-shell.sidebar-collapsed .developer-mode-btn {
    justify-content: flex-start;
    min-height: 34px;
    padding: 0 10px;
  }

  .sidebar-toggle {
    display: none;
  }

  .view-nav {
    height: auto;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .toolbar,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .project-detail-layout,
  .audit-board,
  .change-log-filters {
    grid-template-columns: 1fr;
  }

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

  .project-detail-main .detail-section:nth-child(odd) {
    border-right: 0;
  }

  .project-detail-main .detail-section:nth-last-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .project-detail-main .detail-section:last-child {
    border-bottom: 0;
  }

  .project-detail-main,
  .project-detail-aside,
  .audit-lane .audit-list {
    max-height: none;
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 680px) {
  html {
    background: #eef2f6;
  }

  body {
    background: #eef2f6;
  }

  button,
  input,
  select,
  textarea {
    font-size: 16px;
  }

  button {
    min-height: 40px;
    padding: 0 10px;
  }

  .login-view {
    min-height: 100svh;
    align-items: start;
    padding: 14px;
  }

  .login-stack {
    width: 100%;
    max-width: 480px;
    gap: 12px;
  }

  .login-card {
    padding: 18px;
  }

  .app-shell {
    display: block;
    min-height: auto;
    width: 100%;
  }

  .workspace,
  .sidebar {
    padding: 12px;
  }

  .workspace {
    gap: 12px;
    grid-template-rows: none;
    width: 100%;
    overflow: hidden;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #243140;
  }

  .sidebar-head,
  .app-shell.sidebar-collapsed .sidebar-head {
    padding: 0 0 12px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

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

  .view-nav {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
  }

  .view-nav-items {
    display: flex;
    flex: 0 1 auto;
    gap: 8px;
    overflow: visible;
  }

  .developer-mode-btn {
    margin-top: 0;
  }

  .view-nav button {
    flex: 0 0 auto;
    width: auto;
    min-width: 112px;
    scroll-snap-align: start;
  }

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

  .project-detail-view,
  .audit-view {
    max-height: none;
    overflow: visible;
  }

  .project-detail-hero,
  .audit-hero,
  .project-detail-main,
  .project-detail-aside,
  .audit-lane,
  .audit-history {
    box-shadow: var(--shadow);
  }

  .project-detail-title,
  .audit-item-head {
    display: grid;
  }

  .project-detail-title h2,
  .audit-title h2 {
    font-size: 24px;
  }

  .project-detail-summary,
  .audit-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric {
    padding: 10px;
  }

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

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

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
  }

  .topbar-actions button {
    width: 100%;
    min-width: 0;
  }

  .user-badge {
    grid-column: 1 / -1;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .dev-grid,
  .dev-create-grid {
    grid-template-columns: 1fr;
  }

  .login-stack {
    grid-template-columns: 1fr;
  }

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

  .user-actions {
    align-items: stretch;
    min-width: 0;
  }

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

  .toolbar label:first-child {
    grid-column: 1 / -1;
  }

  .toolbar-action-buttons {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar-icon-button {
    width: 100%;
    min-width: 0;
  }

  .content-grid {
    gap: 12px;
    min-width: 0;
  }

  .table-panel {
    display: none;
  }

  .mobile-card-list {
    display: grid;
    gap: 10px;
    min-width: 0;
  }

  .project-card {
    display: grid;
    gap: 10px;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    cursor: pointer;
  }

  .project-card.selected {
    border-color: #7aa7ff;
    box-shadow: 0 0 0 2px rgba(47, 111, 237, 0.12), var(--shadow);
  }

  .project-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
  }

  .project-card-head > div {
    min-width: 0;
  }

  .project-card-head h3,
  .project-card-head p,
  .project-card-address {
    margin: 0;
  }

  .project-card-head h3 {
    font-size: 18px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .project-card-head p,
  .project-card-address {
    color: var(--muted);
  }

  .project-card-address {
    overflow-wrap: anywhere;
  }

  .project-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

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

  .project-card-facts div {
    min-width: 0;
    padding-left: 8px;
    border-left: 2px solid var(--line);
  }

  .project-card-facts dt,
  .project-card-facts dd {
    margin: 0;
  }

  .project-card-facts dt {
    color: var(--muted);
    font-size: 12px;
  }

  .project-card-facts dd {
    margin-top: 3px;
    overflow: hidden;
    color: var(--ink);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .detail-panel,
  .audit-panel {
    box-shadow: var(--shadow);
    min-width: 0;
  }

  .detail-panel {
    padding: 12px;
  }

  .field-row {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .audit-list {
    grid-template-columns: 1fr;
  }

  .audit-meta,
  .timeline-item {
    grid-template-columns: 1fr;
  }

  dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    margin: auto;
    padding: 14px;
  }

  #userDialog {
    width: calc(100vw - 16px);
  }

  .dev-user-list {
    max-height: none;
  }

  .user-actions {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .user-actions .status-pill {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .user-actions button {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .metrics,
  .toolbar,
  .project-detail-summary,
  .audit-stats,
  .project-card-facts,
  .change-row {
    grid-template-columns: 1fr;
  }

  .workspace,
  .sidebar {
    padding: 10px;
  }

  .topbar-actions,
  .user-actions,
  menu {
    display: grid;
    grid-template-columns: 1fr;
  }

  .project-card-head {
    display: grid;
  }

  .project-card-head .status-pill {
    justify-self: start;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .change-log-item-head {
    display: grid;
  }

  .change-log-item time {
    white-space: normal;
  }
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  background: var(--bg);
}
