:root {
  --ink: #172033;
  --muted: #6d7688;
  --line: #e7eaf0;
  --bg: #f6f8fc;
  --primary: #5a57e8;
  --green: #0d9f6e;
  --red: #dd4c56;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    14px/1.45 Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}

.app {
  min-height: 100vh;
  display: flex;
}

/* =========================================================
   SIDEBAR
   ========================================================= */

aside {
  position: fixed;
  inset: 0 auto 0 0;

  width: 252px;

  padding: 28px 16px;

  background: #11182b;
  color: #aab4c9;

  display: flex;
  flex-direction: column;
}

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

  padding: 0 10px 30px;

  color: #fff;

  text-decoration: none;

  font-size: 20px;
  font-weight: 800;
}

.brand b {
  display: grid;
  place-items: center;

  width: 30px;
  height: 30px;

  border-radius: 9px;

  background: linear-gradient(135deg, #7775ff, #4e48d9);
}

.brand span {
  color: #8381ff;
}

.nav-links,
nav {
  display: grid;
  gap: 6px;
}

nav a {
  color: #aeb8cf;

  text-decoration: none;

  padding: 11px 12px;

  border-radius: 8px;

  font-weight: 600;
}

nav a:hover,
nav a.active {
  background: #222b45;
  color: #fff;
}

/* =========================================================
   USER
   ========================================================= */

.user {
  margin-top: auto;

  display: flex;
  align-items: center;

  gap: 9px;

  padding: 12px 8px;

  border-top: 1px solid #28324a;
}

.user i {
  font-style: normal;

  background: #5a57e8;
  color: #fff;

  width: 30px;
  height: 30px;

  border-radius: 50%;

  display: grid;
  place-items: center;

  font-weight: 700;
}

.user span {
  color: #fff;
  font-weight: 600;
  flex: 1;
}

.user small {
  display: block;
  color: #8e9ab3;
  font-weight: 400;
}

.user button {
  border: 0;
  background: none;

  color: #aeb8cf;

  font-size: 20px;

  cursor: pointer;
}

/* =========================================================
   MAIN CONTENT
   ========================================================= */

main {
  margin-left: 252px;

  width: calc(100% - 252px);

  /* Keep the desktop frame tidy without sacrificing usable table width. */
  padding: 46px clamp(28px, 2.5vw, 48px);
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  gap: 24px;

  margin-bottom: 30px;
}

.page-head h1 {
  margin: 5px 0;

  font-size: 30px;

  letter-spacing: -0.8px;
}

.page-head p,
.panel-head p,
.form-card > p {
  margin: 0;

  color: var(--muted);
}

/* =========================================================
   EYEBROW
   ========================================================= */

em,
.eyebrow {
  margin: 0;

  font-size: 11px;
  font-style: normal;

  color: #7775ea;

  font-weight: 800;

  letter-spacing: 1.3px;
}

/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 42px;

  background: var(--primary);
  color: #fff;

  border: 0;
  border-radius: 8px;

  padding: 10px 16px;

  text-decoration: none;

  font: 700 14px inherit;

  cursor: pointer;

  box-shadow: 0 5px 14px #5a57e83b;
}

.btn:hover {
  filter: brightness(0.96);
}

.btn:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 3px solid #b9b8ff;
  outline-offset: 2px;
}

.secondary {
  background: #fff;
  color: var(--ink);

  box-shadow: 0 1px 2px #00000010;

  border: 1px solid var(--line);
}

.actions {
  display: flex;
  flex-wrap: wrap;

  gap: 10px;
}

.actions form {
  margin: 0;
}

/* =========================================================
   METRICS
   ========================================================= */

.metrics {
  display: grid;

  grid-template-columns: repeat(4, 1fr);

  gap: 16px;

  margin-bottom: 24px;
}

.metrics article,
.panel,
.form-card {
  background: #fff;

  border: 1px solid var(--line);
  border-radius: 12px;

  box-shadow: 0 2px 8px #11182b08;
}

.metrics article {
  padding: 20px;

  display: grid;

  gap: 8px;

  border-top: 3px solid #6971f3;
}

.metrics .good {
  border-top-color: var(--green);
}

.metrics .bad {
  border-top-color: var(--red);
}

