:root {
  --bg-1: #f4efe4;
  --bg-2: #d9e3f0;
  --text: #1d2433;
  --muted: #5f6673;
  --panel: #fff8ef;
  --panel-2: #f6fbff;
  --line: #d5dbe5;
  --primary: #0f7b6c;
  --primary-strong: #0a5c52;
  --danger: #be2d2d;
  --up: #177d3f;
  --down: #b43a2d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Segoe UI", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  color: var(--text);
}

body {
  position: relative;
  background: var(--bg-1);
}

.loading-overlay {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
}

.loading-card {
  min-width: 280px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #ffffffaa;
  background: #fffffff2;
  box-shadow: 0 10px 26px #32405b26;
}

.loading-text {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.loading-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e6edf6;
}

.loading-bar-inner {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--primary), #1a9c89);
  transition: width 220ms ease;
}

.hidden {
  display: none !important;
}


.bg-gradient {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 18%, #ffd39e 0 18%, transparent 40%),
    radial-gradient(circle at 83% 80%, #a4d9d2 0 20%, transparent 42%),
    linear-gradient(140deg, var(--bg-1), var(--bg-2));
  z-index: -1;
}

.topbar {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: min(1600px, 90vw);
  margin: 24px auto 12px;
  padding: 16px 20px;
  border-radius: 18px;
  border: 1px solid #ffffff88;
  background: linear-gradient(160deg, #ffffffee, #ffffffbf);
  backdrop-filter: blur(8px);
  box-shadow:
    0 22px 42px #1f2f4f33,
    0 2px 0 #ffffffb5 inset,
    0 -12px 28px #ffffff6a inset;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: -140%;
  z-index: -2;
  background: conic-gradient(
    from 0deg,
    #e63559,
    #f48d1e,
    #f0cf2e,
    #1fb955,
    #06a6df,
    #386ef0,
    #7e40d6,
    #e63559
  );
  filter: saturate(1.35) contrast(1.06) blur(20px);
  opacity: 0.72;
  animation: topbar-rainbow-rotate 9s linear infinite;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    linear-gradient(180deg, #ffffffe3, #ffffffbe),
    radial-gradient(120% 60% at 15% -5%, #ffffffc4 0 35%, transparent 62%);
}

.topbar > * {
  position: relative;
  z-index: 1;
  min-width: 0;
}

@keyframes topbar-rainbow-rotate {
  from { transform: rotate(0deg) scale(1); }
  to { transform: rotate(360deg) scale(1.08); }
}

h1,
h2,
strong,
th {
  font-family: "Aptos", "Segoe UI Semibold", "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  letter-spacing: 0.2px;
}

h1 {
  margin: 0;
  font-size: 1.55rem;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 58px;
  height: 58px;
  display: block;
  flex: 0 0 auto;
  filter: drop-shadow(0 10px 18px #12233f24);
}

.brand-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  text-decoration: none;
}

.brand-home:focus-visible {
  outline: 2px solid #233a5e;
  outline-offset: 4px;
}

.brand-copy {
  min-width: 0;
}

.brand-eyebrow {
  display: block;
  margin-bottom: 5px;
  font-family: "Aptos", "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #4a6284;
}

.brand-copy h1 {
  font-size: 1.62rem;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

nav {
  display: flex;
  gap: 8px;
}

nav a {
  text-decoration: none;
  color: var(--text);
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  transition: 150ms ease;
}

nav a:hover,
nav a.active {
  color: #fff;
  border-color: var(--primary);
  background: linear-gradient(120deg, var(--primary), #1a9c89);
}

.container {
  width: min(1600px, 90vw);
  margin: 0 auto 48px;
  display: grid;
  gap: 16px;
}

.page-footer {
  width: min(1600px, 90vw);
  margin: 0 auto 28px;
  padding: 4px 4px 12px;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

body.modal-open {
  overflow: hidden;
}

.service-modal {
  position: fixed;
  inset: 0;
  z-index: 10010;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(17, 28, 44, 0.58);
  backdrop-filter: blur(10px);
}

.service-modal-dialog {
  width: min(980px, 100%);
  max-height: min(88vh, 920px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #f5f8fc 100%);
  border: 1px solid rgba(35, 58, 94, 0.14);
  border-radius: 24px;
  box-shadow: 0 28px 70px rgba(15, 27, 44, 0.24);
}

.service-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid rgba(35, 58, 94, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 247, 251, 0.96));
}

.service-modal-header h2 {
  margin: 0;
  font-size: 1.38rem;
  line-height: 1.2;
}

.service-modal-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.service-modal-close {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(35, 58, 94, 0.14);
  border-radius: 999px;
  background: #fff;
  color: #233a5e;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  transition: 150ms ease;
}

.service-modal-close:hover {
  border-color: rgba(35, 58, 94, 0.28);
  transform: translateY(-1px);
}

.service-modal-body {
  overflow: auto;
  padding: 22px 24px 24px;
  display: grid;
  gap: 18px;
}

.service-modal-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.service-modal-stat {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(35, 58, 94, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 18px rgba(50, 64, 91, 0.08);
}

.service-modal-stat-label,
.service-modal-meta-label {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.service-modal-stat-value {
  min-width: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.service-modal-stat-detail {
  color: #5a6c89;
  font-size: 0.84rem;
}

.service-modal-section {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(35, 58, 94, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
}

.service-modal-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.service-modal-section h3 {
  margin: 0;
  font-size: 1rem;
}

.service-modal-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(35, 58, 94, 0.08);
  color: #233a5e;
  font-size: 0.82rem;
  font-weight: 600;
}

.service-modal-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.service-modal-meta-item {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: #f6f9fd;
}

.service-modal-meta-item-wide {
  grid-column: 1 / -1;
}

.service-modal-meta-value {
  min-width: 0;
  color: var(--text);
  word-break: break-word;
}

.service-modal-inline-detail {
  display: inline-block;
  margin-left: 8px;
  color: #5a6c89;
}

.service-modal-table-wrap {
  overflow: auto;
  border: 1px solid rgba(35, 58, 94, 0.08);
  border-radius: 14px;
}

.service-modal-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: #fff;
}

.service-modal-table th,
.service-modal-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(35, 58, 94, 0.08);
  text-align: left;
  vertical-align: top;
}

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

.service-modal-empty {
  padding: 28px 16px;
  border: 1px dashed rgba(35, 58, 94, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  text-align: center;
  color: var(--muted);
}

.service-modal-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.service-modal-empty p {
  margin: 0;
}

.service-modal-empty-error strong {
  color: var(--danger);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.metric {
  background: linear-gradient(160deg, #fff9ee, #f3fbff);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.88) inset,
    0 4px 0 rgba(0, 0, 0, 0.05),
    0 8px 22px rgba(50, 64, 91, 0.12);
  min-width: 0;
}

.summary-grid .metric:nth-child(1) {
  background: linear-gradient(160deg, #fff5e6 0%, #ffd48a 100%);
}

.summary-grid .metric:nth-child(2) {
  background: linear-gradient(160deg, #e8f3ff 0%, #a8ccef 100%);
}

.summary-grid .metric:nth-child(3) {
  background: linear-gradient(160deg, #e5f9ee 0%, #8cdcad 100%);
}

.summary-grid .metric:nth-child(4) {
  background: linear-gradient(160deg, #fff0ee 0%, #f5aaa8 100%);
}

.summary-grid .metric:nth-child(5) {
  background: linear-gradient(160deg, #f4eeff 0%, #c0a0f5 100%);
}

.summary-grid .metric:nth-child(6) {
  background: linear-gradient(160deg, #fef8e0 0%, #f5d670 100%);
}

.summary-grid .metric:nth-child(7) {
  background: linear-gradient(160deg, #e2f7f8 0%, #78cdd3 100%);
}

.summary-grid .metric:nth-child(8) {
  background: linear-gradient(160deg, #edf0ff 0%, #99aaf0 100%);
}

.metric p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.metric strong {
  font-size: 1.45rem;
}

.metric-value {
  margin-top: 2px;
}

.metric-range-value {
  margin-top: 2px;
  font-size: 0.95rem;
  line-height: 1.35;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
}

.panel {
  background: #fffffff0;
  border: 1px solid #ffffff99;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 25px #32405b12;
  min-width: 0;
}

.panel h2 {
  margin: 0;
}

.section-title {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.section-title .title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  color: #233a5e;
  flex: 0 0 auto;
}

.section-title .title-icon svg {
  width: 1.42rem;
  height: 1.42rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.section-title .title-text {
  min-width: 0;
}

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

.panel-header > *,
.history-footer > * {
  min-width: 0;
}

.all-availability-badge {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.all-availability-badge.availability-good {
  color: #177d3f;
}

.all-availability-badge.availability-warn {
  color: #b38100;
}

.all-availability-badge.availability-bad {
  color: #b43a2d;
}

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

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 860px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 11px 9px;
  vertical-align: middle;
}

.page-dashboard th,
.page-dashboard td {
  padding: 9px 7px;
}

.th-sort {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.th-sort.active::after {
  content: " \25BC";
  font-size: 0.75em;
}

.th-sort.active[data-sort-dir="asc"]::after {
  content: " \25B2";
}

tbody tr {
  transition: 120ms ease;
}

tbody tr:hover {
  background: #f6faff;
}

.selected-row {
  background: #ecf7ff;
}

a {
  color: #0a5883;
}

.url-ellipsis {
  display: inline-block;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.page-dashboard .url-ellipsis {
  max-width: 280px;
}

.port-scan-value {
  display: inline-block;
  max-width: 152px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.port-scan-value.is-empty {
  color: var(--muted);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge.up {
  color: #fff;
  background: var(--up);
}

.badge.warn {
  color: #2f3646;
  background: #ffe29a;
}

.badge.down {
  color: #fff;
  background: var(--down);
}

.badge.unknown {
  color: #2f3646;
  background: #dfe4ea;
}

.host-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted, #8892a4);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 1px 8px;
  vertical-align: middle;
  letter-spacing: 0.2px;
}

.name-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.status-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.service-name-with-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.dot-up {
  background: var(--up);
  box-shadow: 0 0 4px var(--up);
}

.dot-down {
  background: var(--down);
  box-shadow: 0 0 4px var(--down);
  animation: dot-pulse 1.4s ease-in-out infinite;
}

.dot-unknown {
  background: #adb5bd;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.btn,
.select,
input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
}

.select,
input {
  background: #fff;
  color: var(--text);
}

input {
  width: 100%;
  min-width: 0;
}

.btn {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: 140ms ease;
}

.btn:hover {
  background: var(--primary-strong);
}

.btn.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.btn.secondary.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn.tiny {
  padding: 6px 10px;
  font-size: 0.86rem;
}

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

.charts-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 4fr) minmax(0, 1fr);
}

#latencyChart,
#uptimeChart {
  min-height: 390px;
  max-height: 430px;
}

canvas {
  width: 100%;
  min-height: 280px;
  max-height: 320px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.form-grid select,
.form-grid input:not([type="checkbox"]) {
  height: 46px;
  line-height: 1.2;
  padding-top: 0;
  padding-bottom: 0;
}

.test-data-grid {
  display: grid;
  grid-template-columns: minmax(150px, 240px) minmax(150px, 190px) auto;
  gap: 12px;
  align-items: end;
}

.test-data-grid select {
  width: 100%;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.report-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 1.2fr auto;
  gap: 12px;
  align-items: end;
}

.report-grid.report-grid-compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 12px;
}

.report-col-monitor {
  grid-column: 1 / 3;
}

.report-col-recipients {
  grid-column: 3 / 5;
}

.field-span-all {
  grid-column: 1 / -1;
}

.report-col-frequency {
  grid-column: 2;
}

.report-col-mode {
  grid-column: 1;
}

.report-col-daily-hour {
  grid-column: 3;
}

.report-col-options {
  grid-column: 4;
}

.report-col-submit {
  grid-column: 4;
}

.report-col-line-token {
  grid-column: 1 / 3;
}

.report-col-teams {
  grid-column: 3 / 5;
}

.report-col-line-to {
  grid-column: 1 / 4;
  grid-row: 4;
}

.check-row {
  display: flex;
  gap: 18px;
  align-items: center;
  min-height: 46px;
}

.check-item {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.95rem;
  grid-template-columns: none;
}

.check-item input[type="checkbox"] {
  width: auto;
  min-width: auto;
  transform: scale(1.15);
}

.report-actions {
  display: flex;
  align-items: end;
  justify-content: stretch;
}

.report-save-btn {
  min-width: 0;
  width: 100%;
}

.report-col-submit {
  grid-column: 4;
  grid-row: 4;
}

.report-grid select,
.report-grid input:not([type="checkbox"]) {
  height: 44px;
  line-height: 1.2;
  padding-top: 0;
  padding-bottom: 0;
}

.report-grid label {
  gap: 4px;
}

.report-inline-note {
  grid-column: 1 / -1;
  grid-row: 5;
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.port-scan-config-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 24px;
  align-items: end;
}

.port-scan-config-main {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.port-scan-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  margin: 0;
}

.port-scan-config-field {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.port-scan-config-field input:not([type="checkbox"]) {
  height: 46px;
}

.port-scan-config-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
}

.port-scan-config-note {
  grid-column: 1 / -1;
  grid-row: auto;
  margin-top: -2px;
}

@media (max-width: 900px) {
  .port-scan-config-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .port-scan-config-actions {
    justify-content: stretch;
  }

  .port-scan-config-actions .btn {
    width: 100%;
  }
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.row-actions > * {
  min-width: 0;
}

.latency-filters {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.latency-filters input[type="datetime-local"] {
  width: 210px;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.inline-field {
  color: var(--muted);
  font-size: 0.88rem;
}

.history-footer {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.message {
  margin: 12px 0 0;
  min-height: 1.2em;
  color: #8f2b00;
}

.port-scan-request-log {
  margin: 12px 0 0;
  padding: 12px 14px;
  min-height: 132px;
  max-height: 280px;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(35, 58, 94, 0.12);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  color: #24415d;
  font: 12px/1.55 Consolas, "Courier New", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.health-delay-overview {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.health-delay-state {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(35, 58, 94, 0.1);
  background: rgba(255, 255, 255, 0.82);
}

.health-delay-state strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.health-delay-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.health-delay-state.is-ok {
  background: linear-gradient(160deg, #eefaf3, #def4e7);
}

.health-delay-state.is-warn {
  background: linear-gradient(160deg, #fff7ea, #ffe5bf);
}

.health-delay-state.is-error {
  background: linear-gradient(160deg, #fff0ee, #ffd7d1);
}

.health-delay-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.health-delay-item {
  padding: 15px 16px;
  border-radius: 16px;
  border: 1px solid rgba(35, 58, 94, 0.1);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 24px rgba(50, 64, 91, 0.08);
}

.health-delay-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.health-delay-item-head strong {
  min-width: 0;
  font-size: 1rem;
}

.health-delay-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(180, 58, 45, 0.12);
  color: #8e2f25;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.health-delay-item-meta,
.health-delay-item-note {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.health-delay-item-note {
  color: var(--text);
}

.health-delay-fix-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--text);
}

.health-delay-fix-list li + li {
  margin-top: 6px;
}

.history-alert-row td {
  color: var(--danger);
  font-weight: 600;
}

.log-cell-wrap {
  max-width: 360px;
  white-space: normal;
  word-break: break-word;
}

.service-admin-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(560px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.service-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, #fffdf7, #f7fbff);
  box-shadow: 0 8px 20px rgba(50, 64, 91, 0.08);
  overflow: hidden;
}

.service-card.service-card-warn {
  border-color: #e4c65c;
  background: linear-gradient(160deg, #fff8d7, #fff1b3);
  box-shadow: 0 8px 20px rgba(153, 117, 0, 0.12);
}

.service-card.service-card-warn .service-card-header {
  background: linear-gradient(180deg, #fff6cf, #ffefae);
  border-bottom-color: #ecd27a;
}

.service-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid #e8edf5;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.service-card-title {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.service-card-title strong {
  font-size: 1.02rem;
}

.service-card-url {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  word-break: break-all;
}

.service-check-mode-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.service-check-mode-detail {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.service-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.check-mode-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.check-mode-badge.single {
  background: rgba(26, 156, 137, 0.12);
  color: var(--primary);
}

.check-mode-badge.dual {
  background: rgba(40, 89, 168, 0.12);
  color: #2a57a8;
}

.check-mode-badge.pending {
  background: rgba(179, 129, 0, 0.14);
  color: #8b6500;
}

.table-service-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.service-card-side {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
}

.service-card-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.service-card-meta {
  color: var(--muted);
  font-size: 0.84rem;
  max-width: 280px;
  white-space: normal;
}

.service-card-body {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
}

.service-card-body-compact {
  gap: 12px;
}

.service-card-section {
  display: grid;
  gap: 8px;
}

.service-card-section h3 {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text);
}

.service-card-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.service-card-grid label {
  margin: 0;
}

.service-card .field-default {
  display: none;
}

.service-main-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.service-main-grid label,
.service-card-grid-compact label {
  margin: 0;
}

.service-main-grid input:not([type="checkbox"]),
.service-main-grid select,
.service-card-grid-compact input:not([type="checkbox"]),
.service-card-grid-compact select {
  height: 46px;
}

.service-main-grid select,
.service-card-grid-compact select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.service-result-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.service-result-item {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #f7fafc;
  border: 1px solid #e6edf4;
}

.service-result-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

.service-result-item strong {
  font-size: 0.93rem;
}

.service-result-item-wide {
  grid-column: 1 / -1;
}

.service-advanced {
  border: 1px solid #e6edf4;
  border-radius: 12px;
  background: #fcfdff;
  padding: 10px 12px;
}

.service-advanced summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}

.service-advanced summary::-webkit-details-marker {
  display: none;
}

.service-advanced summary::after {
  content: "展開";
  float: right;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.service-advanced[open] summary::after {
  content: "收合";
}

.service-card-grid-compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.span-1 {
  grid-column: span 1;
}

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

.span-3 {
  grid-column: span 3;
}

.service-inline-check {
  align-self: end;
  min-height: 0;
}

.service-result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.service-result-grid > div {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #f7fafc;
  border: 1px solid #e6edf4;
}

.service-result-grid span {
  color: var(--muted);
  font-size: 0.8rem;
}

.service-result-grid strong {
  font-size: 0.95rem;
}

.service-result-wide {
  grid-column: 1 / -1;
}

.service-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 14px 14px;
}

.service-empty {
  padding: 18px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  background: #fbfdff;
  color: var(--muted);
  text-align: center;
}

.service-add-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.service-defaults-intro {
  margin: 0 0 12px;
}

.service-defaults-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.service-defaults-grid > div {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #e6edf4;
  border-radius: 12px;
  background: #f8fbff;
}

.service-defaults-grid strong {
  font-size: 0.86rem;
  color: var(--text);
}

.service-defaults-grid span {
  font-size: 0.82rem;
  color: var(--muted);
}

.service-defaults-grid-compact {
  margin-top: 12px;
}

.field-default {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.probe-admin-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.probe-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, #fffdf7, #f7fbff);
  box-shadow: 0 8px 20px rgba(50, 64, 91, 0.08);
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}

.probe-card-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.probe-card-subtitle {
  margin-top: 4px;
  font-size: 0.84rem;
  color: var(--muted);
}

.probe-status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.probe-online {
  background: rgba(23, 125, 63, 0.12);
  color: var(--up);
}

.probe-offline {
  background: rgba(190, 45, 45, 0.12);
  color: var(--danger);
}

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

.probe-card-grid > div {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #f7fafc;
  border: 1px solid #e6edf4;
}

.probe-card-grid span {
  color: var(--muted);
  font-size: 0.78rem;
}

.probe-card-grid strong {
  font-size: 0.92rem;
}

.probe-wide {
  grid-column: 1 / -1;
}

.probe-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.probe-card-compact {
  border-radius: 12px;
  padding: 10px 12px;
  gap: 8px;
}

.probe-card-compact .probe-card-header {
  gap: 8px;
}

.probe-card-compact .probe-card-header strong {
  display: block;
  line-height: 1.2;
}

.probe-card-compact .probe-card-subtitle {
  margin-top: 2px;
  font-size: 0.8rem;
  line-height: 1.3;
}

.probe-card-compact .probe-status-badge {
  padding: 4px 9px;
  font-size: 0.78rem;
}

.probe-compact-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 6px;
}

.probe-compact-kpi,
.probe-compact-line {
  display: grid;
  gap: 3px;
  border: 1px solid #e6edf4;
  border-radius: 10px;
}

.probe-compact-kpi {
  padding: 6px 8px;
  background: #f7fafc;
}

.probe-compact-line {
  padding: 7px 9px;
  background: #ffffff;
}

.probe-compact-kpi span,
.probe-compact-line span {
  color: var(--muted);
  font-size: 0.74rem;
}

.probe-compact-kpi strong,
.probe-compact-line strong {
  font-size: 0.88rem;
  line-height: 1.3;
}

.probe-compact-lines {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.probe-compact-line-wide {
  grid-column: 1 / -1;
}

.probe-compact-error {
  border-color: rgba(190, 45, 45, 0.18);
  background: #fff8f8;
}

.probe-card-compact .probe-card-actions {
  gap: 6px;
  margin-top: 2px;
}

.probe-card-compact .log-cell-wrap {
  max-width: none;
}

.probe-card-compact-v2 {
  gap: 6px;
  padding: 9px 10px;
}

.probe-card-compact-v2 .probe-card-header {
  align-items: center;
}

.probe-card-side-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.probe-card-compact-v2 .probe-card-actions {
  padding: 0;
  gap: 4px;
}

.probe-card-compact-v2 .probe-card-actions .btn {
  min-width: 0;
  padding: 5px 9px;
}

.probe-compact-grid-six {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.probe-card-compact-v2 .probe-compact-kpi {
  padding: 5px 7px;
}

.probe-card-compact-v2 .probe-compact-kpi span,
.probe-card-compact-v2 .probe-compact-summary span {
  font-size: 0.72rem;
}

.probe-card-compact-v2 .probe-compact-kpi strong,
.probe-card-compact-v2 .probe-compact-summary strong {
  font-size: 0.84rem;
  line-height: 1.2;
}

.probe-compact-summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.probe-compact-summary {
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid #e6edf4;
  border-radius: 10px;
  background: #ffffff;
}

.probe-port-scan-summary {
  gap: 4px;
  background: linear-gradient(180deg, #f8fbff, #ffffff);
}

.probe-port-scan-summary small {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.probe-card-compact-v2 .log-cell-wrap {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 720px) {
  .brand-logo {
    width: 50px;
    height: 50px;
  }

  .brand-eyebrow {
    display: none;
  }

  .brand-copy h1 {
    font-size: 1.34rem;
  }

  .probe-compact-lines {
    grid-template-columns: 1fr;
  }

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

  .probe-card-side-actions {
    width: 100%;
    justify-content: space-between;
  }
}

/* ---- Scroll FAB (floating scroll buttons) ---- */
.fab-wrap {
  position: fixed;
  bottom: 20px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fab {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(15, 123, 108, 0.88);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(50, 64, 91, 0.28);
  backdrop-filter: blur(6px);
  transition: opacity 220ms ease, transform 220ms ease, background 150ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.fab:hover {
  background: rgba(10, 92, 82, 0.96);
  transform: scale(1.08);
}

.fab.fab--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.72);
}

@media (max-width: 980px) {
  .service-admin-list {
    grid-template-columns: 1fr;
  }

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

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

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

  .service-card-grid,
  .service-main-grid,
  .service-result-strip,
  .service-card-grid-compact,
  .probe-card-grid,
  .service-result-grid,
  .service-add-grid,
  .service-defaults-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .service-card-section .service-card-grid label,
  .service-main-grid label,
  .service-card-grid-compact label,
  .span-1,
  .span-2,
  .span-3 {
    grid-column: auto !important;
  }

  .test-data-grid {
    grid-template-columns: 1fr;
  }

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

  .latency-filters {
    justify-content: flex-start;
  }

  .latency-filters input[type="datetime-local"] {
    width: 170px;
  }
}

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

  .field-span-all {
    grid-column: span 1;
  }

  .report-col-frequency,
  .report-col-mode,
  .report-col-daily-hour,
  .report-col-options,
  .report-col-submit {
    grid-column: span 1;
  }

  .check-row {
    flex-wrap: wrap;
    min-height: 0;
  }

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

  .service-defaults-grid {
    grid-template-columns: 1fr;
  }

  .service-main-grid,
  .service-result-strip,
  .service-card-grid-compact,
  .probe-card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .container,
  .topbar {
    width: 96vw;
  }

  nav {
    width: 100%;
  }

  nav a {
    flex: 1;
    text-align: center;
    padding: 8px 6px;
    font-size: 0.88rem;
  }

  h1 {
    font-size: 1.25rem;
  }

  .topbar p {
    font-size: 0.82rem;
  }

  .panel {
    padding: 12px;
    min-width: 0;
    overflow-x: hidden;
  }

  .panel-header {
    flex-wrap: wrap;
    gap: 8px;
  }

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

  .service-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .service-card-side {
    justify-items: start;
    text-align: left;
  }

  .service-card-meta {
    white-space: normal;
    word-break: break-word;
  }

  .service-card-grid,
  .service-result-grid,
  .service-add-grid {
    grid-template-columns: 1fr;
  }

  .service-card-actions {
    flex-direction: column;
  }

  .service-card-actions .btn {
    width: 100%;
  }

  /* ---- 4 cards per row on mobile ---- */
  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }

  .summary-grid .metric {
    padding: 9px 7px;
    border-radius: 10px;
  }

  .summary-grid .metric p {
    font-size: 0.68rem;
    margin-bottom: 3px;
  }

  .summary-grid .metric strong {
    font-size: 1rem;
  }

  .summary-grid .metric-range-value {
    font-size: 0.72rem;
  }

  /* ---- Contain overflow at container level ---- */
  .container {
    overflow-x: hidden;
  }

  /* ---- Tables → Card view on mobile ---- */
  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 0 !important;
    display: block;
  }

  table thead {
    display: none;
  }

  table tbody {
    display: block;
  }

  table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: #fff;
    transition: none;
    box-shadow: 0 2px 8px rgba(50, 64, 91, 0.06);
  }

  table tbody tr:hover {
    background: #f6faff;
  }

  table tbody tr.selected-row {
    background: #ecf7ff;
  }

  table tbody td {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 5px 0;
    border: none;
    border-bottom: 1px solid #eff1f6;
    font-size: 0.87rem;
    vertical-align: unset;
  }

  table tbody td:last-child {
    border-bottom: none;
    padding-bottom: 3px;
  }

  table tbody td::before {
    content: attr(data-label);
    flex-shrink: 0;
    width: 72px;
    min-width: 72px;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.3px;
  }

  table tbody td[data-label=""]::before,
  table tbody td:not([data-label])::before {
    display: none;
    width: 0;
    min-width: 0;
  }

  /* inputs and links fill remaining space in flex td */
  table tbody td > input:not([type="checkbox"]),
  table tbody td > .name-cell input:not([type="checkbox"]),
  table tbody td > .url-ellipsis {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  /* Fix: checkbox must keep its natural size, not stretch full-width */
  table tbody td > input[type="checkbox"] {
    width: auto;
    min-width: 0;
    flex: 0 0 auto;
    transform: scale(1.2);
  }

  /* URL: allow wrapping on mobile; top-align label against multi-line URL */
  .url-ellipsis {
    max-width: none;
    white-space: normal;
    word-break: break-all;
    overflow: visible;
    text-overflow: unset;
  }

  table tbody td[data-label="URL"] {
    align-items: flex-start;
  }

  /* Admin: button cells go side-by-side at the bottom of each card */
  #adminServicesBody td:nth-child(n+5) {
    width: auto;
    border-bottom: none;
    padding: 6px 4px 4px 0;
    flex: 0 0 auto;
  }

  #adminServicesBody td:nth-child(n+5)::before {
    display: none;
  }

  /* First button cell: visual separator line above button group */
  #adminServicesBody td:nth-child(5) {
    border-top: 1px solid var(--line);
    margin-top: 4px;
    padding-top: 8px;
  }

  /* Fix: interval number input — cap width, no need to be full-width */
  #adminServicesBody td:nth-child(3) > input[type="number"] {
    flex: 0 0 auto;
    width: 84px;
  }

  /* ---- Charts: shorter on small screens ---- */
  canvas {
    min-height: 190px;
    max-height: 230px;
  }

  /* ---- Latency filter controls ---- */
  .latency-filters {
    width: 100%;
    justify-content: flex-start;
  }

  .latency-filters input[type="datetime-local"] {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }

  /* ---- Hint text: allow wrapping ---- */
  .hint {
    white-space: normal;
  }

  /* ---- Admin: full-width save button ---- */
  .report-save-btn {
    min-width: 0;
    width: 100%;
  }

  /* ---- Admin: report form selects + inputs — full width, natural height ---- */
  .report-grid select {
    width: 100%;
    min-width: 0;
  }

  .report-grid select,
  .report-grid input:not([type="checkbox"]) {
    height: auto;
    padding: 10px 12px;
    line-height: normal;
  }

  /* ---- Admin: delete/add-service danger + submit buttons full-width ---- */
  .test-data-grid .btn,
  .form-grid .btn {
    width: 100%;
  }

  /* ---- Admin: line user stats text wrap ---- */
  #lineUserStats {
    white-space: normal;
    word-break: break-all;
  }
}

/* ---- Responsive refinement: tablet + mobile ---- */
@media (max-width: 1180px) {
  .topbar,
  .container {
    width: min(100vw - 28px, 1180px);
  }

  th,
  td {
    padding: 10px 8px;
    font-size: 0.94rem;
  }

  .url-ellipsis {
    max-width: 250px;
  }

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

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

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

  .report-col-monitor,
  .report-col-recipients,
  .report-col-mode,
  .report-col-frequency,
  .report-col-daily-hour,
  .report-col-options,
  .report-col-line-token,
  .report-col-line-to,
  .report-col-submit,
  .report-inline-note {
    grid-column: auto;
    grid-row: auto;
  }

  .report-col-line-token,
  .report-col-line-to,
  .report-inline-note {
    grid-column: 1 / -1;
  }

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

  .latency-filters {
    justify-content: flex-start;
  }

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

  .test-data-grid .btn {
    grid-column: 1 / -1;
  }

  .report-col-submit {
    grid-column: 1 / -1;
  }

  .report-actions {
    justify-content: flex-end;
  }

  .report-save-btn {
    width: min(320px, 100%);
    margin-left: auto;
  }

  .service-card-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .service-card-actions .btn {
    width: 100%;
  }
}

@media (max-width: 860px) {
  .topbar,
  .container {
    width: calc(100vw - 20px);
  }

  .topbar {
    margin: 16px auto 10px;
    padding: 14px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  nav {
    width: 100%;
    flex-wrap: wrap;
  }

  nav a {
    flex: 1 1 calc(33.333% - 6px);
    text-align: center;
  }

  .container {
    margin-bottom: 32px;
  }

  .panel {
    padding: 14px;
  }

  .panel-header,
  .history-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel-header .row-actions,
  .history-footer .row-actions {
    width: 100%;
  }

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

  .row-actions .btn:not(.tiny),
  .row-actions .select,
  .row-actions input:not([type="checkbox"]) {
    flex: 1 1 180px;
  }

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

  .report-grid.report-grid-compact {
    grid-template-columns: 1fr;
  }

  .report-col-monitor,
  .report-col-recipients,
  .report-col-mode,
  .report-col-frequency,
  .report-col-daily-hour,
  .report-col-options,
  .report-col-line-token,
  .report-col-line-to,
  .report-col-submit,
  .report-inline-note {
    grid-column: 1;
    grid-row: auto;
  }

  .check-row {
    flex-wrap: wrap;
    min-height: 0;
  }

  .service-card-grid,
  .service-main-grid,
  .service-result-strip,
  .service-card-grid-compact,
  .service-result-grid,
  .service-add-grid,
  .service-defaults-grid,
  .probe-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .latency-filters input[type="datetime-local"] {
    width: auto;
    flex: 1 1 220px;
  }

  .all-availability-badge {
    white-space: normal;
  }
}

@media (max-width: 860px) {
  .service-modal-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .service-modal-meta-item-wide {
    grid-column: auto;
  }

  .health-delay-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .summary-grid .metric {
    padding: 12px 10px;
    border-radius: 12px;
  }

  .summary-grid .metric p {
    font-size: 0.74rem;
    margin-bottom: 4px;
  }

  .summary-grid .metric strong {
    font-size: 1.08rem;
  }

  .summary-grid .metric-range-value {
    font-size: 0.78rem;
  }

  nav a {
    flex: 1 1 calc(33.333% - 6px);
    font-size: 0.84rem;
  }

  .row-actions .btn,
  .row-actions .select,
  .row-actions input:not([type="checkbox"]) {
    width: 100%;
    flex: 1 1 100%;
  }

  .service-card-grid,
  .service-main-grid,
  .service-result-strip,
  .service-card-grid-compact,
  .service-result-grid,
  .service-add-grid,
  .service-defaults-grid,
  .probe-card-grid,
  .probe-compact-grid-six {
    grid-template-columns: 1fr;
  }

  .probe-card-side-actions,
  .probe-card-actions {
    width: 100%;
    justify-content: stretch;
  }

  .probe-card-actions .btn {
    flex: 1 1 100%;
  }

  .service-card-actions {
    grid-template-columns: 1fr;
  }

  table tbody td::before {
    width: 84px;
    min-width: 84px;
  }

  .history-footer {
    align-items: stretch;
  }

  .history-footer .hint {
    width: 100%;
  }

  .service-modal {
    padding: 12px;
  }

  .service-modal-dialog {
    max-height: 92vh;
    border-radius: 20px;
  }

  .service-modal-header,
  .service-modal-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .service-modal-summary-grid,
  .service-modal-meta-grid {
    grid-template-columns: 1fr;
  }

  .service-modal-meta-item-wide {
    grid-column: auto;
  }

  .service-modal-section-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 1100px) {
  .page-dashboard .topbar,
  .page-dashboard .container {
    width: calc(100vw - 24px);
  }

  .page-dashboard .topbar {
    margin: 16px auto 10px;
    padding: 14px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-dashboard nav {
    width: 100%;
    flex-wrap: wrap;
  }

  .page-dashboard nav a {
    flex: 1 1 calc(33.333% - 6px);
    text-align: center;
  }

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

  .page-dashboard .panel-header,
  .page-dashboard .history-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .page-dashboard .panel-header .row-actions,
  .page-dashboard .history-footer .row-actions,
  .page-dashboard .latency-filters {
    width: 100%;
    justify-content: flex-start;
  }

  .page-dashboard .row-actions {
    flex-wrap: wrap;
  }

  .page-dashboard .row-actions .btn:not(.tiny),
  .page-dashboard .row-actions .select,
  .page-dashboard .row-actions input:not([type="checkbox"]) {
    flex: 1 1 180px;
  }

  .page-dashboard .latency-filters input[type="datetime-local"] {
    width: 100%;
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }

  .page-dashboard .all-availability-badge,
  .page-dashboard .hint {
    white-space: normal;
  }
}
