/*
 * Mobile first: one column by default, two panels side by side once there is
 * room. Everything is sized in rem so a phone's larger default text scales the
 * layout instead of overflowing it.
 */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2b4a7d;
  --accent-ink: #ffffff;
  --warn-bg: #fef3c7;
  --warn-ink: #92400e;
  --error-bg: #fee2e2;
  --error-ink: #991b1b;
  --ok-bg: #dcfce7;
  --ok-ink: #166534;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a21;
    --ink: #e5e7eb;
    --muted: #9ca3af;
    --line: #2a2f3a;
    --accent: #5b8def;
    --accent-ink: #0b1020;
    --warn-bg: #3b2f0b;
    --warn-ink: #fcd34d;
    --error-bg: #3f1d1d;
    --error-ink: #fca5a5;
    --ok-bg: #14351f;
    --ok-ink: #86efac;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main { max-width: 60rem; margin: 0 auto; padding: 1rem; }
main.centered { max-width: 26rem; padding-top: 3rem; }

h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.1rem; margin: 0; }
.muted { color: var(--muted); }
.small-text { font-size: 0.85rem; }
.grow { flex: 1; }

.bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}
.bar button { flex: 0 0 auto; }

/* Three controls plus the title do not fit a narrow phone on one line, and a
   clipped "Atsijungti" is worse than a second row: give the title its own. */
@media (max-width: 30rem) {
  .bar > strong { flex: 1 0 100%; }
  .bar .grow { display: none; }
  .bar #whoami { flex: 1; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.panel-head h2 { flex: 1; }

/* Controls. 2.75rem keeps every tap target at the 44px minimum. */
button {
  font: inherit;
  min-height: 2.75rem;
  padding: 0 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
button.small { min-height: 2.25rem; padding: 0 0.75rem; font-size: 0.9rem; }
button.link { border: none; background: none; color: var(--accent); padding: 0 0.5rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.danger { color: var(--error-ink); }

.field { display: block; margin-bottom: 0.9rem; }
.field > span, .field > legend { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.9rem; }
fieldset.field { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.8rem; }

input, select {
  font: inherit;
  width: 100%;
  min-height: 2.75rem;
  padding: 0 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: inherit;
}
.check { display: flex; align-items: center; gap: 0.5rem; min-height: 2.25rem; font-weight: normal; }
.check input { width: auto; min-height: auto; }

.notice { padding: 0.7rem 0.9rem; border-radius: var(--radius); margin: 0 0 0.75rem; }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice.error { background: var(--error-bg); color: var(--error-ink); }
.notice.ok { background: var(--ok-bg); color: var(--ok-ink); }

.cards, .status-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
@media (min-width: 44rem) { .cards { grid-template-columns: 1fr 1fr; } }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.card.off { opacity: 0.6; }
.card h3 { margin: 0; font-size: 1rem; }
.card .row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-top: 0.3rem; }
.tag {
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.status-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.status-list li:last-child { border-bottom: none; }

/* The clinic picker: a filtered list rather than 1,487 <option> elements. */
.picker {
  list-style: none;
  margin: -0.6rem 0 0.9rem;
  padding: 0;
  max-height: 14rem;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.picker li { padding: 0; border-bottom: 1px solid var(--line); }
.picker li:last-child { border-bottom: none; }
.picker button {
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 0;
  padding: 0.5rem 0.7rem;
  display: block;
}
.picker .where { display: block; font-size: 0.82rem; color: var(--muted); }
.chosen { margin: -0.5rem 0 0.9rem; font-size: 0.9rem; }

dialog {
  width: min(34rem, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 1.1rem;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog h2 { margin: 0 0 0.9rem; }

menu.actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
}

/* Long service names must wrap rather than push the dialog sideways. */
select, .card h3, .chosen { overflow-wrap: anywhere; }

/* The generated password is read aloud or copied once, so legibility beats
   elegance: a monospace face separates the characters people confuse. */
.generated {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin: 0 0 0.9rem;
  overflow-wrap: anywhere;
  user-select: all;
}

