:root {
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --gray: #8e8e93;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at 20% 0%, #ffffff 0, var(--bg) 38%, #eeeeef 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }

.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  padding: 28px 20px;
  background: rgba(255, 255, 255, 0.72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(24px);
}
.sidebar-backdrop { display: none; }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 32px; }
.brand span, .page-head p { color: var(--muted); font-size: 14px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #007aff, #34c759);
  box-shadow: 0 10px 24px rgba(0, 122, 255, .25);
}
.brand-mark.large { width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 14px; }
.menu-group { margin-bottom: 10px; }
.menu-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 11px 12px;
  text-align: left;
}
.menu-toggle:hover { background: rgba(0, 122, 255, .08); color: var(--text); }
.menu-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--gray);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  transition: transform .2s ease;
}
.menu-chevron::before { content: "▾"; }
.menu-group.open .menu-chevron { transform: rotate(180deg); }
.submenu {
  overflow: hidden;
  max-height: 0;
  opacity: .25;
  transition: max-height .22s ease, opacity .18s ease;
}
.menu-group.open .submenu { max-height: none; opacity: 1; }
.submenu a {
  display: block;
  min-height: 42px;
  margin: 2px 0 2px 12px;
  padding: 11px 12px 11px 18px;
  border-radius: 12px;
  color: #333;
  font-size: 15px;
  position: relative;
}
.submenu a::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  border-radius: 999px;
  background: transparent;
}
.submenu a:hover,
.submenu a.active {
  background: #eef4ff;
  color: var(--blue);
}
.submenu a.active::before { background: var(--blue); }
.menu-link {
  display: block;
  min-height: 42px;
  margin: 0 0 10px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.menu-link:hover,
.menu-link.active {
  background: rgba(0, 122, 255, .08);
  color: var(--blue);
}

.main { min-width: 0; }
.topbar {
  height: 68px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--line);
  background: rgba(245,245,247,.74); backdrop-filter: blur(20px);
  position: sticky; top: 0; z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sidebar-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.8);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.home-link { font-weight: 700; }
