/* DermIntraOp web app: shared styles. Mirrors the iOS app's look. */
:root {
  color-scheme: light dark;
  --navy: #012B68;
  --navy-ink: #0A2F6B;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --fg: #1C1C1E;
  --fg-2: #6C6C70;
  --line: #E5E5EA;
  --field: #F2F2F7;
  --accent: #2E7D9E;
  --ok: #2F7A45;
  --warn: #A8650A;
  --stop: #B3261E;
  --tint-ok: #E3F2E7;
  --tint-warn: #FFF1D6;
  --tint-stop: #FDE3E1;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --r: 12px;
  --pad: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1C1C1E; --fg: #F2F2F7; --fg-2: #98989F; --line: #2C2C2E;
    --field: #2C2C2E; --accent: #6FB3D2; --ok: #6FC98A; --warn: #F0B04A; --stop: #FF8A80;
    --tint-ok: #15301D; --tint-warn: #3A2A0C; --tint-stop: #3A1512;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--fg); font: 400 17px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* layout */
.appbar {
  position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  display: grid; grid-template-columns: minmax(64px, auto) 1fr minmax(64px, auto); align-items: center; gap: 8px;
}
.appbar h1 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; }
.appbar button, .appbar a.btn-bar {
  background: none; border: 0; color: #fff; font: 400 16px/1 var(--sans);
  padding: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
}
.appbar .right { justify-self: end; }
.appbar .home-link, .appbar .title-link { color: #fff; text-decoration: none; }
.appbar .home-link { padding: 8px; font-size: 16px; white-space: nowrap; }
.appbar .title-link:hover, .appbar .home-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.appbar a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 40px); }

/* cards */
.card { background: var(--card); border-radius: var(--r); padding: var(--pad); margin-bottom: 14px; }
.card.tight { padding: 0; overflow: hidden; }
.section-label {
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--fg-2); margin: 0 0 10px;
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px var(--pad); }
.card.tight .row + .row { border-top: 1px solid var(--line); }
.row label, .row .k { color: var(--fg); }
.row .v { color: var(--accent); font-weight: 500; }
.muted { color: var(--fg-2); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: 10px; }

/* nav list (home + pickers) */
.list { background: var(--card); border-radius: var(--r); overflow: hidden; margin-bottom: 14px; }
.list-item {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px var(--pad); background: none; border: 0; border-top: 1px solid var(--line);
  color: var(--fg); font: 400 17px/1.3 var(--sans); cursor: pointer; text-decoration: none;
}
.list-item:first-child { border-top: 0; }
.list-item:active { background: var(--field); }
.list-item .chev { margin-left: auto; color: var(--fg-2); }
.list-item.soon { opacity: .5; cursor: default; }
.list-item.soon:active { background: none; }
.list-item .tag {
  margin-left: auto; flex: 0 0 auto; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--fg-2); background: var(--field);
  border-radius: 999px; padding: 5px 10px; white-space: nowrap;
}
.list-item .t { font-weight: 500; }
.list-item .s { display: block; font-size: 13px; color: var(--fg-2); margin-top: 2px; }
.icon-tile {
  width: 42px; height: 42px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 20px;
}

/* controls */
button, input, select, textarea { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border: 0; border-radius: 10px;
  background: var(--navy); color: #fff; font-weight: 600; cursor: pointer; width: 100%;
}
.btn:disabled { background: var(--field); color: var(--fg-2); cursor: default; }
.btn.secondary { background: var(--field); color: var(--fg); }
.btn.danger { background: var(--stop); color: #fff; }
.field {
  background: var(--field); border: 0; border-radius: 8px; padding: 9px 12px;
  min-width: 0; max-width: 100%; text-align: right; font-variant-numeric: tabular-nums;
}
input.field { width: 110px; }
select.field { text-align: left; max-width: 62%; }
.seg { display: flex; background: var(--field); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button {
  flex: 1; border: 0; background: none; border-radius: 7px; padding: 8px 10px;
  font-size: 14px; cursor: pointer; color: var(--fg); white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--card); font-weight: 600; }
.switch { position: relative; width: 51px; height: 31px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--field); border-radius: 999px; transition: background .15s; pointer-events: none; }
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
  background: #fff; border-radius: 50%; transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
  border-radius: 999px; padding: 8px 14px; font-size: 15px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }

/* result blocks */
.pill { display: inline-block; font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 999px; }
.pill.ok { background: var(--tint-ok); color: var(--ok); }
.pill.warn { background: var(--tint-warn); color: var(--warn); }
.pill.stop { background: var(--tint-stop); color: var(--stop); }
.stat { background: var(--field); border-radius: 10px; padding: 12px; }
.stat .lbl { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--fg-2); }
.stat .big { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .big span { font-size: 14px; font-weight: 500; color: var(--fg-2); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.bar { height: 12px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width .2s; }
.bar.warn > i { background: var(--warn); } .bar.stop > i { background: var(--stop); }
.notice { border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.45; }
.notice.warn { background: var(--tint-warn); color: var(--fg); }
.notice.info { background: var(--field); color: var(--fg); }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th, table.data td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-2); font-weight: 600; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* gate + sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; display: grid; align-items: end; }
.sheet {
  background: var(--bg); border-radius: 14px 14px 0 0; max-height: 88vh; overflow-y: auto;
  padding: 8px 0 calc(env(safe-area-inset-bottom, 0px) + 24px);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; }
.sheet-head b { font-size: 18px; }
.sheet-head button { background: none; border: 0; color: var(--accent); font-size: 16px; cursor: pointer; }
.gate { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; }
.gate .inner { max-width: 620px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 28px) 20px 32px; }
.gate h2 { font-size: 28px; margin: 0 0 4px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; cursor: pointer; font-size: 15px; }
.check input { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; accent-color: var(--navy); }
.brandline { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brandline img { width: 56px; height: 56px; border-radius: 13px; }
.brandline b { display: block; font-size: 22px; }

.citation { font-size: 13px; line-height: 1.5; color: var(--fg-2); }
.citation + .citation { margin-top: 12px; }
.footer-note { font-size: 12px; color: var(--fg-2); text-align: center; padding: 18px 8px 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
