:root {
  --bg-1: #0b0f14;
  --bg-2: #0f1520;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --text: #e6edf3;
  --text-secondary: rgba(230, 237, 243, 0.7);
  --accent: #4facfe;
  --accent-2: #00f2fe;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 20% 10%, #1a2433 0%, transparent 60%),
              radial-gradient(900px 500px at 80% 20%, #111b27 0%, transparent 65%),
              linear-gradient(180deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  width: 100%;
  max-width: 980px;
  padding: 32px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
  gap: 32px;
  align-items: center;
}

.hero-media {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  padding: 0;
}

.hero-image {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.home-brand {
  margin-bottom: 10px;
}

.home-brand-logo {
  width: min(320px, 88%);
  height: auto;
  display: block;
}

.home-stats {
  margin-top: 16px;
}

.home-section {
  margin-top: 16px;
}

.home-section-title {
  margin: 0 0 12px 0;
  font-size: 24px;
}

.home-sub-title {
  margin: 16px 0 10px 0;
  font-size: 20px;
}

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

.home-feature-card {
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  padding: 14px;
  background: rgba(12, 19, 29, 0.4);
}

.home-feature-card h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
}

.home-feature-card p {
  margin: 0;
  color: rgba(230, 237, 243, 0.8);
  line-height: 1.5;
  font-size: 14px;
}

.home-steps {
  margin: 0;
  padding-left: 20px;
  color: rgba(230, 237, 243, 0.9);
}

.home-steps li {
  margin: 0 0 8px 0;
  line-height: 1.5;
}

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

.home-stat-item {
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  padding: 14px 12px;
  background: rgba(12, 19, 29, 0.45);
}

.home-stat-value {
  font-size: 34px;
  line-height: 1.1;
  font-weight: 800;
  color: #eaf4ff;
  letter-spacing: 0.3px;
}

.home-stat-label {
  margin-top: 8px;
  color: rgba(230, 237, 243, 0.78);
  font-size: 14px;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
}

.title {
  font-size: 40px;
  margin: 0 0 12px 0;
  letter-spacing: 0.2px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.6;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(79, 172, 254, 0.15);
  color: #bfe3ff;
  border: 1px solid rgba(79, 172, 254, 0.3);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  margin-bottom: 16px;
}

.cta {
  margin-top: 22px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  text-decoration: none;
  color: #0b0f14;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 600;
}

.btn.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--glass-border);
}

.btn.outline {
  background: rgba(79, 172, 254, 0.12);
  color: #bfe3ff;
  border-color: rgba(79, 172, 254, 0.35);
}

.btn.outline:hover {
  background: rgba(79, 172, 254, 0.18);
  border-color: rgba(79, 172, 254, 0.55);
}

