/* Squarefrog Uptime Monitor */
:root {
  --brand: #ef0c77;          /* logo pink */
  --accent: #d10a68;         /* slightly deeper pink: passes WCAG AA for text and white-on-pink buttons */
  --accent-text: #c2095f;
  --bg: #f6f5f7; --card: #fff; --text: #1f1a22; --muted: #6f6874; --border: #e8e3ea;
  --up: #15803d; --up-bg: #dcfce7; --down: #dc2626; --down-bg: #fee2e2;
  --pending: #a16207; --pending-bg: #fef3c7;
  --blip: #f59e0b; --blip-text: #92400e; --blip-bg: #fef3c7;
  --radius: 12px;
  --font: "Ubuntu", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Ubuntu Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent-text: #ff6aad;
    --bg: #141116; --card: #1e1a21; --text: #ece8ee; --muted: #a39ba8; --border: #332c37;
    --up: #4ade80; --up-bg: #12341f; --down: #f87171; --down-bg: #3d1717;
    --pending: #facc15; --pending-bg: #3a3112;
    --blip: #f59e0b; --blip-text: #fbbf24; --blip-bg: #3a2a0c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* Layout; padding respects the iPhone notch / home indicator */
.wrap {
  max-width: 1100px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
header { background: var(--card); border-bottom: 3px solid var(--brand); padding-top: env(safe-area-inset-top); }
header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 400; font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; flex: none; }
.brand b { font-weight: 700; }
nav { display: flex; align-items: center; gap: 18px; }
nav a, nav button { color: var(--muted); font-weight: 500; white-space: nowrap; }
nav a.active { color: var(--accent-text); }
main.wrap { padding-top: 24px; padding-bottom: 40px; }
footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 24px;
  color: var(--muted); font-size: .8rem; padding-top: 8px; padding-bottom: max(24px, env(safe-area-inset-bottom));
}