.user-actions { display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 14px; white-space: nowrap; }
.content { padding: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
h1 { font-size: 20px; letter-spacing: 0; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0; }

.card, .metric {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}
.card { padding: 18px; overflow-x: auto; overflow-y: hidden; }
.card-head { margin-bottom: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric { padding: 20px; }
.metric span { color: var(--muted); font-size: 14px; }
.metric strong { display: block; font-size: 34px; margin-top: 8px; }
.metric.good strong { color: var(--green); }
.metric.bad strong { color: var(--red); }
.metric.muted strong { color: var(--gray); }

table { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: fixed; }
th, td { padding:5px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.empty { color: var(--muted); text-align: center; padding: 28px; }
.log-detail {
  display: block;
  max-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #3a3a3c;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.log-filter-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(140px, 220px) auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 10px;
}

.status { display: inline-flex; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #eee; }
.status.up { color: #0b6b2a; background: #e8f8ee; }
.status.down { color: #a01812; background: #ffe9e7; }
.status.unknown { color: #5f6368; background: #f0f1f3; }
.status.waiting,
.status.queued { color: #174ea6; background: #e8f0fe; }
.status.running { color: #8a4b00; background: #fff3d6; }
.status.success { color: #0b6b2a; background: #e8f8ee; }
.status.failed,
.status.disabled { color: #a01812; background: #ffe9e7; }

.actions form { margin: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 12px; padding: 9px 14px; font-weight: 600; cursor: pointer;
  min-height: 38px;
}
.btn.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.btn.danger { color: var(--red); }
.btn.disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}
.actions .btn.small { padding: 6px 10px; min-height: 30px; font-size: 12px; float: left;margin-right: 3px; margin-bottom: 3px;}
.btn.full { width: 100%; }
.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
}
.checkbox-row .checkbox {
  margin: 0;
}
.ai-analysis-card {
  margin-bottom: 14px;
}
.ai-result {
  max-height: 520px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.security-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.security-row p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.secret-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}
.totp-qr {
  display: block;
  width: 180px;
  height: 180px;
  margin: 10px auto 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.form { display: grid; gap: 16px; }
.grid-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.narrow { max-width: 520px; }
.span-2 { grid-column: span 2; }
label {  color: var(--muted); font-size: 13px; font-weight: 600;     margin-right: 10px; }
.form-muted { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; background: #fff; color: var(--text); font: inherit;
}
textarea { min-height: 92px; resize: vertical; }
input[type="checkbox"] { width: auto; justify-self: start; }
.form-actions { display: flex; gap: 10px; }
.scheduled-picker-row {
  display: grid;
  grid-template-columns: minmax(180px, 280px) auto;
  align-items: end;
  gap: 12px;
}
.custom-schedule {
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.58);
}
.scheduled-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}
.scheduled-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  background: #eef4ff;
  color: #174ea6;
  font-size: 13px;
  font-weight: 700;
}
.scheduled-chip button {
  border: 0;
  background: transparent;
  color: currentColor;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}
.check-list { background: #fafafa; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.form-section-title {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 4px;
}
.form-section-title h2 { margin-bottom: 4px; }
.form-section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.form-section-title code {
  background: #f2f2f7;
  border-radius: 6px;
  padding: 2px 5px;
}

.alert-condition-panel {
  display: grid;
  gap: 12px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.condition-builder {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.58);
}
.condition-builder-row {
  display: grid;
  gap: 12px;
  align-items: end;
}
.condition-builder-row-top {
  grid-template-columns: minmax(280px, 2fr) minmax(180px, 1fr);
}
.condition-builder-row-bottom {
  grid-template-columns: minmax(260px, 2fr) minmax(140px, 160px) minmax(180px, 1fr);
}
.condition-builder-actions {
  display: flex;
  justify-content: flex-start;
}
.condition-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.72);
}
.condition-table {
  min-width: 900px;
}
.condition-table th,
.condition-table td {
  padding: 9px 10px;
}
.condition-table th:nth-child(1),
.condition-table td:nth-child(1) {
  width: 30%;
}
.condition-table th:nth-child(2),
.condition-table td:nth-child(2) {
  width: 13%;
}
.condition-table th:nth-child(3),
.condition-table td:nth-child(3) {
  width: 22%;
}
.condition-table th:nth-child(4),
.condition-table td:nth-child(4) {
  width: 11%;
}
.condition-table th:nth-child(5),
.condition-table td:nth-child(5) {
  width: 16%;
}
.condition-table th:nth-child(6),
.condition-table td:nth-child(6) {
  width: 8%;
  white-space: nowrap;
}
.alert-config-form {
  gap: 18px;
}
.tabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.64);
  width: fit-content;
}
.tab {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 9px 14px;
}
.tab.active {
  background: var(--blue);
  color: #fff;
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}
.notification-config {
  display: grid;
  gap: 14px;
}
.notification-config .tabs {
  margin-bottom: 2px;
}
.tab-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.tab-panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.template-textarea {
  min-height: 320px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}
.template-help {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.58);
}

.flash-stack {
  position: fixed;
  top: 84px;
  right: 28px;
  z-index: 80;
  display: grid;
  gap: 12px;
  width: min(460px, calc(100vw - 40px));
  pointer-events: none;
}
.flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 14px 14px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.8);
  color: #174ea6;
  box-shadow: 0 18px 45px rgba(0,0,0,.14);
  backdrop-filter: blur(18px);
  pointer-events: auto;
  animation: toast-in .22s ease-out;
}
.flash.error {
  background: rgba(255, 233, 231, .95);
  color: #a01812;
  border-color: rgba(255, 190, 184, .8);
}
.flash.success {
  background: rgba(232, 248, 238, .95);
  color: #0b6b2a;
  border-color: rgba(179, 232, 197, .85);
}
.monitor-progress-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .22);
  backdrop-filter: blur(8px);
}
.monitor-progress-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(255,255,255,.82);
  box-shadow: 0 28px 80px rgba(0,0,0,.24);
}
.monitor-progress-head {
  display: grid;
  gap: 5px;
}
.monitor-progress-head strong {
  font-size: 18px;
}
.monitor-progress-head span,
.monitor-progress-name,
.monitor-progress-time {
  color: var(--muted);
  font-size: 13px;
}
.monitor-progress-name {
  color: var(--text);
  font-weight: 700;
}
.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e5ea;
}
.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width .22s ease;
}
.progress-fill.failed {
  background: var(--red);
}
.flash-closing {
  opacity: 0;
  transform: translateX(14px);
  transition: opacity .18s ease, transform .18s ease;
}
.flash-close {
  border: 0;
  background: transparent;
  color: currentColor;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  opacity: .65;
  padding: 0 2px;
}
.flash-close:hover { opacity: 1; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) translateX(10px); }
  to { opacity: 1; transform: translateY(0) translateX(0); }
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 12px 14px;
  color: var(--muted);
}
.pagination-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.pagination-info {
  font-size: 13px;
}
.pagination-ellipsis {
  padding: 0 4px;
  color: var(--muted);
}

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel {
  width: min(420px, 100%);
  padding: 34px;
  border-radius: 24px;
  background: rgba(255,255,255,.82);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.8);
  backdrop-filter: blur(24px);
}
.login-panel-wide { width: min(520px, 100%); }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 30px; }
.login-brand p { margin: 6px 0 0; color: var(--muted); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .28);
  backdrop-filter: blur(12px);
}
.modal-backdrop[hidden] { display: none; }
.modal-panel {
  width: min(820px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 22px;
  box-shadow: 0 28px 80px rgba(0,0,0,.22);
  padding: 22px;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
.modal-head p { margin: 6px 0 0; color: var(--muted); }
.confirm-panel {
  width: min(440px, 100%);
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.confirm-actions .btn {
  min-width: 92px;
}
.confirm-actions .btn.danger {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}
.modal-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: #f2f2f7;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
}
.modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.modal-grid div {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px;
}
.modal-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.modal-section { margin-top: 16px; }
.modal-section h3 {
  font-size: 14px;
  margin: 0 0 8px;
  color: var(--muted);
}
.modal-section pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f8fa;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.variable-help-table {
  min-width: 100%;
  table-layout: auto;
}
.variable-help-table th,
.variable-help-table td {
  white-space: normal;
  vertical-align: top;
}
.variable-help-table code {
  word-break: break-word;
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    width: min(300px, 86vw);
    transform: translateX(-104%);
    transition: transform .22s ease;
    overflow-y: auto;
    box-shadow: 18px 0 50px rgba(0,0,0,.16);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 65;
    border: 0;
    background: rgba(0,0,0,.22);
    backdrop-filter: blur(8px);
  }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 0 12px; gap: 10px; }
  .user-actions { gap: 10px; font-size: 13px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .scheduled-picker-row { grid-template-columns: 1fr; }
  .condition-builder-row-top,
  .condition-builder-row-bottom { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .content { padding: 20px; }
  .log-filter-row { grid-template-columns: 1fr; }
  .modal-grid { grid-template-columns: 1fr; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .tab-panel-head { align-items: stretch; flex-direction: column; }
  .tab-panel-head .btn { width: fit-content; }
}

@media (max-width: 640px) {
  .topbar { height: auto; min-height: 62px; align-items: flex-start; flex-direction: column; padding: 10px 12px; }
  .topbar-left { width: 100%; }
  .user-actions { width: 100%; justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
  .content { padding: 14px; }
  .page-head { gap: 12px; margin-bottom: 16px; }
  .page-head .btn.primary { width: 100%; }
  .tab-panel-head .btn { width: 100%; }
  h1 { font-size: 24px; }
  .card { border-radius: 14px; padding: 12px; }
  .metric-grid { grid-template-columns: 1fr; }
  .log-filter-row { gap: 10px; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn,
  .log-filter-row .btn { flex: 1 1 120px; }
  .flash-stack { top: 12px; right: 12px; left: 12px; width: auto; }
  .modal-backdrop { padding: 12px; }
  .modal-panel { border-radius: 16px; padding: 16px; }
}

/* Max Payment inspired admin theme */
:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --text: #1d1d1f;
  --muted: #86868b;
  --line: #e5e5ea;
  --blue: #007aff;
  --green: #10b981;
  --red: #f43f5e;
  --gray: #94a3b8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .01), 0 4px 16px rgba(0, 0, 0, .04);
}

body {
  background: #f5f5f7;
  color: #1d1d1f;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .12); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, .25); }

.shell {
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  padding: 18px 14px;
  background: #ffffff;
  border-right: 1px solid rgba(229, 229, 234, .72);
  box-shadow: 1px 0 0 rgba(255, 255, 255, .9);
  backdrop-filter: none;
}

.brand {
  min-height: 56px;
  margin-bottom: 18px;
  padding: 8px 10px;
}

.brand strong {
  color: #1d1d1f;
  font-size: 16px;
}

.brand span {
  color: #86868b;
  font-size: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, #007aff, #10b981);
  box-shadow: 0 8px 18px rgba(0, 122, 255, .18);
}

.menu-group,
.menu-link {
  margin-bottom: 4px;
}

.menu-toggle,
.menu-link {
  min-height: 40px;
  border-radius: 10px;
  color: #515154;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
  transition: background-color .15s cubic-bezier(.16, 1, .3, 1), color .15s ease;
}

.menu-toggle:hover,
.menu-link:hover {
  background: rgba(0, 0, 0, .04);
  color: #1d1d1f;
}

.menu-chevron::before {
  content: "▾";
}

.submenu a {
  min-height: 40px;
  margin: 4px 0 4px 10px;
  padding: 10px 12px 10px 22px;
  border-radius: 10px;
  color: #515154;
  font-size: 14px;
  transition: background-color .15s cubic-bezier(.16, 1, .3, 1), color .15s ease;
}

.submenu a:hover {
  background: rgba(0, 0, 0, .04);
  color: #1d1d1f;
}

.submenu a.active,
.menu-link.active {
  background: #007aff;
  color: #ffffff;
  font-weight: 600;
}

.submenu a.active::before {
  background: transparent;
}

.topbar {
  height: 64px;
  background: rgba(245, 245, 247, .86);
  border-bottom: 1px solid rgba(229, 229, 234, .72);
  backdrop-filter: blur(16px);
}

.home-link {
  color: #1d1d1f;
  font-size: 15px;
  font-weight: 700;
}

.user-actions {
  color: #86868b;
}

.user-actions a:hover {
  color: #007aff;
}

.content {
  padding: 24px 28px 32px;
}

.page-head {
  margin-bottom: 22px;
}

h1 {
  color: #0f172a;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}

h2 {
  color: #1d1d1f;
  font-size: 18px;
  font-weight: 700;
}

.brand span,
.page-head p {
  color: #64748b;
  font-size: 14px;
}

.card,
.metric,
.login-panel {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, .04);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .01), 0 4px 16px rgba(0, 0, 0, .04);
  backdrop-filter: none;
}

.card {
  padding: 20px;
}

.metric {
  padding: 18px;
}

.metric span {
  color: #86868b;
  font-size: 13px;
}

.metric strong {
  color: #1d1d1f;
  font-size: 28px;
  font-weight: 800;
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  font-size: 13px;
}

th {
  background: #f8fafc;
  color: #86868b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

tbody tr {
  transition: background-color .15s ease;
}

tbody tr:hover {
  background: #f8fafc;
}

.btn {
  min-height: 36px;
  border: 1px solid rgba(0, 0, 0, .05);
  border-radius: 10px;
  background: rgba(0, 0, 0, .04);
  color: #1d1d1f;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  transition: transform .2s cubic-bezier(.16, 1, .3, 1), background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease;
}

.btn:hover {
  background: #007aff;
  border-color: #007aff;
  color: #ffffff;
}

.btn.primary {
  background: #007aff;
  border-color: #007aff;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(0, 122, 255, .12);
}

.btn.primary:hover {
  background: #0071e3;
  border-color: #0071e3;
  transform: translateY(-.5px);
}

.btn.danger {
  color: #f43f5e;
}

.btn.danger:hover {
  background: #f43f5e;
  border-color: #f43f5e;
  color: #ffffff;
}

.actions .btn.small {
  min-height: 28px;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  float: none;
}

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

input,
select,
textarea {
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(0, 0, 0, .05);
  color: #1d1d1f;
  padding: 10px 12px;
  transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  background: #ffffff;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, .15);
}

label {
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}

.log-filter-row,
.custom-schedule,
.condition-builder,
.template-help,
.condition-table-wrap,
.check-list {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, .04);
  border-radius: 16px;
}

.status {
  border-radius: 9999px;
  border: 0;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status.up,
.status.success {
  color: #059669;
  background: #ecfdf5;
}

.status.down,
.status.failed,
.status.disabled {
  color: #e11d48;
  background: #fff1f2;
}

.status.unknown {
  color: #64748b;
  background: #f1f5f9;
}

.status.running {
  color: #d97706;
  background: #fffbeb;
}

.status.waiting,
.status.queued {
  color: #2563eb;
  background: #eff6ff;
}

.flash,
.modal-panel,
.monitor-progress-panel {
  border: 1px solid rgba(0, 0, 0, .04);
  border-radius: 20px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 20px 48px rgba(0, 0, 0, .14);
}

.modal-backdrop,
.monitor-progress-backdrop {
  background: rgba(15, 23, 42, .28);
  backdrop-filter: blur(12px);
}

.modal-close {
  background: #f1f5f9;
  color: #64748b;
}

.tabs {
  border-radius: 12px;
  background: #f8fafc;
}

.tab {
  border-radius: 9px;
}

.tab.active {
  background: #007aff;
  color: #ffffff;
}

.pagination {
  color: #64748b;
}



.login-page {
  background: #f5f5f7;
}

.login-brand h1 {
  font-size: 28px;
  font-weight: 800;
}

.monitor-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.monitor-type-test {
  color: #2563eb;
  background: #eff6ff;
}

.monitor-type-real {
  color: #059669;
  background: #ecfdf5;
}

.monitor-type-unknown {
  color: #64748b;
  background: #f1f5f9;
}

/* Final mobile overrides. Keep this block at the end so theme styles cannot override it. */
@media (max-width: 980px) {
  html,
  body {
    overflow-x: hidden;
  }

  .shell {
    display: block;
    min-width: 0;
  }

  .main {
    width: 100%;
    min-width: 0;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    width: min(320px, 86vw);
    transform: translateX(-104%);
    transition: transform .22s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 18px 0 50px rgba(15, 23, 42, .18);
  }

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

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 65;
    border: 0;
    background: rgba(15, 23, 42, .28);
    backdrop-filter: blur(8px);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
  }

  .topbar {
    height: auto;
    min-height: 60px;
    gap: 10px;
    padding: 10px 12px;
  }

  .topbar-left {
    min-width: 0;
  }

  .user-actions {
    min-width: 0;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .content {
    padding: 16px;
  }

  .page-head,
  .tab-panel-head,
  .section-head {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .page-head .btn,
  .page-head .form-actions,
  .tab-panel-head .btn {
    width: 100%;
  }

  .grid-form,
  .nested-grid,
  .scheduled-picker-row,
  .condition-builder-row-top,
  .condition-builder-row-bottom,
  .log-filter-row {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

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

  .card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 760px;
  }

  .actions {
    min-width: 160px;
  }

  .form-actions {
    flex-wrap: wrap;
  }

  .form-actions .btn {
    flex: 1 1 140px;
  }

  .tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }

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

  .modal-panel {
    width: min(100%, 860px);
    max-height: calc(100vh - 24px);
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-left,
  .user-actions {
    width: 100%;
  }

  .home-link {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .content {
    padding: 12px;
  }

  h1 {
    font-size: 20px;
    line-height: 1.25;
  }

  h2 {
    font-size: 17px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .submenu a,
  .menu-toggle,
  .menu-link {
    min-height: 42px;
    font-size: 14px;
  }

  .card,
  .metric,
  .login-panel {
    border-radius: 14px;
  }

  .card {
    padding: 12px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

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

  .btn {
    min-height: 38px;
    padding: 8px 12px;
  }

  input,
  select,
  textarea {
    min-height: 40px;
    font-size: 16px;
  }

  textarea {
    min-height: 110px;
  }

  .log-filter-row,
  .condition-builder,
  .template-help,
  .check-list {
    border-radius: 14px;
  }

  .condition-table,
  .variable-help-table {
    min-width: 760px;
  }

  .modal-backdrop,
  .monitor-progress-backdrop {
    padding: 10px;
  }

  .modal-panel,
  .monitor-progress-panel {
    border-radius: 16px;
    padding: 14px;
  }

  .modal-head {
    gap: 10px;
  }

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

  .modal-actions,
  .confirm-actions {
    flex-wrap: wrap;
  }

  .modal-actions .btn,
  .confirm-actions .btn {
    flex: 1 1 120px;
  }

  .flash-stack {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
  }

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

  .pagination-actions {
    justify-content: flex-start;
  }
}
