/* Alcon Trial Log — phone-first app shell.
   Brand colours come from the Alcon Bioactive logo (blue / leaf green / yellow). */

:root {
    --bg: #e6f0f4;
    --bg-2: #d9e7ee;
    --surface: #ffffff;
    --surface-2: #f3f8fa;
    --fg: #0e1d29;
    --muted: #5f7383;
    --line: #d7e4eb;
    --line-strong: #bfd2dc;
    --accent: #16719a;
    --accent-2: #0f5b7d;
    --accent-fg: #ffffff;
    --accent-soft: #dcedf6;
    --leaf: #7fbb36;
    --leaf-soft: #e6f3d6;
    --sun: #f2c318;
    --c2: #c98410;
    --ok: #2f8f4e;
    --warn: #b56a00;
    --bad: #c4372d;
    --warn-soft: #fdf3e1;
    --bad-soft: #fdecea;
    --shadow-sm: 0 1px 2px rgba(14, 29, 41, 0.06);
    --shadow:
        0 1px 2px rgba(14, 29, 41, 0.05),
        0 8px 24px -12px rgba(14, 29, 41, 0.18);
    --shadow-lg: 0 18px 40px -18px rgba(14, 29, 41, 0.35);
    --glass: rgba(255, 255, 255, 0.78);
    --hero: linear-gradient(
        135deg,
        #0f5b7d 0%,
        #16719a 45%,
        #3f9a6a 80%,
        #7fbb36 100%
    );
    --radius: 18px;
    --radius-sm: 12px;
    --sans:
        "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto,
        sans-serif;
    --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
    --nav-h: 72px;
    color-scheme: only light;
}
/* Light mode only (dark theme removed on request). */

/* ---------- base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}
[hidden]:not([hidden="until-found" i]) {
    display: none !important;
}
html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: 80px;
}
body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    min-height: 100vh;
    min-height: 100dvh;
}
img {
    max-width: 100%;
}
button {
    -webkit-tap-highlight-color: transparent;
}

/* ---------- splash ---------- */
.splash {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    background: radial-gradient(
        120% 80% at 50% 0%,
        #ffffff 0%,
        #eef5f9 60%,
        #e3eef3 100%
    );
    transition:
        opacity 0.45s ease,
        visibility 0.45s ease;
}
.splash.out {
    opacity: 0;
    visibility: hidden;
}
.splash-in {
    display: grid;
    justify-items: center;
    gap: 22px;
    animation: splashIn 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.splash img {
    width: min(58vw, 240px);
    height: auto;
}
.splash-bar {
    width: 120px;
    height: 4px;
    border-radius: 99px;
    background: #dbe7ee;
    overflow: hidden;
}
.splash-bar i {
    display: block;
    width: 40%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #16719a, #7fbb36);
    animation: load 1.1s ease-in-out infinite;
}
.splash p {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #5f7383;
}
@keyframes splashIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.96);
    }
}
@keyframes load {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(260%);
    }
}

/* ---------- top bar ---------- */
header.top {
    position: sticky;
    top: 0;
    z-index: 10;
    padding-top: env(safe-area-inset-top, 0px);
    background: var(--glass);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--line);
}
.top-in {
    max-width: 720px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.brand img {
    width: 38px;
    height: 38px;
    flex: none;
}
.brand div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.brand b {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.15;
}
.brand span {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 11px 6px 9px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--muted);
    white-space: nowrap;
}
.conn i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}
.conn.on {
    color: var(--ok);
}
.conn.on i {
    box-shadow: 0 0 0 0 currentColor;
    animation: pulse 2.4s infinite;
}
.conn.off {
    color: var(--bad);
}
.conn.wait i,
.conn.sync i {
    animation: blink 1s infinite;
}
.conn.sync {
    color: var(--warn);
}
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent);
    }
    70%,
    100% {
        box-shadow: 0 0 0 7px transparent;
    }
}
@keyframes blink {
    50% {
        opacity: 0.3;
    }
}

