:root {
  color-scheme: light;
  --vpc-orange: #eba151;
  --vpc-charcoal: #333333;
  --vpc-gray: #979797;
  --vpc-dark: #1e1d23;
  --vpc-light-gray: #e6e6e6;
  --vpc-white: #ffffff;
  --ink: var(--vpc-charcoal);
  --muted: #6f6f6f;
  --line: var(--vpc-light-gray);
  --soft: #f7f7f7;
  --panel: var(--vpc-white);
  --primary: var(--vpc-orange);
  --primary-strong: #cf7f26;
  --danger: #b3261e;
  --warning: #956100;
  --success: #26724f;
  --shadow: 0 18px 50px rgba(26, 37, 62, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--soft);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px 1fr;
}

.sidebar {
  background: var(--vpc-dark);
  color: var(--vpc-white);
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  padding: 12px;
  min-height: 76px;
  background: var(--vpc-white);
  border-radius: 8px;
}

.brand img {
  display: block;
  width: 100%;
  max-width: 188px;
  height: auto;
}

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

nav a {
  color: var(--vpc-light-gray);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
}

nav a.active,
nav a:hover {
  background: rgba(235, 161, 81, 0.16);
  color: var(--vpc-white);
}

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

.topbar,
.panel-toolbar,
.topbar-actions,
.document-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.notice {
  margin: -6px 0 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px 14px;
  color: var(--muted);
  font-weight: 650;
}

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

.notice.success {
  border-left-color: var(--success);
  color: var(--success);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.35rem;
}

.topbar-actions {
  gap: 10px;
}

.primary-button,
.icon-button,
button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--vpc-dark);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.primary-button:hover {
  background: var(--primary-strong);
  color: var(--vpc-white);
}

.icon-button {
  width: 40px;
  padding: 0;
  display: grid;
  place-items: center;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.summary-grid article,
.fax-panel,
.data-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-grid article {
  padding: 18px;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.summary-grid strong {
  font-size: 1.55rem;
}

.fax-panel {
  overflow: hidden;
}

.view-panel {
  display: grid;
  gap: 18px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.data-panel {
  overflow: hidden;
}

.data-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.data-panel > header span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.activity-list,
.entity-list {
  display: grid;
}

.activity-row,
.entity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.activity-row {
  justify-content: flex-start;
}

.activity-row:last-child,
.entity-row:last-child {
  border-bottom: 0;
}

.activity-row div,
.entity-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.activity-row strong,
.entity-row strong {
  font-size: 0.95rem;
}

.activity-row span:not(.status),
.entity-row span:not(.status),
.empty-state {
  color: var(--muted);
  font-size: 0.86rem;
}

.empty-state {
  padding: 18px 16px;
}

.compact-table {
  min-width: 760px;
}

.panel-toolbar {
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tabs button {
  border: 0;
  background: transparent;
  min-height: 32px;
  padding: 0 14px;
  color: var(--muted);
}

.tabs button.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(24, 36, 56, 0.1);
}

.db-state {
  color: var(--muted);
  font-size: 0.9rem;
}

.db-state.connected {
  color: var(--success);
}

.db-state.error {
  color: var(--danger);
}

.filters {
  display: grid;
  grid-template-columns: 1.5fr repeat(5, minmax(130px, 1fr));
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 650;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  min-height: 40px;
  padding: 0 11px;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.danger-button {
  color: var(--danger);
}

.danger-button:hover {
  border-color: #f2b8b5;
  background: #fff3f2;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.route {
  display: grid;
  gap: 3px;
}

.route strong {
  font-size: 0.95rem;
}

.route span {
  color: var(--muted);
  font-size: 0.85rem;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  background: #e8f4ef;
  color: var(--success);
}

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

.status.pending {
  background: #fff4d8;
  color: var(--warning);
}

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

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
}

.drawer-dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  margin: auto 14px auto auto;
  border: 0;
  padding: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.drawer-dialog::backdrop {
  background: rgba(15, 23, 42, 0.38);
}

.drawer {
  padding: 22px;
  display: grid;
  gap: 18px;
}

.drawer header,
.drawer footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.drawer footer {
  justify-content: flex-end;
}

.form-error {
  border: 1px solid #f2b8b5;
  border-radius: 8px;
  background: #fff3f2;
  color: var(--danger);
  padding: 11px 12px;
  font-weight: 650;
}

.drop-zone {
  border: 1px dashed #9aa6b8;
  border-radius: 8px;
  min-height: 150px;
  place-items: center;
  text-align: center;
  padding: 22px;
}

.drop-zone input {
  width: 1px;
  height: 1px;
  opacity: 0;
  position: absolute;
}

.details-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0;
}

.details-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

dd {
  margin: 5px 0 0;
}

.document-actions {
  gap: 10px;
}

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

.timeline div {
  display: grid;
  gap: 4px;
  border-left: 3px solid var(--primary);
  padding-left: 12px;
  color: var(--muted);
}

.timeline strong {
  color: var(--ink);
}

pre {
  white-space: pre-wrap;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.settings-menu {
  position: fixed;
  right: 154px;
  top: 76px;
  display: grid;
  gap: 14px;
  width: min(360px, calc(100vw - 28px));
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 3;
}

.settings-menu h3 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
}

.settings-row {
  display: grid;
  gap: 2px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.settings-row strong {
  font-size: 0.94rem;
}

.settings-row span,
.muted {
  color: var(--muted);
  font-size: 0.84rem;
}

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

  .sidebar {
    display: none;
  }

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

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

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

  .settings-menu {
    right: 18px;
    top: 82px;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 18px;
  }

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

  .topbar-actions,
  .tabs {
    width: 100%;
  }

  .primary-button {
    justify-content: center;
    flex: 1;
  }

  .summary-grid,
  .filters,
  .details-list {
    grid-template-columns: 1fr;
  }

  .data-panel > header,
  .entity-row {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    overflow-x: auto;
  }

  .tabs button {
    flex: 1 0 auto;
  }
}
