:root {
  --bg: #f4f7fb;
  --menu: #162033;
  --menu-soft: #202c44;
  --sidebar-width: 232px;
  --surface: #ffffff;
  --surface-soft: #f8fafd;
  --line: #e1e7f0;
  --line-strong: #c4cfdd;
  --text: #172033;
  --muted: #6d7890;
  --blue: #2f6fed;
  --blue-soft: #eaf1ff;
  --cyan: #10a6a6;
  --green: #20a66a;
  --amber: #b36b00;
  --red: #c43d3d;
  --purple: #7956d8;
  --bubble-out: #dff3ff;
  --bubble-in: #ffffff;
  --shadow: 0 16px 40px rgba(31, 47, 75, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(47, 111, 237, 0.08), rgba(16, 166, 166, 0.08)),
    var(--bg);
}

.auth-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 22px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand strong,
.auth-brand span {
  display: block;
}

.auth-brand strong {
  font-size: 18px;
}

.auth-brand span {
  color: var(--muted);
  font-size: 12px;
}

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

.auth-form h1 {
  margin: 0;
  font-size: 22px;
}

.auth-form p {
  margin: -4px 0 4px;
  color: var(--muted);
  line-height: 1.5;
}

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

.auth-form input,
.auth-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
  font-weight: 700;
}

.auth-form textarea {
  resize: vertical;
  min-height: 86px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-all;
}

.totp-setup {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.auth-error {
  min-height: 18px;
  margin: -6px 0 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
}

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

.app-menu {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--menu);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.menu-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #4f8cff, #25c2a0);
  color: #fff;
  font-weight: 800;
}

.menu-brand strong,
.menu-brand span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-brand strong {
  font-size: 16px;
}

.menu-brand span,
.menu-footer {
  color: rgba(255, 255, 255, 0.64);
  font-size: 12px;
}

.menu-nav {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 8px 10px;
}

.menu-item {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  text-align: left;
  padding: 0 10px;
  font-weight: 700;
}

.menu-item:hover,
.menu-item.active {
  background: var(--menu-soft);
  color: #fff;
}

.menu-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  font-size: 15px;
}

.menu-footer {
  padding: 14px 16px 18px;
}

.main-shell {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr);
  background: var(--bg);
  container: workspace / inline-size;
}

.topbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.topbar > div:first-child {
  min-width: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.select-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.select-label select {
  min-width: 142px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.view {
  display: none;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: auto;
}

.view.active {
  display: block;
}

.inbox-view.active {
  display: grid;
}

.page-scroll {
  padding: 18px 22px 28px;
}

.hero-strip {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 16px;
  margin-bottom: 16px;
}

.hero-panel,
.insight-panel,
.settings-panel,
.data-panel,
.metric-card,
.mini-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(31, 47, 75, 0.03);
}

.hero-panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.hero-panel h2,
.settings-panel h2,
.data-panel h2,
.mini-panel h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
}

.section-subtitle {
  margin-top: 18px !important;
}

.hero-panel p,
.settings-panel p,
.data-panel p,
.mini-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.metric-card {
  padding: 14px;
  min-height: 102px;
  display: grid;
  align-content: space-between;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
  font-weight: 850;
}

.metric-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.85fr);
  gap: 16px;
}

.data-panel,
.settings-panel,
.mini-panel {
  padding: 16px;
}

.panel-grid {
  display: grid;
  gap: 16px;
}

.chart-bars {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 10px;
}

.bar-label,
.bar-value {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.bar-fill {
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: var(--blue);
}

.trend-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(30px, 1fr));
  align-items: end;
  gap: 10px;
  height: 180px;
  margin-top: 16px;
  padding-top: 8px;
}

.trend-day {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 0;
}

.trend-stack {
  width: 100%;
  max-width: 34px;
  height: 128px;
  display: grid;
  align-items: end;
  border-radius: 8px;
  background: #edf1f7;
  overflow: hidden;
}

.trend-in,
.trend-out {
  width: 100%;
}

.trend-in {
  background: var(--blue);
}

.trend-out {
  background: var(--cyan);
}

.trend-label {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
}

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

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

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  text-transform: uppercase;
}

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

.queue-list,
.reminder-list,
.note-list,
.settings-list {
  display: grid;
  gap: 10px;
}

.queue-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.queue-filter {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
}