.home-download-btn {
  background: linear-gradient(135deg, #5ad6ff, #2e9bff 55%, #7cf2ff);
  color: #04111f;
  border-color: rgba(140, 235, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(180, 245, 255, 0.45), 0 10px 24px rgba(46, 155, 255, 0.35);
}

.home-download-btn:hover {
  background: linear-gradient(135deg, #7ce1ff, #42acff 55%, #98f6ff);
  box-shadow: 0 0 0 1px rgba(200, 250, 255, 0.7), 0 14px 30px rgba(66, 172, 255, 0.45);
}

.btn.danger {
  background: rgba(189, 54, 54, 0.22);
  color: #ffd2d2;
  border-color: rgba(255, 124, 124, 0.45);
}

.mini-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.card {
  background: rgba(10, 16, 24, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 22px;
}

.card h3 {
  margin: 0 0 10px 0;
  font-size: 18px;
}

.code {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  color: #9bd2ff;
}

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .title { font-size: 32px; }
  .home-stats-grid { grid-template-columns: 1fr 1fr; }
  .home-feature-grid { grid-template-columns: 1fr; }
}

.app-body {
  display: block;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  width: 100%;
  max-width: 1200px;
  padding: 28px;
  margin: 0 auto;
}

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: calc(100vh - 56px);
}

.side-user {
  font-size: 20px;
  font-weight: 700;
  margin-top: 4px;
}

.side-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gear-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  text-decoration: none;
  color: var(--text);
  background: rgba(12, 19, 29, 0.5);
  font-size: 18px;
}

.gear-link.active,
.gear-link:hover {
  border-color: rgba(79, 172, 254, 0.55);
  background: rgba(79, 172, 254, 0.18);
}

.side-email {
  font-size: 13px;
  color: var(--text-secondary);
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.side-footer {
  margin-top: 18px;
}

.nav-link {
  display: block;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 12px;
  background: rgba(12, 19, 29, 0.5);
}

.nav-link.active {
  border-color: rgba(79, 172, 254, 0.55);
  background: rgba(79, 172, 254, 0.18);
}

.nav-section-title {
  margin-top: 10px;
  padding: 2px 2px;
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(230, 237, 243, 0.55);
}

.main-panel {
  min-height: calc(100vh - 56px);
}

.panel-head {
  margin-bottom: 14px;
}

.panel-title {
  margin: 0 0 8px 0;
  font-size: 34px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card {
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 14px;
  background: rgba(10, 16, 24, 0.6);
}

.metric-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.metric-value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 700;
}

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

.events-filter {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.events-filter label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.events-filter select {
  min-width: 110px;
}

.events-meta {
  margin-top: 6px;
}

.events-meta summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
}

.events-meta pre {
  margin: 6px 0 0;
  padding: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
}

.events-table {
  table-layout: auto;
}

.events-col-time {
  width: 96px;
}

.events-col-type {
  width: 90px;
}

.events-col-action {
  width: 130px;
}

.events-col-target {
  width: 160px;
}

.events-col-result {
  width: 80px;
}

.events-col-source {
  width: 110px;
}

.events-message-cell {
  white-space: normal;
  word-break: break-word;
  min-width: 180px;
}

.events-table th:nth-child(7),
.events-table td:nth-child(7) {
  white-space: nowrap;
}

.events-table th:nth-child(6),
.events-table td:nth-child(6) {
  min-width: 180px;
}

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

/* Keep My Devices table width stable so long message payloads don't stretch columns. */
.devices-table {
  table-layout: fixed;
}

.hidden {
  display: none !important;
}

/* Firmware upload progress (OTA library) */
.upload-progress {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.10);
  overflow: hidden;
  margin-top: 12px;
}
.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(70, 200, 255, 0.80), rgba(80, 140, 255, 0.80));
  box-shadow: 0 0 18px rgba(70, 200, 255, 0.25);
  transition: width 120ms linear;
}
.upload-progress-text {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: rgba(235, 245, 255, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 8px;
  text-align: left;
  font-size: 14px;
}

.th-sort {
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sort-arrow {
  opacity: 0.45;
  font-size: 11px;
}

.sort-arrow.active {
  opacity: 1;
}

.col-expand {
  width: 30px;
}

.expand-btn {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--glass-border);
  background: rgba(12, 19, 29, 0.5);
  color: var(--text);
  cursor: pointer;
  padding: 0;
  line-height: 18px;
}

.col-name {
  width: 130px;
}

.col-uid {
  width: 140px;
}

.col-last-seen {
  width: 96px;
}

.col-status {
  width: 85px;
}

.col-action {
  width: 65px;
}

.col-remark {
  width: 100%;
}

.cell-scroll {
  display: block;
  max-width: 170px;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.cell-scroll code {
  white-space: nowrap;
}

.col-name .cell-scroll {
  max-width: 120px;
}

.col-name .inline-input {
  max-width: 120px;
}

.col-uid .cell-scroll {
  max-width: 130px;
}

.js-remark-input {
  max-width: 260px;
}

.col-remark .cell-scroll {
  width: 100%;
  max-width: none;
}

.note-cell {
  display: block;
  width: 100%;
  white-space: pre-wrap; /* preserve user-entered newlines */
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 4.2em; /* ~3 lines; keeps table compact */
  scrollbar-width: thin;
  color: rgba(230, 237, 243, 0.92);
}

.col-remark .inline-input {
  width: 100%;
  max-width: none;
}

.inline-textarea {
  width: 100%;
  max-width: 170px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: rgba(9, 15, 23, 0.9);
  color: var(--text);
  font-family: inherit;
  line-height: 1.35;
  resize: vertical;
  min-height: 44px;
  max-height: 120px;
}

.col-remark .inline-textarea {
  width: 100%;
  max-width: none;
}

.col-last-seen .js-last-seen {
  display: block;
  white-space: normal;
  line-height: 1.25;
  overflow: hidden;
}

.inline-input {
  width: 100%;
  max-width: 170px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: rgba(9, 15, 23, 0.9);
  color: var(--text);
}

.action-row {
  display: inline-flex;
  gap: 8px;
}

.col-action .action-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.col-action .mini-btn {
  justify-content: center;
  padding: 4px 6px;
}

.msg-detail-row.hidden {
  display: none;
}

.msg-detail-row td {
  padding-top: 0;
}

.msg-detail-box {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(7, 12, 20, 0.55);
  max-width: 100%;
  overflow: hidden;
}

.msg-detail-title {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-secondary);
}

.latest-msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  min-width: 0;
}

