:root {
  color-scheme: light;
  --bg: #f1ece2;
  --surface: #fbfaf6;
  --surface-2: #edf4ef;
  --ink: #16221e;
  --muted: #52635b;
  --line: #c9d2cc;
  --green: #0e4f3d;
  --green-dark: #0a1f19;
  --coral: #bf3826;
  --amber: #9a5700;
  --violet: #246b8e;
  --shadow: 0 18px 40px rgba(31, 41, 36, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-oracta-sans), Manrope, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

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

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  border-radius: var(--radius);
  margin-bottom: 18px;
}

.brand-mark-logo {
  padding: 0;
  overflow: hidden;
  background: transparent;
}

.brand-mark-logo img {
  display: block;
  width: 100%;
  height: 100%;
}

.login-panel h1,
.page-title h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.02;
  letter-spacing: 0;
}

.login-panel h1 {
  font-family: var(--font-oracta-display), Fraunces, Georgia, serif;
  font-weight: 600;
}

.login-panel p,
.page-title p,
.muted {
  color: var(--muted);
}

.login-form,
.stack {
  display: grid;
  gap: 14px;
}

.stack.tight {
  gap: 5px;
}

.compact-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.split-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.phone-pin {
  align-content: start;
  margin-bottom: 10px;
}

.pin-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 42px;
  gap: 8px;
  align-items: center;
}

.pin-form select {
  min-width: 0;
  width: 100%;
  min-height: 42px;
}

.field {
  display: grid;
  gap: 7px;
}

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

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

textarea {
  min-height: 112px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(33, 124, 91, 0.14);
}

.dashboard {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: #fcfaf5;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.brand-row .brand-mark {
  width: 38px;
  height: 38px;
  margin-bottom: 0;
}

.brand-row strong {
  display: block;
  font-family: var(--font-oracta-display), Fraunces, Georgia, serif;
  font-size: 20px;
  font-weight: 600;
}

.brand-row small {
  color: var(--muted);
}

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