.queue-filter.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.queue-item,
.reminder-item,
.note-item,
.settings-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.queue-top,
.reminder-top,
.settings-top,
.profile-name,
.row-between {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.row-between.center {
  align-items: center;
}

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

.inline-options,
.button-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.muted {
  color: var(--muted);
}

.small-text {
  font-size: 12px;
}

.inbox-view {
  height: 100%;
  min-height: 0;
  grid-template-columns: clamp(260px, 25vw, 350px) minmax(0, 1fr) clamp(290px, 26vw, 380px);
  overflow: hidden;
}

.conversation-pane,
.profile-panel {
  min-width: 0;
  background: var(--surface);
}

.conversation-pane {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
}

.pane-toolbar {
  min-width: 0;
  padding: 14px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.search-input:focus,
select:focus,
textarea:focus,
input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.13);
  outline: none;
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-top: 12px;
}

.filter-button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

.filter-button.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}

.conversation-count {
  min-height: 36px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}

.conversation-list {
  min-height: 0;
  overflow: auto;
}

.conversation-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  text-align: left;
  border-left: 3px solid transparent;
}

.conversation-item:hover,
.conversation-item.active {
  background: #f0f5ff;
}

.conversation-item.active {
  border-left-color: var(--blue);
}

.conversation-main {
  min-width: 0;
}

.conversation-name-row,
.conversation-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.conversation-name,
.conversation-phone,
.conversation-last {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-name {
  font-weight: 800;
}

.conversation-phone,
.conversation-last {
  color: var(--muted);
  font-size: 12px;
}

.conversation-last {
  margin-top: 6px;
}

.conversation-side {
  display: grid;
  justify-items: end;
  gap: 8px;
  min-width: 70px;
}

.time-text {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.unread-badge {
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.status-badge,
.tag-pill,
.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-new {
  background: #edf1f7;
  color: #51607a;
}

.status-hot {
  background: #ffe8e8;
  color: #a42424;
}

.status-warm {
  background: #fff2d9;
  color: var(--amber);
}

.status-cold {
  background: #e9f0ff;
  color: #2e5ebd;
}

.status-closed {
  background: #e7f8ef;
  color: #167247;
}

.status-lost {
  background: #f1e8ec;
  color: #83424f;
}

.chat-panel {
  container: chat / inline-size;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #eef3f8;
}

.chat-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.chat-title {
  min-width: 0;
}

.chat-title h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.compact-select {
  max-width: 170px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 8px;
}

.message-list {
  min-height: 0;
  overflow: auto;
  padding: 20px;
  background:
    linear-gradient(rgba(238, 243, 248, 0.92), rgba(238, 243, 248, 0.92)),
    radial-gradient(circle at 18px 18px, rgba(47, 111, 237, 0.08) 2px, transparent 2px);
  background-size: auto, 36px 36px;
}

.message-row {
  display: flex;
  margin-bottom: 10px;
}

.message-row.outbound {
  justify-content: flex-end;
}

.message-bubble {
  width: fit-content;
  max-width: min(640px, 76%);
  padding: 10px 12px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bubble-in);
  box-shadow: 0 2px 8px rgba(20, 33, 31, 0.04);
}

.message-row.outbound .message-bubble {
  background: var(--bubble-out);
  border-color: #c4e6f8;
}

.message-row.recalled .message-bubble {
  background: #f8fafc;
  border-style: dashed;
}

.message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.message-media {
  display: grid;
  gap: 8px;
  min-width: min(320px, 64vw);
}

.message-media-title {
  font-weight: 800;
  font-size: 13px;
}

.message-audio-player {
  width: min(320px, 64vw);
  max-width: 100%;
}

.message-caption {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.message-media-link {
  color: var(--blue);
  font-weight: 800;
}

.message-meta {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.message-error {
  margin-top: 6px;
  color: #b91c1c;
  font-size: 11px;
  line-height: 1.35;
}

.message-context-menu {
  position: fixed;
  z-index: 100;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 34px rgba(23, 32, 51, 0.18);
}

.message-context-menu[hidden] {
  display: none;
}

.message-context-menu button {
  display: block;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  text-align: left;
}

.message-context-menu button:hover {
  background: var(--blue-soft);
}

.message-context-menu button:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.message-context-menu button:disabled:hover {
  background: transparent;
}

.composer {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, calc(100% - 86px)) 76px;
  grid-template-areas: "message send";
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 4;
}

.composer textarea {
  grid-area: message;
  min-width: 0;
  width: 100%;
  min-height: 44px;
  max-height: 130px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.composer > button[type="submit"] {
  grid-area: send;
  min-width: 76px;
  width: 100%;
}

.slash-reply-menu {
  position: absolute;
  left: 12px;
  right: 98px;
  bottom: calc(100% - 4px);
  display: grid;
  gap: 4px;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 34px rgba(23, 32, 51, 0.15);
  z-index: 12;
}

.slash-reply-menu[hidden] {
  display: none;
}

.slash-reply-option {
  display: grid;
  gap: 3px;
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.slash-reply-option:hover,
.slash-reply-option.active {
  border-color: #c4d5ff;
  background: var(--blue-soft);
}

.slash-reply-option strong,
.slash-reply-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slash-reply-option span,
.slash-reply-empty {
  color: var(--muted);
  font-size: 12px;
}

.slash-reply-empty {
  padding: 12px;
  text-align: center;
}

.profile-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
}

.profile-panel-toolbar,
.compact-chat-action {
  display: none;
}

.profile-panel-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-section h3 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 850;
}

.profile-name h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
}

.profile-name p {
  margin: 4px 0 0;
  color: var(--muted);
}

.field-grid {
  display: grid;
  gap: 10px;
}

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

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

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.permission-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.field-grid label,
.dialog label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field-grid input,
.field-grid select,
.field-grid textarea,
.dialog input,
.dialog textarea,
.dialog select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
}

.stacked-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-top: 10px;
}