.msg-head-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.latest-msg-payload-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  border: 1px solid;
  text-decoration: none;
}

.status-chip.online {
  color: #9cffc7;
  border-color: rgba(76, 230, 146, 0.45);
  background: rgba(47, 163, 106, 0.2);
}

.status-chip.offline {
  color: #ffb5b5;
  border-color: rgba(255, 122, 122, 0.45);
  background: rgba(173, 47, 47, 0.2);
}

.status-chip.pending {
  color: #ffe6a3;
  border-color: rgba(255, 210, 92, 0.45);
  background: rgba(176, 126, 30, 0.2);
}

.status-chip.expired {
  color: #d6d6d6;
  border-color: rgba(170, 170, 170, 0.45);
  background: rgba(88, 88, 88, 0.2);
}

.status-chip.revoke-pending {
  color: #ffd9a1;
  border-color: rgba(255, 173, 64, 0.5);
  background: rgba(176, 95, 20, 0.22);
}

.pending-detail {
  display: grid;
  gap: 6px;
}

.pending-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.pending-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 8px;
  align-items: center;
}

.pending-label {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.9;
}

.pending-value {
  min-width: 0;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.pending-value code {
  white-space: nowrap;
}

.pending-suffix {
  grid-column: 2;
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.8;
}

.status-chip.info {
  color: #bfe3ff;
  border-color: rgba(79, 172, 254, 0.45);
  background: rgba(79, 172, 254, 0.14);
}

.time-chip {
  color: rgba(230, 237, 243, 0.92);
}

.token-grid {
  display: grid;
  gap: 8px;
}

.token-row {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 8px;
  align-items: center;
}

.token-label {
  color: rgba(230, 237, 243, 0.72);
  font-size: 12px;
}

.token-value {
  min-width: 0;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.token-suffix {
  grid-column: 2;
  color: rgba(230, 237, 243, 0.6);
  font-size: 12px;
}

.token-result {
  margin-top: 12px;
}

.error-text {
  color: #ff8b8b;
}

.device-link {
  color: inherit;
  text-decoration: none;
}

.name-cell-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.device-gear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 7px;
  border: 1px solid var(--glass-border);
  background: rgba(12, 19, 29, 0.5);
  color: rgba(230, 237, 243, 0.92);
  text-decoration: none;
  font-size: 12px;
  line-height: 1;
  flex: 0 0 auto;
}

.device-gear-btn:hover {
  border-color: rgba(79, 172, 254, 0.55);
  background: rgba(79, 172, 254, 0.18);
}

.device-link:hover {
  text-decoration: underline;
  text-decoration-color: rgba(79, 172, 254, 0.55);
}

.device-head {
  display: block;
}

.device-head-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}

.back-link {
  display: inline-block;
  color: rgba(230, 237, 243, 0.8);
  text-decoration: none;
  margin-bottom: 0;
}

.back-link:hover {
  text-decoration: underline;
}

.device-title {
  margin: 0;
  /* Title always gets the full row so it won't be forced into a narrow column on mobile. */
  width: 100%;
  max-width: 100%;
}

.device-sub {
  color: var(--text-secondary);
  font-size: 13px;
}