.nav button,
.icon-button,
.primary,
.secondary,
.danger,
.ghost {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: var(--radius);
  transition: transform 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.nav button {
  justify-content: flex-start;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.nav button:hover,
.nav button.active {
  background: #ebf3ef;
  color: var(--green-dark);
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: white;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--amber);
}

.status-dot.live {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(33, 124, 91, 0.12);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary {
  padding: 10px 15px;
  background: var(--green);
  color: white;
  font-weight: 800;
}

.primary:hover,
.secondary:hover,
.danger:hover,
.ghost:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.secondary {
  padding: 10px 14px;
  background: #e9eee9;
  color: var(--ink);
  font-weight: 800;
}

.danger {
  padding: 10px 14px;
  background: var(--coral);
  color: white;
  font-weight: 800;
}

.ghost {
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.icon-button {
  width: 42px;
  background: white;
  border: 1px solid var(--line);
  color: var(--ink);
}

.grid {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.grid > * {
  min-width: 0;
}

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

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

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

.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(31, 41, 36, 0.06);
  min-width: 0;
}

.panel {
  padding: 18px;
}

.card {
  padding: 16px;
}

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

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

.metric strong {
  font-size: 31px;
  line-height: 1;
  overflow-wrap: anywhere;
}

.call-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.call-mini-stat {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfffd;
}

.call-mini-stat span,
.call-mini-stat small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.call-mini-stat strong {
  font-size: 20px;
  line-height: 1;
  overflow-wrap: anywhere;
}

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

.check-tile {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfffd;
  font-weight: 800;
  color: var(--text);
}

.check-tile input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.profile-stat strong {
  font-size: 18px;
  line-height: 1.25;
}

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

.panel h2,
.card h3 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0;
}

.card h3 {
  font-size: 16px;
}

.provider-card.active,
.voice-card.active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(33, 124, 91, 0.12), 0 10px 24px rgba(31, 41, 36, 0.06);
}

.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.voice-card {
  min-height: 138px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  text-align: left;
  display: grid;
  gap: 7px;
  align-content: start;
}

.voice-card strong,
.voice-card span,
.voice-card p {
  overflow-wrap: anywhere;
}

.voice-card span {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.voice-card p {
  margin: 0;
  color: var(--muted);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.provider-ops-table td p,
.provider-deployments-table td p {
  margin: 6px 0 0;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.tag.warn {
  background: #fff2d7;
  color: #815b14;
}

.tag.coral {
  background: #ffe6df;
  color: #8f3e2e;
}

.tag.success {
  background: #e4f4ea;
  color: var(--green-dark);
}

.version-list {
  display: grid;
  gap: 10px;
}

.version-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.version-row.active {
  border-color: rgba(33, 124, 91, 0.35);
  background: #fbfffd;
}

.version-row > div {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.version-row .tag {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.version-row b,
.version-row time {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.version-tools .tag-row {
  display: grid;
  gap: 5px;
}

.version-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-action {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.call-stage {
  display: grid;
  grid-template-columns: minmax(290px, 410px) minmax(0, 1fr);
  gap: 18px;
}

.call-orb {
  aspect-ratio: 1;
  max-width: 270px;
  margin: 10px auto;
  border-radius: 999px;
  background:
    radial-gradient(circle at 44% 42%, #fff 0 11%, transparent 12%),
    conic-gradient(from 180deg, var(--green), #79b66f, var(--amber), var(--coral), var(--violet), var(--green));
  display: grid;
  place-items: center;
  color: white;
  box-shadow: 0 22px 55px rgba(33, 124, 91, 0.18);
}

.call-orb.live {
  animation: pulse 1.4s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { transform: scale(0.98); filter: saturate(0.92); }
  to { transform: scale(1.02); filter: saturate(1.15); }
}

.transcript {
  height: min(58vh, 560px);
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 4px;
}

.bubble {
  max-width: 84%;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #eef3ef;
  color: var(--ink);
}

.bubble.assistant {
  justify-self: start;
  border-left: 4px solid var(--green);
}

.bubble.user {
  justify-self: end;
  background: #fff0e8;
  border-right: 4px solid var(--coral);
}

.bubble small {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 4px;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 18px;
}

.customer-list {
  display: grid;
  gap: 9px;
}

.customer-button {
  width: 100%;
  text-align: left;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--ink);
}

.customer-button.active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(33, 124, 91, 0.12);
}

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

.empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
  padding: 22px;
}

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

.notice {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fff;
}

.notice.warn {
  border-color: #edc66f;
  background: #fff8e8;
  color: #69470d;
}

.gate-block {
  margin: 0 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(380px, calc(100vw - 36px));
  background: var(--ink);
  color: white;
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

.access-workspace {
  align-content: start;
}

.access-toolbar,
.access-filters {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.segmented button {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segmented button.active {
  color: var(--green-dark);
  background: var(--surface-2);
}

.access-split {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.access-user-list {
  display: grid;
  gap: 6px;
  max-height: 620px;
  overflow: auto;
  padding-right: 3px;
}

.access-user-row {
  width: 100%;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.access-user-row.active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(33, 124, 91, 0.12);
}

.access-user-row span:first-child,
.check-row span,
.permission-override-row span:first-child,
.permission-catalogue-row span:first-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.access-user-row small,
.check-row small,
.permission-override-row small,
.permission-catalogue-row small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.role-picker,
.permission-matrix fieldset {
  margin: 0;
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.role-picker legend,
.permission-matrix legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.check-row {
  min-height: 44px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.permission-override-grid,
.permission-matrix,
.permission-catalogue {
  display: grid;
  gap: 10px;
}

.permission-override-row,
.permission-matrix-row,
.permission-catalogue-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(120px, 160px) minmax(100px, 140px);
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.permission-matrix-row {
  grid-template-columns: minmax(220px, 1fr) minmax(110px, 150px);
}

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

.permission-catalogue section {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.permission-catalogue-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.permission-override-row:last-child,
.permission-matrix-row:last-child,
.permission-catalogue-row:last-child {
  border-bottom: 0;
}

.table-wrap {
  max-width: 100%;
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table-wrap .table {
  margin: 0;
}

.danger.ghost,
.ghost.danger {
  color: var(--coral);
  background: transparent;
}

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

  .sidebar {
    position: sticky;
    z-index: 20;
    height: auto;
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .nav {
    grid-column: 1 / -1;
    display: flex;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .nav button {
    justify-content: center;
    flex: 0 0 auto;
    min-height: 38px;
    padding: 8px 10px;
  }

  .sidebar-foot {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: end;
  }

  .sidebar-foot .status-pill {
    display: none;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .call-stat-grid,
  .checkbox-grid,
  .call-stage,
  .profile-layout,
  .split,
  .inline-form,
  .access-split,
  .permission-catalogue {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 18px;
  }

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

  .nav button span {
    display: inline;
  }

  .brand-row small {
    display: none;
  }

  .access-toolbar,
  .access-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .access-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .access-tabs button {
    flex: 0 0 auto;
  }

  .permission-override-row,
  .permission-matrix-row,
  .permission-catalogue-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .table {
    display: block;
    overflow-x: auto;
    white-space: normal;
  }

  .provider-ops-table,
  .provider-setup-table,
  .twilio-number-table,
  .platform-tenants-table,
  .provider-deployments-table,
  .customer-data-table,
  .readiness-table,
  .provider-ops-table tbody,
  .provider-setup-table tbody,
  .twilio-number-table tbody,
  .platform-tenants-table tbody,
  .provider-deployments-table tbody,
  .customer-data-table tbody,
  .readiness-table tbody,
  .provider-ops-table tr,
  .provider-setup-table tr,
  .twilio-number-table tr,
  .platform-tenants-table tr,
  .provider-deployments-table tr,
  .customer-data-table tr,
  .readiness-table tr,
  .provider-ops-table td,
  .provider-setup-table td,
  .twilio-number-table td,
  .platform-tenants-table td,
  .customer-data-table td,
  .readiness-table td {
    display: block;
    width: 100%;
  }

  .provider-deployments-table td,
  .provider-setup-table td,
  .twilio-number-table td,
  .platform-tenants-table td,
  .customer-data-table td,
  .readiness-table td {
    display: block;
    width: 100%;
  }

  .provider-ops-table thead,
  .provider-setup-table thead,
  .twilio-number-table thead,
  .platform-tenants-table thead,
  .provider-deployments-table thead,
  .customer-data-table thead,
  .readiness-table thead {
    display: none;
  }

  .provider-ops-table tr,
  .provider-setup-table tr,
  .twilio-number-table tr,
  .platform-tenants-table tr,
  .provider-deployments-table tr,
  .customer-data-table tr,
  .readiness-table tr {
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
  }

  .provider-ops-table td,
  .provider-setup-table td,
  .twilio-number-table td,
  .platform-tenants-table td,
  .provider-deployments-table td,
  .customer-data-table td,
  .readiness-table td {
    border-bottom: 0;
    display: grid;
    grid-template-columns: minmax(92px, 32%) minmax(0, 1fr);
    gap: 10px;
    padding: 8px 0;
  }

  .provider-ops-table td::before,
  .provider-setup-table td::before,
  .twilio-number-table td::before,
  .platform-tenants-table td::before,
  .provider-deployments-table td::before,
  .customer-data-table td::before,
  .readiness-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .panel {
    overflow-x: auto;
  }

  .version-row {
    grid-template-columns: 1fr;
  }
}
