:root {
  color-scheme: dark;
  --bg: #080b14;
  --panel: #171b2d;
  --panel-2: #1f2438;
  --panel-3: #2a3046;
  --line: #303755;
  --line-soft: rgba(148, 163, 184, 0.14);
  --text: #f8fafc;
  --muted: #9aa4b8;
  --faint: #687187;
  --brand: #8b7cff;
  --brand-2: #6f7dff;
  --ok: #37e6a1;
  --danger: #ff6575;
  --warn: #f6c945;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius: 18px;
  --z-modal: 50;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% -10%, rgba(111, 125, 255, 0.2), transparent 26rem),
    linear-gradient(180deg, #111521 0, #080b14 40rem);
  color: var(--text);
  font-family: "Fira Sans", ui-sans-serif, system-ui, sans-serif;
  line-height: 1.5;
  -webkit-tap-highlight-color: rgba(139, 124, 255, 0.24);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.hidden {
  display: none !important;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 100;
  transform: translateY(-160%);
  border-radius: 999px;
  background: var(--brand);
  color: white;
  padding: 10px 14px;
  text-decoration: none;
  transition: transform 180ms ease;
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.min-w-0 {
  min-width: 0;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
}

.login-card {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(31, 36, 56, 0.96), rgba(20, 24, 39, 0.98));
  box-shadow: var(--shadow);
  padding: 34px;
}

.brand-mark,
.brand-icon {
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--brand), #3b82f6);
  color: #fff;
}

.brand-mark {
  width: 54px;
  height: 54px;
  margin-bottom: 24px;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(34px, 8vw, 52px);
  line-height: 1;
  text-wrap: balance;
}

h2 {
  margin-bottom: 4px;
  font-size: 22px;
}

h3 {
  margin-bottom: 6px;
  font-size: 16px;
}

.login-copy,
.toolbar-card p,
.modal-header p,
.muted,
.status {
  color: var(--muted);
}

.login-form,
.modal-form,
.form-section {
  display: grid;
  gap: 12px;
}

label {
  color: #d7ddec;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #202538;
  color: var(--text);
  padding: 12px 14px;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #6f7890;
}

.form-error {
  min-height: 22px;
  color: var(--danger);
  font-size: 14px;
}

.primary-button,
.danger-button,
.ghost-button,
.action-button,
.icon-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  padding: 0 18px;
  box-shadow: 0 10px 28px rgba(111, 125, 255, 0.26);
}

.primary-button:hover {
  box-shadow: 0 14px 36px rgba(111, 125, 255, 0.34);
}

.ghost-button {
  border-color: var(--line);
  background: #1b2032;
  color: #dbe2f1;
  padding: 0 16px;
}

.danger-button {
  border-color: rgba(255, 101, 117, 0.45);
  background: rgba(255, 101, 117, 0.1);
  color: #ff8f99;
  padding: 0 16px;
}

.ghost-button:hover,
.danger-button:hover,
.action-button:hover,
.icon-button:hover {
  border-color: #58617d;
  background: #252b42;
}

.app-view {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 260px 1fr auto;
  gap: 18px;
  align-items: center;
  min-height: 66px;
  border-bottom: 1px solid #1e2434;
  background: rgba(17, 21, 33, 0.94);
  padding: 0 28px;
  backdrop-filter: blur(18px);
}

.brand,
.nav-tab,
.top-actions,
.toolbar,
.row-actions,
.email-cell,
.tag-list,
.state,
.pagination-bar,
.pagination-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  color: #d9d5ff;
  font-size: 18px;
  font-weight: 700;
}

.nav-tabs {
  display: flex;
  gap: 8px;
}

.nav-tab {
  gap: 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
}

.nav-tab.active {
  background: rgba(139, 124, 255, 0.18);
  color: #c9c3ff;
}

.top-actions {
  gap: 12px;
}

