/* Pintop Webhook Router
   Official brand values from the Pintop Technologies Brand Guidelines:
   dark blue #215273, dark moderate cyan #359D9E, light grayish lime #CFF4D2.
   Typeface: Helvetica (Neue Haas Grotesk). */

:root {
  --brand-blue: #215273;
  --brand-blue-deep: #1a4260;
  --brand-blue-ink: #143449;
  --brand-teal: #359d9e;
  --brand-teal-deep: #2b8384;
  --brand-lime: #cff4d2;

  --canvas: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #f0f4f0;
  --surface-3: #e9efea;
  --ink: #14232e;
  --ink-2: #3c505c;
  --muted: #5d707b;
  --line: #dee6e2;
  --line-strong: #c8d4ce;

  --success: #176b45;
  --success-bg: #e7f4ec;
  --warn: #7a5200;
  --warn-bg: #fbf1da;
  --danger: #a8231b;
  --danger-bg: #fbeae8;
  --info: #215273;
  --info-bg: #e8f0f5;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 35, 46, 0.05);
  --shadow-pop: 0 18px 40px rgba(16, 34, 45, 0.18);

  --font: "Helvetica Neue", Helvetica, "Neue Haas Grotesk Text Pro", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  --sidebar-w: 252px;
  --content-max: 1240px;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, dl, dd, ol, ul {
  margin: 0;
}

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.012em;
  line-height: 1.25;
}

ul, ol {
  padding: 0;
  list-style: none;
}

a {
  color: var(--brand-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

img, svg {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--brand-teal);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: var(--brand-lime);
  color: var(--brand-blue-ink);
}

.sr-only {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--brand-lime);
  color: var(--brand-blue-ink);
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: top 0.15s var(--ease);
}

.skip-link:focus {
  top: 12px;
  text-decoration: none;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.mono-sm,
.code-value,
.code-block,
.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

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

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

.inline-form {
  display: inline-flex;
  margin: 0;
}

.inline-form button {
  margin: 0;
}

/* ---------- Layout ---------- */

.app-body {
  background: var(--canvas);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 30px 34px 48px;
  flex: 1;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 34px 26px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--brand-blue);
  color: #e8f1f4;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 6px;
}

.sidebar-brand {
  display: block;
  padding: 2px 0 14px;
}

.sidebar-brand:hover {
  text-decoration: none;
}

.brand-logo {
  width: 156px;
  height: auto;
}

.sidebar .sidebar-close {
  display: none;
  color: #e8f1f4;
}

.sidebar-context {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 10px 18px;
  padding: 7px 10px;
  border: 1px solid rgba(207, 244, 210, 0.18);
  border-radius: 999px;
  color: #cfe6e4;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-weight: 700;
  width: fit-content;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-lime);
  flex: none;
}

.status-dot-off {
  background: #8fa3ad;
}

.status-dot-on {
  background: var(--brand-lime);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-heading {
  margin: 16px 12px 6px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #9fb8c2;
  font-weight: 700;
}

.nav-heading:first-child {
  margin-top: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #d7e5e8;
  font-weight: 500;
  position: relative;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
  text-decoration: none;
}

.nav-link.is-active {
  background: rgba(207, 244, 210, 0.13);
  color: #ffffff;
}

.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--brand-lime);
}

.nav-link .icon {
  color: #a9c6cd;
}

.nav-link.is-active .icon,
.nav-link:hover .icon {
  color: var(--brand-lime);
}

.sidebar-foot {
  border-top: 1px solid rgba(207, 244, 210, 0.14);
  padding-top: 14px;
  margin-top: 20px;
}

.account-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  color: #eaf3f4;
}

.account-link:hover {
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}

.account-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.account-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-role {
  font-size: 11px;
  color: #a9c6cd;
}

.account-link .icon {
  color: #a9c6cd;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-lime);
  color: var(--brand-blue-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
}

.avatar-sm {
  width: 30px;
  height: 30px;
  font-size: 10px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 17px;
}

.logout-form {
  margin-top: 4px;
}

.nav-button {
  font-size: 13px;
}

.mobile-bar {
  display: none;
}

.nav-scrim {
  position: fixed;
  inset: 0;
  background: rgba(16, 34, 45, 0.5);
  z-index: 30;
}

/* ---------- Page header ---------- */

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

.page-head-text {
  min-width: 0;
}

.page-head h1 {
  font-size: 26px;
  line-height: 1.15;
}

.page-subtitle {
  margin-top: 5px;
  color: var(--muted);
  max-width: 68ch;
}

.page-head-compact {
  justify-content: flex-end;
  margin-bottom: 8px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: none;
  padding-top: 2px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn .icon {
  width: 17px;
  height: 17px;
}

.btn-primary {
  background: var(--brand-blue);
  color: #ffffff;
  border-color: var(--brand-blue);
}

.btn-primary:hover {
  background: var(--brand-blue-deep);
  border-color: var(--brand-blue-deep);
}

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

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: #b5c4bd;
}

.btn-quiet {
  background: transparent;
  color: var(--ink-2);
  border-color: transparent;
}

.btn-quiet:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: #8f1d16;
  border-color: #8f1d16;
}

