*,*::before,*::after { box-sizing: border-box; }
html,body { margin: 0; }
body {
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  background: #f4f5f7; color: #1c2026; line-height: 1.45;
}
a { color: #1976d2; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; background: #f0f1f3; padding: 1px 4px; border-radius: 3px; }
small { color: #777; font-weight: normal; font-size: 0.82em; }

header {
  background: #1c2026; color: #fff;
  padding: 12px 24px;
  display: flex; justify-content: space-between; align-items: center;
}
header h1 { margin: 0; font-size: 1.05rem; font-weight: 600; }
header a { color: #fff; text-decoration: none; }
header form.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
header form.logout span { opacity: 0.7; font-size: 0.9rem; }
header button { background: #2a2f37; color: #fff; border: 1px solid #3a3f48; padding: 5px 12px; border-radius: 3px; cursor: pointer; font-size: 0.85rem; }
header button:hover { background: #353b44; }

main { max-width: 1000px; margin: 28px auto; padding: 0 20px; }

.card { background: #fff; border: 1px solid #e1e3e7; border-radius: 5px; padding: 22px 26px; margin-bottom: 18px; }
.card h2 { margin: 0 0 14px; font-size: 1.15rem; }
.card h2 small { font-weight: normal; color: #888; margin-left: 6px; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.row.right { justify-content: flex-end; }
.muted { color: #777; }

.btn, button {
  display: inline-block; padding: 8px 14px;
  background: #eee; border: 1px solid #d0d3d7;
  border-radius: 3px; cursor: pointer;
  text-decoration: none; color: #1c2026;
  font: inherit; font-size: 0.9rem;
}
.btn:hover, button:hover { background: #e3e5e9; }
.btn.primary, button[type=submit] {
  background: #1976d2; color: #fff; border-color: #1976d2;
}
.btn.primary:hover, button[type=submit]:hover { background: #1565c0; border-color: #1565c0; }
button:disabled { opacity: 0.5; cursor: wait; }

.login { max-width: 380px; margin: 60px auto 0; }
.login h2 { text-align: center; margin-bottom: 18px; }

form label { display: block; margin-bottom: 14px; font-weight: 500; font-size: 0.92rem; }
form input {
  width: 100%; padding: 9px 10px; font: inherit; font-size: 0.95rem;
  margin-top: 4px; border: 1px solid #c8ccd2; border-radius: 3px;
  background: #fff;
}
form input:focus { outline: 2px solid #1976d2; outline-offset: -1px; }

.error { color: #b00020; margin: 0 0 12px; font-size: 0.9rem; }
.error.inline { margin: 4px 0 0; font-weight: normal; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid #ececec; text-align: left; font-size: 0.91rem; }
th { background: #fafafa; font-weight: 600; }

.result { padding: 14px 18px; border-radius: 4px; margin-top: 18px; border: 1px solid; }
.result.ok { background: #e8f5e9; border-color: #66bb6a; }
.result.fail { background: #ffebee; border-color: #ef5350; }
.step { margin: 0 0 6px; padding: 6px 10px; border-radius: 3px; font-size: 0.92rem; }
.step.ok   { background: #f1f8f3; border-left: 3px solid #66bb6a; }
.step.fail { background: #fdf0f0; border-left: 3px solid #ef5350; }
.result h3 { margin: 0 0 8px; font-size: 1rem; }
.result details { margin-top: 8px; }
.result summary { cursor: pointer; font-size: 0.9rem; color: #555; }
.result pre {
  background: #1c2026; color: #e6e8eb; padding: 12px 14px;
  border-radius: 3px; overflow: auto; max-height: 380px;
  font-size: 0.82rem; line-height: 1.4; margin-top: 8px;
}

.htmx-indicator { opacity: 0; transition: opacity 200ms ease; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* ── Tablet / iPad ─────────────────────────────────────────────────────── */

/* iPad portrait (≤820px): tighten margins, let cards breathe, single column */
@media (max-width: 820px) {
  main { padding: 0 14px; margin-top: 18px; }
  .card { padding: 18px 18px; }
  .row { flex-wrap: wrap; gap: 8px; }
  .row.right { justify-content: stretch; }
  .row.right .btn,
  .row.right button { flex: 1 1 140px; }

  /* Tenants table: let it scroll horizontally instead of getting clipped */
  .card table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td { white-space: nowrap; }

  /* Login centred lower so the soft-keyboard doesn't push it off-screen */
  .login { margin-top: 24px; }

  /* Deploy-output <pre> wraps so users can read it without sideways scroll */
  .result pre { white-space: pre-wrap; word-break: break-word; }
}

/* Touch devices (iPad, regardless of orientation): bigger tap targets */
@media (hover: none) and (pointer: coarse) {
  .btn, button { min-height: 40px; padding-top: 10px; padding-bottom: 10px; }
  form input { font-size: 16px; padding: 12px 12px; }    /* 16px prevents iOS auto-zoom */
  header { padding: 14px 20px; }
  header h1 { font-size: 1rem; }
}