h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; font-weight: 500; margin: 0 0 12px; }
h3 { font-size: .95rem; font-weight: 500; margin: 0 0 12px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.file-list { margin: 4px 0 0; padding-left: 18px; }
.file-list li { margin-bottom: 2px; }
input[type=file] { padding: 7px; }

/* Monitor switcher */
.switcher { display: flex; gap: 8px; align-items: center; margin-bottom: 18px; }
.switcher select { flex: 0 1 420px; min-width: 0; margin: 0; }
.switcher .button { min-width: 44px; padding: 6px 12px; text-align: center; font-size: 1.25rem; line-height: 1.3; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.toolbar h1 { margin-bottom: 8px; }
.toolbar > div { display: flex; flex-wrap: wrap; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 12px 0 20px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: var(--muted); }
.stat b { display: block; font-size: 1.6rem; font-weight: 700; color: var(--text); }
.stat.up b { color: var(--up); } .stat.down b { color: var(--down); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: 0; }
tr.ongoing td { background: var(--down-bg); }
.mobile-only { display: none; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 500; background: var(--pending-bg); color: var(--pending); white-space: nowrap; }
.badge.up { background: var(--up-bg); color: var(--up); }
.badge.down { background: var(--down-bg); color: var(--down); }
.badge.paused { background: var(--border); color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.mono { font-family: var(--mono); overflow-wrap: anywhere; }
code, pre { font-family: var(--mono); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--up-bg); color: var(--up); overflow-wrap: anywhere; }
.flash.error { background: var(--down-bg); color: var(--down); }

/* Buttons and forms */
button, .button {
  display: inline-block; border: 0; border-radius: 8px; padding: 9px 16px; min-height: 40px;
  background: var(--accent); color: #fff; font: 500 15px/1.4 var(--font); cursor: pointer;
  -webkit-appearance: none; appearance: none; touch-action: manipulation;
}
button:hover, .button:hover { filter: brightness(1.08); text-decoration: none; }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
button.secondary, .button.secondary { background: var(--border); color: var(--text); }
button.danger { background: var(--down); }
button.small { padding: 4px 12px; min-height: 32px; font-size: .85rem; }
button.link { background: none; color: var(--muted); padding: 0; min-height: 0; font-weight: 500; }
form.inline { display: inline; }
.form label { display: block; margin-bottom: 14px; font-weight: 500; font-size: .9rem; }
.form label small { font-weight: 400; color: var(--muted); }
.form label.check { font-weight: 400; display: flex; gap: 10px; align-items: center; }
/* 16px stops iOS Safari zooming in when a field is focused */
input, select, textarea {
  width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: 16px/1.4 var(--font);
}
select { min-height: 42px; }
input[type=checkbox] { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.login { max-width: 380px; margin: 40px auto; }
.login label { display: block; margin-bottom: 14px; }
.login button { width: 100%; }
.notes { display: flex; gap: 6px; align-items: flex-start; min-width: 240px; }
.notes textarea { margin: 0; font-size: 14px; }

/* Check history strip and chart */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.range-form { display: flex; gap: 6px; align-items: center; }
.range-form select { width: auto; margin: 0; min-height: 36px; padding: 6px 10px; }
.js .js-hide { display: none; }
.strip { display: block; width: 100%; height: 32px; margin-bottom: 8px; }
.bar.up { fill: var(--up); background: var(--up); }
.bar.down { fill: var(--down); background: var(--down); }
.bar.blip { fill: var(--blip); background: var(--blip); }
.bar.none { fill: var(--border); background: var(--border); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.badge.blip { background: var(--blip-bg); color: var(--blip-text); }
.print-only { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chart { width: 100%; height: 160px; display: block; background: var(--bg); border-radius: 8px; }
.chart .line { stroke: var(--brand); }
.strip.has-active .bar:not(.active) { opacity: .4; }
.strip .bar { cursor: pointer; }
.strip-info { min-height: 1.5em; margin: 0 0 6px; color: var(--muted); }
.strip.has-active + .strip-info { color: var(--text); font-weight: 500; }
.chart-wrap { position: relative; touch-action: pan-y; cursor: crosshair; }
.chart-guide, .chart-dot, .chart-tip { position: absolute; pointer-events: none; opacity: 0; transition: opacity .12s; }
.hovering .chart-guide, .hovering .chart-dot, .hovering .chart-tip { opacity: 1; }
.chart-guide { top: 0; bottom: 0; width: 1px; background: var(--muted); }
.chart-dot { width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px var(--card); }
.chart-tip {
  white-space: nowrap; padding: 5px 9px; border-radius: 6px; font-size: .8rem; font-weight: 500;
  background: var(--text); color: var(--card); box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
pre { background: var(--bg); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: .85rem; }
.empty { text-align: center; padding: 40px 16px; }

/* Phones */
@media screen and (max-width: 680px) {
  body { font-size: 15px; }
  header .wrap { min-height: 54px; gap: 10px; }
  header .wrap:has(nav) .brand span { display: none; }   /* logo only when the nav needs the room */
  nav { gap: 12px; font-size: .95rem; }
  main.wrap { padding-top: 16px; }
  h1 { font-size: 1.35rem; }
  .card { padding: 16px; border-radius: 10px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stats.three { grid-template-columns: repeat(3, 1fr); }
  .stat { padding: 12px; }
  .stat b { font-size: 1.35rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar > div { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar > div > form { display: block; }
  .toolbar button, .toolbar .button { width: 100%; text-align: center; }

  /* Tables become stacked cards */
  .table-wrap { overflow-x: visible; }
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody { display: block; }
  table.responsive tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px;
    padding: 14px 0; border-bottom: 1px solid var(--border);
  }
  table.responsive tr:last-child { border-bottom: 0; }
  table.responsive tr.ongoing { background: var(--down-bg); margin: 0 -16px; padding: 14px 16px; }
  table.responsive tr.ongoing td { background: none; }
  table.responsive td { display: block; padding: 0; border: 0; min-width: 0; }
  table.responsive td.full { grid-column: 1 / -1; }
  table.responsive td[data-label]::before {
    content: attr(data-label); display: block; font-size: .7rem; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted); font-family: var(--font); margin-bottom: 2px;
  }
  .desktop-only { display: none !important; }
  .mobile-only { display: inline; }
  .notes { min-width: 0; }
  footer { flex-direction: column; align-items: center; text-align: center; }
  .switcher select { flex: 1; }
}
@media screen and (max-width: 360px) {
  nav { gap: 8px; font-size: .85rem; }
  header .wrap { gap: 6px; }
}

/* Pull-to-refresh indicator (home-screen app only); Log out becomes an icon on phones */
.logout svg { display: none; vertical-align: middle; }
@media screen and (max-width: 680px) {
  .logout span { display: none; }
  .logout svg { display: inline-block; }
}
.ptr {
  position: fixed; z-index: 50; left: 50%; top: calc(env(safe-area-inset-top) + 4px);
  width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--muted); box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
  opacity: 0; transform: translate(-50%, 0); pointer-events: none;
  transition: transform .2s ease, opacity .2s ease, color .15s;
}
.ptr.dragging { transition: color .15s; }
.ptr.ready { color: var(--brand); }
.ptr.spin { opacity: 1; color: var(--brand); }
.ptr.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .ptr, .ptr.spin svg { animation: none; transition: none; }
}

/* Print: no menus, monitor navigation, buttons or grey backgrounds; always the light colour scheme */
@media print {
  :root {
    --bg: #fff; --card: #fff; --text: #000; --muted: #555; --border: #ccc;
    --up: #15803d; --up-bg: #dcfce7; --down: #dc2626; --down-bg: #fee2e2;
    --pending: #a16207; --pending-bg: #fef3c7; --blip: #f59e0b; --blip-text: #92400e; --blip-bg: #fef3c7;
    --accent-text: #000;
    color-scheme: light;
  }
  @page { margin: 15mm; }
  html, body { background: #fff; font-size: 11pt; }
  header { border-bottom: 2px solid var(--brand); padding: 0; }
  header .wrap { min-height: 0; padding-bottom: 8px; }
  .brand span { display: inline !important; }
  nav, .switcher, .toolbar > div, .range-form, .strip-info, .ptr, .chart-guide, .chart-dot, .chart-tip,
  button, .button, .flash, .no-print { display: none !important; }
  .wrap, main.wrap { max-width: none; padding-left: 0; padding-right: 0; }
  .print-only { display: inline; }
  .card, .stat { border-color: var(--border); break-inside: avoid; page-break-inside: avoid; box-shadow: none; }
  .card.table-wrap { break-inside: auto; page-break-inside: auto; }   /* long tables may span pages */
  h2 { break-after: avoid; page-break-after: avoid; }
  .table-wrap { overflow: visible; }
  tr { break-inside: avoid; }
  td:first-child, td[data-label="Started"], td[data-label="Resolved"] { white-space: nowrap; }
  .chart { background: #fff; border: 1px solid var(--border); }
  pre { background: #fff; border: 1px solid var(--border); }
  textarea, input, select { background: #fff; border: 0; padding: 0; resize: none; }
  a { color: var(--text); }
  /* Keep status colours (bars, badges) when printing */
  .strip, .bar, .badge, .legend i, .stat b, tr.ongoing td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  footer { padding: 12px 0 0; border-top: 1px solid var(--border); margin-top: 12px; }
}
