:root {
  --bg: #09111f;
  --bg-soft: #111b2c;
  --panel: rgba(11, 21, 36, 0.84);
  --panel-strong: rgba(10, 19, 33, 0.96);
  --panel-border: rgba(118, 149, 193, 0.18);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f3f7fc;
  --muted: #9baec6;
  --accent: #1f7bef;
  --accent-strong: #56a9ff;
  --success: #63d6a6;
  --danger: #ff7f8e;
  --warning: #ffd37a;
  --shadow: 0 24px 72px rgba(0, 0, 0, 0.34);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(31, 123, 239, 0.24), transparent 28%),
    radial-gradient(circle at left center, rgba(16, 55, 100, 0.42), transparent 36%),
    linear-gradient(180deg, #07111c 0%, #0c1728 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.82), transparent);
}

a {
  color: inherit;
}

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

.page-shell {
  position: relative;
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.page-shell.narrow {
  width: min(760px, calc(100% - 24px));
  padding-top: 48px;
}

.topbar,
.panel,
.tool-card,
.admin-card,
.login-hero {
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 14px;
  height: 56px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-strong), #0b427f);
  box-shadow: 0 0 40px rgba(86, 169, 255, 0.5);
}

.eyebrow,
.section-kicker,
.tool-kicker,
.group-label {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
}

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

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 16px 30px rgba(31, 123, 239, 0.28);
}

.button.danger {
  color: white;
  background: linear-gradient(135deg, #d84f61, #ff7f8e);
  box-shadow: 0 16px 30px rgba(216, 79, 97, 0.22);
}

.button.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--line);
}

.button.ghost.active {
  border-color: rgba(86, 169, 255, 0.45);
  color: #dcecff;
}

.button.full-width {
  width: 100%;
}

.button.button-small {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.92rem;
}

.danger-outline {
  border-color: rgba(255, 127, 142, 0.3);
  color: #ffd6dc;
}

.user-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.user-chip span {
  font-size: 0.9rem;
  color: var(--muted);
}

