:root {
  --bg-top: #0d1828;
  --bg-bottom: #040a13;
  --sidebar: rgba(8, 16, 28, 0.94);
  --panel: rgba(17, 31, 50, 0.92);
  --panel-border: rgba(138, 165, 205, 0.14);
  --text: #f3f6fb;
  --muted: #8ea4c1;
  --muted-strong: #b4c3d8;
  --gold: #d4af37;
  --gold-soft: #f6d982;
  --success: #4fd098;
  --warning: #e9b24e;
  --danger: #f26d6d;
  --info: #6aa0ff;
  --shadow: 0 26px 60px rgba(3, 8, 16, 0.38);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI Variable Text", "Aptos", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(212, 175, 55, 0.12), transparent 26%),
    radial-gradient(circle at 85% 10%, rgba(90, 140, 255, 0.16), transparent 24%),
    radial-gradient(circle at bottom left, rgba(79, 208, 152, 0.1), transparent 22%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(transparent 95%, rgba(255, 255, 255, 0.03) 96%, transparent 97%),
    linear-gradient(90deg, transparent 95%, rgba(255, 255, 255, 0.02) 96%, transparent 97%);
  background-size: 28px 28px;
  opacity: 0.22;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  padding: 24px 20px;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(180deg, var(--sidebar) 0%, rgba(5, 10, 18, 0.98) 100%);
  backdrop-filter: blur(18px);
}

.workspace {
  padding: 28px;
}

.sidebar-block,
.panel,
.auth-card {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel) 0%, rgba(9, 17, 31, 0.92) 100%);
  box-shadow: var(--shadow);
}

.sidebar-block {
  padding: 20px;
  margin-bottom: 16px;
}

.panel {
  padding: 22px;
}

.brand-panel h1,
.workspace-header h2,
.panel h3,
.auth-card h2 {
  font-family: "Aptos Display", "Segoe UI Variable Display", "Trebuchet MS", sans-serif;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--gold-soft);
}

.brand-panel h1,
.workspace-header h2,
.panel h3,
.auth-card h2,
p {
  margin-top: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.note-title,
.status-label {
  margin: 0 0 10px;
  font-weight: 700;
  color: var(--muted-strong);
}

.status-row,
.panel-head,
.workspace-header,
.header-actions,
.panel-actions,
.status-actions,
.editor-actions,
.scrape-actions {
  display: flex;
  gap: 12px;
}

.status-row,
.workspace-header,
.panel-head {
  justify-content: space-between;
  align-items: flex-start;
}

.panel-head.compact {
  margin-bottom: 16px;
}

.workspace-header {
  margin-bottom: 20px;
}

.panel-actions,
.header-actions,
.status-actions,
.editor-actions,
.scrape-actions {
  flex-wrap: wrap;
  align-items: center;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill {
  background: rgba(255, 255, 255, 0.08);
}

.badge.success {
  background: rgba(79, 208, 152, 0.14);
  color: var(--success);
}

.badge.warning {
  background: rgba(233, 178, 78, 0.14);
  color: var(--warning);
}

.badge.danger {
  background: rgba(242, 109, 109, 0.14);
  color: var(--danger);
}

.badge.info {
  background: rgba(106, 160, 255, 0.14);
  color: var(--info);
}

.badge.neutral {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted-strong);
}

.nav-panel {
  display: grid;
  gap: 10px;
}

.nav-button,
button {
  font: inherit;
}

.nav-button,
.ghost-button,
.primary-button,
.mini-button {
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.nav-button:hover,
.ghost-button:hover,
.primary-button:hover,
.mini-button:hover {
  transform: translateY(-1px);
}

.nav-button,
.ghost-button,
.mini-button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-button {
  width: 100%;
  padding: 13px 14px;
  text-align: left;
  font-weight: 600;
}

.nav-button.active {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.22) 0%, rgba(212, 175, 55, 0.08) 100%);
  border-color: rgba(212, 175, 55, 0.28);
  color: #fff3cf;
}

.ghost-button,
.primary-button {
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  font-weight: 700;
}

.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ghost-button.danger {
  color: #ffd7d7;
  background: rgba(242, 109, 109, 0.12);
}

.ghost-button.active {
  border-color: rgba(212, 175, 55, 0.32);
  background: rgba(212, 175, 55, 0.16);
  color: #fff0bf;
}

