﻿:root {
  --background: #faf8ff;
  --surface-low: #f2f3ff;
  --surface-lowest: #ffffff;
  --surface-high: #e2e7ff;
  --surface-highest: #dae2fd;
  --on-surface: #131b2e;
  --on-surface-variant: #424754;
  --primary: #0058be;
  --primary-container: #2170e4;
  --secondary: #505f76;
  --secondary-container: #d0e1fb;
  --outline: rgba(114, 119, 133, 0.18);
  --error: #ba1a1a;
  --radius: 14px;
  --shadow: 0 12px 40px -12px rgba(19, 27, 46, 0.08);
}

html.light {
  color-scheme: light;
}

:root,
html.light {
  --c-background: 250 248 255;
  --c-surface: 250 248 255;
  --c-surface-bright: 250 248 255;
  --c-surface-dim: 210 217 244;
  --c-surface-container-lowest: 255 255 255;
  --c-surface-container-low: 242 243 255;
  --c-surface-container: 234 237 255;
  --c-surface-container-high: 226 231 255;
  --c-surface-container-highest: 218 226 253;
  --c-surface-variant: 218 226 253;
  --c-on-background: 19 27 46;
  --c-on-surface: 19 27 46;
  --c-on-surface-variant: 66 71 84;
  --c-outline: 114 119 133;
  --c-outline-variant: 194 198 214;
  --c-primary: 0 88 190;
  --c-primary-container: 33 112 228;
  --c-on-primary: 255 255 255;
  --c-on-primary-container: 254 252 255;
  --c-primary-fixed: 216 226 255;
  --c-primary-fixed-dim: 173 198 255;
  --c-on-primary-fixed: 0 26 66;
  --c-on-primary-fixed-variant: 0 67 149;
  --c-secondary: 80 95 118;
  --c-secondary-container: 208 225 251;
  --c-on-secondary: 255 255 255;
  --c-on-secondary-container: 84 100 122;
  --c-secondary-fixed: 211 228 254;
  --c-secondary-fixed-dim: 183 200 225;
  --c-on-secondary-fixed: 11 28 48;
  --c-on-secondary-fixed-variant: 56 72 93;
  --c-tertiary: 0 105 71;
  --c-tertiary-container: 0 133 91;
  --c-on-tertiary: 255 255 255;
  --c-on-tertiary-container: 245 255 246;
  --c-tertiary-fixed: 111 251 190;
  --c-tertiary-fixed-dim: 78 222 163;
  --c-on-tertiary-fixed: 0 33 19;
  --c-on-tertiary-fixed-variant: 0 82 54;
  --c-error: 186 26 26;
  --c-error-container: 255 218 214;
  --c-on-error: 255 255 255;
  --c-on-error-container: 147 0 10;
  --c-inverse-surface: 40 48 68;
  --c-inverse-on-surface: 238 240 255;
  --c-inverse-primary: 173 198 255;
  --c-surface-tint: 0 90 194;
}