.metrics span {
  color: var(--muted);

  font-weight: 600;
}

.metrics strong {
  font-size: 27px;

  letter-spacing: -1px;
}

.mini {
  grid-template-columns: repeat(3, 1fr);
}

.mini strong {
  font-size: 16px;

  letter-spacing: 0;
}

/* =========================================================
   PANELS
   ========================================================= */

.panel {
  overflow: hidden;
}

.panel-head {
  padding: 20px 22px;

  display: flex;
  justify-content: space-between;
  align-items: center;

  gap: 16px;
}

.panel-head h2 {
  margin: 0 0 4px;

  font-size: 16px;
}

.history-head {
  padding-block: 18px;
}

.page-size-form {
  display: flex;
  align-items: center;

  gap: 8px;

  color: var(--muted);

  font-weight: 700;

  white-space: nowrap;
}

.page-size-form select {
  min-height: 38px;

  padding: 8px 30px 8px 10px;

  border: 1px solid #d8ddea;
  border-radius: 7px;

  background: #fff;

  color: var(--ink);

  font: inherit;
}

.compact-btn {
  min-height: 38px;

  padding: 8px 12px;
}

.inventory-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 20px;
}

.inventory-filters select,
.inventory-filters input {
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #d8ddea;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.inventory-filters input {
  min-width: 220px;
  flex: 1;
}
.inventory-filters button[type="submit"] {
  display: none;
}

.table-actions {
  white-space: nowrap;
}
.table-actions a,
.table-actions button {
  margin-right: 10px;
  border: 0;
  background: transparent;
  color: #5654d8;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.table-actions button {
  color: #b72937;
}
.table-actions form {
  display: inline;
}

.inventory-toggle {
  display: block;
  margin: 24px 0 16px;
  font-weight: 700;
}

#optional-database {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

#optional-database h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

/* =========================================================
   TABLE
   ========================================================= */

.scroll {
  overflow: auto;
}

table {
  width: 100%;

  border-collapse: collapse;

  text-align: left;
}

th {
  background: #fafbfe;

  color: #7a8497;

  font-size: 11px;

  letter-spacing: 0.5px;

  text-transform: uppercase;
}

th,
td {
  padding: 15px 22px;

  border-top: 1px solid var(--line);
}

tbody tr:hover {
  background: #fafbfe;
}

td a {
  color: var(--ink);

  text-decoration: none;

  font-weight: 700;
}

td small {
  display: block;

  color: var(--muted);

  font-size: 12px;

  margin-top: 3px;
}

/* =========================================================
   BADGES
   ========================================================= */

code {
  font:
    12px ui-monospace,
    monospace;

  color: #505b70;
}

.badge {
  display: inline-block;

  padding: 5px 9px;

  border-radius: 20px;

  font-size: 11px;

  letter-spacing: 0.3px;

  text-transform: uppercase;
}

.up {
  background: #e5f8ef;
  color: #087b52;
}

.down {
  background: #ffeaec;
  color: #b72937;
}

.unknown {
  background: #f0f2f5;
  color: #667085;
}

/* =========================================================
   EMPTY / BACK / TITLE
   ========================================================= */

.empty {
  text-align: center;

  padding: 48px !important;

  color: var(--muted);

  line-height: 2;
}

.empty strong {
  color: var(--ink);
}

.back {
  display: inline-block;

  margin-bottom: 20px;

  color: #6268d8;

  text-decoration: none;

  font-weight: 700;
}

.title {
  display: flex;
  align-items: center;

  gap: 12px;
}