.page-shell {
  width: min(1350px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 26px 0 60px;
}

.toolbar-card {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: center;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(25, 29, 47, 0.96);
  box-shadow: var(--shadow);
  padding: 26px 28px;
}

.docs-toolbar {
  grid-template-columns: 1fr auto;
}

.toolbar {
  justify-content: flex-end;
  gap: 10px;
}

.select-control {
  min-width: 124px;
}

.page-size-control {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.page-size-control select {
  width: 92px;
}

.search-control {
  position: relative;
  width: min(280px, 100%);
}

.search-control input {
  padding-right: 42px;
}

.search-control svg {
  position: absolute;
  right: 13px;
  top: 50%;
  color: #7d879d;
  transform: translateY(-50%);
}

.table-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 27, 45, 0.98);
  box-shadow: var(--shadow);
}

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

.pagination-bar {
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line-soft);
  padding: 14px 18px;
}

.pagination-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.page-indicator {
  min-width: 72px;
  color: #d7ddec;
  text-align: center;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th {
  background: #2a3042;
  color: #aeb7c8;
  font-weight: 700;
  text-align: left;
}

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 16px 18px;
  vertical-align: middle;
}

.checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
}

td {
  color: #dfe5f3;
}

tbody tr {
  transition: background-color 180ms ease;
}

tbody tr:hover {
  background: rgba(139, 124, 255, 0.07);
}

.email-cell {
  min-width: 0;
  gap: 10px;
}

.email-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 14px rgba(139, 124, 255, 0.9);
}

.email-text {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-list {
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  border-radius: 999px;
  background: rgba(111, 125, 255, 0.18);
  color: #aeb6ff;
  padding: 5px 10px;
}

.owner-tag {
  background: rgba(55, 230, 161, 0.12);
  color: #8df0c7;
  font-family: "Fira Code", ui-monospace, monospace;
}

.code-tag {
  display: inline-flex;
  width: fit-content;
  margin-top: 8px;
  color: #0f172a;
  background: var(--warn);
}

.state {
  gap: 7px;
  font-weight: 700;
}

.state span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.state.ok {
  color: var(--ok);
}

.state.ok span {
  background: var(--ok);
}

.state.error {
  color: var(--danger);
}

.state.error span {
  background: var(--danger);
}

.row-actions {
  gap: 8px;
}

.action-button {
  border-color: #404a72;
  background: transparent;
  color: #b8c3ff;
  padding: 0 12px;
}

.action-button.danger {
  border-color: rgba(255, 101, 117, 0.5);
  color: #ff8995;
}

.action-button.neutral {
  color: #d2d8e8;
}

.empty-state,
.empty-line {
  color: var(--muted);
  padding: 32px;
  text-align: center;
}

.modal,
.drawer {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  overscroll-behavior: contain;
}

.modal-backdrop,
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 16, 0.72);
  backdrop-filter: blur(8px);
}

.modal-panel,
.drawer-panel {
  position: relative;
  border: 1px solid var(--line);
  background: #171b2d;
  box-shadow: var(--shadow);
}

.modal-panel {
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100vh - 42px);
  margin: 20px auto;
  overflow-y: auto;
  border-radius: 22px;
  padding: 24px;
}

.drawer-panel {
  width: min(620px, 100vw);
  height: 100%;
  margin-left: auto;
  overflow-y: auto;
  border-radius: 22px 0 0 22px;
  padding: 24px;
}

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

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-color: var(--line);
  background: #202538;
  color: #dfe5f3;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #111625;
  padding: 5px;
}

.mode-tab {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}

.mode-tab.active {
  background: rgba(139, 124, 255, 0.22);
  color: #e2ddff;
}

.hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.messages-list {
  display: grid;
  gap: 12px;
}

.message-card {
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: #1d2235;
  padding: 16px;
}

.message-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.message-head h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.message-head span {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 13px;
}

.message-card p {
  overflow-wrap: anywhere;
}

.docs-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(14, 18, 31, 0.98);
  box-shadow: var(--shadow);
  padding: 22px;
}

.docs-card pre {
  margin: 0;
  overflow-x: auto;
  color: #dce5f7;
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .topbar,
  .toolbar-card {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .top-actions,
  .pagination-bar {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

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

  .page-shell {
    width: min(100vw - 20px, 1350px);
    padding-top: 16px;
  }

  .toolbar-card {
    padding: 18px;
  }

  .modal-panel,
  .drawer-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    margin: 0;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