/* ---------- layout ---------- */
.wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 4px 16px
        calc(var(--nav-h) + 40px + env(safe-area-inset-bottom, 0px));
}
[data-view]:not([hidden]) {
    animation: viewIn 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes viewIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}
h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 18px 0 6px;
    text-wrap: balance;
}
h2 {
    font-size: 13px;
    font-weight: 800;
    margin: 26px 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
h2 .count {
    font-size: 11px;
    min-width: 22px;
    padding: 2px 7px;
    border-radius: 99px;
    background: var(--accent-soft);
    color: var(--accent);
    text-align: center;
    letter-spacing: 0;
}
h2 .count:empty {
    display: none;
}
.sub {
    color: var(--muted);
    margin: 0 0 18px;
    font-size: 14.5px;
}
.page-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 14px 0 18px;
}
.page-head h1 {
    margin: 2px 0 4px;
    font-size: 23px;
}
.page-head .sub {
    margin: 0;
}
.back {
    flex: none;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--fg);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s;
}
.back:active {
    transform: scale(0.94);
}
.back svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- home hero ---------- */
.hero {
    position: relative;
    overflow: hidden;
    margin-top: 14px;
    border-radius: 24px;
    padding: 20px 18px 18px;
    color: #fff;
    background: var(--hero);
    box-shadow: var(--shadow-lg);
}
.hero::before,
.hero::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}
.hero::before {
    width: 220px;
    height: 220px;
    right: -70px;
    top: -90px;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.22),
        transparent 70%
    );
}
.hero::after {
    width: 160px;
    height: 160px;
    left: -50px;
    bottom: -80px;
    background: radial-gradient(
        circle,
        rgba(242, 195, 24, 0.28),
        transparent 70%
    );
}
.hero small {
    position: relative;
    display: block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.8;
}
.hero h1 {
    position: relative;
    margin: 4px 0 16px;
    font-size: 24px;
    color: #fff;
}
.hstats {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.hstat {
    border-radius: 14px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    min-width: 0;
}
.hstat b {
    display: block;
    font-family: var(--mono);
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
}
.hstat span {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hstat.hot {
    background: rgba(255, 214, 80, 0.25);
    border-color: rgba(255, 224, 120, 0.5);
}

/* ---------- home: entry list, same order as the Google Sheet tabs ---------- */
.tiles {
    display: grid;
    gap: 10px;
    counter-reset: step;
}
.tile {
    font: inherit;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px 12px 12px;
    color: var(--fg);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition:
        transform 0.15s ease,
        box-shadow 0.2s ease,
        border-color 0.2s;
    min-width: 0;
}
.tile:hover {
    box-shadow: var(--shadow);
    border-color: var(--line-strong);
}
.tile:active {
    transform: scale(0.98);
}
.tile .step {
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--line);
}
.tile .ic {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
}
.tile .ic.g {
    background: var(--leaf-soft);
    color: var(--ok);
}
.tile .ic.y {
    background: var(--warn-soft);
    color: var(--warn);
}
.tile svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.tile .txt {
    flex: 1;
    min-width: 0;
}
.tile b {
    display: block;
    font-size: 15.5px;
    font-weight: 700;
    line-height: 1.25;
}
.tile .txt span {
    display: block;
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 2px;
    line-height: 1.35;
}
.tile .chev {
    flex: none;
    width: 20px;
    height: 20px;
    color: var(--muted);
    transition:
        transform 0.15s,
        color 0.15s;
}
.tile:hover .chev {
    color: var(--accent);
    transform: translateX(2px);
}

/* ---------- forms ---------- */
form {
    display: grid;
    gap: 16px;
}
.group {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    display: grid;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    min-width: 0;
}
.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.row3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}
label,
.lbl {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.01em;
}
.u {
    font-family: var(--mono);
    font-weight: 500;
    font-size: 11.5px;
    color: var(--muted);
    opacity: 0.85;
}
input,
select,
textarea {
    font: inherit;
    font-size: 16px;
    color: var(--fg);
    background: var(--surface-2);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    width: 100%;
    min-height: 50px;
    transition:
        border-color 0.15s,
        box-shadow 0.15s,
        background 0.15s;
    -webkit-appearance: none;
    appearance: none;
}
select {
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8f9c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
}
input[type="date"],
input[type="datetime-local"],
input[type="month"] {
    min-width: 0;
}
input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: 0.6;
}
input.num {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}
textarea {
    min-height: 92px;
    resize: vertical;
}
input:hover,
select:hover,
textarea:hover {
    border-color: var(--line-strong);
}
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
button:focus-visible,
.addph:focus-within {
    outline: 2.5px solid var(--accent);
    outline-offset: 2px;
}
fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin: 0;
    display: grid;
    gap: 16px;
    min-width: 0;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
