:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --soft: #eef3f7;
  --text: #1f2937;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #b42318;
  --green: #16803c;
  --violet: #6d28d9;
  --shadow: 0 12px 30px rgba(31, 41, 55, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141b;
  --panel: #171d26;
  --soft: #202834;
  --text: #edf2f7;
  --muted: #a3adbd;
  --line: #303948;
  --accent: #2dd4bf;
  --accent-strong: #99f6e4;
  --blue: #82aaff;
  --amber: #f6c76f;
  --red: #ff9b91;
  --green: #67d391;
  --violet: #c4a7ff;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

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

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

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

h1 {
  font-size: 28px;
  font-weight: 760;
}

h2 {
  font-size: 18px;
  font-weight: 730;
}

h3 {
  font-size: 14px;
  font-weight: 720;
}

.topbar {
  align-items: stretch;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  min-height: 0;
  padding: 18px 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-area {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 16px;
  justify-content: space-between;
  min-width: 0;
}

.main-nav {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 2px;
  padding: 3px;
}

.nav-item {
  background: transparent;
  border: 0;
  color: var(--muted);
  min-height: 32px;
  padding: 0 12px;
}

.nav-item.active {
  background: var(--panel);
  box-shadow: 0 1px 4px rgba(31, 41, 55, 0.08);
  color: var(--accent-strong);
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.top-actions {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, auto) minmax(150px, auto) minmax(185px, auto) minmax(96px, auto) auto minmax(150px, auto);
}

input,
select,
button,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 12px;
}

input,
select,
textarea {
  background: var(--panel);
  color: var(--text);
  min-width: 0;
}

textarea {
  line-height: 1.4;
  min-height: 84px;
  padding: 10px 12px;
  resize: vertical;
}

button {
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.live-badge {
  align-items: center;
  align-self: center;
  background: #ecfdf7;
  border: 1px solid #b7e2c7;
  border-radius: 999px;
  color: var(--accent-strong);
  display: inline-flex;
  font-size: 12px;
  font-weight: 760;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.live-badge span {
  animation: livePulse 1.5s ease-in-out infinite;
  background: var(--green);
  border-radius: 999px;
  box-shadow: 0 0 0 0 rgba(22, 128, 60, 0.35);
  height: 8px;
  width: 8px;
}

.user-menu {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  min-width: 0;
}

.user-menu span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu .secondary-button {
  min-height: 34px;
  padding: 0 10px;
}

.theme-toggle {
  background: var(--soft);
  border-color: var(--line);
  color: var(--accent-strong);
  min-height: 34px;
  padding: 0 10px;
}

.login-screen {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-width: 420px;
  padding: 24px;
  width: 100%;
}

.login-card h1 {
  font-size: 28px;
}

.login-copy,
.login-card label span {
  color: var(--muted);
}

.login-copy {
  line-height: 1.5;
}

.login-card label {
  display: grid;
  gap: 6px;
}

.login-card label span {
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.login-error {
  color: var(--red);
  font-size: 13px;
  font-weight: 760;
  min-height: 18px;
}

.shell {
  display: grid;
  gap: 22px;
  padding: 22px 28px 44px;
}

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

.metric {
  animation: liftIn 260ms ease-out both;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 84px;
  padding: 14px;
}

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

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

.workspace-grid {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 400px);
  position: relative;
}

.workspace-main {
  min-width: 0;
}

.view-panel {
  display: none;
}

.view-panel.active {
  animation: panelIn 180ms ease-out;
  display: block;
}

.queue-panel,
.kanban-section,
.registry-section {
  min-width: 0;
}

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

.result-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stage-summary {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.stage-chip {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
}

.stage-chip.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.stage-chip strong {
  color: var(--muted);
}

.dot {
  border-radius: 999px;
  flex: 0 0 10px;
  height: 10px;
  width: 10px;
}

.client-table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 470px;
  overflow: auto;
}

.client-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 900px;
  width: 100%;
}

.client-table th:nth-child(1),
.client-table td:nth-child(1) {
  width: 22%;
}

.client-table th:nth-child(2),
.client-table td:nth-child(2) {
  width: 17%;
}

.client-table th:nth-child(3),
.client-table td:nth-child(3) {
  width: 11%;
}

.client-table th:nth-child(4),
.client-table td:nth-child(4) {
  width: 10%;
}

.client-table th:nth-child(5),
.client-table td:nth-child(5) {
  width: 11%;
}

.client-table th:nth-child(6),
.client-table td:nth-child(6) {
  width: 17%;
}

.client-table th:nth-child(7),
.client-table td:nth-child(7) {
  width: 12%;
}

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

.client-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}

.client-table tbody tr {
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease;
}

.client-table tbody tr:hover,
.client-table tbody tr.selected {
  background: #effbf8;
}

.client-table tbody tr.just-moved {
  animation: rowMoved 1.6s ease-out;
}

.client-table td {
  font-size: 13px;
}

.client-table td span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.table-pagination,
.stage-pager {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  justify-content: space-between;
}

.table-pagination {
  background: #ffffff;
  border-top: 1px solid var(--line);
  bottom: 0;
  min-height: 48px;
  padding: 8px 12px;
  position: sticky;
}

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

.pager.compact {
  gap: 4px;
}

.pager strong {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pager-button {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  min-height: 32px;
  padding: 0 10px;
}

.pager-button.icon {
  min-width: 32px;
  padding: 0;
}

.pager-button:disabled {
  color: #98a2b3;
  cursor: not-allowed;
  opacity: 0.55;
}

.stage-badge {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  font-weight: 700;
  gap: 6px;
  white-space: nowrap;
}

.stage-badge::before {
  background: var(--stage-color);
  border-radius: 999px;
  content: "";
  height: 9px;
  width: 9px;
}

.attention,
.pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
  padding: 6px 8px;
  white-space: nowrap;
}

.attention.danger {
  background: #ffecea;
  color: var(--red);
}

.attention.warning,
.pill.warn {
  background: #fff4df;
  color: var(--amber);
}

.attention.info {
  background: #eaf1ff;
  color: var(--blue);
}

.attention.neutral {
  background: #edf1f5;
  color: #475569;
}

.attention.success,
.pill.good {
  background: #eaf7ef;
  color: var(--green);
}

.client-panel {
  min-width: 0;
  position: sticky;
  top: 106px;
}

.panel-head-actions {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.panel-close {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: none;
  font-size: 22px;
  font-weight: 700;
  height: 32px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 32px;
}

.panel-close:hover {
  color: var(--text);
}

#appShell.kanban-mode .workspace-grid {
  grid-template-columns: minmax(0, 1fr);
}

#appShell.kanban-mode .client-panel {
  background: rgba(246, 248, 251, 0.96);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(31, 41, 55, 0.22);
  max-height: min(760px, calc(100vh - 180px));
  opacity: 0;
  overflow: auto;
  padding: 10px;
  pointer-events: none;
  position: absolute;
  right: 0;
  top: 0;
  transform: translateX(18px) scale(0.98);
  transition: opacity 180ms ease, transform 180ms ease;
  width: min(420px, calc(100vw - 74px));
  z-index: 20;
}