/* Toast notifications */
.toast-stack {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 30;
  display: grid;
  gap: 12px;
  width: min(390px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid #dfe3ec;
  border-left: 4px solid #6971f3;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 36px #11182b2e;
  animation: toast-in 0.24s ease-out;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.success {
  border-left-color: var(--green);
}
.toast.error {
  border-left-color: var(--red);
}
.toast-hiding {
  opacity: 0;
  transform: translateX(18px);
}
.toast-icon {
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #eef0ff;
  color: #5654d8;
  font-weight: 800;
}
.toast.success .toast-icon {
  background: #e5f8ef;
  color: #087b52;
}
.toast.error .toast-icon {
  background: #ffeaec;
  color: #b72937;
}
.toast-copy {
  display: grid;
  gap: 2px;
  flex: 1;
}
.toast-copy strong {
  font-size: 14px;
}
.toast-copy small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.toast-close {
  margin: -5px -5px 0 0;
  padding: 3px 6px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #8991a1;
  font-size: 20px;
  cursor: pointer;
}
.toast-close:hover {
  background: #f0f2f5;
  color: var(--ink);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================
   PAGINATION
   ========================================================= */

.pagination {
  display: grid;

  grid-template-columns: 1fr auto 1fr;

  align-items: center;

  gap: 12px;

  padding: 16px 22px;

  border-top: 1px solid var(--line);
}

.page-link {
  color: #5654d8;

  font-weight: 700;

  text-decoration: none;
}

.page-link:last-child {
  justify-self: end;
}

.page-link.disabled {
  color: #a5adba;
}

.page-status {
  color: var(--muted);

  font-weight: 600;

  text-align: center;
}

/* =========================================================
   NORMAL FORMS
   ========================================================= */

.form-page {
  max-width: 840px;
}

.form-card {
  padding: 36px;
}

.form-card h1 {
  margin: 6px 0;
}

.form-card > p:last-of-type {
  max-width: 58ch;
}

.field {
  margin: 24px 0;
}

.field label {
  display: block;

  font-weight: 700;

  margin-bottom: 7px;
}

.field input:not([type="checkbox"]),
.field textarea,
.field select {
  width: 100%;

  padding: 11px 12px;

  border: 1px solid #d8ddea;
  border-radius: 7px;

  background: #fff;

  font: inherit;
}

.field textarea {
  min-height: 130px;

  resize: vertical;
}

.field small {
  display: block;

  color: var(--muted);

  margin-top: 5px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: #7775ea;

  outline: 3px solid #e7e7ff;
}

.checkbox-field {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 20px;

  padding: 16px;

  border: 1px solid var(--line);
  border-radius: 9px;

  background: #fafbfe;
}

.checkbox-field label {
  margin: 0;
}

.checkbox-field small {
  margin-bottom: 0;
}

.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;

  accent-color: var(--primary);
}

.error,
.form-errors {
  color: #b72937;

  font-size: 12px;
}

.error {
  display: block;

  margin-top: 6px;
}

.form-errors {
  margin: 20px 0;

  padding: 12px 14px;

  border: 1px solid #f4c8cc;
  border-radius: 8px;

  background: #ffeaec;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;

  gap: 18px;

  margin-top: 32px;

  padding-top: 24px;

  border-top: 1px solid var(--line);
}

.form-actions a {
  color: var(--muted);

  text-decoration: none;

  font-weight: 700;
}

.auth {
  margin: 0;

  width: 100%;

  min-height: 100vh;

  display: grid;
  place-items: center;

  background:
    radial-gradient(circle at 10% 10%, #e7e7ff, transparent 32%), var(--bg);
}

.login-brand {
  color: var(--ink);
}

/* =========================================================
   DASHBOARD RESPONSIVE
   ========================================================= */

@media (max-width: 800px) {
  aside {
    position: static;

    width: 100%;
    height: auto;

    padding: 16px;

    flex-direction: row;
    align-items: center;
  }

  .app {
    display: block;
  }

  .brand {
    padding: 0;
  }

  .user {
    margin: 0 0 0 auto;

    border: 0;

    padding: 0;
  }

  nav {
    display: none;
  }

  main {
    margin: 0;

    width: 100%;

    padding: 28px 18px;
  }

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

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

@media (max-width: 560px) {
  .page-head,
  .history-head {
    align-items: flex-start;

    flex-direction: column;
  }

  .actions,
  .actions form,
  .actions .btn {
    width: 100%;
  }

  .page-size-form {
    width: 100%;

    flex-wrap: wrap;
  }

  .inventory-filters {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .inventory-filters input {
    min-width: 0;
  }

  .page-size-form select {
    flex: 1;
  }

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

  .page-status {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .page-link:last-child {
    justify-self: end;
  }
}

@media (max-width: 480px) {
  .metrics {
    grid-template-columns: 1fr;
  }

  .page-head h1 {
    font-size: 24px;
  }

  th,
  td {
    padding: 13px 16px;
  }
}

/* =========================================================
   SERVER MODAL
   ========================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;

  z-index: 1000;

  display: grid;
  place-items: center;

  padding: 24px;

  background: rgba(17, 24, 43, 0.58);

  backdrop-filter: blur(3px);
}

.modal-backdrop[hidden],
.user-api-form[hidden] {
  display: none;
}

.panel[aria-busy="true"] {
  opacity: 0.72;
}

.pagination button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.pagination button:disabled {
  color: #a5adba;
  cursor: default;
}

/* =========================================================
   MODAL CARD
   ========================================================= */

.modal-card {
  width: min(860px, calc(100vw - 48px));

  max-height: calc(100vh - 48px);

  display: flex;
  flex-direction: column;

  overflow: hidden;

  background: #fff;

  border: 1px solid #dfe3ec;
  border-radius: 16px;

  box-shadow: 0 24px 70px rgba(17, 24, 43, 0.28);
}

/* =========================================================
   MODAL HEADER
   ========================================================= */

.modal-head {
  flex: 0 0 auto;

  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  gap: 20px;

  padding: 24px 28px 18px;
}

.modal-title-group {
  display: flex;
  align-items: flex-start;

  gap: 14px;
}

.modal-icon {
  display: grid;
  place-items: center;

  flex: 0 0 46px;

  width: 46px;
  height: 46px;

  border-radius: 11px;

  background: #f1f0ff;

  color: var(--primary);
}

.server-modal .eyebrow {
  margin: 1px 0 4px;

  font-size: 11px;

  line-height: 1.3;

  letter-spacing: 1.25px;
}

.modal-head h2 {
  margin: 0;

  font-size: 26px;
  line-height: 1.2;

  letter-spacing: -0.5px;
}

.server-modal .modal-description {
  margin: 6px 0 0;

  color: var(--muted);

  font-size: 14px;

  line-height: 1.5;
}

.modal-close {
  display: grid;
  place-items: center;

  flex: 0 0 34px;

  width: 34px;
  height: 34px;

  border-radius: 8px;

  color: #737b8d;

  text-decoration: none;

  font-size: 28px;
  font-weight: 300;

  line-height: 1;

  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.modal-close:hover {
  background: #f3f4f7;

  color: var(--ink);
}

/* =========================================================
   MODAL FORM
   ========================================================= */

.server-modal form {
  min-height: 0;

  display: flex;
  flex-direction: column;

  flex: 1;
}

.modal-body {
  flex: 1;

  min-height: 0;

  overflow-y: auto;

  padding: 12px 28px 24px;
}

/* =========================================================
   MODAL GRID
   ========================================================= */

.modal-form-grid {
  display: grid;

  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 18px 20px;
}

.server-modal .field {
  margin: 0;
}

.server-modal .field label {
  display: block;

  margin: 0 0 7px;

  color: var(--ink);

  font-size: 13px;

  font-weight: 700;
}

/* =========================================================
   MODAL INPUTS
   ========================================================= */

.server-modal .field input:not([type="checkbox"]),
.server-modal .field textarea,
.server-modal .field select {
  width: 100%;

  min-height: 46px;

  padding: 11px 13px;

  border: 1px solid #d8ddea;
  border-radius: 8px;

  background: #fff;

  color: var(--ink);

  font: inherit;

  font-size: 14px;

  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.server-modal .field input:focus,
.server-modal .field textarea:focus,
.server-modal .field select:focus {
  outline: none;

  border-color: #7775ea;

  box-shadow: 0 0 0 3px #e9e8ff;
}

.server-modal input::placeholder,
.server-modal textarea::placeholder {
  color: #9aa2b1;

  opacity: 1;
}

/* =========================================================
   CHECK INTERVAL
   ========================================================= */

.input-with-suffix {
  position: relative;
}

.input-with-suffix input {
  padding-right: 80px !important;
}

.input-with-suffix > span {
  position: absolute;

  top: 50%;
  right: 13px;

  transform: translateY(-50%);

  color: var(--muted);

  font-size: 12px;

  font-weight: 600;

  pointer-events: none;
}

/* =========================================================
   ACTIVE
   ========================================================= */

.active-field {
  min-width: 0;
}

.active-field-content {
  min-height: 46px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 16px;

  padding: 7px 12px;

  border: 1px solid var(--line);
  border-radius: 8px;

  background: #fafbfe;
}

.active-field-content > div {
  min-width: 0;
}

.active-field-content label {
  margin: 0 !important;
}

.active-field-content small {
  display: block;

  margin: 2px 0 0;

  color: var(--muted);

  font-size: 11px;
}

/* =========================================================
   SWITCH
   ========================================================= */

.switch {
  position: relative;

  flex: 0 0 40px;

  width: 40px;
  height: 22px;

  margin: 0 !important;

  cursor: pointer;
}

.switch input {
  position: absolute;

  width: 1px;
  height: 1px;

  opacity: 0;
}

.switch-slider {
  position: absolute;

  inset: 0;

  border-radius: 999px;

  background: #c9ced8;

  transition: background 0.2s ease;
}

.switch-slider::before {
  content: "";

  position: absolute;

  top: 3px;
  left: 3px;

  width: 16px;
  height: 16px;

  border-radius: 50%;

  background: #fff;

  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);

  transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider {
  background: var(--primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-slider {
  outline: 3px solid #c9c8ff;

  outline-offset: 2px;
}

/* =========================================================
   DESCRIPTION
   ========================================================= */

.description-field {
  grid-column: 1 / -1;
}

.server-modal .description-field textarea {
  min-height: 92px;

  max-height: 160px;

  resize: vertical;
}

.optional-label {
  margin-left: 5px;

  color: #929aab;

  font-size: 11px;

  font-weight: 500;
}

/* =========================================================
   REQUIRED
   ========================================================= */

.required {
  color: var(--red);
}

/* =========================================================
   MODAL ERRORS
   ========================================================= */

.server-modal .error {
  display: block;

  margin-top: 5px;

  color: #b72937;

  font-size: 12px;
}

/* =========================================================
   MODAL FOOTER
   ========================================================= */

.server-modal .form-actions {
  flex: 0 0 auto;

  display: flex;
  align-items: center;
  justify-content: flex-end;

  gap: 10px;

  margin: 0;

  padding: 16px 28px 20px;

  border-top: 1px solid var(--line);

  background: #fcfcfe;
}

.server-modal .form-actions .btn {
  min-width: auto;

  min-height: 42px;

  padding: 9px 16px;

  font-size: 14px;
}

.server-modal .form-actions .secondary {
  min-width: 90px;
}

.button-plus {
  display: inline-grid;
  place-items: center;

  width: 19px;
  height: 19px;

  margin-right: 7px;

  border-radius: 50%;

  background: #fff;

  color: var(--primary);

  font-size: 16px;

  line-height: 1;
}

/* =========================================================
   MODAL TABLET
   ========================================================= */

@media (max-width: 700px) {
  .modal-backdrop {
    padding: 16px;
  }

  .modal-card {
    width: 100%;

    max-height: calc(100vh - 32px);
  }

  .modal-head {
    padding: 20px 20px 16px;
  }

  .modal-body {
    padding: 10px 20px 20px;
  }

  .modal-form-grid {
    grid-template-columns: 1fr;

    gap: 16px;
  }

  .description-field {
    grid-column: auto;
  }

  .server-modal .form-actions {
    padding: 15px 20px 18px;
  }
}

/* =========================================================
   MODAL MOBILE
   ========================================================= */

@media (max-width: 480px) {
  .modal-backdrop {
    padding: 10px;

    align-items: center;
  }

  .modal-card {
    max-height: calc(100vh - 20px);

    border-radius: 12px;
  }

  .modal-icon {
    width: 40px;
    height: 40px;

    flex-basis: 40px;
  }

  .modal-title-group {
    gap: 10px;
  }

  .modal-head h2 {
    font-size: 22px;
  }

  .server-modal .modal-description {
    font-size: 13px;
  }

  .modal-head {
    padding: 18px 16px 14px;
  }

  .modal-body {
    padding: 8px 16px 18px;
  }

  .server-modal .form-actions {
    padding: 14px 16px 16px;
  }

  .server-modal .form-actions .btn {
    flex: 1;
  }
}
