/* Poppins, self-hosted (SIL Open Font License, see fonts/OFL.txt) */
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/poppins-400.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/poppins-500.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/poppins-600.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/poppins-700.woff2") format("woff2"); }
:root {
    --primary: hsl(210, 90%, 60%);
    --foreground: hsl(222.2, 84%, 4.9%);
    --muted: hsl(215.4, 16.3%, 46.9%);
    --border: hsl(214.3, 31.8%, 91.4%);
    --page: #f9fafb;
    --danger: hsl(0, 84%, 60%);
    --card: rgba(255, 255, 255, 0.9);
    --header: #fff;
    --input: #fff;
    --nav-active: hsl(210, 90%, 95%);
}
html[data-theme="dark"] {
    --foreground: #f8fafc;
    --muted: #94a3b8;
    --border: #334155;
    --page: #0f172a;
    --danger: hsl(0, 84%, 70%);
    --card: #1e293b;
    --header: #1e293b;
    --input: #0f172a;
    --nav-active: hsl(210, 45%, 22%);
}
* { box-sizing: border-box; }
html { overflow-x: hidden; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
/* No double-tap zoom on controls; pinch zoom still works. */
* { touch-action: manipulation; }
/* Headings can't be selected, so a double-tap on them doesn't select a word and zoom to it. */
h1, h2, h3, .welcome, .home-box, .weighed-tabs { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body {
    margin: 0;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: "Poppins", "Segoe UI", system-ui, sans-serif;
    background: var(--page);
    color: var(--foreground);
}
button, input, select, textarea { font: inherit; }
/* Phone safety: no box may be wider than the space it sits in. */
input, select, textarea { max-width: 100%; min-width: 0; }
label, fieldset, .card { min-width: 0; }
.mark {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.125rem;
}
.login-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.brand { text-align: center; margin-bottom: 32px; }
.brand .mark { margin: 0 auto 16px; }
h1 { margin: 0; font-size: 1.875rem; font-weight: 700; }
.subtitle { margin: 8px 0 0; color: var(--muted); }
.card {
    width: 100%;
    max-width: 28rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    padding: 24px;
}
form { display: grid; gap: 24px; }
label { display: grid; gap: 8px; font-size: 0.875rem; font-weight: 500; }
input {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input);
    color: var(--foreground);
    font-size: 16px;
}
input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.primary {
    height: 40px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 500;
    cursor: pointer;
}
.primary:disabled { opacity: 0.6; cursor: default; }
#status { min-height: 1.25rem; margin: 0; color: var(--danger); font-size: 0.875rem; }
header {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    padding: 12px 24px;
    background: var(--header);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}
.brand-row { display: flex; align-items: center; gap: 12px; }
button.brand-row {
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
button.brand-row:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; }
.brand-row .mark { width: 36px; height: 36px; font-size: 0.95rem; }
.sign-out {
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input);
    color: var(--foreground);
    cursor: pointer;
}
.menu-button {
    display: none;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input);
    color: var(--foreground);
    cursor: pointer;
}
.menu-icon, .menu-icon::before, .menu-icon::after {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--foreground);
    position: relative;
}
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
.menu-icon::before { top: -6px; }
.menu-icon::after { top: 6px; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-link {
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.nav-link.active { background: var(--nav-active); color: var(--primary); font-weight: 600; }
.hub { width: 100%; max-width: 960px; margin: 32px auto; padding: 0 16px; }
.home-card, #tab-settings { margin-inline: auto; }
.welcome h2 { text-align: center; }
.my-name:empty { display: none; }
.nav-name { margin: 0 4px 0 12px; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 0.9rem; }
.home-name { margin: -8px 0 8px; text-align: center; font-size: 1.1rem; font-weight: 600; overflow-wrap: anywhere; }
.tab-name { margin-left: 8px; color: var(--muted); font-size: 1rem; font-weight: 400; overflow-wrap: anywhere; }
.home-actions { display: grid; gap: 12px; }
.weighed-tabs { display: flex; gap: 8px; margin: 0 0 16px; flex-wrap: wrap; }
.weighed-tabs button {
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input);
    color: var(--muted);
    cursor: pointer;
}
.tab-icon { display: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.weighed-tabs select.tab-pick { width: auto; height: 36px; padding: 0 8px; color: var(--muted); font-size: 16px; cursor: pointer; }
.weighed-tabs select.tab-pick.active { background: var(--nav-active); color: var(--primary); font-weight: 600; }
.weighed-tabs button.active { background: var(--nav-active); color: var(--primary); font-weight: 600; }
.home-tab, .theme-choice {
    height: 48px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--input);
    color: var(--foreground);
    font-weight: 600;
    cursor: pointer;
}
.setting { display: grid; gap: 12px; margin-top: 20px; }
.setting h3 { margin: 0; font-size: 1rem; }
.theme-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-choice { height: 40px; }
.theme-choice.active { background: var(--nav-active); color: var(--primary); }
#tab-settings input { font-size: 16px; }
.hub .card h2 { margin: 0 0 16px; font-size: 1.5rem; font-weight: 600; }
.weighed-bar { display: flex; gap: 12px; align-items: end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.filter-group { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
#stock-filter { width: 15rem; }
.stock-desc { display: block; max-width: 15rem; color: var(--muted); font-size: 0.875rem; font-weight: 400; overflow-wrap: anywhere; }
.stock-desc:empty { display: none; }
.weighed-bar label, .add-panel label { display: grid; gap: 6px; font-size: 0.875rem; font-weight: 500; }
.weighed-bar label.check { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.weighed-bar label.check input { width: 18px; height: 18px; }
select, .add-panel input { height: 40px; max-width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--input); padding: 0 12px; color: var(--foreground); font-size: 16px; }
.add-panel { display: grid; gap: 12px; margin-bottom: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--page); }
.weight-row { display: flex; gap: 8px; align-items: center; max-width: 100%; }
.weight-row input { width: 9rem; max-width: 100%; min-width: 0; flex: 0 1 9rem; font-size: 16px; }
.add-panel input { font-size: 16px; }
.weighed-bar .primary, .add-panel .primary { width: auto; padding: 0 16px; }
.add-panel .primary.icon { width: 56px; min-width: 56px; height: 40px; padding: 0; font-size: 1.5rem; line-height: 1; }
.card.wide { width: 100%; max-width: none; min-width: 0; }
.table-wrap { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-size: 0.75rem; font-weight: 600; }
@media (max-width: 700px) {
    .hide-narrow { display: none; }
    header, .hub, #hub-view { padding-left: 12px; padding-right: 12px; width: 100%; max-width: 100%; }
    header { display: flex; flex-wrap: wrap; }
    .brand-row { min-width: 0; }
    .menu-button { display: grid; flex: 0 0 40px; margin-left: auto; }
    nav {
        display: none;
        width: 100%;
        margin-left: 0;
        flex-direction: column;
        align-items: stretch;
        padding-bottom: 8px;
    }
    nav.open { display: flex; }
    nav .nav-link, nav .sign-out { width: 100%; text-align: left; }
    .weighed-bar, .add-panel, .filter-group { align-items: stretch; }
    .filter-group { width: 100%; }
    #stock-filter { width: 100%; }
    .stock-desc { max-width: none; }
    .weighed-bar select, .weighed-bar .primary { width: 100%; }
    .hub .card { padding: 16px; }
    .hub .card h2 { font-size: 1.3rem; }
    .weighed-tabs .icon-tab { display: inline-grid; place-items: center; min-width: 48px; height: 40px; }
    .weighed-tabs .icon-tab[hidden] { display: none; }
    .icon-tab .tab-icon { display: block; }
    .icon-tab .tab-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .weighed-tabs select.tab-pick { height: 40px; }
}
.stock-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stock-actions .primary, .stock-actions .sign-out { width: auto; }
td.wrap { white-space: normal; min-width: 8rem; }
.grant-list { display: grid; gap: 6px; }
.access-list { display: grid; gap: 12px; }
.access-card { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.access-card strong { overflow-wrap: anywhere; }
.access-card > input { width: 100%; font-size: 16px; }
.filters-admin { display: grid; gap: 12px; max-width: 32rem; grid-template-columns: minmax(0, 1fr); }
.filters-admin .filter-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.filters-admin .people-bar { min-width: 0; flex: 1 1 14rem; }
.filters-admin h3 { margin: 8px 0 0; }
.filter-row { display: flex; align-items: center; justify-content: space-between; }
label.check { display: flex; align-items: center; gap: 8px; min-height: 32px; }
label.check input { width: 18px; height: 18px; }
tr.editing td { background: var(--nav-active); }
.note { margin: 0; color: var(--muted); }
[hidden] { display: none !important; }

/* Full-screen spinner while the app loads or reloads (shown by index.html, hidden by hub.js). */
.app-loading { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--page); color: var(--muted); font-size: 0.95rem; }
.app-loading[hidden] { display: none; }
.app-spinner { width: 44px; height: 44px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: app-spin 0.8s linear infinite; }
@keyframes app-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .app-spinner { animation-duration: 2.4s; } }