#appShell.kanban-mode.panel-open .client-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

#appShell.kanban-mode .panel-close {
  display: inline-flex;
}

#appShell.registry-mode .workspace-grid {
  grid-template-columns: minmax(0, 1fr);
}

#appShell.registry-mode .client-panel {
  display: none;
}

.client-panel > .section-head {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  padding: 14px;
}

.notice {
  background: #eaf7ef;
  border: 1px solid #b7e2c7;
  border-radius: 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 760;
  margin-bottom: 12px;
  padding: 10px 12px;
}

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

.compact-facts {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.fact {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

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

.fact strong {
  max-width: 56%;
  overflow-wrap: anywhere;
  text-align: right;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.link-button,
.doc a {
  color: var(--blue);
  font-size: 13px;
  font-weight: 760;
  text-decoration: none;
}

.link-button {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
}

.detail-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
}

.action-editor label {
  display: grid;
  gap: 6px;
}

.action-editor label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

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

.destructive-actions {
  grid-template-columns: minmax(130px, auto) 1fr 1fr;
}

.secondary-button {
  background: #ffffff;
  color: var(--accent-strong);
}

.danger-button,
.ghost-danger {
  border-color: #ffd1d1;
}

.danger-button {
  background: var(--red);
  color: #ffffff;
}

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

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

.doc-progress {
  background: #edf1f5;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.doc-progress span {
  background: var(--accent);
  display: block;
  height: 100%;
  transition: width 220ms ease;
}

.doc {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  min-height: 54px;
  padding: 9px;
}

.doc.received {
  background: #fbfefd;
}

.doc.pending {
  background: #fffdf8;
}

.doc-title-row {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.doc-title-row h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.doc-title-row span,
.doc-wait {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-dot {
  border-radius: 999px;
  height: 12px;
  width: 12px;
}

.status-dot.ok {
  background: var(--green);
}

.status-dot.wait {
  background: var(--amber);
}

.registry-main-head {
  margin-bottom: 14px;
}

.registry-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
}

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

.user-admin-panel {
  grid-column: 1 / -1;
}

.user-admin-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(360px, 0.9fr) minmax(360px, 1.1fr);
}

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

.registry-form label {
  display: grid;
  gap: 6px;
}

.inline-form + .document-config-list,
.document-form {
  margin-top: 12px;
}

.registry-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

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

.toggle-field {
  align-items: center;
  align-self: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex !important;
  flex-direction: row;
  gap: 10px !important;
  min-height: 48px;
  padding: 0 12px;
}

.toggle-field input {
  accent-color: var(--accent);
  height: 18px;
  width: 18px;
}

.toggle-field span {
  text-transform: none !important;
}

.compact-action {
  min-height: 32px;
  padding: 0 10px;
}

.registry-list {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
}

.registry-client {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-height: 56px;
  padding: 9px 10px;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
  width: 100%;
}

.registry-client:hover,
.registry-client.active {
  background: #effbf8;
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(31, 41, 55, 0.08);
}

.registry-client span:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.registry-client strong,
.registry-client small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.registry-client small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.user-list {
  align-content: start;
  border-top: 0;
  margin-top: 0;
  max-height: 320px;
  overflow: auto;
  padding-top: 0;
}

.service-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.service-tab {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  min-height: 34px;
  padding: 0 10px;
}

.service-tab.active {
  background: #effbf8;
  border-color: var(--accent);
  color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.inline-form {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(180px, 1fr) auto;
}

.document-form {
  grid-template-columns: minmax(180px, 1fr) minmax(130px, auto) auto;
}

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

.doc-config {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 14px minmax(0, 1fr) auto auto auto;
  min-height: 58px;
  padding: 9px;
}

.doc-config h3,
.doc-config p {
  overflow-wrap: anywhere;
}

.ghost-danger {
  background: #fff7f7;
  border-color: #ffd1d1;
  color: var(--red);
}

.modal-host {
  inset: 0;
  position: fixed;
  z-index: 80;
}

.modal-backdrop {
  animation: fadeIn 160ms ease-out;
  background: rgba(15, 23, 42, 0.46);
  inset: 0;
  position: absolute;
}

.confirm-modal {
  animation: modalIn 190ms ease-out;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.26);
  display: grid;
  gap: 14px;
  left: 50%;
  max-width: min(440px, calc(100vw - 28px));
  padding: 20px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
}

.confirm-modal > p {
  color: var(--text);
  line-height: 1.45;
}

.modal-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-top: 4px;
}

.muted,
.timeline small {
  color: var(--muted);
  font-size: 12px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 3px solid var(--line);
  padding-left: 10px;
}

.kanban {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  overflow-x: auto;
  padding-bottom: 8px;
}

.stage {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 220px;
  min-width: 220px;
  padding: 10px;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.stage.drop-target {
  background: #e8faf5;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.18), 0 14px 30px rgba(15, 118, 110, 0.12);
  transform: translateY(-2px);
}

.stage-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.stage-title {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--text);
  display: flex;
  gap: 8px;
  min-height: 0;
  min-width: 0;
  padding: 0;
}

.count {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  min-width: 26px;
  padding: 2px 8px;
  text-align: center;
}

.card {
  animation: cardIn 220ms ease-out both;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px;
  transition: border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.card:hover,
.card.active {
  border-color: var(--accent);
}

.card:hover {
  box-shadow: 0 10px 24px rgba(31, 41, 55, 0.1);
  transform: translateY(-1px);
}

.card.dragging {
  opacity: 0.5;
  transform: rotate(1deg) scale(0.98);
}

.card.just-moved {
  animation: cardMoved 1.6s ease-out;
  border-color: var(--accent);
}

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

.card-summary {
  color: #344054;
  font-size: 13px;
  line-height: 1.35;
}

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

.pill {
  background: #f2f4f7;
  color: #344054;
}

.stage-pager {
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 8px;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 14px 4px;
}

.toast-host {
  bottom: 18px;
  display: grid;
  gap: 10px;
  left: 18px;
  max-width: min(380px, calc(100vw - 32px));
  position: fixed;
  z-index: 30;
}

.toast {
  animation: toastIn 220ms ease-out;
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(31, 41, 55, 0.18);
  display: grid;
  gap: 4px;
  padding: 12px 14px;
}

.toast strong {
  color: var(--text);
  font-size: 14px;
}

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

.toast.info {
  border-left-color: var(--blue);
}

.toast.warning {
  border-left-color: var(--amber);
}

.toast.leaving {
  animation: toastOut 240ms ease-in forwards;
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: #121821;
}

:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder {
  color: #727d8d;
}

:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .stage-chip,
:root[data-theme="dark"] .table-pagination,
:root[data-theme="dark"] .pager-button,
:root[data-theme="dark"] .panel-close,
:root[data-theme="dark"] .link-button,
:root[data-theme="dark"] .registry-client,
:root[data-theme="dark"] .service-tab,
:root[data-theme="dark"] .doc-config,
:root[data-theme="dark"] .count,
:root[data-theme="dark"] .confirm-modal,
:root[data-theme="dark"] .toast {
  background: var(--panel);
}

:root[data-theme="dark"] .client-table th {
  background: #121821;
}

:root[data-theme="dark"] .client-table tbody tr:hover,
:root[data-theme="dark"] .client-table tbody tr.selected,
:root[data-theme="dark"] .registry-client:hover,
:root[data-theme="dark"] .registry-client.active,
:root[data-theme="dark"] .service-tab.active {
  background: rgba(45, 212, 191, 0.1);
}

:root[data-theme="dark"] .live-badge {
  background: rgba(103, 211, 145, 0.13);
  border-color: rgba(103, 211, 145, 0.32);
}

:root[data-theme="dark"] .secondary-button {
  background: #121821;
  color: var(--accent-strong);
}

:root[data-theme="dark"] .metric,
:root[data-theme="dark"] .registry-panel,
:root[data-theme="dark"] .client-table-wrap,
:root[data-theme="dark"] .compact-facts,
:root[data-theme="dark"] .detail-box,
:root[data-theme="dark"] .client-panel > .section-head,
:root[data-theme="dark"] .card {
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] #appShell.kanban-mode .client-panel {
  background: rgba(15, 20, 27, 0.96);
}

:root[data-theme="dark"] .doc.received {
  background: rgba(103, 211, 145, 0.08);
}

:root[data-theme="dark"] .doc.pending {
  background: rgba(246, 199, 111, 0.08);
}

:root[data-theme="dark"] .pill {
  background: #242d3a;
  color: #d9e2ec;
}

:root[data-theme="dark"] .attention.danger {
  background: rgba(255, 155, 145, 0.14);
}

:root[data-theme="dark"] .attention.warning,
:root[data-theme="dark"] .pill.warn {
  background: rgba(246, 199, 111, 0.16);
}

:root[data-theme="dark"] .attention.info {
  background: rgba(130, 170, 255, 0.15);
}

:root[data-theme="dark"] .attention.neutral {
  background: #242d3a;
  color: var(--muted);
}

:root[data-theme="dark"] .attention.success,
:root[data-theme="dark"] .pill.good {
  background: rgba(103, 211, 145, 0.14);
}

:root[data-theme="dark"] .notice {
  background: rgba(103, 211, 145, 0.12);
  border-color: rgba(103, 211, 145, 0.32);
}

:root[data-theme="dark"] .doc-progress {
  background: #26303d;
}

:root[data-theme="dark"] .stage.drop-target {
  background: rgba(45, 212, 191, 0.12);
}

:root[data-theme="dark"] .card-summary {
  color: #cbd5e1;
}

:root[data-theme="dark"] .ghost-danger {
  background: rgba(255, 155, 145, 0.1);
  border-color: rgba(255, 155, 145, 0.28);
}

:root[data-theme="dark"] .danger-button {
  border-color: rgba(255, 155, 145, 0.38);
}

@keyframes livePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 128, 60, 0.35);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(22, 128, 60, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(22, 128, 60, 0);
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 8px));
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@keyframes liftIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cardMoved {
  0% {
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.24);
    transform: scale(0.98);
  }
  45% {
    box-shadow: 0 0 0 5px rgba(15, 118, 110, 0.14);
    transform: scale(1.015);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0);
    transform: scale(1);
  }
}