fieldset > legend {
    float: left;
    width: 100%;
    padding: 0;
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: var(--fg);
    display: flex;
    align-items: center;
    gap: 8px;
}
fieldset > legend::before {
    content: "";
    width: 4px;
    height: 16px;
    border-radius: 4px;
    background: linear-gradient(var(--accent), var(--leaf));
}
fieldset > legend + * {
    clear: both;
}

/* chips */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.chip {
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1.5px solid var(--line);
    background: var(--surface);
    color: var(--fg);
    cursor: pointer;
    min-height: 40px;
    transition:
        background 0.15s,
        color 0.15s,
        border-color 0.15s,
        transform 0.1s;
}
.chip:hover {
    border-color: var(--line-strong);
}
.chip:active {
    transform: scale(0.95);
}
.chip[aria-pressed="true"] {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
    box-shadow: 0 4px 12px -6px var(--accent);
}

/* actions */
.actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 4px;
}
form .actions {
    position: sticky;
    bottom: 0;
    z-index: 4;
    margin: 4px -16px 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(
        to top,
        var(--bg) 70%,
        color-mix(in srgb, var(--bg) 0%, transparent)
    );
    grid-template-columns: 1fr auto;
}
.btn {
    font: inherit;
    font-weight: 700;
    font-size: 16px;
    border-radius: 14px;
    padding: 14px 18px;
    border: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: var(--accent-fg);
    cursor: pointer;
    min-height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 10px 22px -12px var(--accent);
    transition:
        transform 0.12s,
        filter 0.15s,
        opacity 0.15s;
}
.btn:hover {
    filter: brightness(1.06);
}
.btn:active {
    transform: scale(0.98);
}
.btn.ghost {
    background: var(--surface);
    color: var(--accent);
    border: 1.5px solid var(--line);
    box-shadow: var(--shadow-sm);
}
.btn svg {
    width: 19px;
    height: 19px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
form .actions .btn.ghost {
    padding-inline: 16px;
}
.btn:disabled {
    opacity: 0.7;
    cursor: progress;
}
.btn.loading::before {
    content: "";
    width: 17px;
    height: 17px;
    border-radius: 50%;
    border: 2.5px solid currentColor;
    border-right-color: transparent;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.note {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}
.calc {
    font-family: var(--mono);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}
.calc:empty {
    display: none;
}
.alerts {
    display: grid;
    gap: 8px;
}
.alerts:empty {
    display: none;
}
.alert {
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
    background: var(--warn-soft);
    color: var(--fg);
    border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.alert.bad {
    background: var(--bad-soft);
    border-color: color-mix(in srgb, var(--bad) 35%, transparent);
}
.banner {
    background: var(--accent-soft);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-size: 14px;
    margin-top: 14px;
    border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
}
.banner.warn {
    background: var(--warn-soft);
    border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}

/* sync bar */
.syncbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding: 10px 10px 10px 14px;
    border-radius: 14px;
    background: var(--warn-soft);
    border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
    font-size: 13.5px;
    font-weight: 600;
}
.syncbar span {
    flex: 1;
    min-width: 0;
}
.syncbar::before {
    content: "";
    flex: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2.5px solid var(--warn);
    border-right-color: transparent;
}
.syncbar.busy::before {
    animation: spin 0.8s linear infinite;
}
.syncbar button {
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    padding: 7px 12px;
    border-radius: 10px;
    border: 0;
    background: var(--surface);
    color: var(--fg);
    cursor: pointer;
}

/* closure pairs */
.pairs {
    display: grid;
    gap: 6px;
}
.pairs > div:not(.pair) {
    padding: 6px 0;
    border-bottom: 1px dashed var(--line);
}
.pairs > div:last-child {
    border-bottom: 0;
}
.pair {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) 1fr 1fr;
    gap: 8px;
    align-items: center;
}
.pair.head span {
    font-size: 11.5px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.pair .pl {
    font-size: 14px;
    font-weight: 700;
    min-width: 0;
}
.pair .pl small {
    display: block;
    font-family: var(--mono);
    font-weight: 400;
    color: var(--muted);
    font-size: 11.5px;
}
.pair input {
    min-height: 44px;
    padding: 9px 10px;
}
.delta {
    font-family: var(--mono);
    font-size: 12px;
    margin-top: 4px;
}
.delta:empty {
    display: none;
}
.up {
    color: var(--ok);
}
.down {
    color: var(--bad);
}

/* ---------- bottom nav ---------- */
nav.tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 12;
    padding: 0 14px calc(10px + env(safe-area-inset-bottom, 0px));
    pointer-events: none;
}
.tabs-in {
    pointer-events: auto;
    max-width: 420px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 6px;
    border-radius: 24px;
    background: var(--glass);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
}
.tab {
    font: inherit;
    background: none;
    border: 0;
    border-radius: 18px;
    color: var(--muted);
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    min-height: 54px;
    transition:
        background 0.2s,
        color 0.2s;
}
.tab svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.tab[aria-selected="true"] {
    color: var(--accent);
    background: var(--accent-soft);
}
/* form screens: focus mode — hide the tab bar, the action bar sits at the bottom */
body:is(
        [data-screen="trial"],
        [data-screen="supply"],
        [data-screen="mon"],
        [data-screen="add"],
        [data-screen="close"]
    )
    nav.tabs {
    display: none;
}
body:is(
        [data-screen="trial"],
        [data-screen="supply"],
        [data-screen="mon"],
        [data-screen="add"],
        [data-screen="close"]
    )
    .wrap {
    padding-bottom: 24px;
}

/* ---------- toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    background: var(--fg);
    color: var(--bg);
    padding: 12px 18px;
    border-radius: 14px;
    font-size: 14.5px;
    font-weight: 600;
    z-index: 30;
    max-width: calc(100% - 32px);
    width: max-content;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
body:is(
        [data-screen="trial"],
        [data-screen="supply"],
        [data-screen="mon"],
        [data-screen="add"],
        [data-screen="close"]
    )
    .toast {
    bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translate(-50%, 10px);
    }
}

/* ---------- records ---------- */
.filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}
.seg {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px;
    margin: 0 -2px;
    border-radius: 16px;
    background: var(--bg-2);
    scrollbar-width: none;
}
.seg::-webkit-scrollbar {
    display: none;
}
.seg .chip {
    flex: 1 0 auto;
    white-space: nowrap;
    border: 0;
    background: transparent;
    min-height: 38px;
    border-radius: 12px;
    color: var(--muted);
}
.seg .chip[aria-pressed="true"] {
    background: var(--surface);
    color: var(--fg);
    box-shadow: var(--shadow-sm);
}
.list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}
.rec {
    font: inherit;
    text-align: left;
    width: 100%;
    color: var(--fg);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    min-width: 0;
    box-shadow: var(--shadow-sm);
}
.rec.pending {
    border-style: dashed;
    border-color: color-mix(in srgb, var(--warn) 50%, var(--line));
}
.syncing {
    color: var(--warn);
    font-weight: 600;
}
.trialcard {
    cursor: pointer;
    position: relative;
    border-left: 4px solid var(--accent);
    transition:
        transform 0.15s,
        box-shadow 0.2s;
}
.trialcard:hover {
    box-shadow: var(--shadow);
}
.trialcard:active {
    transform: scale(0.985);
}
.rec .h {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15.5px;
    flex-wrap: wrap;
}
.rec .t {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
}
.kv {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    font-size: 12.5px;
}
.kv:empty {
    display: none;
}
.kv span {
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 3px 9px;
}
.kv span b {
    font-family: var(--mono);
    font-weight: 600;
    color: var(--fg);
    margin-left: 2px;
}
.obs {
    margin-top: 10px;
    font-size: 14px;
    overflow-wrap: anywhere;
}
.obs b {
    color: var(--muted);
    font-weight: 700;
}
.pill {
    font-size: 11.5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 700;
    white-space: nowrap;
    background: color-mix(in srgb, currentColor 12%, transparent);
}
.p-run {
    color: var(--accent);
}
.p-done {
    color: var(--ok);
}
.p-plan {
    color: var(--muted);
}
.p-hold {
    color: var(--warn);
}
.p-ctrl {
    color: var(--c2);
}
.empty {
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius);
    padding: 26px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    background: color-mix(in srgb, var(--surface) 50%, transparent);
}
.copybox {
    width: 100%;
    font-family: var(--mono);
    font-size: 13px;
    min-height: 140px;
}
.export {
    margin-top: 18px;
}

