:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #1d2528;
  --muted: #66777d;
  --line: #dbe3e6;
  --brand: #176f63;
  --brand-dark: #0e5148;
  --accent: #b35c1e;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(28, 43, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #102326;
  color: #eef6f4;
  padding: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #f0b35a;
  color: #102326;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.2;
}

.brand p,
.toolbar p,
.editor-head p {
  color: var(--muted);
  font-size: 13px;
}

.sidebar .field span {
  color: #c7d6d7;
}

.main {
  padding: 28px;
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.toolbar h2 {
  font-size: 24px;
}

.content-grid,
.imports-layout,
.photos-layout,
.live-layout,
.billing-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 440px;
  gap: 20px;
  align-items: start;
}

.billing-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.report-metrics {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.metric-card strong {
  display: block;
  color: var(--ink);
  font-size: 24px;
  overflow-wrap: anywhere;
}

.setup-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  padding: 18px;
}

.setup-panel h3 {
  font-size: 18px;
  margin-bottom: 10px;
}

.setup-panel ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.setup-panel code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7faf9;
  color: var(--brand-dark);
  padding: 2px 6px;
  overflow-wrap: anywhere;
}

.inline-field {
  min-width: min(320px, 100%);
  margin-bottom: 0;
}

.table-wrap,
.editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f0f6f4;
}

.tenant-name {
  font-weight: 700;
}

.tenant-slug {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.profile-report-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.profile-report-list.muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.profile-report-item {
  display: grid;
  gap: 4px;
  max-width: 520px;
  padding: 8px 0 0;
}

.profile-report-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #edf4f2;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
}

.pill.off {
  background: #f4efec;
  color: var(--accent);
}

.editor {
  padding: 18px;
}

.editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.editor h3 {
  font-size: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

.sidebar input {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 111, 99, 0.14);
}

.switch-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 16px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.switch input {
  width: 16px;
  height: 16px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 13px;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.button.primary {
  background: var(--brand);
  color: #fff;
}

.button.primary:hover {
  background: var(--brand-dark);
}

.button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.button.danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  color: var(--danger);
}

.sidebar .button {
  width: 100%;
  margin-bottom: 10px;
}

.sidebar .button.ghost {
  border-color: rgba(255, 255, 255, 0.18);
  color: #eef6f4;
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  color: #c7d6d7;
  font-size: 13px;
}

.auth-user {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.auth-user span {
  color: #eef6f4;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
}

.status-dot.ok {
  background: #2fb071;
}

.secret-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #f0d1a9;
  border-radius: 8px;
  background: #fff8ee;
  padding: 12px;
  margin: 8px 0 14px;
}

.secret-box span {
  grid-column: 1 / -1;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.secret-box code {
  overflow-wrap: anywhere;
  color: #3c2d1c;
}

.sub-panel {
  border-top: 1px solid var(--line);
  margin: 16px 0 14px;
  padding-top: 16px;
}

.compact-head {
  margin-bottom: 12px;
}

.hint-text {
  border: 1px solid #cce1dc;
  border-radius: 6px;
  background: #f1f8f6;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
  padding: 10px 11px;
}

.member-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.member-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 110px 78px;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
  padding: 10px;
}

.member-main {
  min-width: 0;
}

.member-main strong,
.member-main span {
  display: block;
  overflow-wrap: anywhere;
}

.member-main strong {
  font-size: 13px;
}

.member-main span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.member-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.member-password {
  flex: 1 1 180px;
  min-width: 0;
}

.member-actions .button {
  min-height: 36px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.split-actions {
  justify-content: space-between;
  gap: 10px;
}

.filter-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  padding: 18px;
}

.compact-filter {
  box-shadow: none;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.filter-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.filter-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 20px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--brand) 7%, var(--panel));
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
}

.filter-chip strong {
  color: var(--muted);
  font-weight: 800;
}

.filter-chip.muted {
  background: var(--panel);
  color: var(--muted);
}

.ops-stack {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-head h3 {
  font-size: 18px;
}

.table-status {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.empty-state {
  background: color-mix(in srgb, var(--line) 18%, var(--panel));
  color: var(--muted);
  font-weight: 700;
  padding: 24px 14px;
  text-align: center;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.button.is-busy {
  gap: 8px;
}

.button.is-busy::before {
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  animation: button-spin 700ms linear infinite;
}

.pill.error {
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
  color: var(--danger);
}

.pill.warning {
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  color: var(--accent);
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}

.preview {
  margin-top: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.live-thread {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.live-messages {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow: auto;
}

.message-bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfc;
}

.message-bubble.incoming {
  border-color: #cce1dc;
  background: #f1f8f6;
}

.message-bubble.ai_note,
.message-bubble.ai_outgoing {
  border-color: #f0d1a9;
  background: #fff8ee;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.message-bubble p {
  margin-top: 6px;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.message-bubble small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.preview-items {
  display: grid;
  gap: 10px;
}

.preview-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcfc;
}

.preview-item strong {
  color: var(--brand-dark);
}

.preview-item p {
  margin-top: 4px;
  color: var(--ink);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.photo-thumb {
  display: block;
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: #f7faf9;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: #102326;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.hidden {
  display: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #eef7f5;
  color: #167463;
  padding: 4px 10px;
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .content-grid,
  .imports-layout,
  .photos-layout,
  .live-layout,
  .billing-layout {
    grid-template-columns: 1fr;
  }

  .billing-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid,
  .filter-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .toolbar,
  .editor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .switch-row,
  .filter-grid,
  .filter-grid.compact,
  .billing-metrics,
  .member-row,
  .split-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