@keyframes rowMoved {
  0% {
    background: #dff8ee;
    box-shadow: inset 4px 0 0 var(--accent);
  }
  100% {
    background: transparent;
    box-shadow: inset 0 0 0 rgba(15, 118, 110, 0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@media (max-width: 1180px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .top-actions {
    grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(145px, 0.6fr)) minmax(180px, 0.75fr) auto auto minmax(140px, auto);
  }

  .client-panel {
    position: static;
  }
}

@media (max-width: 900px) {
  .brand-area {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .top-actions {
    grid-template-columns: 1fr 1fr;
  }

  .top-actions > input,
  .top-actions > button {
    grid-column: span 2;
  }

  .live-badge {
    justify-content: center;
  }

  .user-menu {
    grid-column: span 2;
    justify-content: space-between;
  }

  .kanban {
    grid-template-columns: repeat(4, 220px);
  }

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

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

@media (max-width: 640px) {
  .topbar,
  .shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .metrics,
  .top-actions {
    grid-template-columns: 1fr;
  }

  .top-actions > input,
  .top-actions > button {
    grid-column: auto;
  }

  .user-menu {
    grid-column: auto;
  }

  .editor-actions {
    grid-template-columns: 1fr;
  }

  .registry-form,
  .inline-form,
  .document-form {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: auto;
  }

  .doc-config {
    grid-template-columns: 14px minmax(0, 1fr);
  }

  .doc-config > .pill,
  .doc-config > button {
    grid-column: 2;
    justify-self: start;
  }

  .toast-host {
    left: 16px;
    max-width: none;
    right: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
