/* MessageHub App & Admin UI */
:root {
  --primary: #ff4f42;
  --primary-dark: #e63e32;
  --primary-light: #fff0ee;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 260px;
  --danger: #dc2626;
  --success: #059669;
  --warning: #d97706;
  --radius: 10px;
  --font: 'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); }
a { color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1rem; font: 600 .875rem/1 var(--font);
  border-radius: 8px; border: none; cursor: pointer; text-decoration: none;
}
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); color: #fff; }
.btn--outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { padding: .35rem .7rem; font-size: .8125rem; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; border: 1px solid rgba(220, 38, 38, .35); }
.btn--ghost:hover { background: #fef2f2; color: var(--danger); }
.btn--on-dark { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.35); color: #fff; }
.btn--on-dark:hover { background: rgba(255,255,255,.22); color: #fff; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .875rem; }
.alert--error { background: #fee2e2; color: #991b1b; }
.alert--success { background: #d1fae5; color: #065f46; }
.alert--info { background: #dbeafe; color: #1e40af; }
.alert--warning { background: #fef3c7; color: #92400e; }

/* Auth & Install */
.auth-body, .install-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  padding: 1rem;
}
.auth-card, .install-card {
  width: 100%; max-width: 420px; background: #fff; padding: 2rem;
  border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.15);
}
.auth-card h1, .install-card h1 { margin: 0 0 .5rem; font-size: 1.5rem; }
.auth-footer { text-align: center; font-size: .875rem; margin-top: 1rem; }
.install-card form label, .auth-card form label {
  display: block; margin-bottom: .75rem; font-size: .8125rem; font-weight: 600;
}
.install-card input, .auth-card input, .install-card select {
  width: 100%; margin-top: .25rem; padding: .6rem .75rem;
  border: 1px solid var(--border); border-radius: 8px; font: inherit;
}
.install-card hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* App layout */
.app-body { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: #0f172a; color: #94a3b8;
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}
.sidebar__brand {
  padding: 1.25rem; color: #fff; font-weight: 800; text-decoration: none;
  border-bottom: 1px solid #334155;
}
.sidebar__nav { flex: 1; padding: 1rem .75rem; }
.sidebar__nav a {
  display: block; padding: .65rem .85rem; border-radius: 8px;
  color: #cbd5e1; text-decoration: none; font-size: .9375rem; margin-bottom: .25rem;
}
.sidebar__nav a:hover { background: #1e293b; color: #fff; }
.sidebar__nav a.is-active { background: var(--primary); color: #fff; }
.sidebar__user {
  display: flex; align-items: center; gap: .65rem; padding: 1rem;
  border-top: 1px solid #334155; font-size: .8125rem;
}
.sidebar__user strong { display: block; color: #fff; }
.sidebar__avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .75rem;
}
.sidebar__logout { margin-left: auto; color: #94a3b8; text-decoration: none; font-size: 1.1rem; }

.app-main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.app-topbar h1 { margin: 0; font-size: 1.25rem; }
.sidebar-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; cursor: pointer; }
.app-content { padding: 1.5rem; flex: 1; }

/* Inbox */
.inbox-layout {
  display: grid; grid-template-columns: 320px 1fr; gap: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; height: calc(100vh - 140px); min-height: 520px;
}
.inbox-view-tabs {
  display: flex;
  gap: .25rem;
  padding: .5rem .75rem 0;
  border-bottom: 1px solid var(--border);
}
.inbox-view-tabs__btn {
  flex: 1;
  text-align: center;
  padding: .45rem .5rem;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
}
.inbox-view-tabs__btn:hover { color: var(--text); background: #f8fafc; }
.inbox-view-tabs__btn.is-active {
  color: var(--primary);
  background: #fff;
  border-color: var(--border);
  margin-bottom: -1px;
}
.inbox-view-tabs__count {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0 .35rem;
  font-size: .7rem;
  line-height: 1.25rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
}
.inbox-filter-check { font-size: .75rem; display: flex; align-items: center; gap: .25rem; white-space: nowrap; }
.inbox-empty-hint { padding: 1rem; color: var(--muted); font-size: .875rem; }
.assignee-badge { font-size: .65rem; background: #e0e7ff; color: #3730a3; padding: .1rem .35rem; border-radius: 4px; }
.chat-header__meta { color: var(--muted); }
.chat-header__actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.chat-toolbar { display: flex; flex-wrap: wrap; gap: .35rem; padding: .5rem 1.25rem; border-bottom: 1px solid var(--border); background: #fafafa; }
.chat-panel { display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-panel .chat-messages { flex: 1; min-height: 200px; }
.inbox-sidebar-panel {
  border-top: 1px solid var(--border); padding: .75rem 1.25rem; background: #f8fafc;
  max-height: 220px; overflow-y: auto; font-size: .8125rem;
}
.inbox-sidebar-panel summary { cursor: pointer; font-weight: 600; margin-bottom: .5rem; }
.note-form textarea { width: 100%; margin-bottom: .35rem; padding: .5rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.note-list { list-style: none; margin: .5rem 0 0; padding: 0; }
.note-list li { padding: .5rem 0; border-top: 1px solid var(--border); }
.note-list p { margin: .25rem 0 0; color: var(--text); }
.msg-media { max-width: 240px; max-height: 180px; border-radius: 8px; display: block; margin-bottom: .35rem; }
.msg-file { font-weight: 600; }
.msg-bubble--system { opacity: .85; font-style: italic; }
.chart-bars { display: flex; align-items: flex-end; gap: .5rem; padding: 1rem 0; min-height: 120px; flex-wrap: wrap; }
.chart-bar { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.chart-bar::before { content: ''; display: block; width: 28px; height: var(--h, 20px); background: var(--primary); border-radius: 4px 4px 0 0; min-height: 4px; }
.chart-bar small { font-size: .65rem; color: var(--muted); }

/* Update banner & Dashboard */
.update-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .85rem 1.25rem; margin-bottom: 1rem;
  background: linear-gradient(90deg, #fef3c7, #fff7ed);
  border: 1px solid #fcd34d; border-radius: 10px; font-size: .875rem;
}
.dashboard-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem;
}
.dashboard-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1.5rem 1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s;
}
.dashboard-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.08); color: inherit; }
.dashboard-card--primary { border-color: var(--primary); background: var(--primary-light); }
.dashboard-card__value { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.dashboard-card__label { font-size: .8125rem; color: var(--muted); margin-top: .35rem; text-align: center; }
.update-steps-list { margin: 0; padding-left: 1.25rem; line-height: 1.7; font-size: .875rem; }
.changelog-list { margin: .5rem 0 0; padding-left: 1.25rem; font-size: .875rem; line-height: 1.6; }
.feature-matrix { padding: 1rem 1.25rem; }
.feature-matrix__group { margin: 1rem 0 .5rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.feature-matrix__group:first-child { margin-top: 0; }
.feature-matrix__row { display: flex; align-items: center; gap: .75rem; padding: .4rem 0; font-size: .875rem; }

.flow-form {
  border: 1px solid var(--border);
  padding: 1.25rem;
  border-radius: 12px;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  background: #fafafa;
}
.flow-form__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .25rem;
}
.flow-form__head h3 { margin: 0; }
.flow-form label { display: block; font-size: .8125rem; font-weight: 600; }
.flow-form textarea {
  width: 100%; margin-top: .35rem; padding: .6rem .75rem;
  border: 1px solid var(--border); border-radius: 8px; font: inherit; font-weight: 400;
}
.flow-form select { width: 100%; margin-top: .35rem; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; }

.sla-badge { font-size: .65rem; background: #fef3c7; color: #b45309; padding: .1rem .35rem; border-radius: 4px; font-weight: 700; }
.conv-item--sla { border-left: 3px solid #f59e0b; }
.conv-item--resolved { opacity: .85; }
.conv-item--resolved .conv-item__name::after {
  content: ' · Erledigt';
  font-weight: 500;
  font-size: .7rem;
  color: var(--muted);
}

.flow-step-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem;
  margin-bottom: .5rem;
  display: grid;
  gap: .4rem;
}
.flow-step-row label { font-size: .75rem; font-weight: 600; }
.flow-step-row input, .flow-step-row textarea { width: 100%; margin-top: .2rem; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 6px; font-weight: 400; }
.conversation-list { border-right: 1px solid var(--border); overflow-y: auto; }
.conversation-list__filters { padding: .75rem; border-bottom: 1px solid var(--border); display: flex; gap: .5rem; flex-wrap: wrap; }
.conversation-list__filters select, .conversation-list__filters input {
  flex: 1; min-width: 100px; padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 6px; font-size: .8125rem;
}
.conv-item {
  display: block; padding: .85rem 1rem; border-bottom: 1px solid var(--border);
  text-decoration: none; color: inherit; transition: background .15s;
}
.conv-item:hover { background: #f8fafc; }
.conv-item.is-active { background: var(--primary-light); border-left: 3px solid var(--primary); }
.conv-item__top { display: flex; justify-content: space-between; margin-bottom: .25rem; }
.conv-item__name { font-weight: 600; font-size: .875rem; }
.conv-item__time { font-size: .7rem; color: var(--muted); }
.conv-item__preview { font-size: .8125rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item__meta { display: flex; gap: .35rem; margin-top: .35rem; align-items: center; }
.channel-badge { font-size: .65rem; padding: .15rem .4rem; border-radius: 4px; background: #f1f5f9; }
.unread-badge { background: var(--primary); color: #fff; font-size: .65rem; font-weight: 700; padding: .1rem .4rem; border-radius: 999px; margin-left: auto; }

.chat-panel { display: flex; flex-direction: column; min-width: 0; }
.chat-panel__empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.chat-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.chat-header h2 { margin: 0; font-size: 1rem; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.msg-bubble { max-width: 75%; padding: .65rem .9rem; border-radius: 12px; font-size: .875rem; line-height: 1.45; }
.msg-bubble--in { align-self: flex-start; background: #f1f5f9; border-bottom-left-radius: 4px; }
.msg-bubble--out { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg-bubble time { display: block; font-size: .65rem; opacity: .7; margin-top: .35rem; }
.chat-compose { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; }
.chat-compose textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 120px;
  padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 8px; font: inherit;
}
.chat-compose button { align-self: flex-end; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: 220px 1fr; gap: 1.5rem; }
.settings-tabs { display: flex; flex-direction: column; gap: .25rem; }
.settings-tabs a {
  padding: .65rem .85rem; border-radius: 8px; text-decoration: none; color: var(--text);
  font-size: .875rem; border: 1px solid transparent;
}
.settings-tabs a.is-active { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); font-weight: 600; }
.settings-tabs .status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .4rem; }
.status-dot--connected { background: var(--success); }
.status-dot--disconnected { background: #94a3b8; }
.status-dot--pending { background: var(--warning); }
.status-dot--error { background: var(--danger); }

.settings-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
}
.settings-panel h2 { margin: 0 0 .5rem; font-size: 1.125rem; }
.settings-panel > p { color: var(--muted); font-size: .875rem; margin: 0 0 1.25rem; }
.form-grid { display: grid; gap: 1rem; }
.form-grid label { display: block; font-size: .8125rem; font-weight: 600; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%; margin-top: .3rem; padding: .55rem .7rem;
  border: 1px solid var(--border); border-radius: 8px; font: inherit; font-weight: 400;
}
.form-grid .hint { font-size: .75rem; color: var(--muted); font-weight: 400; margin-top: .25rem; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.25rem; }
.webhook-box {
  background: #f8fafc; border: 1px dashed var(--border); padding: 1rem;
  border-radius: 8px; font-size: .8125rem; word-break: break-all; margin: 1rem 0;
}
.webhook-box code { display: block; margin-top: .5rem; user-select: all; }

/* Admin (legacy stats – still used elsewhere) */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.stat-card strong { display: block; font-size: 1.75rem; }
.stat-card span { font-size: .8125rem; color: var(--muted); }

/* Admin hub */
.admin-page .app-content {
  max-width: 1120px;
  padding-top: 0;
}
.admin-page .app-topbar {
  background: transparent;
  border-bottom: none;
  padding-bottom: 0;
}
.admin-page .app-topbar h1 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  margin-bottom: 1.75rem;
  padding: .35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}
.admin-nav__link {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem 1rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.admin-nav__link:hover { background: #f8fafc; color: var(--text); }
.admin-nav__link.is-active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}
.admin-nav__link--muted { margin-left: auto; font-size: .8125rem; }
.admin-nav__icon { font-size: 1rem; line-height: 1; }

.admin-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
  padding: 1.75rem 2rem;
  border-radius: 16px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 55%, #0f766e 100%);
  color: #fff;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .18);
}
.admin-hero--compact { padding: 1.35rem 1.75rem; }
.admin-hero__eyebrow {
  margin: 0 0 .35rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255, 255, 255, .65);
}
.admin-hero__title {
  margin: 0 0 .5rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.admin-hero--compact .admin-hero__title { font-size: 1.35rem; margin-bottom: .25rem; }
.admin-hero__desc {
  margin: 0;
  font-size: .9375rem;
  color: rgba(255, 255, 255, .8);
  max-width: 36rem;
  line-height: 1.5;
}
.admin-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
.admin-stat {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
  transition: transform .15s, box-shadow .15s;
}
.admin-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}
.admin-stat__icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  border-radius: 12px;
  flex-shrink: 0;
}
.admin-stat--users .admin-stat__icon { background: #ede9fe; }
.admin-stat--conversations .admin-stat__icon { background: #dbeafe; }
.admin-stat--messages .admin-stat__icon { background: var(--primary-light); }
.admin-stat--channels .admin-stat__icon { background: #d1fae5; }
.admin-stat__value {
  display: block;
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.1;
}
.admin-stat__label {
  font-size: .8125rem;
  color: var(--muted);
  font-weight: 500;
}

.admin-section { margin-bottom: 2rem; }
.admin-section__head { margin-bottom: 1rem; }
.admin-section__head h3 {
  margin: 0 0 .25rem;
  font-size: 1.125rem;
  font-weight: 700;
}
.admin-section__head p {
  margin: 0;
  font-size: .875rem;
  color: var(--muted);
}

.admin-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .85rem;
}
.admin-quick-card {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.admin-quick-card:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 20px rgba(255, 79, 66, .12);
  transform: translateY(-2px);
  color: inherit;
}
.admin-quick-card__icon { font-size: 1.5rem; line-height: 1; }
.admin-quick-card__title { font-weight: 700; font-size: .9375rem; }
.admin-quick-card__desc { font-size: .8125rem; color: var(--muted); line-height: 1.4; }

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}
.admin-card--flush { padding: 0; overflow: hidden; }
.admin-card__head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.admin-card__head h3 { margin: 0 0 .25rem; font-size: 1.0625rem; }
.admin-card__head p { margin: 0; font-size: .875rem; color: var(--muted); }
.admin-card__head-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--primary-light);
  border-radius: 10px;
  flex-shrink: 0;
}

.admin-form__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.admin-field { display: block; }
.admin-field__label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--text);
}
.admin-field input,
.admin-field select {
  width: 100%;
  padding: .6rem .8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.admin-field input:focus,
.admin-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 79, 66, .15);
}
.admin-form__actions { margin-top: 1.25rem; }

.admin-table-wrap { border: none; border-radius: 0; }
.admin-table th {
  padding: .85rem 1.25rem;
  background: #f8fafc;
}
.admin-table td {
  padding: 1rem 1.25rem;
  vertical-align: middle;
}
.admin-table__muted { color: var(--muted); font-size: .8125rem; }
.admin-table__empty {
  text-align: center;
  padding: 2.5rem 1rem !important;
  color: var(--muted);
}
.admin-table__empty a { font-weight: 600; }
.admin-table__actions-col { width: 200px; text-align: right; }

.admin-channel {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.admin-channel__icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.admin-channel strong { display: block; font-size: .9375rem; }
.admin-channel small { display: block; font-size: .75rem; color: var(--muted); margin-top: .1rem; }

.admin-user-cell {
  display: flex;
  align-items: center;
  gap: .85rem;
}
.admin-user-cell__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #e63e32);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.admin-user-cell strong { display: block; font-size: .9375rem; }
.admin-user-cell small { display: block; font-size: .8125rem; color: var(--muted); margin-top: .1rem; }
.admin-user-cell__you {
  display: inline-block;
  margin-left: .35rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .1rem .35rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 4px;
  vertical-align: middle;
}

.admin-row-actions form {
  display: flex;
  justify-content: flex-end;
  gap: .35rem;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.status-pill--success { background: #d1fae5; color: #065f46; }
.status-pill--warning { background: #fef3c7; color: #92400e; }
.status-pill--danger { background: #fee2e2; color: #991b1b; }
.status-pill--muted { background: #f1f5f9; color: #64748b; }
.status-pill--success::before,
.status-pill--warning::before,
.status-pill--danger::before,
.status-pill--muted::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}

.admin-hint {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: .8125rem;
  color: var(--muted);
}
.admin-hint strong {
  display: block;
  color: var(--text);
  margin-bottom: .5rem;
  font-size: .875rem;
}
.admin-hint ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.admin-hint li {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

@media (max-width: 1024px) {
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .admin-quick-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Logs & System health */
.log-tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
}
.log-tabs__link {
  padding: .5rem 1rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
}
.log-tabs__link.is-active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}
.log-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
  font-size: .8125rem;
}
.log-filters a {
  padding: .3rem .65rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid transparent;
}
.log-filters a.is-active,
.log-filters a:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.log-filters__purge { margin-left: auto; }
.log-list { max-height: 70vh; overflow-y: auto; }
.log-list__empty { padding: 2rem; text-align: center; color: var(--muted); }
.log-entry {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--border);
}
.log-entry.log-level--error { border-left-color: var(--danger); background: #fffbfb; }
.log-entry.log-level--warning { border-left-color: var(--warning); background: #fffef8; }
.log-entry.log-level--info { border-left-color: #3b82f6; }
.log-entry__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  margin-bottom: .35rem;
}
.log-entry__level {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.log-entry__head time { font-size: .75rem; color: var(--muted); }
.log-entry__msg { margin: 0; font-size: .875rem; line-height: 1.45; word-break: break-word; }
.log-entry__meta { margin: .35rem 0 0; font-size: .75rem; color: var(--muted); }
.log-entry__ctx { margin-top: .5rem; font-size: .75rem; }
.log-entry__ctx pre {
  margin: .35rem 0 0;
  padding: .65rem;
  background: #f8fafc;
  border-radius: 6px;
  overflow-x: auto;
  font-size: .7rem;
}
.log-payload summary { cursor: pointer; font-size: .8125rem; color: var(--primary); }
.log-payload pre {
  max-width: 320px;
  max-height: 120px;
  overflow: auto;
  font-size: .65rem;
  margin-top: .35rem;
}
.log-pagination {
  display: flex;
  gap: .35rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.log-pagination a {
  padding: .35rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  font-size: .8125rem;
  color: var(--text);
}
.log-pagination a.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }

.health-grid { display: flex; flex-direction: column; }
.health-row {
  display: grid;
  grid-template-columns: 100px 180px 1fr;
  gap: 1rem;
  align-items: center;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.health-row:last-child { border-bottom: none; }
.health-row__detail { color: var(--muted); font-size: .8125rem; }
.health-row__detail a { font-weight: 600; }

@media (max-width: 768px) {
  .health-row { grid-template-columns: 1fr; gap: .35rem; }
}

@media (max-width: 640px) {
  .admin-hero { padding: 1.25rem; }
  .admin-hero__actions { width: 100%; }
  .admin-hero__actions .btn { flex: 1; }
  .admin-nav__link--muted { margin-left: 0; width: 100%; justify-content: center; }
  .admin-stats { grid-template-columns: 1fr; }
  .admin-quick-grid { grid-template-columns: 1fr; }
  .admin-form__grid { grid-template-columns: 1fr; }
  .admin-table__actions-col { width: auto; }
  .admin-row-actions form { justify-content: flex-start; }
}

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: .2rem .5rem; border-radius: 4px; font-size: .7rem; font-weight: 600; }
.badge--admin { background: #ede9fe; color: #5b21b6; }
.badge--agent { background: #dbeafe; color: #1e40af; }
.badge--viewer { background: #f1f5f9; color: #475569; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1rem; }
.card h3 { margin: 0 0 1rem; }

/* Settings hub */
.settings-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  align-items: start;
}
.settings-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  position: sticky;
  top: 1rem;
}
.settings-sidebar__title {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 0 0 .75rem;
  font-weight: 700;
}
.settings-sidebar__link {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .65rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: .875rem;
  margin-bottom: .15rem;
}
.settings-sidebar__link:hover { background: #f1f5f9; }
.settings-sidebar__link.is-active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.settings-content { min-width: 0; }
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.settings-panel h2 { margin: 0 0 .35rem; font-size: 1.25rem; }
.settings-panel > p { color: var(--muted); font-size: .875rem; margin: 0 0 1.25rem; }
.settings-subheading {
  font-size: .8125rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 1.25rem 0 .5rem;
  grid-column: 1 / -1;
}
.form-row-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.checkbox-label { display: flex !important; align-items: center; gap: .5rem; font-weight: 400 !important; }
.channel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}
.channel-tab {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .8125rem;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
}
.channel-tab.is-active { border-color: var(--primary); background: var(--primary-light); font-weight: 600; }
.profile-header { display: flex; align-items: center; gap: 1rem; }
.package-badge {
  margin-top: .5rem;
  font-size: .8125rem;
  background: #fef3c7;
  color: #92400e;
  padding: .35rem .65rem;
  border-radius: 8px;
  display: inline-block;
}
.package-badge--empty { background: #f1f5f9; color: var(--muted); }
.package-badge__link { margin-left: .5rem; font-weight: 600; }
.template-picker {
  padding: .45rem .5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .8125rem;
  max-width: 140px;
}
.chat-compose { flex-wrap: wrap; }
.chat-compose textarea { min-width: 200px; }

/* Team Chat */
.team-chat {
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.team-chat__intro { padding: 1rem 1.25rem; margin: 0; font-size: 0.875rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.team-chat__messages { max-height: 420px; overflow-y: auto; padding: 1rem; }
.team-chat__msg { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.team-chat__avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; flex-shrink: 0;
}
.team-chat__msg p { margin: 0.25rem 0 0; font-size: 0.9375rem; }
.team-chat__time { font-size: 0.7rem; color: var(--muted); margin-left: 0.5rem; }
.team-chat__compose {
  display: flex; gap: 0.5rem;
  padding: 1rem; border-top: 1px solid var(--border);
}
.team-chat__compose input { flex: 1; padding: 0.65rem; border: 1px solid var(--border); border-radius: 8px; }

@media (max-width: 900px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-sidebar { position: static; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.is-open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .inbox-layout { grid-template-columns: 1fr; height: auto; }
  .conversation-list { max-height: 280px; border-right: none; border-bottom: 1px solid var(--border); }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-tabs { flex-direction: row; flex-wrap: wrap; }
}
