:root {
  color-scheme: dark;
  --bg: #071018;
  --panel: #101b27;
  --panel-2: #0d1722;
  --line: rgba(150, 190, 210, 0.18);
  --line-strong: rgba(79, 216, 239, 0.34);
  --text: #f4fbfd;
  --muted: #9fb2c2;
  --cyan: #22c7d8;
  --cyan-2: #5de4f2;
  --pink: #ef3d9a;
  --green: #40d46f;
  --amber: #f4bd50;
  --danger: #ff6480;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at 76% 10%, rgba(239, 61, 154, 0.14), transparent 28rem),
    radial-gradient(circle at 18% 0%, rgba(34, 199, 216, 0.17), transparent 24rem),
    var(--bg);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  min-height: 100vh;
  padding: 1.4rem 1rem;
  border-right: 1px solid var(--line);
  background: rgba(4, 10, 17, 0.84);
}

.brand {
  display: block;
  padding: 0.2rem 0.7rem 1rem;
}

.brand img {
  width: 12.2rem;
  max-width: 100%;
}

.nav {
  display: grid;
  gap: 0.35rem;
}

.nav-item {
  min-height: 2.85rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d7e4eb;
  text-align: left;
  padding: 0.72rem 0.9rem;
  font-size: 0.94rem;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(79, 216, 239, 0.18);
  background: linear-gradient(90deg, rgba(34, 199, 216, 0.22), rgba(255, 255, 255, 0.04));
  color: #fff;
}

.support-box,
.plan-box {
  margin-top: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
}

.plan-box {
  margin-top: 0;
}

.support-box span,
.plan-box span,
.metric-card span,
.settings-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.support-box p,
.plan-box p {
  margin: 0.45rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.support-box a,
.primary-button,
.ghost-button,
.danger-button,
.link-button,
.inline-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.55rem;
  border: 1px solid rgba(79, 216, 239, 0.4);
  border-radius: 8px;
  background: rgba(79, 216, 239, 0.08);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
}

.support-box a {
  width: 100%;
}

.main {
  min-width: 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(16rem, 24rem) minmax(18rem, 1fr) auto;
  align-items: center;
  gap: 1rem;
  min-height: 5.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 13, 21, 0.72);
  backdrop-filter: blur(18px);
}

.account-picker span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid rgba(150, 190, 210, 0.22);
  border-radius: 8px;
  background: #0d1722;
  color: var(--text);
  padding: 0.78rem 0.85rem;
  outline: none;
}

textarea {
  resize: vertical;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 199, 216, 0.14);
}

.top-status {
  display: flex;
  justify-content: center;
  gap: 1rem;
  min-width: 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #dfeaf0;
  font-size: 0.86rem;
  font-weight: 700;
}

.dot {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(64, 212, 111, 0.12);
}

