:root {
  --bg: #f6f4ef;
  --bg-accent: #ece7df;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-strong: #ffffff;
  --ink: #111111;
  --muted: #6a6864;
  --line: rgba(17, 17, 17, 0.1);
  --line-strong: rgba(17, 17, 17, 0.16);
  --dark: #171717;
  --dark-2: #202020;
  --dark-3: #2b2b2b;
  --success: #0f7a55;
  --warning: #9a6700;
  --danger: #b42318;
  --accent: #111111;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(17, 17, 17, 0.08);
  --shadow-soft: 0 10px 30px rgba(17, 17, 17, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), transparent 28%),
    radial-gradient(circle at bottom right, rgba(230, 223, 212, 0.85), transparent 22%),
    linear-gradient(180deg, #f9f7f2 0%, #f3efe8 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(255, 255, 255, 0.9), transparent 30%),
    linear-gradient(180deg, #f7f5f0 0%, #f1ece4 100%);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: -0.01em;
}

body.modal-open {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(17, 17, 17, 0.02), transparent 35%),
    radial-gradient(circle at 80% 10%, rgba(17, 17, 17, 0.03), transparent 18%);
}

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

button {
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--dark);
  color: white;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: #000;
  box-shadow: var(--shadow-soft);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  background: var(--panel-strong);
  color: var(--ink);
  border-color: var(--line-strong);
}

button.secondary:hover {
  background: #f4f1ec;
}

button.danger {
  background: #fff;
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.2);
}

button.danger:hover {
  background: rgba(180, 35, 24, 0.06);
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

button.ghost:hover {
  background: rgba(17, 17, 17, 0.04);
  border-color: rgba(17, 17, 17, 0.18);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(17, 17, 17, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  padding: 11px 12px;
  min-height: 44px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(17, 17, 17, 0.38);
  box-shadow: 0 0 0 4px rgba(17, 17, 17, 0.06);
  background: #fff;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

label input,
label select,
label textarea {
  color: var(--ink);
  font-size: 14px;
}

.sidebar {
  min-height: 100vh;
  position: sticky;
  top: 0;
  padding: 24px 18px;
  color: rgba(255, 255, 255, 0.86);
  background:
    linear-gradient(180deg, #151515 0%, #101010 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08) inset;
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: auto 18px 18px 18px;
  height: 180px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
  opacity: 0.8;
  pointer-events: none;
}

.brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  color: #fff;
  background:
    linear-gradient(180deg, #2c2c2c 0%, #141414 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 15px;
  color: #fff;
}

.brand span {
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
}

nav {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
}

.tab {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  text-align: left;
  border-radius: 14px;
  border: 1px solid transparent;
  min-height: 46px;
  padding: 0 14px;
}

.tab.active,
.tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.08);
}

main {
  min-width: 0;
  position: relative;
  z-index: 1;
}

.topbar {
  min-height: 108px;
  padding: 26px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 248, 243, 0.72);
  backdrop-filter: blur(18px);
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

h1 {
  font-size: 30px;
  font-weight: 650;
}

h2 {
  font-size: 18px;
  font-weight: 650;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

#toast {
  min-width: 220px;
  min-height: 38px;
  display: grid;
  align-items: center;
  justify-content: end;
  color: var(--success);
  font-size: 14px;
}

.view {
  display: none;
  padding: 26px 32px 42px;
}

.view.active {
  display: grid;
  gap: 18px;
  animation: fadeUp 220ms ease both;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.metric {
  padding: 18px;
  display: grid;
  gap: 10px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 30px;
  font-weight: 650;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

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

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

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

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

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

.result {
  min-height: 22px;
  color: var(--success);
}

.webhook-box {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
}

.webhook-box span {
  color: var(--muted);
  font-size: 13px;
}

.webhook-box code {
  overflow-wrap: anywhere;
}

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

.filter-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 180px) minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(15, 122, 85, 0.08);
  color: var(--success);
  font-size: 12px;
  border: 1px solid rgba(15, 122, 85, 0.12);
}

.badge.warn {
  background: rgba(154, 103, 0, 0.08);
  color: var(--warning);
  border-color: rgba(154, 103, 0, 0.14);
}

.badge.fail {
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.14);
}

.status-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.status-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal.open {
  display: flex;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.58);
  backdrop-filter: blur(8px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 22px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(17, 17, 17, 0.08);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.24);
}

.modal-panel-wide {
  width: min(920px, 100%);
}

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

.modal-header p {
  margin-top: 6px;
}

.modal-close {
  flex: 0 0 auto;
}

.modal-stack {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.modal-inline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-inline-head h3 {
  margin: 0;
  font-size: 15px;
}

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

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

@media (max-width: 1024px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
    box-shadow: none;
  }

  .sidebar::after {
    display: none;
  }

  nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-grid,
  .split,
  .form-grid.two,
  .filter-row {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .view,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  nav {
    grid-template-columns: 1fr 1fr;
  }

  .metric strong {
    font-size: 26px;
  }

  .modal {
    padding: 12px;
  }

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

  .modal-header,
  .modal-inline-head {
    flex-direction: column;
    align-items: stretch;
  }
}