.btn-danger-quiet {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--danger);
}

.btn-danger-quiet:hover {
  background: var(--danger-bg);
  border-color: #e4b8b5;
}

.btn-quiet-danger {
  color: var(--danger);
}

.btn-quiet-danger:hover {
  background: var(--danger-bg);
}

.btn-sm {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12.5px;
}

.btn-block {
  width: 100%;
}

.btn.is-copied {
  background: var(--success-bg);
  border-color: #bfe0cd;
  color: var(--success);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

/* ---------- Panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-quiet {
  background: var(--surface-2);
  box-shadow: none;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head-wrap {
  flex-wrap: wrap;
}

.panel-head h2 {
  font-size: 16px;
}

.panel-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
  max-width: 74ch;
}

.panel-body {
  padding: 18px 20px;
}

.panel-body-bordered {
  border-top: 1px solid var(--line);
}

.panel-danger-zone {
  border-color: #eccac7;
}

.danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.danger-row h3 {
  font-size: 14px;
}

.danger-row p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
  max-width: 70ch;
}

.subhead {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 8px;
}

.panel-body .subhead {
  margin-top: 2px;
}

/* ---------- Stats ---------- */

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

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px 14px;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--brand-blue);
}

.stat:nth-child(2) {
  border-top-color: var(--brand-teal);
}

.stat:nth-child(3) {
  border-top-color: #b9922f;
}

.stat:nth-child(4) {
  border-top-color: var(--danger);
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--info-bg);
  color: var(--brand-blue);
}

.stat-icon .icon {
  width: 16px;
  height: 16px;
}

.stat-icon-teal {
  background: #e4f2f1;
  color: var(--brand-teal-deep);
}

.stat-icon-amber {
  background: var(--warn-bg);
  color: var(--warn);
}

.stat-icon-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.stat-value {
  margin-top: 12px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-unit {
  font-size: 17px;
  margin-left: 1px;
  color: var(--muted);
}

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

/* ---------- Dashboard ---------- */

.dash-main {
  min-width: 0;
}

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr);
  gap: 20px;
  align-items: start;
}

.dash-side {
  display: grid;
  gap: 0;
}

.health {
  padding: 16px 20px 18px;
  display: grid;
  gap: 10px;
}

.health-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-2);
}

.health-row strong {
  font-size: 15px;
}

.meter {
  width: 100%;
  height: 8px;
  appearance: none;
  border: 0;
  border-radius: 99px;
  overflow: hidden;
  background: var(--surface-3);
}

.meter::-webkit-progress-bar {
  background: var(--surface-3);
  border-radius: 99px;
}

.meter::-webkit-progress-value {
  background: var(--brand-teal);
  border-radius: 99px;
}

.meter::-moz-progress-bar {
  background: var(--brand-teal);
  border-radius: 99px;
}

.plain-list {
  display: grid;
}

.plain-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.plain-list li:last-child {
  border-bottom: 0;
}

.plain-list-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.plain-list-main a {
  font-weight: 600;
  color: var(--ink);
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: center;
}

.mini-stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mini-stats strong {
  font-size: 18px;
}

.mini-stats span {
  font-size: 11px;
  color: var(--muted);
}

/* ---------- Tables ---------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: 0.075em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 16px;
  background: #fafbfa;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background: #fafcfa;
}

.data-table .cell-actions {
  text-align: right;
  white-space: nowrap;
}

.row-link {
  font-weight: 600;
  color: var(--ink);
}

.row-link:hover {
  color: var(--brand-blue);
}

.cell-strong {
  display: block;
  font-weight: 600;
  color: var(--ink);
}

.cell-sub {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

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

.cell-link {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Badges & tags ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-neutral {
  background: var(--surface-3);
  color: var(--ink-2);
}

.provider-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

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

.tag {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 11.5px;
}

.pill {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.pill-on-blue {
  background: rgba(207, 244, 210, 0.16);
  color: var(--brand-lime);
  border: 1px solid rgba(207, 244, 210, 0.28);
}

/* ---------- Forms ---------- */