/* ---------- summary ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    min-width: 0;
    box-shadow: var(--shadow-sm);
}
.card > .lbl {
    font-size: 13px;
    font-weight: 800;
    color: var(--fg);
}
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 14px;
}
.stat {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 12px;
}
.stat b {
    display: block;
    font-family: var(--mono);
    font-size: 20px;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.stat span {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}
.sumbody {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}
.tblwrap {
    overflow-x: auto;
    margin-top: 10px;
    -webkit-overflow-scrolling: touch;
}
table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
th,
td {
    padding: 9px 6px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: nowrap;
}
tbody tr:last-child td {
    border-bottom: 0;
}
th:first-child,
td:first-child {
    text-align: left;
}
th {
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
td {
    font-family: var(--mono);
}
td:first-child,
td.tx {
    font-family: var(--sans);
    font-weight: 600;
    white-space: normal;
}
.chart {
    width: 100%;
    height: auto;
    display: block;
    margin-top: 12px;
}
.legend {
    display: flex;
    gap: 16px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    margin-top: 6px;
}
.legend i {
    display: inline-block;
    width: 14px;
    height: 4px;
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 6px;
}

/* ---------- photos ---------- */
.photos {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.ph {
    position: relative;
    width: 86px;
    height: 86px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.ph img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ph button {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 16px;
    line-height: 26px;
    padding: 0;
    cursor: pointer;
}
.addph {
    position: relative;
    width: 86px;
    height: 86px;
    border-radius: 14px;
    border: 1.5px dashed color-mix(in srgb, var(--accent) 60%, transparent);
    color: var(--accent);
    background: var(--accent-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.addph svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.addph input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.recph {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.recph button,
.recph a {
    display: block;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    width: 64px;
    height: 64px;
    background: var(--surface);
    cursor: pointer;
}
.recph img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(4, 10, 15, 0.9);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
}
.lightbox button {
    position: absolute;
    top: calc(14px + env(safe-area-inset-top, 0px));
    right: 14px;
    font: inherit;
    font-weight: 700;
    background: #fff;
    color: #111;
    border: 0;
    border-radius: 999px;
    padding: 9px 16px;
    cursor: pointer;
}

/* ---------- responsive ---------- */
@media (max-width: 420px) {
    .row {
        grid-template-columns: 1fr;
    }
    .row.keep {
        grid-template-columns: 1fr 1fr;
    }
    .row3 {
        gap: 8px;
    }
    .row3 input {
        padding-inline: 10px;
    }
    h1 {
        font-size: 24px;
    }
}
@media (max-width: 350px) {
    .row3 {
        grid-template-columns: 1fr 1fr;
    }
    form .actions {
        grid-template-columns: 1fr;
    }
}
@media (min-width: 640px) {
    .hero {
        padding: 26px 24px 22px;
    }
    .hero h1 {
        font-size: 28px;
    }
}
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* date + time needs the full width on phones so the time isn't cut off */
@media (max-width: 480px) {
    .row.keep:has(input[type="datetime-local"]) {
        grid-template-columns: 1fr;
    }
    .hstat span {
        white-space: normal;
        line-height: 1.25;
    }
    .brand span {
        display: none;
    }
}

/* home: completed trials under the active ones */
.subhead {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.trialcard.done {
    border-left-color: var(--ok);
    opacity: 0.85;
}

/* photo that couldn't load (e.g. private Drive file): tap still opens it */
.recph .noimg {
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
    text-decoration: none;
}
.recph .noimg img {
    display: none;
}
.recph .noimg::after {
    content: "Photo ↗";
    font-size: 11px;
    font-weight: 700;
}

/* ---------- colour layer: light, but branded (not plain white) ---------- */
body {
    background:
        radial-gradient(
            900px 420px at 100% -10%,
            rgba(127, 187, 54, 0.16),
            transparent 60%
        ),
        radial-gradient(
            800px 500px at -10% 30%,
            rgba(22, 113, 154, 0.14),
            transparent 60%
        ),
        linear-gradient(180deg, #e3eef4 0%, #eaf3ee 100%);
    background-attachment: fixed;
}

/* brand header bar */
header.top {
    background: linear-gradient(115deg, #0d5272 0%, #16719a 55%, #2d8a62 100%);
    border-bottom: 0;
    box-shadow: 0 6px 20px -12px rgba(13, 82, 114, 0.7);
    color: #fff;
}
.brand img {
    background: #fff;
    border-radius: 12px;
    padding: 3px;
    width: 40px;
    height: 40px;
}
.brand b {
    color: #fff;
}
.brand span {
    color: rgba(255, 255, 255, 0.75);
}
.conn {
    background: rgba(255, 255, 255, 0.95);
    border-color: transparent;
}

/* section headings carry the brand colour */
h2 {
    color: var(--accent-2);
}
h2::before {
    content: "";
    width: 4px;
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(var(--accent), var(--leaf));
}

/* entry tiles: each type has its own colour (icon, edge, step) */
.tile {
    --c: #16719a;
    --c-soft: #dcedf6;
    border-left: 4px solid var(--c);
    background: linear-gradient(100deg, #fff 70%, var(--c-soft));
}
.tile:has(.ic.g) {
    --c: #5f9e24;
    --c-soft: #e6f3d6;
}
.tile:has(.ic.y) {
    --c: #d99a06;
    --c-soft: #fdf1d3;
}
.tile:has(.ic.t) {
    --c: #13918f;
    --c-soft: #d8f1ef;
}
.tile .ic,
.tile .ic.g,
.tile .ic.y {
    background: var(--c);
    color: #fff;
    box-shadow: 0 6px 14px -8px var(--c);
}
.tile .step {
    background: var(--c-soft);
    border-color: transparent;
    color: var(--c);
}
.tile .chev,
.tile:hover .chev {
    color: var(--c);
}
.tile:hover {
    border-color: var(--c);
    border-left-color: var(--c);
}

/* cards and form groups: soft tinted edge */
.group,
fieldset,
.card,
.rec {
    border-color: #d3e3ea;
    box-shadow:
        0 1px 2px rgba(13, 82, 114, 0.06),
        0 10px 24px -18px rgba(13, 82, 114, 0.35);
}
fieldset > legend {
    color: var(--accent-2);
}

/* bottom nav: solid brand pill for the active tab */
.tabs-in {
    background: rgba(255, 255, 255, 0.92);
    border-color: #cfe0e8;
}
.tab[aria-selected="true"] {
    background: linear-gradient(135deg, #16719a, #2d8a62);
    color: #fff;
    box-shadow: 0 8px 18px -10px #16719a;
}

/* records segment + filters */
.seg {
    background: #d4e5ed;
}
.seg .chip[aria-pressed="true"] {
    color: var(--accent-2);
}