.device-head-bottom {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.device-head-left {
  min-width: 0;
}

.device-head-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.device-status-pills {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}

.kv-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(230, 237, 243, 0.92);
  font-size: 12px;
  line-height: 1;
}

.kv-pill .k {
  color: rgba(230, 237, 243, 0.60);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-size: 10px;
  flex: 0 0 auto;
}

.kv-pill .v {
  display: inline-flex;
  align-items: center;
  color: #bfe6ff;
  border-radius: 999px;
  padding: 4px 10px;
  min-height: 22px;
  border: 1px solid rgba(79, 172, 254, 0.45);
  background: rgba(79, 172, 254, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  font-weight: 700;
  max-width: 300px;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.device-last-seen {
  font-size: 12px;
  color: var(--text-secondary);
}

.device-note-wrap {
  display: grid;
  gap: 6px;
  min-width: 260px;
  max-width: 520px;
}

.device-note-label {
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: rgba(230, 237, 243, 0.6);
}

.device-note-box {
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(7, 12, 20, 0.55);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.4;
  color: rgba(230, 237, 243, 0.92);
  text-align: left;
  white-space: pre-wrap;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

textarea.device-note-box {
  width: 100%;
  min-height: 62px;
  max-height: 160px;
  resize: vertical;
  font-family: inherit;
  outline: none;
}

.tabs {
  padding: 16px;
}

.tab-bar {
  display: flex;
  gap: 0;
  align-items: flex-end;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0;
  margin-bottom: 14px;
}

.tab-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  font-size: 13px;
  margin-bottom: -1px;
  font-weight: 600;
}

.tab-btn + .tab-btn {
  margin-left: 6px;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.tab-btn.active {
  border-color: rgba(79, 172, 254, 0.62);
  background: rgba(79, 172, 254, 0.24);
  color: #d9efff;
}

.section-title {
  margin-top: 10px;
  margin-bottom: 8px;
  font-size: 12px;
  color: rgba(230, 237, 243, 0.75);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

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

/* Conversation header: keep actions on the left to match the rest of the page. */
.section-title-row.left-actions {
  justify-content: flex-start;
}

.section-title-row .section-title {
  margin-bottom: 0;
}

.cmd-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.cmd-btn-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.cmd-input {
  flex: 1 1 360px;
  max-width: none;
}

.cmd-result {
  margin-top: 10px;
  white-space: pre;
  overflow-x: auto;
}

.chat-box {
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(7, 12, 20, 0.55);
  padding: 12px;
  max-height: 360px;
  overflow-y: auto;
}

.msg-detail-box .chat-box {
  margin-top: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.chat-empty {
  padding: 8px 4px;
}

.chat-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

.chat-row.left {
  align-items: flex-start;
}

.chat-row.right {
  align-items: flex-end;
}

.chat-meta {
  font-size: 11px;
  color: rgba(230, 237, 243, 0.62);
  white-space: nowrap;
}

.chat-row.left .chat-text,
.chat-row.left .chat-meta {
  text-align: left;
}

.chat-bubble {
  max-width: 100%;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.chat-bubble.left {
  background: transparent;
}

.chat-bubble.right {
  background: transparent;
}

.chat-text {
  font-size: 13px;
  /* Wrap long single-line payloads so the page doesn't overflow horizontally. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  scrollbar-width: thin;
}

.chat-row.right .chat-text,
.chat-row.right .chat-meta {
  text-align: right;
  padding-right: 5px;
}

/* Capsule-style action button */
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  min-width: 86px;
}

.pill-btn.primary {
  color: #0b0f14;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.pill-btn.primary:hover {
  filter: brightness(1.06);
}

.pill-btn.active {
  color: #d8efff;
  border-color: rgba(79, 172, 254, 0.65);
  background: rgba(79, 172, 254, 0.22);
}

.pill-btn.danger {
  color: #ffd2d2;
  background: rgba(173, 47, 47, 0.28);
  border-color: rgba(255, 122, 122, 0.45);
}

.pill-btn.danger:hover {
  background: rgba(173, 47, 47, 0.36);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar,
  .main-panel {
    min-height: auto;
  }
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