.form-shell {
  display: grid;
  gap: 0;
}

.form-section {
  padding: 20px;
}

.form-section-head {
  margin-bottom: 16px;
}

.form-section-head h2 {
  font-size: 15px;
}

.form-section-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
  max-width: 78ch;
}

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

.form-grid:last-child {
  margin-bottom: 0;
}

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

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

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field > label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}

.label-note {
  color: var(--muted);
  font-weight: 400;
  font-size: 11.5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

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

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235d707b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 34px;
}

input::placeholder,
textarea::placeholder {
  color: #91a0a8;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 3px rgba(53, 157, 158, 0.16);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.help {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.help a {
  font-weight: 600;
}

.input-action {
  position: relative;
}

.input-action input {
  padding-right: 44px;
}

.input-action-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
}

.input-suffix {
  position: relative;
}

.input-suffix input {
  padding-right: 42px;
}

.input-suffix span {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 12px;
}

.select-sm {
  min-height: 34px;
  padding: 5px 30px 5px 9px;
  font-size: 12.5px;
  width: auto;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field .icon {
  position: absolute;
  left: 9px;
  color: var(--muted);
  pointer-events: none;
}

.search-field input {
  min-height: 34px;
  padding: 5px 10px 5px 30px;
  font-size: 12.5px;
  width: 210px;
}

.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 4px 0 8px;
}

.form-footer-inline {
  justify-content: flex-start;
  padding: 0;
}

.field-switch {
  gap: 6px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  width: fit-content;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.15s var(--ease);
  flex: none;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(20, 35, 46, 0.22);
  transition: transform 0.15s var(--ease);
}

.switch input:checked + .switch-track {
  background: var(--brand-teal);
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--brand-teal);
  outline-offset: 2px;
}

.switch-inline {
  margin-top: 7px;
}

.form-alert,
.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  border: 1px solid;
  font-size: 13px;
}

.form-alert {
  background: var(--danger-bg);
  border-color: #e7c1be;
  color: #6e1712;
}

.form-alert .icon,
.banner .icon {
  margin-top: 1px;
}

.form-alert strong,
.banner strong {
  display: block;
  font-size: 13px;
}

.form-alert p,
.banner p {
  margin-top: 2px;
}

.form-alert ul {
  margin-top: 4px;
  padding-left: 16px;
  list-style: disc;
}

.form-alert li {
  margin-top: 2px;
}

.banner-success {
  background: var(--success-bg);
  border-color: #bfe0cd;
  color: #0f4f32;
}

.banner-warn {
  background: var(--warn-bg);
  border-color: #ead6a8;
  color: #5e3f00;
}

.banner-danger {
  background: var(--danger-bg);
  border-color: #e7c1be;
  color: #6e1712;
}

.banner-key {
  background: #eef7ee;
  border-color: #b9d9bd;
  color: #173f2a;
  align-items: flex-start;
}

.banner-grow {
  flex: 1;
  min-width: 0;
}

.inline-note {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.inline-note-warn {
  background: var(--warn-bg);
  border-color: #ead6a8;
  color: #5e3f00;
}

.inline-note strong {
  display: block;
}

.inline-note p {
  margin-top: 2px;
}

.callout-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  color: var(--ink-2);
}

.callout-row .icon {
  color: var(--brand-teal-deep);
  margin-top: 1px;
}

.callout-row h3 {
  font-size: 13.5px;
}

.callout-row p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
  max-width: 90ch;
}

/* ---------- Flash ---------- */

.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 18px;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 13px;
  font-weight: 500;
}

.flash-success {
  background: var(--success-bg);
  border-color: #bfe0cd;
  color: #0f4f32;
}

.flash-error {
  background: var(--danger-bg);
  border-color: #e7c1be;
  color: #6e1712;
}

.flash span {
  flex: 1;
}

.flash-close {
  width: 26px;
  height: 26px;
  min-width: 26px;
  color: inherit;
}

/* ---------- Detail ---------- */

.detail-hero-meta {
  padding-top: 0;
  align-items: center;
}

.detail-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 6px 2px 20px;
}

.detail-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-title-line h2 {
  font-size: 22px;
}

.detail-sub {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12.5px;
}

.detail-sub .icon {
  color: #9fb0b8;
}

.detail-stats {
  display: flex;
  gap: 26px;
  flex: none;
}