html.dark {
  color-scheme: dark;
  --c-background: 9 14 25;
  --c-surface: 10 15 27;
  --c-surface-bright: 28 36 53;
  --c-surface-dim: 6 10 18;
  --c-surface-container-lowest: 8 12 22;
  --c-surface-container-low: 13 20 34;
  --c-surface-container: 18 26 43;
  --c-surface-container-high: 24 34 54;
  --c-surface-container-highest: 32 43 66;
  --c-surface-variant: 44 56 82;
  --c-on-background: 229 236 248;
  --c-on-surface: 229 236 248;
  --c-on-surface-variant: 173 185 207;
  --c-outline: 116 132 160;
  --c-outline-variant: 58 72 100;
  --c-primary: 105 163 255;
  --c-primary-container: 28 98 205;
  --c-on-primary: 5 16 35;
  --c-on-primary-container: 235 242 255;
  --c-primary-fixed: 30 48 82;
  --c-primary-fixed-dim: 49 75 122;
  --c-on-primary-fixed: 225 236 255;
  --c-on-primary-fixed-variant: 176 207 255;
  --c-secondary: 154 174 204;
  --c-secondary-container: 42 55 77;
  --c-on-secondary: 6 16 31;
  --c-on-secondary-container: 222 234 255;
  --c-secondary-fixed: 37 52 76;
  --c-secondary-fixed-dim: 51 69 98;
  --c-on-secondary-fixed: 223 234 255;
  --c-on-secondary-fixed-variant: 188 207 234;
  --c-tertiary: 84 227 169;
  --c-tertiary-container: 19 100 75;
  --c-on-tertiary: 0 29 18;
  --c-on-tertiary-container: 218 255 239;
  --c-tertiary-fixed: 28 74 58;
  --c-tertiary-fixed-dim: 40 109 82;
  --c-on-tertiary-fixed: 213 255 236;
  --c-on-tertiary-fixed-variant: 139 244 195;
  --c-error: 255 180 171;
  --c-error-container: 113 32 32;
  --c-on-error: 55 0 0;
  --c-on-error-container: 255 218 214;
  --c-inverse-surface: 226 231 241;
  --c-inverse-on-surface: 21 28 42;
  --c-inverse-primary: 0 88 190;
  --c-surface-tint: 105 163 255;
  --background: rgb(var(--c-background));
  --surface-low: rgb(var(--c-surface-container-low));
  --surface-lowest: rgb(var(--c-surface-container-lowest));
  --surface-high: rgb(var(--c-surface-container-high));
  --surface-highest: rgb(var(--c-surface-container-highest));
  --on-surface: rgb(var(--c-on-surface));
  --on-surface-variant: rgb(var(--c-on-surface-variant));
  --primary: rgb(var(--c-primary));
  --primary-container: rgb(var(--c-primary-container));
  --secondary: rgb(var(--c-secondary));
  --secondary-container: rgb(var(--c-secondary-container));
  --outline: rgb(var(--c-outline) / 0.32);
  --error: rgb(var(--c-error));
  --shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.75);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(circle at 0% 0%, rgb(var(--c-primary-fixed) / 0.32) 0%, var(--background) 40%, var(--surface-low) 100%);
  color: var(--on-surface);
}

a {
  color: var(--primary);
  text-decoration: none;
}

h1,
h2,
h3 {
  margin-top: 0;
  letter-spacing: -0.02em;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface-low);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand h1 {
  margin-bottom: 0;
  font-size: 1.4rem;
}

.brand p {
  margin: 4px 0 0;
  color: var(--on-surface-variant);
}

nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-link {
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--on-surface);
  transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  background: var(--surface-highest);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--on-surface-variant);
}

.main {
  padding: 28px;
  display: grid;
  gap: 20px;
}

.hero-card,
.card,
.metric-card {
  background: var(--surface-lowest);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.hero-card {
  background: linear-gradient(135deg, #ffffff 10%, #ecf2ff 100%);
}

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

.metrics-grid {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.metric-card h3 {
  margin-bottom: 8px;
  color: var(--on-surface-variant);
}

.metric-card strong {
  font-size: 1.8rem;
}

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

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

thead th {
  text-align: left;
  font-weight: 600;
  color: var(--on-surface-variant);
  padding: 6px 8px;
}

tbody td {
  background: var(--surface-low);
  padding: 10px 8px;
}

tbody tr td:first-child {
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
}

tbody tr td:last-child {
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
}

form {
  display: grid;
  gap: 12px;
}

.inline-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-right: 8px;
}

label {
  font-size: 0.9rem;
  color: var(--on-surface-variant);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--outline);
  background: var(--surface-low);
  color: var(--on-surface);
  border-radius: 10px;
  padding: 11px;
  font: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 88, 190, 0.2);
  background: var(--surface-lowest);
}

textarea {
  resize: vertical;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-container));
}

.btn-secondary {
  color: var(--on-surface);
  background: var(--secondary-container);
}