.primary-button {
  color: #172132;
  background: linear-gradient(135deg, var(--gold) 0%, #f4d77b 100%);
}

button:disabled {
  opacity: 0.62;
  cursor: wait;
  transform: none;
}

input,
textarea,
select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  transition: border-color 0.16s ease, background 0.16s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(212, 175, 55, 0.6);
  background: rgba(255, 255, 255, 0.06);
}

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

label,
fieldset {
  display: grid;
  gap: 8px;
  min-width: 0;
}

label span,
fieldset legend {
  color: var(--muted-strong);
  font-size: 13px;
}

fieldset {
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}

.toggle-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--gold);
}

.toggle-field span {
  color: var(--text);
}

.banner {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(106, 160, 255, 0.12);
  color: #d7e6ff;
}

.banner.success {
  background: rgba(79, 208, 152, 0.14);
  color: #d4f8e9;
}

.banner.warning {
  background: rgba(233, 178, 78, 0.14);
  color: #fff0c9;
}

.banner.danger {
  background: rgba(242, 109, 109, 0.14);
  color: #ffd6d6;
}

.auth-view {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 56px);
}

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

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

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

.stat-card {
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(20, 35, 56, 0.94) 0%, rgba(12, 22, 36, 0.94) 100%);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-value {
  margin-top: 10px;
  font-size: 34px;
  font-weight: 800;
}

.stat-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.overview-grid,
.academies-grid,
.support-grid,
.users-grid {
  display: grid;
  gap: 20px;
}

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

.users-grid {
  grid-template-columns: minmax(560px, 1.35fr) minmax(340px, 0.95fr);
}

.support-grid {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.summary-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted-strong);
  font-size: 12px;
}

.mini-list,
.case-list,
.import-summary {
  display: grid;
  gap: 12px;
}

.mini-list-item,
.case-card,
.message-bubble {
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}

.mini-list-item,
.case-card {
  padding: 14px;
}

.case-card {
  width: 100%;
  color: inherit;
  text-align: left;
}

.case-card.active {
  border-color: rgba(212, 175, 55, 0.42);
  background: rgba(212, 175, 55, 0.1);
}

.case-card-meta,
.list-meta,
.empty-state,
.muted-row {
  color: var(--muted);
  font-size: 13px;
}

.case-title,
.mini-list-item strong,
.table-primary {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

tbody tr.selected-row {
  background: rgba(212, 175, 55, 0.08);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.mini-button.danger {
  color: #ffd7d7;
  background: rgba(242, 109, 109, 0.12);
}

.mini-button.accent {
  color: #fff1c4;
  background: rgba(212, 175, 55, 0.14);
}

.detail-panel {
  min-height: 620px;
}

.message-thread {
  display: grid;
  gap: 12px;
  min-height: 300px;
  max-height: 560px;
  overflow: auto;
  padding-right: 6px;
  margin-bottom: 18px;
}

.thread-row {
  display: flex;
}

.thread-row.admin {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(88%, 660px);
  padding: 14px;
}

.thread-row.admin .message-bubble {
  background: rgba(212, 175, 55, 0.16);
  border-color: rgba(212, 175, 55, 0.25);
}

.message-sender {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-strong);
}

.message-text {
  margin: 8px 0;
  white-space: pre-wrap;
  line-height: 1.55;
}

.message-time {
  font-size: 12px;
  color: var(--muted);
}

.message-image {
  display: block;
  max-width: 220px;
  margin-top: 10px;
  border-radius: var(--radius-sm);
}

.reply-form {
  display: grid;
  gap: 12px;
}

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

.academy-form .span-2,
.settings-form .span-2,
.user-form .span-2 {
  grid-column: 1 / -1;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.align-end {
  display: flex;
  justify-content: flex-end;
}

.import-summary {
  min-height: 180px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}

.import-summary h4 {
  margin: 0;
}

.summary-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.summary-list li {
  color: var(--muted-strong);
}

.search-input {
  min-width: 220px;
  max-width: 340px;
}

.scrape-form {
  display: grid;
  gap: 14px;
}

.table-location,
.table-secondary {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
}

.muted-row {
  padding: 16px 0;
}

.mono {
  font-family: "Cascadia Code", "Consolas", monospace;
}

@media (max-width: 1400px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }

  .support-grid,
  .users-grid,
  .overview-grid,
  .academies-grid,
  .settings-form,
  .academy-form,
  .user-form {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

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

  .panel,
  .auth-card,
  .sidebar-block {
    padding: 18px;
  }

  .workspace-header,
  .panel-head,
  .panel-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input {
    min-width: 0;
    max-width: none;
  }
}