.detail-stats div {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.detail-stats strong {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.detail-stats span {
  font-size: 11px;
  color: var(--muted);
}

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

.kv-grid > div {
  padding: 11px 20px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.kv-grid > div:nth-last-child(-n+2) {
  border-bottom: 0;
}

.kv-grid dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 3px;
}

.kv-grid dd {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.kv-grid-compact {
  border-top: 1px solid var(--line);
}

.kv-grid-compact > div:nth-last-child(-n+2) {
  border-bottom: 0;
}

.copy-field {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}

.code-value {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  overflow-x: auto;
  white-space: nowrap;
}

.code-block {
  margin: 0;
  padding: 14px 16px;
  border-radius: 8px;
  background: #10222d;
  color: #e4f0ea;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
  tab-size: 2;
}

.code-block-sm {
  font-size: 11.5px;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- Timeline ---------- */

.timeline {
  padding: 18px 20px 20px 20px;
  display: grid;
  gap: 0;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 20px;
}

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

.timeline-item::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 16px;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-marker {
  width: 11px;
  height: 11px;
  margin-top: 4px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--line-strong);
  background: var(--line-strong);
  position: relative;
  z-index: 1;
}

.timeline-marker.is-success {
  background: var(--success);
  box-shadow: 0 0 0 2px #bfe0cd;
}

.timeline-marker.is-danger {
  background: var(--danger);
  box-shadow: 0 0 0 2px #e7c1be;
}

.timeline-marker.is-warn {
  background: var(--warn);
  box-shadow: 0 0 0 2px #ead6a8;
}

.timeline-body {
  min-width: 0;
}

.timeline-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  font-size: 12.5px;
}

.timeline-head time {
  margin-left: auto;
  font-size: 11.5px;
}

.attempt-error {
  margin-top: 6px;
  color: var(--danger);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.timeline-body .code-block {
  margin-top: 8px;
}

/* ---------- Empty states ---------- */

.empty {
  padding: 46px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-compact {
  padding: 26px 20px;
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--brand-blue);
  margin-bottom: 4px;
}

.empty-icon .icon {
  width: 22px;
  height: 22px;
}

.empty h3 {
  font-size: 14px;
}

.empty p {
  color: var(--muted);
  font-size: 12.5px;
  max-width: 52ch;
}

.empty .btn {
  margin-top: 6px;
}

/* ---------- Filters & pagination ---------- */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.filter-chip-row {
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 13px 20px;
  border-top: 1px solid var(--line);
}

.page-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  border: 1px solid transparent;
}

.page-item:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.page-item.is-current {
  background: var(--brand-blue);
  color: #ffffff;
  font-weight: 600;
}

.page-gap {
  color: var(--muted);
  padding: 0 4px;
}

/* ---------- Details / summary ---------- */

.row-details {
  position: relative;
}

.row-details > summary {
  list-style: none;
  display: inline-flex;
  cursor: pointer;
}

.row-details > summary::-webkit-details-marker {
  display: none;
}

.details-body {
  position: absolute;
  right: 0;
  top: 38px;
  z-index: 20;
  width: 330px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  display: grid;
  gap: 16px;
}

.details-body .field {
  gap: 4px;
}

.details-body input,
.details-body select {
  min-height: 36px;
  padding: 6px 9px;
  font-size: 13px;
}

/* ---------- Auth ---------- */

.auth-body {
  background: var(--surface);
}

.auth-shell {
  min-height: 100vh;
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(440px, 0.95fr);
  min-height: 100vh;
}

.auth-brand {
  background: var(--brand-blue);
  color: #ffffff;
  padding: 38px 48px 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-brand::after {
  content: "";
  position: absolute;
  right: -140px;
  bottom: -160px;
  width: 420px;
  height: 420px;
  border: 56px solid rgba(207, 244, 210, 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.auth-brand-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.auth-logo {
  width: 196px;
  height: auto;
}

.auth-brand-copy {
  position: relative;
  z-index: 1;
  max-width: 560px;
  padding: 40px 0;
}

.auth-brand-copy h1 {
  font-size: clamp(30px, 3.2vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.auth-brand-copy > p {
  margin-top: 16px;
  color: #cfe1e6;
  font-size: 15px;
  line-height: 1.6;
  max-width: 52ch;
}

.auth-points {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.auth-points li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e8f2f3;
  font-size: 13.5px;
}

.auth-points .icon {
  color: var(--brand-lime);
}

.auth-foot {
  color: #9fb8c2;
  font-size: 11.5px;
  position: relative;
  z-index: 1;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  background: var(--canvas);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 30px 28px;
  box-shadow: var(--shadow-sm);
}

.auth-card-head {
  margin-bottom: 20px;
}

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

.auth-card-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.auth-card .stack {
  gap: 15px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.auth-help {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

/* ---------- Account ---------- */

.account-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr);
  gap: 20px;
  align-items: start;
}

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

.account-profile h3 {
  font-size: 17px;
}

.account-profile p {
  margin: 2px 0 7px;
  font-size: 12.5px;
}

/* ---------- Error ---------- */

.error-page {
  max-width: 560px;
  margin: 8vh auto;
  padding: 32px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.error-code {
  font-size: 54px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--brand-blue);
  line-height: 1;
}

.error-copy h2 {
  margin-top: 10px;
  font-size: 20px;
}

.error-copy p {
  margin-top: 6px;
  color: var(--muted);
}

.error-actions {
  margin-top: 20px;
}

.app-body .error-page {
  margin-top: 4vh;
}

/* ---------- Dialog ---------- */

.dialog {
  border: 0;
  padding: 0;
  border-radius: var(--radius-lg);
  max-width: 420px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-pop);
  color: var(--ink);
}

.dialog::backdrop {
  background: rgba(16, 34, 45, 0.52);
}

.dialog-body {
  padding: 24px;
}

.dialog-body h2 {
  font-size: 17px;
}

.dialog-body p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  :root {
    --sidebar-w: 226px;
  }

  .content {
    padding: 26px 26px 40px;
  }

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

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

  .dash-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }

  .dash-side .panel:last-child {
    grid-column: 1 / -1;
  }
}

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

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 274px;
    max-width: 82vw;
    z-index: 40;
    transform: translateX(-102%);
    transition: transform 0.22s var(--ease);
    box-shadow: 18px 0 40px rgba(16, 34, 45, 0.22);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar .sidebar-close {
    display: inline-flex;
  }

  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .mobile-logo {
    width: 128px;
    height: auto;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
  }

  .content {
    padding: 22px 18px 36px;
  }

  .app-footer {
    padding: 16px 18px 22px;
  }

  .page-head {
    flex-direction: column;
    gap: 12px;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: initial;
  }

  .detail-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .detail-stats {
    gap: 30px;
  }

  .detail-stats div {
    align-items: flex-start;
  }

  .dash-side {
    grid-template-columns: 1fr;
  }

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

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

  .auth-brand {
    padding: 24px 24px 22px;
    min-height: auto;
  }

  .auth-logo {
    width: 158px;
  }

  .auth-brand-copy {
    padding: 26px 0 4px;
  }

  .auth-brand-copy h1 {
    font-size: 28px;
  }

  .auth-brand-copy > p {
    font-size: 13.5px;
    margin-top: 10px;
  }

  .auth-points {
    display: none;
  }

  .auth-foot {
    display: none;
  }

  .auth-panel {
    padding: 24px 18px 40px;
    align-items: flex-start;
  }

  .auth-card {
    max-width: 460px;
    margin: 0 auto;
  }

  .form-grid,
  .form-grid-3,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }

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

  .kv-grid > div:nth-last-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }

  .kv-grid > div:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 620px) {
  .hide-sm {
    display: none;
  }

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

  .stat-value {
    font-size: 26px;
  }

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

  .panel-head {
    padding: 16px 16px 12px;
  }

  .panel-body,
  .form-section {
    padding: 16px;
  }

  .data-table th,
  .data-table td {
    padding: 10px 12px;
  }

  .filter-bar {
    width: 100%;
  }

  .filter-bar .select-sm,
  .search-field,
  .search-field input {
    width: 100%;
  }

  .search-field {
    flex: 1 1 100%;
  }

  .filter-bar .btn {
    flex: 1;
  }

  .form-footer {
    flex-direction: column-reverse;
  }

  .form-footer .btn {
    width: 100%;
  }

  .danger-row {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .danger-row form,
  .danger-row .btn {
    width: 100%;
  }

  .copy-field {
    flex-direction: column;
  }

  .code-value {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .copy-field .btn {
    width: 100%;
  }

  .details-body {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 12px;
    width: auto;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 60;
  }

  .detail-stats {
    width: 100%;
    justify-content: space-between;
    gap: 12px;
  }

  .kv-grid > div {
    padding: 10px 16px;
  }

  .code-block {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .timeline {
    padding: 16px;
  }

  .timeline-head time {
    margin-left: 0;
    flex-basis: 100%;
  }

  .auth-brand-copy h1 {
    font-size: 24px;
  }

  .page-actions .btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 380px) {
  .content {
    padding-left: 14px;
    padding-right: 14px;
  }

  .page-actions {
    flex-direction: column;
    align-items: stretch;
  }

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

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