:root {
  color-scheme: dark;
  --black: #0a0a0d;
  --surface: #121218;
  --surface-raised: #1c1c24;
  --surface-hover: #2a2a35;
  --border: #2a2a35;
  --text: #ffffff;
  --muted: #a8a8b3;
  --muted-strong: #d1d1d8;
  --success: #37b873;
  --warning: #f2b21e;
  --danger: #ee4d4d;
  --info: #4d8eee;
  --orange: #f2801e;
  --coral: #ee4d5c;
  --magenta: #c72e83;
  --violet: #7b3ea0;
  --indigo: #423a92;
  --gradient: linear-gradient(90deg, var(--orange), var(--coral), var(--magenta), var(--violet), var(--indigo));
}

* { box-sizing: border-box; }

html { background: var(--black); }

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

a { color: var(--text); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  min-height: 62px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 13, 0.98);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-right: 42px;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  display: block;
  width: 164px;
  height: auto;
}

.brand span {
  padding-left: 14px;
  border-left: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.primary-nav {
  display: flex;
  align-items: stretch;
  gap: 26px;
}

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.nav-link:hover,
.nav-link.active { color: var(--text); }

.nav-link.active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--gradient);
}

.admin-menu {
  position: relative;
  align-self: center;
  margin-left: auto;
}

.admin-menu summary {
  cursor: pointer;
  color: var(--muted-strong);
  font-weight: 600;
  list-style: none;
}

.admin-menu summary::-webkit-details-marker { display: none; }
.admin-menu summary::after { content: "⌄"; margin-left: 8px; color: var(--muted); }

