:root {
  --brand: #47dbff;
  --brand-strong: #0088a8;
  --ink: #1f2929;
  --muted: #647070;
  --line: #dbe8e8;
  --surface: #ffffff;
  --canvas: #f5fafb;
  --success: #0f8f5f;
  --warning: #c89400;
  --danger: #d64224;
  --info: #246b7a;
  --shadow: 0 14px 28px rgba(31, 41, 41, 0.09);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-family: Arial, sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: linear-gradient(180deg, #f9fdfe 0%, var(--canvas) 100%);
  color: var(--ink);
  line-height: 1.45;
}

body.sidebar-open {
  overflow: hidden;
}

body.sidebar-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgba(12, 27, 27, 0.34);
}

.hidden {
  display: none !important;
}

body.logged-out .app-shell {
  grid-template-columns: 1fr;
}

body.logged-out .sidebar {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  overflow-x: clip;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 280px;
  max-width: 100%;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 18px 32px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand-lockup {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.brand-lockup strong,
.brand-lockup small {
  display: block;
}

.brand-lockup small {
  margin-top: 3px;
  color: var(--muted);
}

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

.nav-link,
.ghost-button,
.primary-button,
.menu-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
}

.nav-link {
  width: 100%;
  padding: 0 14px;
  text-align: left;
  background: transparent;
  color: var(--muted);
}

.nav-link:hover,
.nav-link.active {
  color: var(--ink);
  background: #e9fbff;
  border-color: #b9f3ff;
}

.proposal-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fcfd;
}

.proposal-note h2,
.panel h2 {
  margin: 0;
  font-size: 1.1rem;
}

