/* FamilyTime portal. Mobile first; working screens use the width they are given. */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1c2333;
  --muted: #5b6477;
  --accent: #2457c5;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --ok: #1e7b3c;
  --border: #d8deea;
  --shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 2px 6px rgba(16, 24, 40, .10);
  --shadow-hover: 0 2px 4px rgba(16, 24, 40, .10), 0 6px 14px rgba(16, 24, 40, .14);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151d;
    --surface: #1a202b;
    --text: #e8ecf4;
    --muted: #a3acbd;
    --accent: #6f9cff;
    --accent-text: #0b1020;
    --danger: #ff8a80;
    --ok: #7bd88f;
    --border: #2c3443;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .45);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .55), 0 6px 14px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

/* Working surface: 92% of the screen, never below 1200px, never wider than the viewport. */
.app-surface {
  width: min(100%, max(1200px, 92%));
  max-width: none;
  margin-inline: auto;
  padding-inline: 16px;
}

p { max-width: 68ch; }
a { color: var(--accent); }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
.topbar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding-block: 10px; }
.brand { font-weight: 700; font-size: 1.2rem; text-decoration: none; color: var(--text); }
.nav { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.nav a, .link-button {
  padding: 6px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}
.nav a.active { background: var(--bg); font-weight: 600; box-shadow: var(--shadow); }
.nav a:hover, .link-button:hover { background: var(--bg); box-shadow: var(--shadow); }
.inline { display: inline; margin: 0; }
.link-button { background: none; border: 0; font: inherit; cursor: pointer; }

.page { padding-block: 20px 40px; }
.footer { padding-block: 12px 24px; color: var(--muted); font-size: .9rem; }

h1 { font-size: 1.6rem; margin: 0 0 12px; }
h2 { font-size: 1.2rem; margin: 24px 0 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card.narrow { max-width: 560px; }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
a.card { display: block; color: inherit; text-decoration: none; transition: box-shadow .15s; }
a.card:hover { box-shadow: var(--shadow-hover); }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
.hint { color: var(--muted); font-size: .9rem; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], select {
  width: 100%;
  max-width: 420px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 5px; width: 18px; height: 18px; box-shadow: var(--shadow); }

.btn, button.btn {
  display: inline-block;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, transform .05s;
}
.btn:hover { box-shadow: var(--shadow-hover); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: .7; cursor: progress; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; align-items: center; }

.notice { background: var(--surface); border-left: 4px solid var(--ok); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; box-shadow: var(--shadow); }
.warning { border-left-color: #c98a00; }
.error-summary:empty { display: none; }
.error-summary, .field-error { color: var(--danger); }
.error-summary ul { margin: 0; padding-left: 20px; }
.field-error { display: block; font-size: .9rem; }

.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.week input { max-width: 100%; }

table.list { width: 100%; border-collapse: collapse; background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list th { background: var(--bg); font-size: .9rem; color: var(--muted); }

.codes { font-family: Consolas, "Cascadia Mono", monospace; font-size: 1.1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.key { font-family: Consolas, "Cascadia Mono", monospace; font-size: 1.1rem; letter-spacing: .05em; word-break: break-all; }
.qr { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 8px; box-shadow: var(--shadow); }
.muted { color: var(--muted); }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .85rem; background: var(--bg); border: 1px solid var(--border); margin-right: 4px; }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.danger { color: var(--danger); border-color: var(--danger); }
.actions.compact { margin-top: 10px; gap: 8px; }
.actions.compact .btn { padding: 8px 14px; }
form.until, form.bind { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
form.until label { margin: 0; font-weight: 400; }
form.until input, form.bind select { width: auto; }
.card.request { border-left: 4px solid var(--accent); }
.pairing-code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 2rem; letter-spacing: .1em; font-weight: 700; margin: 4px 0 12px; }

/* Busy feedback: shown the moment a form is submitted. */
.busy-overlay { position: fixed; inset: 0; background: rgba(10, 14, 22, .35); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.busy-overlay[hidden] { display: none; }
.busy-box { background: var(--surface); color: var(--text); padding: 18px 24px; border-radius: var(--radius); display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow-hover); font-weight: 600; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--accent); border-right-color: var(--accent); }
  * { transition: none !important; }
}

@media (max-width: 600px) {
  .app-surface { padding-inline: 12px; }
  h1 { font-size: 1.35rem; }
  .btn { width: 100%; text-align: center; }
  .actions { flex-direction: column; align-items: stretch; }
  .actions.compact { flex-direction: row; flex-wrap: wrap; }
  .actions.compact .btn, form.until .btn, form.bind .btn { width: auto; }
  table.list { display: block; overflow-x: auto; }
}