.panel,
.login-hero,
.tool-card,
.admin-card {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.panel-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.lead {
  margin-top: 14px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.flash {
  margin-top: 18px;
  padding: 15px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.flash-success {
  background: rgba(99, 214, 166, 0.12);
  border-color: rgba(99, 214, 166, 0.35);
}

.flash-error {
  background: rgba(255, 127, 142, 0.12);
  border-color: rgba(255, 127, 142, 0.35);
}

.login-body .page-shell {
  display: grid;
  gap: 22px;
}

.login-hero {
  padding: 30px;
  background:
    linear-gradient(135deg, rgba(12, 20, 33, 0.95), rgba(11, 30, 57, 0.88)),
    linear-gradient(180deg, transparent, transparent);
}

.login-hero h1 {
  margin-top: 10px;
  font-size: clamp(2.8rem, 8vw, 4.8rem);
  letter-spacing: -0.05em;
  line-height: 0.95;
}

.auth-panel h2,
.hero-panel h2,
.tool-hero h2 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.02;
}

.stack-form {
  display: grid;
  gap: 16px;
}

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

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

.field span {
  color: var(--muted);
  font-size: 0.94rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 14px 16px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  outline: none;
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(86, 169, 255, 0.52);
  box-shadow: 0 0 0 3px rgba(31, 123, 239, 0.12);
}

.dashboard-layout,
.tool-layout,
.admin-layout {
  display: grid;
  gap: 22px;
  margin-top: 22px;
}

.hero-panel {
  padding: 30px;
}

.admin-overview-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.admin-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats-grid,
.tool-grid,
.admin-grid {
  display: grid;
  gap: 16px;
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 24px;
}

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

.stat-card,
.meta-item {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.stat-card span,
.meta-item span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-card strong,
.meta-item strong,
.inline-badge {
  font-size: 1rem;
}

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

.tool-card {
  display: grid;
  gap: 14px;
  padding: 22px;
  background: linear-gradient(180deg, rgba(13, 22, 35, 0.9), rgba(11, 19, 33, 0.82));
}

.tool-card h3,
.admin-card h3 {
  font-size: 1.4rem;
}

.tool-card p:not(.tool-kicker) {
  color: var(--muted);
  line-height: 1.65;
}

.tool-layout {
  grid-template-columns: 1.1fr 0.9fr;
}

.tool-hero {
  padding: 30px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.meta-grid.single-column {
  grid-template-columns: 1fr;
}

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

.users-panel {
  overflow: hidden;
}

.panel-head-inline {
  align-items: center;
  justify-content: space-between;
  flex-direction: row;
}

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.02);
}

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

.users-table th,
.users-table td {
  padding: 18px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.users-table th {
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: rgba(255, 255, 255, 0.02);
}

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

.user-main {
  display: grid;
  gap: 6px;
}

.table-subtle {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

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

.role-pill,
.status-pill,
.tool-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  border: 1px solid var(--line);
}

.role-pill {
  background: rgba(255, 255, 255, 0.04);
}

.role-pill-admin {
  background: rgba(86, 169, 255, 0.12);
  border-color: rgba(86, 169, 255, 0.22);
  color: #dcecff;
}

.status-pill-active {
  color: #061b14;
  background: linear-gradient(180deg, #7ae2b0, #63d6a6);
  border-color: transparent;
}

.status-pill-inactive {
  color: #ffd6dc;
  background: rgba(255, 127, 142, 0.14);
  border-color: rgba(255, 127, 142, 0.28);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 28px 14px;
  background: rgba(3, 9, 19, 0.7);
  backdrop-filter: blur(12px);
}

.modal-card {
  width: min(820px, 100%);
  max-height: calc(100vh - 56px);
  overflow: auto;
  padding: 24px;
  border-radius: 28px;
  border: 1px solid var(--panel-border);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

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

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 8px;
}

.modal-role-list {
  display: grid;
  gap: 14px;
}

.role-card {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.role-card-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

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

.tool-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.tool-pill {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

.confirm-copy {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.toggle,
.checkbox-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.toggle span,
.checkbox-card strong,
.checkbox-card small {
  display: block;
}

.toggle input,
.checkbox-card input {
  margin-top: 4px;
}

.checkbox-card small {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.checkbox-group {
  display: grid;
  gap: 10px;
}

.card-stack {
  display: grid;
  gap: 18px;
}

.admin-card {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.admin-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.inline-badge {
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(86, 169, 255, 0.12);
  border: 1px solid rgba(86, 169, 255, 0.22);
  color: #dcedff;
}

.empty-state {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.16);
  color: var(--muted);
}

@media (max-width: 1080px) {
  .tool-layout,
  .admin-grid,
  .tool-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

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

  .admin-overview-head,
  .role-card-head {
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 18px, 1240px);
    padding-top: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .actions {
    width: 100%;
  }

  .user-chip {
    width: 100%;
    align-items: flex-start;
  }

  .field-grid,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .admin-toolbar,
  .modal-actions {
    width: 100%;
    justify-content: stretch;
  }

  .admin-toolbar .button,
  .modal-actions .button {
    width: 100%;
  }

  .table-shell {
    border: 0;
    background: transparent;
  }

  .users-table,
  .users-table thead,
  .users-table tbody,
  .users-table th,
  .users-table td,
  .users-table tr {
    display: block;
  }

  .users-table thead {
    display: none;
  }

  .users-table tbody {
    display: grid;
    gap: 14px;
  }

  .users-table tr {
    padding: 18px;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
  }

  .users-table td {
    padding: 0;
    border-bottom: 0;
  }

  .users-table td + td {
    margin-top: 12px;
  }

  .users-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
  }

  .table-actions {
    margin-top: 4px;
  }

  .modal-overlay {
    padding: 12px;
  }

  .modal-card {
    padding: 18px;
    max-height: calc(100vh - 24px);
  }
}
