:root {
  --burgundy-950: #3a0617;
  --burgundy-900: #4d0a1f;
  --burgundy-850: #591026;
  --burgundy-800: #63122b;
  --burgundy-700: #7c1533;
  --burgundy-600: #931b3d;
  --burgundy-500: #ab2748;
  --burgundy-400: #c4506c;
  --burgundy-300: #dd8298;
  --rose-100: #fbe6ec;
  --rose-50: #fdf4f6;
  --gold-500: #c9a24a;
  --gold-100: #f7ecd6;
  --ink-900: #26131a;
  --ink-700: #4c333b;
  --muted: #8c6f78;
  --muted-light: #b79ba3;
  --line: #f0e1e6;
  --line-strong: #e8cdd5;
  --surface: #ffffff;
  --canvas: #fffdfd;
  --success-bg: #e7f6ee;
  --success-ink: #1c7a4c;
  --warn-bg: #fdf3dc;
  --warn-ink: #96690a;
  --danger-bg: #fdeaee;
  --danger-ink: #b3234a;
  --shadow-xs: 0 1px 2px rgba(58, 6, 23, 0.05);
  --shadow-sm: 0 2px 10px rgba(58, 6, 23, 0.06);
  --shadow-md: 0 12px 32px rgba(58, 6, 23, 0.09);
  --shadow-lg: 0 28px 64px rgba(58, 6, 23, 0.16);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --font-sans: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink-900);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  letter-spacing: -0.01em;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  font-family: var(--font-sans);
}

::selection {
  background: var(--rose-100);
  color: var(--burgundy-800);
}

/* Thin elegant scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--radius-pill);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--burgundy-300);
}

.icon {
  width: 18px;
  height: 18px;
  display: block;
  flex: 0 0 auto;
}

/* ==================== APP SHELL ==================== */

.app-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

.sidebar {
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 255, 255, 0.06), transparent 45%),
    linear-gradient(165deg, var(--burgundy-800) 0%, var(--burgundy-950) 78%);
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow: hidden;
  position: relative;
  transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1), padding 220ms ease;
}