.admin-menu-content {
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  z-index: 30;
  display: grid;
  min-width: 190px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

.admin-menu-content a,
.menu-action {
  width: 100%;
  justify-content: flex-start;
  padding: 10px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-strong);
  text-align: left;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.admin-menu-content a:hover,
.menu-action:hover { background: var(--surface-hover); color: var(--text); }
.admin-menu-content form { display: block; }

main {
  position: relative;
  isolation: isolate;
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.admin-shell {
  width: 100%;
  padding: 28px;
}

.admin-shell::before {
  content: "";
  position: fixed;
  z-index: -1;
  left: 4%;
  bottom: 2%;
  width: min(58vw, 880px);
  aspect-ratio: 1192 / 182;
  background: url("/assets/hubyone-logo.jpg") center / contain no-repeat;
  opacity: 0.045;
  pointer-events: none;
}

.panel {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.panel + .panel { margin-top: 16px; }
.panel.flush { padding: 0; overflow: hidden; }

h1, h2, h3 {
  margin: 0 0 10px;
  font-family: Poppins, Inter, ui-sans-serif, system-ui, sans-serif;
  line-height: 1.18;
  letter-spacing: 0;
}

h1 { font-size: 38px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 600; }
h3 { font-size: 17px; font-weight: 600; }
p { margin: 0 0 16px; color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.page-header p { margin: 0; }
.page-actions { display: flex; align-items: center; gap: 10px; }

.client-context {
  display: grid;
  gap: 2px;
  margin-bottom: 18px;
  padding-left: 14px;
  border-left: 3px solid var(--coral);
}

.client-context span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.client-context strong { font-family: Poppins, Inter, sans-serif; font-size: 18px; }

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #3d3d4a;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--black);
  font: inherit;
}

input::placeholder, textarea::placeholder { color: #82828f; }
textarea { min-height: 132px; resize: vertical; }

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid rgba(238, 77, 92, 0.55);
  outline-offset: 2px;
  border-color: var(--coral);
}

.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; color: var(--muted); }
.check input { width: 18px; min-height: 18px; margin-top: 2px; accent-color: var(--text); }

.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 15px;
  background: var(--text);
  color: var(--black);
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button:hover, button:hover { background: #ececf0; }
.button.secondary, button.secondary { border-color: #3d3d4a; background: transparent; color: var(--text); }
.button.secondary:hover, button.secondary:hover { background: var(--surface-hover); }
.button.danger, button.danger { border-color: rgba(238, 77, 77, 0.45); background: rgba(238, 77, 77, 0.1); color: #ff8888; }
.button.compact, button.compact { min-height: 34px; padding: 6px 10px; font-size: 12px; }

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

.filters,
.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(4, minmax(130px, 1fr)) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 10px;
}

.toolbar {
  grid-template-columns: minmax(280px, 2fr) minmax(160px, 1fr) auto;
  margin: 0;
}

.report-filters { grid-template-columns: repeat(4, minmax(140px, 1fr)) auto; }
.filter-panel { margin-bottom: 12px; }

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.metric-dot { grid-row: span 2; align-self: center; width: 9px; height: 9px; border-radius: 50%; background: var(--info); }
.metric.warning .metric-dot { background: var(--warning); }
.metric.danger .metric-dot { background: var(--danger); }
.metric strong { font-family: Poppins, sans-serif; font-size: 22px; line-height: 1; }
.metric span { color: var(--muted); font-size: 12px; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
th { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }

.ticket-link { display: block; max-width: 120px; overflow: hidden; color: #8bb8ff; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.subject-cell { min-width: 220px; max-width: 320px; }
.subject-cell strong { display: block; color: var(--muted-strong); font-weight: 600; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--surface-hover);
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.info { color: #79aaff; background: rgba(77, 142, 238, 0.12); }
.badge.success { color: #65d69a; background: rgba(55, 184, 115, 0.12); }
.badge.warning { color: #f6c451; background: rgba(242, 178, 30, 0.12); }
.badge.danger { color: #ff7777; background: rgba(238, 77, 77, 0.12); }
.badge.neutral::before { background: var(--muted); }

.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.detail-item { border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--surface-raised); }
.detail-item span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.conversation { display: grid; gap: 12px; margin-bottom: 18px; }
.message { max-width: 82%; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface-raised); }
.message.team { margin-left: auto; border-color: rgba(77, 142, 238, 0.3); background: rgba(77, 142, 238, 0.08); }
.message-meta { color: var(--muted); font-size: 11px; margin-bottom: 6px; }

.alert { padding: 12px 14px; margin-bottom: 16px; border: 1px solid rgba(238, 77, 77, 0.35); border-radius: 8px; background: rgba(238, 77, 77, 0.08); color: #ff8d8d; }
.alert.success { border-color: rgba(55, 184, 115, 0.35); background: rgba(55, 184, 115, 0.08); color: #73dda5; }
.secret-value, .recovery-codes code, pre.description { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-raised); }
.secret-value { display: block; overflow-wrap: anywhere; padding: 10px 12px; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 16px 0 20px; }
.recovery-codes code { padding: 10px 12px; text-align: center; font-size: 15px; }
pre.description { white-space: pre-wrap; overflow-wrap: anywhere; padding: 14px; font: inherit; }
.mfa-setup { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: center; margin-bottom: 20px; }
.mfa-qr { width: 220px; height: 220px; border: 6px solid #fff; border-radius: 8px; background: #fff; }

.client-layout { display: grid; grid-template-columns: minmax(0, 1fr); min-height: calc(100vh - 118px); }
.client-layout.with-drawer { grid-template-columns: minmax(0, 1fr) minmax(390px, 34vw); margin: -28px; }
.client-main { min-width: 0; }
.client-layout.with-drawer .client-main { padding: 28px; }
.client-drawer { position: sticky; top: 62px; height: calc(100vh - 62px); overflow-y: auto; padding: 28px; border-left: 1px solid var(--border); background: rgba(18, 18, 24, 0.98); }
.drawer-header { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.drawer-close { color: var(--muted); text-decoration: none; font-size: 26px; line-height: 1; }
.drawer-footer { display: grid; grid-template-columns: 1fr 1.1fr; gap: 12px; margin-top: 12px; }
.help { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }
.client-name { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.client-avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #3d3d4a; color: var(--text); }
.client-avatar.active { background: rgba(55, 184, 115, 0.28); color: #86e7b3; }

.virtual-assistant { position: fixed; right: 22px; bottom: 22px; z-index: 80; }
.assistant-launcher { position: relative; display: flex; align-items: center; gap: 12px; min-height: 62px; padding: 8px 17px 8px 9px; border: 1px solid rgba(255, 255, 255, 0.17); border-radius: 999px; background: rgba(13, 13, 26, 0.94); box-shadow: 0 18px 52px rgba(0, 0, 0, 0.42); color: var(--text); cursor: pointer; }
.assistant-launcher:hover { border-color: rgba(236, 29, 154, 0.46); }
.assistant-launcher-copy { display: flex; flex-direction: column; min-width: 142px; text-align: left; }
.assistant-launcher-copy small { margin-bottom: 2px; color: var(--muted); font-size: 10px; }
.assistant-launcher-copy strong { font-size: 13px; }
.assistant-launcher-status { position: absolute; top: 8px; left: 40px; width: 12px; height: 12px; border: 3px solid #0d0d1a; border-radius: 50%; background: #52dc8b; }

.support-assistant-chat {
  position: absolute;
  right: 0;
  bottom: 76px;
  display: flex;
  flex-direction: column;
  width: min(430px, calc(100vw - 30px));
  height: min(650px, calc(100vh - 174px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 24px;
  background: rgba(9, 9, 20, 0.97);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.58);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, 22px, 0) scale(0.96);
  transform-origin: right bottom;
  transition: opacity 220ms ease, transform 260ms cubic-bezier(.2, .7, .2, 1);
}

.virtual-assistant.is-open .support-assistant-chat { opacity: 1; pointer-events: auto; transform: translate3d(0, 0, 0) scale(1); }
.support-assistant-chat::before { position: absolute; top: -80px; right: -70px; width: 230px; height: 180px; background: var(--gradient); content: ""; filter: blur(90px); opacity: 0.12; pointer-events: none; }
.assistant-chat-header { position: relative; display: flex; flex: 0 0 72px; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid var(--border); }
.assistant-identity { display: flex; align-items: center; gap: 11px; }
.assistant-identity > div { display: flex; flex-direction: column; gap: 3px; }
.assistant-identity strong { font-family: Poppins, Inter, sans-serif; font-size: 16px; }
.assistant-identity small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.assistant-identity small i { width: 6px; height: 6px; border-radius: 50%; background: #52dc8b; }
.assistant-avatar { position: relative; display: flex; flex: 0 0 39px; align-items: center; justify-content: center; width: 39px; height: 39px; overflow: hidden; border-radius: 50%; background: #090913; }
.assistant-avatar::after { position: absolute; inset: -6px; border-radius: 50%; background: conic-gradient(from 0deg, #ff8500, #f02490 34%, #6e2aff 67%, #ff8500); content: ""; }
.assistant-avatar::before { position: absolute; z-index: 1; width: 30px; height: 30px; border-radius: 50%; background: #090913; content: ""; }
.assistant-avatar > i { position: relative; z-index: 2; width: 4px; height: 4px; border-radius: 50%; background: #fff; }
.assistant-avatar > i + i { margin-left: 6px; }
.assistant-minimize { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; }
.assistant-messages { display: flex; flex: 1 1 auto; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding: 20px 18px 14px; scrollbar-color: #35354c transparent; scrollbar-width: thin; }
.assistant-message { display: flex; flex-direction: column; max-width: 88%; }
.assistant-message.assistant { align-self: flex-start; }
.assistant-message.user { align-self: flex-end; }
.assistant-message-author { margin: 0 0 5px 7px; color: #85859a; font-size: 9px; font-weight: 700; text-transform: uppercase; }
.assistant-message p { margin: 0; padding: 12px 14px; border-radius: 17px; font-size: 14px; line-height: 1.55; white-space: pre-line; }
.assistant-message.assistant p { border: 1px solid rgba(255, 255, 255, 0.08); border-bottom-left-radius: 5px; background: #171727; color: #dddde6; }
.assistant-message.user p { border-bottom-right-radius: 5px; background: var(--gradient); color: #fff; }
.assistant-message time { margin-top: 4px; padding: 0 4px; color: #6f6f83; font-size: 9px; }
.assistant-message.user time { text-align: right; }
.assistant-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 7px; max-height: 128px; overflow-y: auto; padding: 0 18px 14px; }
.assistant-choice-form { display: contents; }
.assistant-choice { display: inline-flex; align-items: center; min-height: 38px; padding: 9px 13px; border: 1px solid var(--border); border-radius: 999px; background: rgba(255, 255, 255, 0.035); color: #e1e1e8; text-decoration: none; font: 600 12px Inter, sans-serif; cursor: pointer; }
.assistant-choice:hover { border-color: rgba(236, 29, 154, 0.38); background: rgba(236, 29, 154, 0.09); color: #fff; }
.assistant-choice.primary { border-color: #fff; background: #fff; color: #080811; }
.assistant-input { display: flex; flex: 0 0 60px; align-items: center; gap: 8px; padding: 9px 11px 9px 16px; border-top: 1px solid var(--border); }
.assistant-input input { min-width: 0; flex: 1; padding: 0; border: 0; background: transparent; color: #fff; font-size: 14px; outline: 0; }
.assistant-input input::placeholder { color: #646478; }
.assistant-input button { display: flex; flex: 0 0 38px; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: var(--gradient); color: #fff; }
.assistant-input button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
@media (max-width: 1050px) {
  .filters { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .filters label:first-child { grid-column: span 2; }
  .filters .actions { grid-column: 1 / -1; }
  .client-layout.with-drawer { grid-template-columns: minmax(0, 1fr) minmax(360px, 44vw); }
}

@media (max-width: 760px) {
  .app-header { min-height: auto; flex-wrap: wrap; padding: 10px 16px 0; }
  .brand { gap: 9px; margin-right: auto; }
  .brand img { width: 126px; }
  .brand span { padding-left: 9px; font-size: 11px; }
  .primary-nav { order: 3; width: 100%; gap: 20px; overflow-x: auto; }
  .nav-link { min-height: 42px; white-space: nowrap; }
  .admin-menu { align-self: flex-start; margin-top: 9px; }
  main, .admin-shell { width: 100%; padding: 20px 14px 36px; }
  .admin-shell::before { width: 88vw; bottom: 4%; }
  h1 { font-size: 30px; }
  .page-header { align-items: stretch; flex-direction: column; }
  .page-actions .button { width: 100%; }
  .grid, .detail-grid, .filters, .toolbar, .report-filters, .mfa-setup, .recovery-codes, .summary-strip { grid-template-columns: 1fr; }
  .filters label:first-child, .filters .actions { grid-column: auto; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { padding: 16px; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .client-layout.with-drawer { display: block; margin: -20px -14px -36px; }
  .client-layout.with-drawer .client-main { display: none; }
  .client-drawer { position: static; height: auto; min-height: calc(100vh - 104px); padding: 20px 16px; border-left: 0; }
  .drawer-footer { grid-template-columns: 1fr; }
  .virtual-assistant { right: 14px; bottom: 14px; }
  .assistant-launcher { min-height: 56px; padding-right: 10px; }
  .assistant-launcher-copy { display: none; }
  .support-assistant-chat { right: 0; bottom: 66px; width: calc(100vw - 28px); height: min(650px, calc(100vh - 194px)); border-radius: 20px; }
  .assistant-input input { font-size: 16px; }
  .ticket-table thead { display: none; }
  .ticket-table, .ticket-table tbody, .ticket-table tr, .ticket-table td { display: block; width: 100%; }
  .ticket-table tr { padding: 12px; border-bottom: 1px solid var(--border); }
  .ticket-table td { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 6px 0; border: 0; }
  .ticket-table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
  .ticket-link { max-width: 100%; }
  .subject-cell { min-width: 0; max-width: none; }
}

@media (prefers-reduced-motion: no-preference) {
  a, button, input, select, textarea { transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease; }
}
