:root {
  --bg: #f5f5f3;
  --panel: #ffffff;
  --ink: #111111;
  --muted: #6f6f6f;
  --line: #d8d8d3;
  --soft: #efefeb;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: linear-gradient(180deg, #fcfcfa 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select {
  font: inherit;
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 34px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.04);
}
.login-card h1 {
  margin: 0 0 10px;
  font-size: 30px;
  letter-spacing: 0.08em;
}
.login-card p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.7;
}
.stack { display: flex; flex-direction: column; gap: 14px; }
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field label {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px 14px;
  min-height: 44px;
}
.field textarea {
  min-height: 120px;
  resize: vertical;
}
.checkbox-field {
  gap: 0;
}
.checkbox-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.checkbox-control:hover {
  border-color: var(--ink);
}
.checkbox-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.checkbox-mark {
  width: 18px;
  height: 18px;
  border: 1px solid var(--ink);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.checkbox-mark::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 2px solid transparent;
  border-bottom: 2px solid transparent;
  transform: rotate(-45deg) translate(0, -1px);
}
.checkbox-control input:checked + .checkbox-mark {
  background: var(--ink);
}
.checkbox-control input:checked + .checkbox-mark::after {
  border-left-color: #fff;
  border-bottom-color: #fff;
}
.checkbox-control input:focus-visible + .checkbox-mark {
  outline: 2px solid #888;
  outline-offset: 2px;
}
.checkbox-text {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.checkbox-control--radio .checkbox-mark {
  border-radius: 999px;
}
.checkbox-control--radio .checkbox-mark::after {
  width: 8px;
  height: 8px;
  border: none;
  border-radius: 999px;
  background: transparent;
  transform: none;
}
.checkbox-control--radio input:checked + .checkbox-mark::after {
  background: #fff;
}
.dispatch-scope-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.target-client-picker {
  border: 1px solid var(--line);
  background: #fafaf7;
  padding: 12px;
}
.target-client-picker__hint {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.task-budget-preview {
  border: 1px solid var(--line);
  background: #fafaf7;
  padding: 12px;
  display: grid;
  gap: 8px;
}
.task-budget-preview__title {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.task-budget-preview__line {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
}
.target-client-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.target-client-option {
  width: 100%;
  justify-content: flex-start;
}
.target-client-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: none;
}
.target-client-empty {
  margin: 0;
  padding: 10px 2px;
}
.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.table-actions form {
  margin: 0;
}
.text-action {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.danger-action {
  color: #8a1f1f;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin-bottom: 18px;
  font-size: 13px;
}
.subheading {
  margin: 20px 0 10px;
  font-size: 14px;
  letter-spacing: 0.06em;
}
.code-block {
  margin: 0;
  padding: 14px;
  background: #f8f8f6;
  border: 1px solid var(--line);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.7;
}
.record-detail-row > td {
  padding: 0;
  background: #fafaf7;
}
.record-detail-panel {
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 18px;
  background: #fff;
}
.record-detail-panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
  letter-spacing: 0.06em;
}
.primary-btn, .ghost-btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.primary-btn {
  background: var(--ink);
  color: #fff;
}
.ghost-btn {
  background: transparent;
  color: var(--ink);
  line-height: 44px;
}
.error-text {
  color: #8a1f1f;
  font-size: 13px;
}
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.sidebar {
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  background: rgba(255, 255, 255, 0.72);
}
.brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 24px;
}
.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  margin-top: 8px;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nav a {
  display: block;
  border: 1px solid var(--line);
  padding: 13px 14px;
}
.nav a.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.content {
  padding: 28px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}
.topbar h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: 0.04em;
}
.topbar p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.panel, .stat {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
  margin-bottom: 1%;
}
.stat .label {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.stat .value {
  margin: 18px 0 8px;
  font-size: 34px;
  font-weight: 700;
}
.panel-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
  letter-spacing: 0.06em;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
}
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}
.filter-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.list-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.pager {
  display: flex;
  gap: 10px;
}
.record-item-text {
  max-width: 360px;
  line-height: 1.7;
}
.source-cell {
  max-width: 260px;
  word-break: break-all;
}
.client-error-cell {
  max-width: 220px;
  line-height: 1.6;
  word-break: break-word;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
}
.muted { color: var(--muted); }
.tag {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 4px 9px;
  font-size: 12px;
}
.tag--success {
  border-color: #245b36;
  background: #eef8f0;
  color: #245b36;
}
.tag--danger {
  border-color: #8a1f1f;
  background: #fff1f1;
  color: #8a1f1f;
}
.tag--muted {
  border-color: #8b8b84;
  background: #f3f3ef;
  color: #666;
}
.heartbeat-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #8b8b84;
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.12);
}
.heartbeat-indicator--online {
  background: #245b36;
}
.heartbeat-indicator--offline {
  background: #8a1f1f;
}
.heartbeat-indicator--never {
  background: #8b8b84;
}
.toast-region {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
}
.toast {
  border: 1px solid var(--ink);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  padding: 13px 15px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.12);
  animation: toast-in 0.18s ease-out;
}
.toast--success {
  border-color: #245b36;
}
.toast--error {
  border-color: #8a1f1f;
  color: #8a1f1f;
}
.toast--info {
  border-color: #6f6f6f;
  color: #333;
}
.toast[data-leaving="true"] {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.modal-open {
  overflow: hidden;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 17, 17, 0.28);
  backdrop-filter: blur(6px);
}
.modal-backdrop[hidden] {
  display: none;
}
.modal-card {
  width: min(100%, 420px);
  border: 1px solid var(--ink);
  background: rgba(255, 255, 255, 0.98);
  padding: 22px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.2);
  animation: modal-in 0.18s ease-out;
}
.modal-kicker {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.modal-card h2 {
  margin: 8px 0 10px;
  font-size: 24px;
}
.modal-card p {
  margin: 0;
  color: #333;
  line-height: 1.7;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@media (max-width: 1080px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid, .two-col { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .content { padding: 18px; }
  .stats { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: 1fr; }
  .list-meta { align-items: flex-start; flex-direction: column; }
  .topbar { flex-direction: column; }
  .toast-region {
    top: 12px;
    right: 12px;
  }
  .modal-actions {
    flex-direction: column-reverse;
  }
}