.brand {
  display: flex;
  gap: 13px;
  align-items: center;
  min-height: 52px;
  padding: 0 4px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(155deg, #ffffff 0%, #f6e3e8 100%);
  color: var(--burgundy-800);
  font-size: 22px;
  font-weight: 800;
  flex: 0 0 auto;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.brand h1,
.brand p,
.topbar h2,
.panel h3,
.chat-header h3 {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand p,
.eyebrow,
.panel-header span,
.chat-header span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 600;
}

.brand p {
  white-space: nowrap;
  margin-top: 1px;
}

.app-shell.sidebar-collapsed .brand,
.app-shell.sidebar-collapsed .nav-tabs,
.app-shell.sidebar-collapsed .sidebar-footer {
  justify-content: center;
}

.app-shell.sidebar-collapsed .brand div:not(.brand-mark) {
  width: 0;
  overflow: hidden;
  opacity: 0;
}

.app-shell.sidebar-collapsed .nav-tab {
  width: 52px;
  height: 52px;
  padding: 0;
  justify-content: center;
}

.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .mode-panel > div,
.app-shell.sidebar-collapsed .logout-button .nav-label {
  display: none;
}

.app-shell.sidebar-collapsed .nav-icon {
  margin: 0;
}

.app-shell.sidebar-collapsed .mode-panel {
  width: 52px;
  min-height: 52px;
  padding: 0;
  justify-content: center;
}

.app-shell.sidebar-collapsed .mode-panel .switch {
  transform: scale(0.76);
}

.app-shell.sidebar-collapsed .logout-button {
  width: 52px;
  height: 52px;
  padding: 0;
  justify-content: center;
}

.nav-tabs {
  display: grid;
  gap: 6px;
}

.nav-tab,
.refresh-button,
.logout-button,
.icon-button {
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.nav-tab,
.logout-button {
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  padding: 12px 14px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  font-weight: 600;
  font-size: 14.5px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-tab:hover,
.logout-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-tab.active {
  background: #ffffff;
  color: var(--burgundy-800);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.nav-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  flex: 0 0 auto;
  color: currentColor;
  transition: background 160ms ease;
}

.nav-tab.active .nav-icon,
.nav-tab:hover .nav-icon,
.logout-button:hover .nav-icon {
  background: var(--rose-100);
  color: var(--burgundy-700);
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.sidebar-footer form {
  margin: 0;
}

.mode-panel {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.mode-panel .eyebrow {
  display: block;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10.5px;
}

.mode-panel strong {
  font-size: 14px;
  font-weight: 700;
}

.switch {
  width: 50px;
  height: 28px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--gold-500);
  padding: 3px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 160ms ease;
}

.switch span {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transform: translateX(22px);
  transition: transform 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

.switch.off {
  background: rgba(255, 255, 255, 0.18);
}

.switch.off span {
  transform: translateX(0);
}

.switch:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* ==================== MAIN / TOPBAR ==================== */

.main {
  min-width: 0;
  padding: 28px 32px 40px;
  background: var(--canvas);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.sidebar-toggle {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.sidebar-toggle:hover {
  border-color: var(--burgundy-400);
  background: var(--rose-50);
}

.sidebar-toggle:active {
  transform: scale(0.94);
}

.sidebar-toggle span {
  width: 18px;
  height: 2px;
  border-radius: var(--radius-pill);
  background: var(--burgundy-700);
  transition: transform 160ms ease, opacity 160ms ease;
}

.topbar .eyebrow,
.panel-header span,
.chat-header span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
  font-weight: 700;
}

.topbar h2 {
  font-size: 27px;
  font-weight: 800;
  margin-top: 2px;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border-radius: var(--radius-pill);
  padding: 5px 13px 5px 11px;
  background: var(--rose-50);
  color: var(--burgundy-700);
  font-size: 12.5px;
  font-weight: 700;
  border: 1px solid var(--line);
}

.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
  flex: 0 0 auto;
}

.status-pill.warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.status-pill.danger {
  background: var(--danger-bg);
  color: var(--danger-ink);
}

.refresh-button {
  background: var(--burgundy-700);
  color: #fff;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 8px 18px rgba(124, 21, 51, 0.22);
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.refresh-button:hover {
  background: var(--burgundy-850);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(124, 21, 51, 0.28);
}

.refresh-button:active {
  transform: translateY(0);
}

.refresh-button .icon {
  width: 16px;
  height: 16px;
}

.refresh-button.is-loading .icon {
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==================== TABS / PANELS ==================== */

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fade-in 220ms ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: box-shadow 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.metric:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
  border-color: var(--line-strong);
}

.metric-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--rose-50);
  color: var(--burgundy-600);
  flex: 0 0 auto;
}

.metric-icon .icon {
  width: 20px;
  height: 20px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink-900);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.72fr);
  gap: 18px;
}

.panel,
.conversation-list,
.chat-window {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.panel-header,
.chat-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-header h3,
.chat-header h3 {
  font-size: 16px;
  font-weight: 800;
}

.panel-header span {
  background: var(--rose-50);
  color: var(--burgundy-700);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13.5px;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--rose-50);
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: var(--rose-50);
}

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

.contact-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(155deg, var(--burgundy-500), var(--burgundy-800));
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.01em;
}

.avatar.sm {
  width: 34px;
  height: 34px;
  font-size: 12.5px;
}

.contact-name {
  font-weight: 700;
  color: var(--ink-900);
}

.contact-sub {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 1px;
}

.feed {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 16px;
}

.feed-item,
.conversation-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.feed-item {
  border-left: 3px solid var(--burgundy-500);
}

.feed-item.priority-high {
  border-left-color: var(--danger-ink);
}

.feed-item.priority-low {
  border-left-color: var(--muted-light);
}

.feed-item:hover,
.conversation-item:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.feed-item strong,
.conversation-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--ink-900);
}

.feed-item p,
.conversation-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.feed-item p + p,
.conversation-item p + p {
  margin-top: 5px;
}

.feed-meta {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--rose-50);
  color: var(--burgundy-700);
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}

/* ==================== CHATS ==================== */

