/* Dark by default: easier on the eyes in reading rooms and night shifts. */
:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel-2: #1a2540;
  --line: #24314f;
  --text: #e6ebf5;
  --muted: #8b97b0;
  --accent: #4da3ff;
  --good: #3ecf8e;
  --warn: #f5b041;
  --bad: #ff6b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Classes below set display (flex, inline-block…), which would otherwise override the hidden attribute. */
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 26px; margin: 4px 0 14px; letter-spacing: -0.3px; }
h2 { font-size: 17px; margin: 22px 0 8px; }
h3 { font-size: 15px; margin: 0 0 6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: 0.2px; }

.view { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 90px); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: space-around;
  padding: 6px 0 calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); padding: 2px 0; }
.tabs a .ico { font-size: 20px; line-height: 24px; }
.tabs a.active { color: var(--accent); }
.tabs a { position: relative; }
.badge { position: absolute; top: 0; left: 50%; margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }

/* Forms */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--text);
  font: inherit; font-size: 16px; padding: 10px 12px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-size: 14px; }
.check input { margin-top: 3px; }

button { font: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 11px 16px;
  background: var(--accent); color: #04121f; font-weight: 600;
}
.btn.block { width: 100%; margin-top: 16px; }
.btn.ghost { background: var(--panel-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.5; }
.link { border: 0; background: none; color: var(--accent); padding: 0; font-size: 15px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* Cards and lists */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 10px 0; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; color: var(--text); }
.item .thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #000; flex: none; }
.item .thumb.empty { display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.item .meta { min-width: 0; flex: 1; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); }
.pill.good { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
.pill.accent { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 8px 0; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 99px; padding: 5px 12px; font-size: 14px; }
.chips button.on { background: var(--accent); color: #04121f; border-color: var(--accent); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 10px 0; }
.gallery figure { margin: 0; position: relative; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: #000; display: block; cursor: zoom-in; }
.gallery .remove { position: absolute; top: 6px; right: 6px; border: 0; border-radius: 99px; background: rgba(0,0,0,.7); color: #fff; width: 28px; height: 28px; }
.gallery figure.removed img { opacity: .25; }

.field { margin: 12px 0; }
.field .k { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.field .v { white-space: pre-wrap; overflow-wrap: anywhere; }

ul.clean { margin: 6px 0; padding-left: 20px; }
ul.clean li { margin: 3px 0; }

.banner { border-left: 3px solid var(--warn); background: var(--panel); padding: 10px 12px; border-radius: 8px; font-size: 14px; color: var(--muted); margin: 10px 0; }
.big { font-size: 22px; font-weight: 700; margin: 2px 0 6px; }
.ddx { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.ddx:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.for { color: var(--good); }
.against { color: var(--bad); }

.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; padding: 28px 0; }

.lightbox { position: fixed; inset: 0; z-index: 20; background: #000; display: flex; align-items: center; justify-content: center; overflow: auto; }
.lightbox img { max-width: 100%; max-height: 100%; touch-action: pinch-zoom; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 76px); z-index: 30; margin: 0 auto; max-width: 480px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.4); }

.login { max-width: 360px; margin: 12vh auto 0; }

/* Medical certificate: a white sheet on screen, the whole page when printed. */
.paper { background: #fff; color: #111; max-width: 720px; margin: 0 auto; padding: 44px 48px; border-radius: 6px; font: 15px/1.6 Georgia, "Times New Roman", serif; }
.paper p { margin: 12px 0; }
.paper-head { text-align: center; border-bottom: 2px solid #111; padding-bottom: 10px; font-size: 13px; }
.paper-head .clinic { font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.paper-title { text-align: center; font-size: 20px; letter-spacing: 2px; margin: 26px 0 6px; }
.paper-meta { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 18px; }
.sign { margin: 48px 0 0 auto; width: 280px; text-align: center; font-size: 13px; }
.sign img { max-height: 64px; max-width: 220px; display: block; margin: 0 auto -6px; }
.sign-line { border-top: 1px solid #111; padding-top: 4px; font-size: 14px; }
@media (max-width: 560px) { .paper { padding: 24px 18px; font-size: 14px; } }
@media print {
  html, body { background: #fff !important; }
  .topbar, .tabs, .no-print, .toast, .lightbox { display: none !important; }
  .view { padding: 0; max-width: none; }
  .paper { border-radius: 0; padding: 0; max-width: none; }
  @page { margin: 18mm; }
}
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }
.reveal { border: 1px dashed var(--line); border-radius: 12px; padding: 14px; margin-top: 12px; }
