/* SmartCertPro — phone-first. One design that stretches to desktop.
   Big touch targets, obvious labels, honest state colours (design law). */

:root {
  --brand: #12507a;
  --brand-dark: #0e3f61;
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1a2733;
  --muted: #5c6b7a;
  --line: #d9e0e6;
  --ok: #1c7c3f;
  --ok-bg: #e6f4ec;
  --warn: #8a5a00;
  --warn-bg: #fdf3e0;
  --err: #b3261e;
  --err-bg: #fce9e8;
  --queued: #1f5fa8;
  --queued-bg: #e7f0fb;
  --radius: 12px;
  --tap: 48px; /* minimum touch target */
  --maxw: 720px;
  font-size: 17px;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over a class that sets display.
   (Without this, .topbar/.sidenav/.nudge { display: … } override [hidden] and
   an invisible overlay silently swallows taps.) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

/* ---- top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(env(safe-area-inset-top), 10px) 14px 10px;
  background: var(--brand);
  color: #fff;
}
.topbar-title { font-weight: 700; font-size: 1.05rem; flex: 0 0 auto; }
.topbar .queue-pill { margin-left: auto; }
.topbar .linkbtn { color: #fff; }

/* ---- layout ---- */
.view {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 14px calc(96px + env(safe-area-inset-bottom));
}
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

.sidenav {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 14px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.sidenav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
.sidenav a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---- home tiles ---- */
.tiles { display: grid; gap: 12px; margin-bottom: 16px; }
.tile { transition: border-color 0.1s; }
.tile:active { border-color: var(--brand); }

/* ---- cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin: 0 0 16px;
}
h1 { font-size: 1.5rem; margin: 4px 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---- forms ---- */
label { display: block; font-weight: 600; margin: 14px 0 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.9rem; }
input[type="text"], input[type="password"], input[type="tel"], input[type="url"], textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus { outline: 3px solid #bcd7ee; border-color: var(--brand); }

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  background: #fff;
  color: var(--brand);
  border-color: var(--line);
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-dark); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.linkbtn {
  background: none;
  border: none;
  color: var(--brand);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 44px;
  padding: 6px 8px;
}
.iconbtn {
  background: none; border: none; color: inherit; font-size: 1.3rem;
  min-width: 44px; min-height: 44px; cursor: pointer;
}

/* ---- honest state pills ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
}
.pill.ok     { background: var(--ok-bg);     color: var(--ok); }
.pill.saving { background: var(--queued-bg); color: var(--queued); }
.pill.queued { background: var(--queued-bg); color: var(--queued); }
.pill.failed { background: var(--err-bg);    color: var(--err); }
.pill.warn   { background: var(--warn-bg);   color: var(--warn); }

.queue-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 0.85rem; background: rgba(255,255,255,0.18); color: #fff; }

.savebar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.savebar .status { min-height: 32px; display: inline-flex; align-items: center; }

/* ---- logo preview ---- */
.logo-preview {
  display: block;
  max-width: 180px;
  max-height: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: #fff;
  margin: 8px 0;
}

/* ---- messages ---- */
.msg { padding: 12px 14px; border-radius: 10px; margin: 12px 0; font-weight: 600; }
.msg.ok  { background: var(--ok-bg);  color: var(--ok); }
.msg.err { background: var(--err-bg); color: var(--err); }

/* ---- diagnostics tables / logs ---- */
.logrow { border-bottom: 1px solid var(--line); padding: 10px 0; font-size: 0.9rem; }
.logrow .ts { color: var(--muted); font-size: 0.8rem; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #eef2f5; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.tag.err { background: var(--err-bg); color: var(--err); }
.tag.ok  { background: var(--ok-bg);  color: var(--ok); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
.scroll { overflow-x: auto; }

/* ---- build badge ---- */
.build-badge {
  position: fixed;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
  background: rgba(26, 39, 51, 0.82);
  color: #fff;
  font-size: 0.72rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
}

/* ---- install nudge ---- */
.nudge {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  justify-content: center;
  padding: 12px;
}
.nudge-body {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  padding: 16px;
  max-width: var(--maxw);
  width: 100%;
}
.nudge-body strong { display: block; margin-bottom: 4px; }
.nudge-body p { margin: 4px 0 12px; color: var(--muted); }
.nudge-actions { display: flex; align-items: center; gap: 10px; }

/* ---- desktop stretch: the same design, wider and calmer ---- */
@media (min-width: 900px) {
  :root { --maxw: 860px; }
  .view { padding-top: 28px; }
  .form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
  .form-2col .full { grid-column: 1 / -1; }
}