.chat-panel.active {
  display: block;
}

.chat-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 140px);
}

.conversation-list {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.search-box {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.search-box .icon {
  position: absolute;
  left: 30px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px 10px 38px;
  outline: none;
  background: var(--rose-50);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.search-box input:focus {
  background: var(--surface);
}

.conversation-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 12px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  flex: 1;
}

.conversation-item {
  cursor: pointer;
  text-align: left;
  width: 100%;
  display: flex;
  gap: 12px;
}

.conversation-item-body {
  min-width: 0;
  flex: 1;
}

.conversation-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversation-item-top strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item .conversation-time {
  color: var(--muted-light);
  font-size: 11px;
  flex: 0 0 auto;
  font-weight: 600;
}

.conversation-item.active {
  border-color: var(--burgundy-500);
  background: var(--rose-50);
  box-shadow: var(--shadow-sm);
}

.chat-window {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.chat-header-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.messages {
  padding: 22px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background:
    radial-gradient(circle at 100% 0%, rgba(171, 39, 72, 0.03), transparent 40%),
    #fffefe;
}

.message-group {
  display: grid;
  gap: 8px;
}

.bubble {
  max-width: min(680px, 82%);
  border-radius: var(--radius-md);
  padding: 12px 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  font-size: 14px;
  box-shadow: var(--shadow-xs);
}

.bubble.user {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  color: var(--ink-900);
}

.bubble.bot {
  align-self: flex-end;
  background: linear-gradient(155deg, var(--burgundy-600), var(--burgundy-800));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-meta {
  color: var(--muted-light);
  font-size: 11.5px;
  font-weight: 600;
}

.message-group:has(.bubble.bot:last-of-type) .message-meta {
  text-align: right;
}

.empty-state {
  margin: auto;
  color: var(--muted);
  text-align: center;
  padding: 40px 20px;
  display: grid;
  gap: 10px;
  justify-items: center;
  font-size: 14px;
}

.empty-state .icon {
  width: 34px;
  height: 34px;
  color: var(--muted-light);
}

.mobile-scrim {
  display: none;
}

/* ==================== LOGIN ==================== */

body.login-body {
  min-height: 100vh;
  background: var(--canvas);
}

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

.login-hero {
  position: relative;
  background:
    radial-gradient(circle at 85% 12%, rgba(255, 255, 255, 0.08), transparent 40%),
    radial-gradient(circle at 10% 90%, rgba(201, 162, 74, 0.16), transparent 45%),
    linear-gradient(160deg, var(--burgundy-800) 0%, var(--burgundy-950) 85%);
  color: #fff;
  padding: 56px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.login-hero::before,
.login-hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-hero::before {
  width: 420px;
  height: 420px;
  right: -140px;
  top: -140px;
}

.login-hero::after {
  width: 280px;
  height: 280px;
  left: -100px;
  bottom: -80px;
  border-color: rgba(255, 255, 255, 0.06);
}

.login-hero-top .brand-mark {
  width: 52px;
  height: 52px;
  font-size: 24px;
  border-radius: 15px;
}

.login-hero-top .brand {
  gap: 14px;
}

.login-hero-top .brand h1 {
  font-size: 22px;
}

.login-hero-copy {
  position: relative;
  max-width: 420px;
}

.login-hero-copy h2 {
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}

.login-hero-copy p {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 15px;
  line-height: 1.6;
}

.login-hero-stats {
  position: relative;
  display: flex;
  gap: 28px;
  padding-top: 28px;
  margin-top: 28px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.login-hero-stats div strong {
  display: block;
  font-size: 20px;
  font-weight: 800;
}

.login-hero-stats div span {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  font-weight: 600;
}

.login-hero-foot {
  position: relative;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
}

.login-form-side {
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--surface);
}

.login-panel {
  width: min(400px, 100%);
  padding: 8px;
}

.login-panel-head {
  margin-bottom: 30px;
}

.login-mobile-brand {
  display: none;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-mobile-brand .brand-mark {
  background: var(--burgundy-950);
  color: #fff;
}

.login-panel-head h2 {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.login-panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--ink-700);
  font-size: 13px;
  font-weight: 700;
}

.input-wrap {
  position: relative;
}

.input-wrap > .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-light);
  pointer-events: none;
  transition: color 160ms ease;
}

.input-wrap:focus-within .icon {
  color: var(--burgundy-500);
}

.login-form input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px 13px 42px;
  outline: none;
  background: var(--rose-50);
  font-size: 14.5px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.login-form input#password {
  padding-right: 46px;
}

.login-form input:focus,
.search-box input:focus {
  border-color: var(--burgundy-500);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(171, 39, 72, 0.1);
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
}

.password-toggle .icon {
  width: 18px;
  height: 18px;
}

.password-toggle:hover {
  background: var(--rose-100);
  color: var(--burgundy-700);
}

.login-form button[type="submit"] {
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(150deg, var(--burgundy-600), var(--burgundy-800));
  color: #ffffff;
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 800;
  font-size: 15px;
  margin-top: 4px;
  box-shadow: 0 10px 24px rgba(124, 21, 51, 0.26);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.login-form button[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(124, 21, 51, 0.32);
}

.login-form button[type="submit"]:active {
  transform: translateY(0);
}

.login-error {
  display: none;
  align-items: center;
  gap: 8px;
  margin: -6px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: 13px;
  font-weight: 600;
}

.login-error .icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.has-login-error .login-error {
  display: flex;
}

.login-panel-foot {
  margin-top: 26px;
  text-align: center;
  color: var(--muted-light);
  font-size: 12px;
}

/* ==================== RESPONSIVE ==================== */

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

  .login-hero {
    display: none;
  }

  .login-form-side {
    padding: 24px;
  }

  .login-mobile-brand {
    display: flex;
  }
}

@media (max-width: 980px) {
  .content-grid,
  .chat-layout {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(300px, 84vw);
    transform: translateX(-104%);
    box-shadow: 24px 0 60px rgba(58, 6, 23, 0.28);
  }

  .app-shell:not(.sidebar-collapsed) .sidebar {
    transform: translateX(0);
  }

  .app-shell.sidebar-collapsed .brand div:not(.brand-mark),
  .app-shell.sidebar-collapsed .mode-panel > div,
  .app-shell.sidebar-collapsed .nav-label,
  .app-shell.sidebar-collapsed .logout-button .nav-label {
    width: auto;
    display: inline;
    opacity: 1;
  }

  .app-shell.sidebar-collapsed .nav-tab {
    width: 100%;
    height: auto;
    padding: 12px 14px;
    text-align: left;
    justify-content: flex-start;
  }

  .app-shell.sidebar-collapsed .mode-panel {
    width: auto;
    min-height: 0;
    padding: 14px;
    justify-content: space-between;
  }

  .app-shell.sidebar-collapsed .mode-panel .switch {
    transform: none;
  }

  .app-shell.sidebar-collapsed .logout-button {
    width: 100%;
    height: auto;
    padding: 12px 14px;
    justify-content: flex-start;
  }

  .mobile-scrim {
    position: fixed;
    inset: 0;
    background: rgba(38, 19, 26, 0.46);
    backdrop-filter: blur(2px);
    z-index: 20;
  }

  body.sidebar-open .mobile-scrim {
    display: block;
  }

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

@media (max-width: 620px) {
  .main {
    padding: 16px 16px 90px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
  }

  .title-row {
    width: 100%;
  }

  .toolbar {
    width: 100%;
    justify-content: space-between;
  }

  .topbar h2 {
    font-size: 22px;
  }

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

  .metric {
    padding: 14px;
    gap: 10px;
  }

  .metric-icon {
    width: 34px;
    height: 34px;
  }

  .metric strong {
    font-size: 21px;
  }

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

  .chat-layout {
    min-height: auto;
  }

  .conversation-stack {
    max-height: 320px;
  }

  .messages {
    min-height: 420px;
    padding: 16px;
  }

  .bubble {
    max-width: 100%;
  }

  table {
    min-width: 560px;
  }

  .login-form-side {
    padding: 20px;
  }

  .login-panel {
    padding: 0;
  }
}