.dot.cyan {
  background: var(--cyan);
  box-shadow: 0 0 0 5px rgba(34, 199, 216, 0.12);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.avatar {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #dcefff, #93aec1);
  color: #102033;
  font-weight: 900;
}

.user-menu strong,
.user-menu span {
  display: block;
  white-space: nowrap;
}

.user-menu span {
  color: var(--muted);
  font-size: 0.82rem;
}

.view {
  display: none;
  padding: 1.4rem 1.5rem 2rem;
}

.active-view {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.9rem;
}

.compact-metrics {
  margin-bottom: 0.9rem;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 10.5rem;
  padding: 1rem;
}

.metric-card strong {
  display: block;
  margin-top: 1.1rem;
  font-size: clamp(2rem, 4vw, 2.65rem);
  line-height: 1;
}

.gateway-card strong {
  color: var(--green);
  font-size: 2rem;
}

.metric-card p {
  margin: 0.7rem 0 0;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.panel {
  min-width: 0;
  padding: 1rem;
}

.panel-header,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.8rem;
}

h2 {
  font-size: 1rem;
}

.section-title {
  margin-bottom: 1rem;
}

.section-title p {
  margin-top: 0.35rem;
  color: var(--muted);
}

.volume-panel,
.messages-panel {
  grid-column: 1;
}

.api-panel,
.did-panel {
  grid-column: 2;
}

.volume-chart {
  display: grid;
  grid-template-columns: repeat(14, minmax(1.4rem, 1fr));
  align-items: end;
  gap: 0.55rem;
  min-height: 14rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.bar-group {
  display: grid;
  align-items: end;
  grid-template-columns: 1fr 1fr;
  gap: 0.16rem;
  height: 11rem;
}

.bar {
  min-height: 0.35rem;
  border-radius: 999px 999px 0 0;
  background: var(--cyan);
}

.bar.outbound {
  background: var(--pink);
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

.message-filter-toolbar {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.message-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.65rem;
  align-items: end;
}

.message-filter-grid .field {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.message-filter-actions {
  display: flex;
  gap: 0.55rem;
  align-items: end;
}

.message-result-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.message-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.message-pager {
  display: flex;
  gap: 0.55rem;
}

.message-pager button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.message-number-link {
  border: 0;
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--cyan-2);
  text-decoration: underline;
  text-underline-offset: 0.18rem;
}

.message-number-link:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 4px;
}

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

th,
td {
  padding: 0.8rem 0.6rem;
  border-bottom: 1px solid rgba(150, 190, 210, 0.11);
  text-align: left;
  font-size: 0.88rem;
  vertical-align: top;
}

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

.status {
  color: var(--green);
  font-weight: 800;
}

.direction-inbound {
  color: var(--cyan-2);
}

.direction-outbound {
  color: var(--pink);
}

.did-list,
.api-list,
.alert-list {
  display: grid;
  gap: 0.8rem;
  margin-top: 0.9rem;
}

.did-item,
.api-item,
.alert-item {
  padding: 0.8rem;
  border: 1px solid rgba(150, 190, 210, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.did-item strong,
.api-item strong,
.alert-item strong {
  display: block;
}

.did-item span,
.api-item span,
.alert-item span,
.alert-item small {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.alert-item.warning {
  border-color: rgba(244, 189, 80, 0.45);
}

.alert-item.critical {
  border-color: rgba(255, 100, 128, 0.52);
}

.primary-button {
  border: 0;
  padding: 0.8rem 1.1rem;
  background: linear-gradient(135deg, var(--cyan), var(--pink));
}

.ghost-button,
.danger-button,
.link-button {
  padding: 0.55rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
}

.danger-button {
  border-color: rgba(255, 100, 128, 0.45);
  color: #ffd7df;
  background: rgba(255, 100, 128, 0.08);
}

.link-button {
  border: 0;
  color: var(--cyan-2);
  background: transparent;
}

.inline-form,
.send-grid,
.settings-grid {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.inline-form {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.inline-form .form-result {
  grid-column: 1 / -1;
}

.send-grid {
  width: min(46rem, 100%);
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.send-grid label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.settings-form {
  display: grid;
  gap: 0.8rem;
}

.routing-form {
  display: grid;
  grid-template-columns: minmax(9rem, 1.1fr) minmax(9rem, 1fr) minmax(11rem, 1.2fr) auto;
  align-items: center;
  gap: 0.5rem;
  min-width: 38rem;
}

.settings-form label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.toggle-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.toggle-row input {
  width: auto;
}

.compact-toggle {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.routing-result {
  min-height: 1rem;
  color: var(--cyan-2);
  font-size: 0.78rem;
  font-weight: 800;
}

.customer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  min-width: 13rem;
}

.customer-row-result {
  color: var(--cyan-2);
  font-size: 0.78rem;
  font-weight: 800;
}

.message-field {
  grid-column: 1 / -1;
}

.form-result,
.secret-box {
  color: var(--cyan-2);
  font-weight: 800;
}

.secret-box {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid rgba(34, 199, 216, 0.35);
  border-radius: 8px;
  background: rgba(34, 199, 216, 0.08);
  overflow-wrap: anywhere;
}

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

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

.carrier-security-panel {
  margin-top: 1rem;
}

.settings-grid div {
  padding: 1rem;
  border: 1px solid rgba(150, 190, 210, 0.14);
  border-radius: 8px;
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    position: static;
    min-height: auto;
  }

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

  .topbar,
  .metric-grid,
  .dashboard-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .volume-panel,
  .messages-panel,
  .api-panel,
  .did-panel {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .topbar,
  .view {
    padding-inline: 1rem;
  }

  .nav,
  .metric-grid,
  .inline-form,
  .routing-form {
    grid-template-columns: 1fr;
  }

  .top-status,
  .user-menu,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .message-filter-actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  .message-filter-actions button {
    flex: 1 1 8.5rem;
  }

  .message-filter-grid .field {
    min-width: 0;
  }
}