.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-bg {
  background: radial-gradient(circle at 90% 10%, #d8e6ff 0, transparent 35%),
    radial-gradient(circle at 0% 90%, #dbefff 0, transparent 35%),
    var(--background);
}

.auth-card {
  width: min(460px, 100%);
}

.alert {
  padding: 10px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.alert-danger {
  background: #ffe2e0;
  color: var(--error);
}

.chat-box {
  display: grid;
  gap: 10px;
  margin: 20px 0;
  max-height: 450px;
  overflow: auto;
  padding: 8px;
  background: var(--surface-low);
  border-radius: 12px;
}

.msg {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 18px;
  background: var(--surface-high);
}

.msg small {
  color: var(--on-surface-variant);
}

.msg p {
  margin: 4px 0 0;
  white-space: pre-wrap;
}

.msg.outbound {
  justify-self: end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.msg.inbound {
  justify-self: start;
  border-bottom-left-radius: 6px;
}

html.dark .bg-white,
html.dark .bg-white\/80,
html.dark .bg-slate-50,
html.dark .bg-slate-100 {
  background-color: rgb(var(--c-surface-container-lowest) / 0.94) !important;
}

html.dark .bg-slate-200,
html.dark .bg-slate-200\/80,
html.dark .bg-slate-100\/80,
html.dark .bg-surface-container-lowest\/80 {
  background-color: rgb(var(--c-surface-container-high) / 0.88) !important;
}

html.dark .text-slate-950,
html.dark .text-slate-900,
html.dark .text-slate-800,
html.dark .text-slate-700 {
  color: rgb(var(--c-on-surface)) !important;
}

html.dark .text-slate-600,
html.dark .text-slate-500,
html.dark .text-slate-400 {
  color: rgb(var(--c-on-surface-variant)) !important;
}

html.dark .border-slate-200,
html.dark .border-slate-200\/80,
html.dark .border-slate-100,
html.dark .border-white\/70 {
  border-color: rgb(var(--c-outline-variant) / 0.55) !important;
}

html.dark .shadow-sm,
html.dark .shadow,
html.dark .shadow-md,
html.dark .shadow-lg,
html.dark .shadow-xl,
html.dark .shadow-2xl {
  --tw-shadow-color: rgb(0 0 0 / 0.5);
}

@media (min-width: 1024px) {
  body:has([data-conversation-list='1']) [data-conversation-sidebar='1'] {
    width: min(42vw, 700px) !important;
    min-width: 560px;
  }
}

body:has([data-conversation-list='1']) > .flex-1 > .flex-1 > section:first-child {
  display: none !important;
}

body:has([data-conversation-list='1']) > aside.fixed {
  width: 16rem !important;
  min-width: 16rem !important;
  max-width: 16rem !important;
}

body:has([data-conversation-list='1']) [data-filter-form='1'] {
  gap: 0.5rem !important;
}

body:has([data-conversation-list='1']) [data-conversation-list='1'] {
  padding: 0.5rem 0.625rem !important;
}

body:has([data-conversation-list='1']) [data-chat-card='1'] {
  border-radius: 0.875rem !important;
  padding: 0.55rem 0.7rem !important;
}

body:has([data-conversation-list='1']) [data-chat-card='1'] .w-12.h-12,
body:has([data-conversation-list='1']) [data-chat-card='1'] .h-12.w-12 {
  width: 2.5rem !important;
  height: 2.5rem !important;
  border-radius: 0.75rem !important;
}

body:has([data-conversation-list='1']) [data-chat-card='1'] [style*="-webkit-line-clamp:2"] {
  -webkit-line-clamp: 1 !important;
}

body:has([data-conversation-list='1']) [data-chat-card='1'] .mt-3 {
  margin-top: 0.5rem !important;
}

body:has([data-conversation-list='1']) [data-chat-card='1'] [data-tag-badges='1'] {
  margin-top: 0.5rem !important;
}

body:has([data-conversation-list='1']) [data-chat-card='1'] [data-tag-badges='1'] > span:nth-child(n+5) {
  display: none !important;
}

body:has([data-conversation-list='1']) [data-chat-card='1'] [data-tag-badges='1'] span,
body:has([data-conversation-list='1']) [data-chat-card='1'] .rounded-full {
  padding-top: 0.125rem !important;
  padding-bottom: 0.125rem !important;
}

.qr {
  max-width: 240px;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  box-shadow: var(--shadow);
}

.two-col {
  grid-template-columns: 1fr 1fr;
}

.full {
  grid-column: 1 / -1;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
  }

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

  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 14px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .msg {
    max-width: 95%;
  }
}