.proposal-note p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.workspace {
  min-width: 0;
  padding: clamp(14px, 2vw, 24px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 10px 0;
  background: rgba(245, 250, 251, 0.92);
  backdrop-filter: blur(10px);
}

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

.topbar-title h1 {
  margin: 4px 0 0;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  line-height: 1.15;
  word-break: break-word;
}

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

.menu-button {
  display: none;
  padding: 0 14px;
  background: var(--surface);
  border-color: var(--line);
}

.logout-button {
  min-width: 96px;
}

.eyebrow {
  margin: 0;
  color: var(--brand-strong);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-pill,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-live {
  color: var(--danger);
  background: #fff4f1;
  border-color: #ffd7cf;
}

.status-live.is-connected {
  color: var(--success);
  background: #f0fff8;
  border-color: #bdebd5;
}

.context-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 8px 0 22px;
}

.context-strip article {
  min-height: 92px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.context-strip strong,
.context-strip span {
  display: block;
}

.context-strip strong {
  font-size: 1.1rem;
}

.context-strip span {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.view-root {
  display: grid;
  gap: 20px;
}

.auth-shell {
  min-height: calc(100vh - 180px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  align-items: start;
}

.auth-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h2,
.auth-card p {
  margin-top: 0;
}

.auth-card p {
  color: var(--muted);
  line-height: 1.5;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.stat-card,
.panel,
.claim-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card {
  min-height: 142px;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 8px;
  border-top: 4px solid var(--brand);
}

.stat-card span {
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  font-size: 1.75rem;
  line-height: 1.1;
}

.stat-card small {
  color: var(--muted);
  line-height: 1.45;
}

.tone-success {
  border-top-color: var(--success);
}

.tone-cyan {
  border-top-color: var(--brand);
}

.tone-warning {
  border-top-color: var(--warning);
}

.tone-danger {
  border-top-color: var(--danger);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  align-items: start;
  gap: 20px;
}

.panel {
  padding: 20px;
}

.panel-heading {
  min-height: 42px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading strong {
  font-size: 1.25rem;
}

.ghost-button,
.primary-button {
  padding: 0 14px;
}

.ghost-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.ghost-button:hover {
  border-color: var(--brand-strong);
  color: var(--brand-strong);
}

.primary-button {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.primary-button:hover {
  background: #324040;
}

.bar-chart {
  min-height: 280px;
  display: grid;
  grid-template-columns: repeat(6, minmax(58px, 1fr));
  align-items: end;
  gap: 12px;
}

.bar-item {
  min-width: 0;
  display: grid;
  gap: 8px;
  text-align: center;
}

.bar-track {
  height: 190px;
  display: flex;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef7f8;
  overflow: hidden;
}

.bar-track span {
  display: block;
  width: 100%;
  min-height: 10px;
  background: var(--brand);
}

.bar-item small {
  min-height: 34px;
  color: var(--muted);
  font-size: 0.72rem;
}

.queue-list,
.template-list,
.integration-list {
  display: grid;
  gap: 10px;
}

.queue-row,
.priority-item,
.template-item,
.integration-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefe;
}

.queue-row {
  min-height: 68px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.queue-row strong,
.queue-row small {
  display: block;
}

.queue-row small {
  margin-top: 4px;
  color: var(--muted);
}

.priority-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.priority-item {
  min-height: 124px;
  padding: 16px;
}

.priority-item strong,
.priority-item span {
  display: block;
}

.priority-item span {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

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

.detail-grid article {
  min-height: 110px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefe;
}

.detail-grid strong,
.detail-grid span {
  display: block;
}

.detail-grid strong {
  font-size: 1.5rem;
}

.detail-grid span {
  margin-top: 8px;
  color: var(--muted);
}

.controls-heading {
  align-items: center;
}

.table-tools,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

.table-tools input {
  width: 260px;
}

.table-tools select {
  width: 170px;
}

.directory-filter-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 10px;
}

.directory-filter-tools input {
  grid-column: 1 / -1;
  width: 100%;
}

.directory-filter-tools select {
  width: 100%;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

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

.data-table th {
  color: var(--muted);
  font-size: 0.82rem;
}

.data-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.pill-success {
  color: var(--success);
  background: #edfff6;
  border-color: #bfe9d5;
}

.pill-warning {
  color: #755200;
  background: #fff8d9;
  border-color: #f6df7e;
}

.pill-danger {
  color: var(--danger);
  background: #fff2ee;
  border-color: #ffcabc;
}

.pill-info {
  color: var(--info);
  background: #eefcff;
  border-color: #bdeff7;
}

.claim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.claim-card {
  min-height: 286px;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.claim-card h3,
.claim-card p {
  margin: 0;
}

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

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.claim-topline,
.claim-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.claim-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.claim-meta span {
  min-width: 0;
}

.claim-meta strong,
.claim-meta small {
  display: block;
}

.claim-meta small {
  margin-top: 4px;
  color: var(--muted);
}

.sla-track {
  height: 10px;
  border-radius: 999px;
  background: #edf4f4;
  overflow: hidden;
}

.sla-track span {
  display: block;
  height: 100%;
  background: var(--danger);
}

.message-form {
  display: grid;
  gap: 14px;
}

.message-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.template-item {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.stacked-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-summary {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.user-type {
  text-transform: capitalize;
  color: var(--muted);
  font-weight: 700;
}

.template-item strong {
  font-size: 1rem;
}

.template-item small,
.template-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.integration-item {
  min-height: 78px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
}

.integration-item strong,
.integration-item small {
  display: block;
}

.integration-item small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.integration-item em {
  color: var(--muted);
  font-style: normal;
  font-weight: 700;
}

.helper-text {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 41, 41, 0.46);
}

.modal-card {
  width: min(960px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(31, 41, 41, 0.24);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-header h2 {
  margin: 4px 0 0;
}

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

.field-span-2 {
  grid-column: 1 / -1;
}

.modal-section {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.company-summary-grid {
  margin-bottom: 18px;
}

.coordinate-grid {
  margin-top: 8px;
}

.coordinate-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  color: var(--muted);
}

.loader {
  width: 34px;
  height: 34px;
  border: 3px solid #dbe8e8;
  border-top-color: var(--brand-strong);
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  border: 1px solid #bfe9d5;
  border-radius: 8px;
  background: #f0fff8;
  color: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1160px) {
  .two-column {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(320px, 88vw);
    transform: translateX(-104%);
    transition: transform 180ms ease;
    box-shadow: 0 20px 44px rgba(31, 41, 41, 0.2);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .workspace {
    padding: 14px;
  }

  .menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .status-pill {
    white-space: normal;
    text-align: center;
  }

  .context-strip,
  .claim-grid,
  .auth-shell,
  .modal-grid {
    grid-template-columns: 1fr;
  }

  .table-tools,
  .form-actions {
    width: 100%;
    justify-content: stretch;
  }

  .table-tools input,
  .table-tools select,
  .table-tools button,
  .form-actions button,
  .logout-button {
    width: 100%;
  }

  .modal-backdrop {
    padding: 12px;
  }
}

@media (max-width: 620px) {
  .topbar-title h1 {
    font-size: 1.45rem;
  }

  .directory-filter-tools {
    grid-template-columns: 1fr;
  }

  .directory-filter-tools input {
    grid-column: auto;
  }

  .panel,
  .auth-card,
  .modal-card,
  .claim-card {
    padding: 16px;
  }

  .queue-row,
  .claim-topline {
    flex-direction: column;
    align-items: flex-start;
  }

  .bar-chart {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .claim-meta,
  .integration-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .brand-lockup {
    gap: 10px;
  }

  .brand-lockup small {
    font-size: 0.78rem;
  }

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

  .toast {
    right: 12px;
    left: 12px;
    bottom: 12px;
    max-width: none;
  }
}