.quick-reply-item textarea {
  min-height: 112px;
  line-height: 1.45;
}

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

.quick-reply-card {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(20, 33, 31, 0.04);
}

.quick-reply-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.quick-reply-card p {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}

.insight-grid {
  display: grid;
  gap: 10px;
}

.insight-item {
  display: grid;
  gap: 4px;
}

.insight-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.insight-value {
  line-height: 1.45;
}

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

.tag-editor {
  display: grid;
  gap: 8px;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.editable-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 38px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.editable-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 2px 6px 2px 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.editable-tag button {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(47, 111, 237, 0.12);
  color: var(--blue);
  padding: 0;
  line-height: 1;
}

.tag-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.empty-tag {
  color: var(--muted);
  font-size: 12px;
  align-self: center;
}

.tag-pill {
  background: #edf5ff;
  color: #265ca8;
}

.source-pill {
  background: #f0edff;
  color: #5b43aa;
}

.reminder-item.completed {
  opacity: 0.62;
}

.reminder-date {
  color: var(--amber);
  font-size: 12px;
  font-weight: 850;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.85fr);
  gap: 16px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.admin-tab {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
}

.admin-tab.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.status-ready {
  background: #e7f7ef;
  color: #157348;
}

.status-waiting {
  background: #fff3d8;
  color: #9a650c;
}

.connect-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.connect-card strong,
.connect-card span {
  display: block;
}

.connect-card span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.onboarding-steps {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.onboarding-steps div {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.onboarding-steps strong {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
}

.onboarding-steps span {
  color: var(--muted);
  line-height: 1.45;
}

.method-guide {
  display: grid;
  gap: 14px;
}

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

.guide-options label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.guide-options select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.setup-note {
  padding: 10px 12px;
  border: 1px solid #f4c46b;
  border-radius: 8px;
  background: #fff8e7;
  color: #7a5208;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.45;
}

.recommendation-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #b7c9f8;
  border-radius: 8px;
  background: var(--blue-soft);
}

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

.recommendation-card p,
.method-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.method-kicker {
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.method-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

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

.method-card {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.method-card.recommended {
  border-color: #b7c9f8;
  background: #f3f7ff;
}

.compact-guide {
  margin: 14px 0 4px;
}

.compact-guide .method-card-grid {
  grid-template-columns: 1fr;
}

.compact-guide .guide-options {
  grid-template-columns: 1fr;
}

.button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
}

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

.button.secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.button.danger {
  background: #fff5f5;
  border-color: #fecaca;
  color: #b91c1c;
}

.button.danger:hover {
  background: #fee2e2;
}

.button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--blue);
}

.button.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 160px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.dialog {
  width: min(500px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(23, 32, 51, 0.35);
}

.dialog form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

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

.dialog-header h2 {
  margin: 0;
  font-size: 18px;
}

.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}

body.profile-drawer-open::after {
  content: "";
  position: fixed;
  inset: 72px 0 0 var(--sidebar-width);
  background: rgba(23, 32, 51, 0.18);
  z-index: 29;
  pointer-events: none;
}

@media (max-width: 1440px) {
  .inbox-view {
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  }

  .profile-panel {
    display: none;
  }

  .compact-chat-action {
    display: inline-flex;
    align-items: center;
  }

  .profile-panel.open {
    display: block;
    position: fixed;
    top: 72px;
    right: 0;
    bottom: 0;
    width: min(420px, calc(100vw - var(--sidebar-width)));
    z-index: 30;
    border-left: 1px solid var(--line);
    box-shadow: -18px 0 42px rgba(23, 32, 51, 0.18);
  }

  .profile-panel.open .profile-panel-toolbar {
    display: flex;
  }
}

@container workspace (max-width: 1160px) {
  .inbox-view {
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  }

  .profile-panel {
    display: none;
  }

  .compact-chat-action {
    display: inline-flex;
    align-items: center;
  }

  .profile-panel.open {
    display: block;
    position: fixed;
    top: 72px;
    right: 0;
    bottom: 0;
    width: min(420px, calc(100vw - var(--sidebar-width)));
    z-index: 30;
    border-left: 1px solid var(--line);
    box-shadow: -18px 0 42px rgba(23, 32, 51, 0.18);
  }

  .profile-panel.open .profile-panel-toolbar {
    display: flex;
  }
}

@container chat (max-width: 560px) {
  .chat-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .chat-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .compact-select {
    max-width: none;
    flex: 1 1 140px;
  }

  .chat-title p {
    white-space: normal;
  }

  .composer {
    grid-template-columns: 1fr;
    grid-template-areas:
      "message"
      "send";
  }

  .composer > button[type="submit"] {
    width: 100%;
  }

  .slash-reply-menu {
    right: 12px;
  }
}

@container chat (max-width: 440px) {
  .message-list {
    padding: 14px;
  }

  .message-bubble {
    max-width: 90%;
  }
}

@media (max-width: 1180px) {
  :root {
    --sidebar-width: 82px;
  }

  .app-shell {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .menu-brand div:not(.brand-mark),
  .menu-item span:last-child,
  .menu-footer {
    display: none;
  }

  .menu-item {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .inbox-view {
    grid-template-columns: minmax(240px, 32vw) minmax(0, 1fr);
  }

  .profile-panel {
    display: none;
  }

  .compact-chat-action {
    display: inline-flex;
    align-items: center;
  }

  .profile-panel.open {
    display: block;
    position: fixed;
    top: 72px;
    right: 0;
    bottom: 0;
    width: min(420px, calc(100vw - 82px));
    z-index: 30;
    border-left: 1px solid var(--line);
    box-shadow: -18px 0 42px rgba(23, 32, 51, 0.18);
  }

  .profile-panel.open .profile-panel-toolbar {
    display: flex;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .hero-strip,
  .dashboard-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .guide-options,
  .method-card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  :root {
    --sidebar-width: 0px;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: visible;
  }

  .app-menu {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto;
  }

  .menu-brand {
    padding: 10px 12px;
  }

  .menu-brand div:not(.brand-mark),
  .menu-footer {
    display: none;
  }

  .menu-nav {
    grid-auto-flow: column;
    grid-auto-columns: minmax(56px, 1fr);
    overflow-x: auto;
    padding: 10px;
  }

  .menu-item {
    min-height: 40px;
    padding: 0 8px;
  }

  .main-shell {
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }

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

  .topbar-actions {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .select-label {
    flex: 1 1 190px;
    min-width: 0;
  }

  .select-label select {
    width: 100%;
    min-width: 0;
  }

  .page-scroll {
    padding: 14px 12px 22px;
  }

  .metric-grid,
  .field-grid.two,
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .connect-card {
    grid-template-columns: 1fr;
  }

  .inbox-view.active {
    display: grid;
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(210px, 28vh) minmax(560px, calc(100vh - 96px));
    overflow: visible;
  }

  .conversation-pane {
    height: auto;
    min-height: 210px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-panel {
    min-height: 560px;
    height: calc(100vh - 96px);
  }

  .chat-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .chat-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .compact-select {
    max-width: none;
    flex: 1 1 140px;
  }

  .chat-title p {
    white-space: normal;
  }

  .message-bubble {
    max-width: 88%;
  }

  .composer {
    position: sticky;
    bottom: 0;
    grid-template-columns: 1fr;
    grid-template-areas:
      "message"
      "send";
  }

  .composer > button[type="submit"] {
    width: 100%;
  }

  .profile-panel {
    display: block;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .profile-panel:not(.open) {
    display: none;
  }

  .profile-panel.open {
    inset: 0;
    width: auto;
    z-index: 40;
  }

  .profile-panel.open .profile-panel-toolbar {
    display: flex;
  }

  body.profile-drawer-open::after {
    display: none;
  }
}
