:root {
  --navy: #0b3a66; --navy-2: #005c97; --accent: #0073bc; --brand: #0073bc; --ink: #1b2430; --muted: #5d6b7a;
  --bg: #f3f6f9; --card: #ffffff; --line: #dde4ec; --danger: #b42318; --danger-bg: #fdecea;
  --info-bg: #e8f3fc; --ok: #137333; --ok-bg: #e6f4ea; --radius: 12px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); min-height: 100vh; display: flex; flex-direction: column; line-height: 1.5; }
a { color: var(--navy-2); }
.env-banner { background: #fff4ce; color: #5c4400; text-align: center; font-size: .85rem; padding: .3rem 1rem; border-bottom: 1px solid #f0d77a; }
.topbar { background: #fff; color: var(--ink); border-bottom: 3px solid var(--brand); display: flex; align-items: center; justify-content: space-between; padding: .75rem clamp(1rem, 4vw, 2.5rem); gap: 1rem; }
.brand { display: flex; align-items: center; gap: .9rem; color: var(--ink); text-decoration: none; min-width: 0; }
.brand-logo { display: block; height: 36px; width: auto; flex: none; }
.brand-title { padding-left: .9rem; border-left: 1px solid var(--line); color: var(--navy); font-size: 1.15rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.auth-logo { display: block; height: 40px; width: auto; margin: 0 0 1.25rem; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; margin: 0; }
.who { color: var(--muted); font-size: .9rem; }
.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: clamp(1rem, 4vw, 2.5rem); flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); margin-bottom: 1.25rem; }
.auth-card { max-width: 420px; margin: clamp(1rem, 6vh, 4rem) auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 2rem; box-shadow: 0 10px 30px rgba(11,58,102,.08); }
.auth-card h1 { margin: 0 0 .25rem; font-size: 1.5rem; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 1rem 0 .35rem; }
input[type=text], input[type=password] { width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; background: #fff; }
input:focus { outline: 3px solid rgba(0,115,188,.25); border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; padding: .65rem 1.1rem; font-size: .95rem; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--navy-2); color: #fff; }
.btn-primary:hover { background: var(--navy); }
.btn-ghost { background: #fff; color: var(--navy-2); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--navy-2); background: var(--info-bg); }
.btn-block { width: 100%; margin-top: 1.5rem; padding: .8rem; }
.muted { color: var(--muted); }
.help { color: var(--muted); font-size: .85rem; margin-top: 1.25rem; text-align: center; }
.alert { border-radius: 8px; padding: .7rem .9rem; margin: 1rem 0 0; font-size: .92rem; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-info { background: var(--info-bg); color: var(--navy); }
.page-head h1 { margin: .1rem 0 1.25rem; font-size: clamp(1.5rem, 3vw, 2rem); }
.eyebrow { margin: 0; color: var(--muted); font-size: .9rem; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; font-weight: 600; }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.badge-active { background: var(--info-bg); color: var(--navy-2); }
.badge-done { background: var(--ok-bg); color: var(--ok); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; }
.tile h3, .tile h2 { margin-top: 0; }
code { background: #eef2f6; padding: .1rem .35rem; border-radius: 4px; }
@media (max-width: 540px) { .who { display: none; } .brand { gap: .6rem; } .brand-logo { height: 26px; } .brand-title { font-size: 1rem; padding-left: .6rem; } .props { grid-template-columns: 1fr; } .props dd { margin-bottom: .5rem; } }

/* ---- Phase 2: project navigation, overview, file browser ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.subnav { background: #fff; border-bottom: 1px solid var(--line); }
.subnav-inner { max-width: 1040px; margin: 0 auto; display: flex; gap: .25rem; align-items: center; padding: 0 clamp(1rem, 4vw, 2.5rem); overflow-x: auto; }
.subnav-project { font-weight: 700; color: var(--muted); font-size: .85rem; margin-right: 1rem; white-space: nowrap; }
.subnav a { padding: .85rem .9rem; text-decoration: none; color: var(--ink); border-bottom: 3px solid transparent; font-weight: 600; font-size: .95rem; white-space: nowrap; }
.subnav a:hover { color: var(--navy-2); }
.subnav a.active { color: var(--navy-2); border-bottom-color: var(--navy-2); }
.title-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.title-row h1 { margin: .1rem 0; }
.subtitle { color: var(--muted); margin: .25rem 0 1.25rem; }
.page-head { margin-bottom: .5rem; }
.overview-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 1.25rem; }
.overview-grid .card { margin-bottom: 0; }
.overview-grid + .card { margin-top: 1.25rem; }
.card h2 { margin: 0 0 1rem; font-size: 1.1rem; }
.contacts { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.contacts li { display: flex; flex-direction: column; }
.contact-role { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.timeline li { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem .9rem 2.2rem; display: flex; flex-direction: column; gap: .15rem; }
.timeline .dot { position: absolute; left: .9rem; top: 1.15rem; width: .7rem; height: .7rem; border-radius: 50%; background: #c3ccd6; }
.timeline li.done .dot { background: var(--ok); }
.timeline li.active .dot { background: var(--accent); }
.timeline li.hold .dot { background: var(--danger); }
.m-label { font-size: .85rem; color: var(--muted); }
.m-date { font-weight: 700; font-size: 1.05rem; }
.m-status { font-size: .8rem; font-weight: 600; color: var(--navy-2); }
.timeline li.done .m-status { color: var(--ok); }
.timeline li.hold .m-status { color: var(--danger); }
.tile-link { text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.tile-link:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(11,58,102,.10); }
.tile-link h3, .tile-link h2 { color: var(--navy-2); }
.empty { text-align: center; padding: 2.5rem 1.5rem; }
.empty h2 { margin-bottom: .5rem; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .95rem; }
.breadcrumbs a { text-decoration: none; font-weight: 600; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .sep { color: #9aa6b2; }
.search { display: flex; gap: .5rem; align-items: center; }
.search input { width: min(320px, 60vw); padding: .55rem .75rem; border: 1px solid var(--line); border-radius: 8px; font-size: .95rem; }
.btn-secondary { background: #fff; color: var(--navy-2); border: 1px solid var(--line); }
.btn-secondary:hover:not(:disabled) { border-color: var(--navy-2); }
.btn-link { background: none; color: var(--navy-2); padding-left: .4rem; padding-right: .4rem; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.file-card { padding: 0; overflow: hidden; margin-bottom: 6rem; }
.files { width: 100%; border-collapse: collapse; font-size: .93rem; }
.files th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafc; border-bottom: 1px solid var(--line); padding: .7rem .75rem; font-weight: 700; }
.files td { border-bottom: 1px solid #eef2f6; padding: .55rem .75rem; vertical-align: middle; }
.files tbody tr:hover { background: #f7fafd; }
.files tbody tr:last-child td { border-bottom: 0; }
.col-check { width: 2.5rem; text-align: center; }
.col-mod { width: 9rem; white-space: nowrap; color: var(--muted); }
.col-size { width: 6rem; white-space: nowrap; text-align: right; }
.files th.col-size { text-align: right; }
.col-type { width: 10rem; color: var(--muted); }
.name-cell { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.fname { overflow-wrap: anywhere; }
a.fname { font-weight: 600; text-decoration: none; }
a.fname:hover { text-decoration: underline; }
.fpath { font-size: .78rem; color: var(--muted); margin-left: 3.6rem; overflow-wrap: anywhere; }
.toggle, .toggle-spacer { flex: none; width: 1.4rem; height: 1.4rem; }
.toggle { border: 0; background: none; border-radius: 4px; cursor: pointer; position: relative; padding: 0; }
.toggle:hover { background: #e8eef5; }
.toggle::before { content: ""; position: absolute; left: .5rem; top: .42rem; border: .3rem solid transparent; border-left: .42rem solid var(--muted); transition: transform .12s; transform-origin: 25% 50%; }
.toggle[aria-expanded="true"]::before { transform: rotate(90deg); }
.toggle[aria-busy="true"]::before { border-left-color: var(--accent); }
.ficon { flex: none; display: inline-grid; place-items: center; width: 2.4rem; height: 1.5rem; border-radius: 4px; background: #eef2f6; color: var(--navy); font-size: .75rem; font-weight: 800; letter-spacing: .02em; }
.ficon-folder { background: #f6c453; width: 1.6rem; height: 1.2rem; border-radius: 2px 4px 4px 4px; position: relative; margin: 0 .25rem; }
.ficon-folder::before { content: ""; position: absolute; left: 0; top: -.25rem; width: .7rem; height: .3rem; background: #f6c453; border-radius: 2px 2px 0 0; }
.empty-row td { font-size: .85rem; font-style: italic; }
.result-note { margin: 0; padding: .75rem; font-size: .85rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.files + .result-note { border-top: 1px solid var(--line); border-bottom: 0; }
.selection-bar { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); width: min(960px, calc(100% - 2rem)); background: var(--navy); color: #fff; border-radius: 12px; padding: .75rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; box-shadow: 0 12px 30px rgba(11,58,102,.3); z-index: 10; }
.selection-bar[hidden] { display: none; }
.sel-summary span { opacity: .85; margin-left: .25rem; }
.sel-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.selection-bar .btn-link { color: #fff; }
.selection-bar .btn-secondary { background: transparent; color: #fff; border-color: rgba(255,255,255,.45); }
.selection-bar .btn-primary { background: #fff; color: var(--navy); }
.phase-note { font-size: .78rem; opacity: .8; }
@media (max-width: 760px) {
  .overview-grid { grid-template-columns: 1fr; }
  .col-type, .col-mod { display: none; }
  .search input { width: 100%; }
  .search { width: 100%; }
}

/* ---- Phase 3: downloads ---- */
.toolbar-right { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
a.file-link { font-weight: 500; color: var(--ink); text-decoration: none; }
a.file-link:hover { color: var(--navy-2); text-decoration: underline; }
.dl-status { position: fixed; right: 1.25rem; top: 5.5rem; z-index: 20; max-width: min(460px, calc(100% - 2.5rem)); background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: .75rem .5rem .75rem 1rem; display: flex; align-items: center; gap: .6rem; box-shadow: 0 10px 30px rgba(11,58,102,.15); font-size: .92rem; }
.dl-status[hidden] { display: none; }
.dl-status.ok { border-left-color: var(--ok); }
.dl-status.error { border-left-color: var(--danger); color: var(--danger); }
.dl-status .spinner { width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid #cfd8e3; border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; display: none; }
.dl-status.busy .spinner { display: inline-block; }
.dl-status .btn-link { font-size: 1.2rem; line-height: 1; padding: 0 .4rem; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 760px) { .toolbar-right { width: 100%; } #zip-folder { width: 100%; } }
.topbar .btn-ghost { white-space: nowrap; }
@media (max-width: 540px) { .topbar { gap: .5rem; } .topbar .btn-ghost { padding: .45rem .7rem; font-size: .85rem; } }
@media (max-width: 400px) { .brand-logo { height: 22px; } .brand-title { font-size: .92rem; } }

/* Phase 4: passwordless sign-in, project access, dashboard */
input[type=email], input[type=search], input[type=date], input[type=number], select {
  width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; background: #fff; color: var(--ink); font-family: inherit;
}
select { padding-right: 2rem; }
input:focus, select:focus { outline: 3px solid rgba(0,115,188,.25); border-color: var(--accent); }
input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--navy-2); margin: 0; }
.code-input { font-size: 1.6rem !important; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.or { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1.25rem 0 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.passkey-signin .btn-block { margin-top: 1rem; }
.inline-actions { display: flex; justify-content: center; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.staff-link { text-align: center; font-size: .85rem; color: var(--muted); margin-top: 1rem; }
.form-error { color: var(--danger); background: var(--danger-bg); border-radius: 8px; padding: .6rem .8rem; font-size: .9rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; margin: 0; }
.grant-form { display: flex; flex-wrap: wrap; gap: 1rem 1.25rem; align-items: flex-end; }
.grant-form .field { display: flex; flex-direction: column; min-width: 180px; }
.grant-form .field label { margin-top: 0; }
.grant-form .grow { flex: 1 1 280px; }
.grant-form .actions-field { flex-direction: row; align-items: center; gap: 1rem; flex-wrap: wrap; }
.link-form { margin-top: 1rem; }
.link-form + .link-form { padding-top: 1rem; border-top: 1px solid var(--line); }
.link-form .link-now { margin-top: .35rem; font-size: .85rem; color: var(--muted); }
.linked-note { margin: 0 0 1rem; }
.card h2 .count { display: inline-block; min-width: 1.6rem; padding: 0 .5rem; margin-left: .35rem; border-radius: 999px; background: var(--info-bg); color: var(--navy-2); font-size: .8rem; text-align: center; vertical-align: middle; line-height: 1.6rem; }
.card-head-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card-head-row h2 { margin: 0; }
.simple-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.simple-table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
.simple-table td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.simple-table tr:last-child td { border-bottom: 0; }
.simple-table .email { font-weight: 600; word-break: break-all; }
.simple-table .detail { color: var(--muted); word-break: break-word; }
.simple-table .actions { text-align: right; white-space: nowrap; }
.simple-table .actions form { margin: 0; }
.muted-table td { color: var(--muted); }
.muted-table .email { font-weight: 500; }
.btn-link.danger { color: var(--danger); }
.btn-link.danger:hover { text-decoration: underline; }
.page-actions { margin-top: .5rem; }
.project-switch { display: flex; align-items: center; margin: .45rem 1rem .45rem 0; flex: none; }
.project-switch select { width: auto; max-width: 320px; padding: .4rem 2rem .4rem .6rem; font-size: .9rem; font-weight: 600; }
.subnav a.subnav-all { margin-left: auto; color: var(--muted); font-weight: 500; }
.filter-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.filter-row input { max-width: 420px; }
.project-tile { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.project-tile[hidden] { display: none; }
.tile-main { display: block; padding: 1.25rem 1.5rem 1rem; text-decoration: none; color: inherit; flex: 1; }
.tile-main:hover h2 { text-decoration: underline; }
.tile-main h2 { color: var(--navy-2); margin: .5rem 0 .25rem; font-size: 1.05rem; }
.tile-main p { margin: 0; font-size: .9rem; }
.tile-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.tile-number { font-size: .85rem; color: var(--muted); font-weight: 600; }
.tile-links { display: flex; gap: 1.25rem; padding: .7rem 1.5rem; border-top: 1px solid var(--line); background: #fafcfe; font-size: .9rem; }
.tile-links a { text-decoration: none; font-weight: 600; }
.tile-links a.strong { margin-left: auto; }
.admin-card .row { display: flex; gap: .75rem; }
.admin-card .row input { max-width: 240px; }
.admin-card label { margin-top: 0; }
@media (max-width: 760px) {
  .project-switch { margin-right: .5rem; }
  .project-switch select { max-width: 200px; }
  .simple-table thead { display: none; }
  .simple-table tr { display: block; padding: .6rem 0; border-bottom: 1px solid var(--line); }
  .simple-table tr:last-child { border-bottom: 0; }
  .simple-table td { display: block; border: 0; padding: .1rem 0; }
  .simple-table .actions { text-align: left; }
  .grant-form .field { min-width: 100%; }
}
.staff-signin { margin-top: 1.5rem; }
.staff-signin .btn-block { margin-top: 1rem; }
.btn-microsoft { gap: .6rem; text-decoration: none; }
.btn-microsoft svg { flex: none; }

/* Portal admin labels */
.tile-badges { display: inline-flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.badge-stock { background: #fdecc8; color: #7a4b00; }
.badge-nopm { background: #fde2e1; color: #9b1c1c; }
.badge-new { background: #dff3e4; color: #146c2e; margin-left: .4rem; vertical-align: middle; font-size: .72rem; }
.tile-badges .badge-new { margin-left: 0; }
.tile-status { margin: .45rem 0 0; font-size: .88rem; font-weight: 600; color: var(--navy-2); }
.project-table .status-text { display: block; font-size: .88rem; margin-bottom: .15rem; }
.new-note { margin: 0 0 .75rem; color: var(--navy-2); }
.new-note .badge-new { margin: 0 .35rem 0 0; }
.small { font-size: .85rem; }
.filter-row select { max-width: 14rem; }
.admin-table td, .admin-table th { vertical-align: middle; }

/* Dashboard card/list toggle */
.filter-row { flex-wrap: wrap; }
.view-toggle { margin-left: auto; display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.view-btn { border: 0; background: #fff; color: var(--navy-2); font: inherit; font-size: .9rem; font-weight: 600; padding: .5rem .9rem; cursor: pointer; }
.view-btn + .view-btn { border-left: 1px solid var(--line); }
.view-btn:hover { background: var(--info-bg); }
.view-btn[aria-pressed="true"] { background: var(--navy-2); color: #fff; }
.view-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; position: relative; z-index: 1; }
.project-grid[hidden], .project-list-wrap[hidden] { display: none; }
.project-list-wrap { padding: 0; overflow-x: auto; }
.project-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.project-table th, .project-table td { text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.project-table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafc; white-space: nowrap; }
.project-table tbody tr:last-child > * { border-bottom: 0; }
.project-table tbody tr:hover { background: #f5f9fd; }
.project-table tr[hidden] { display: none; }
.project-table a { color: var(--navy-2); font-weight: 600; text-decoration: none; }
.project-table a:hover { text-decoration: underline; }
.project-table a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.project-table .col-number { white-space: nowrap; font-variant-numeric: tabular-nums; }
.project-table .col-status { white-space: nowrap; }
.project-table .col-status .badge { margin-right: .25rem; }
.project-table .col-links { white-space: nowrap; }
.project-table .col-links a { margin-right: .75rem; font-weight: 500; }
.project-table .col-links a.strong { font-weight: 700; }
@media (max-width: 760px) {
  .view-toggle { margin-left: 0; }
  .project-table td, .project-table th { padding: .6rem .6rem; }
}
.pager { display: flex; align-items: center; gap: 1rem; margin: 1rem 0 2rem; }
.log-table .col-when { white-space: nowrap; }
.log-table .col-what.log-bad { color: var(--danger); }
.activity-link { font-weight: 600; }

/* Accessibility (phase 5) */
.skip-link { position: absolute; left: .5rem; top: -4rem; z-index: 100; background: var(--navy); color: #fff; padding: .7rem 1rem; border-radius: 0 0 8px 8px; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 0; }
main:focus { outline: none; }
a:focus-visible, button:focus-visible, select:focus-visible, summary:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn { min-height: 44px; }
.view-btn { min-height: 44px; }
input[type=checkbox] { width: 1.5rem; height: 1.5rem; }
.project-list-wrap:focus-visible { outline-offset: -3px; }
@media (min-width: 541px) { .who { display: inline-block; } }
.brand { min-height: 44px; }
.subnav a { min-height: 44px; display: inline-flex; align-items: center; padding-top: 0; padding-bottom: 0; }
.tile-links a, .project-table .col-links a, .project-table a { display: inline-flex; align-items: center; min-height: 44px; }
.project-table .col-number a { min-height: 44px; }
.toggle { min-width: 44px; min-height: 44px; }
@media (max-width: 760px) {
  input[type=text], input[type=search], input[type=email], input[type=number], input[type=date], select { min-height: 44px; }
  .project-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .project-table, .project-table tbody, .project-table tr, .project-table th, .project-table td { display: block; width: 100%; }
  .project-table tr { padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
  .project-table td, .project-table th[scope=row] { border: 0; padding: .1rem 0; }
  .project-table td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: .35rem; }
  .project-table .col-when { font-weight: 700; }
  .project-table .col-when::before { display: none; }
  .log-table .col-who { overflow-wrap: anywhere; }
  .project-table tbody tr:has(.col-number) { display: flex; flex-wrap: wrap; align-items: center; column-gap: .6rem; }
  .project-table .col-number { width: auto; order: 1; font-size: 1.05rem; }
  .project-table .col-machine { width: auto; order: 2; flex: 1 1 60%; }
  .project-table .col-customer { order: 3; width: 100%; color: var(--muted); }
  .project-table .col-pm { order: 4; width: auto; }
  .project-table .col-status { order: 5; width: 100%; }
  .project-table .col-links { order: 6; width: 100%; }
}
select, input[type=search], input[type=text], input[type=email] { min-height: 44px; }
@media (min-width: 541px) { .who { padding: .8rem .25rem; } }
.fname { display: inline-block; padding: .55rem 0; }
/* ---- Customer uploads ---- */
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.page-alert { margin: 0 0 1.25rem; }
.dropzone { border: 2px dashed #b9c7d6; border-radius: var(--radius); padding: 1.75rem 1rem; text-align: center; background: #f8fafc; transition: border-color .15s, background .15s; }
.dropzone.is-over { border-color: var(--accent); background: var(--info-bg); }
.dz-title { margin: 0; font-weight: 700; color: var(--navy); }
.dz-or { margin: .25rem 0 .5rem; font-size: .85rem; }
.dz-pick { margin: 0; font-size: .95rem; min-height: 44px; }
.dz-chosen { margin: .75rem 0 0; font-size: .9rem; overflow-wrap: anywhere; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.dropzone:focus-within { border-color: var(--accent); }
.upload-help { font-size: .88rem; margin: .75rem 0 0; }
.upload-actions { margin-top: 1rem; }
.upload-actions .btn { min-height: 44px; }
.upload-progress { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; flex-wrap: wrap; }
.upload-progress[hidden] { display: none; }
.upload-progress progress { flex: 1 1 200px; height: 1rem; accent-color: var(--navy-2); }
.upload-result ul, #upload-result ul { margin: .35rem 0 0; padding-left: 1.25rem; overflow-wrap: anywhere; }
.session-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.session-head h2 { margin: 0; }
.upload-table .up-name { overflow-wrap: anywhere; font-weight: 600; }
.upload-table .col-action { text-align: right; white-space: nowrap; }
.btn-small { padding: .4rem .8rem; font-size: .85rem; min-height: 44px; }
.remove-form { margin: 0; display: inline; }
.done-form { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }
.done-form .btn { min-height: 44px; }
@media (max-width: 760px) { .upload-table .col-action { text-align: left; padding-top: .4rem !important; } .upload-table .col-size { text-align: left; } }
#upload-result .alert + .alert { margin-top: .5rem; }

/* ---- Product tour (wwwroot/js/tour.js) ---- */
.tour-btn { gap: .35rem; text-decoration: none; }
.tour-btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; border: 2px solid currentColor; font-size: .8rem; font-weight: 800; line-height: 1; }
.footer-tour a { color: var(--navy-2); }
@media (max-width: 420px) {
  .tour-btn-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar { padding-left: .75rem; padding-right: .75rem; }
  .topbar .tour-btn { padding: .4rem .45rem; }
  .topbar .btn-ghost { padding: .4rem .6rem; }
  .topbar-actions { gap: .4rem; }
  .brand { gap: .45rem; }
  .brand-title { font-size: .85rem; padding-left: .45rem; }
}
html.tour-open { scroll-behavior: auto; }
dialog.tour { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; overflow: hidden; color: var(--ink); }
dialog.tour::backdrop { background: transparent; }
dialog.tour.tour-centered { background: rgba(9, 22, 38, .62); }
.tour-spot { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(9, 22, 38, .62); outline: 3px solid #fff; outline-offset: 0; pointer-events: none; transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease; }
.tour-spot::after { content: ""; position: absolute; inset: -6px; border-radius: 14px; border: 3px solid var(--accent); }
dialog.tour.tour-centered .tour-spot { display: none; }
.tour-card { position: fixed; width: min(380px, calc(100vw - 16px)); background: var(--card); border-radius: 14px; padding: 1.25rem 1.25rem 1rem; box-shadow: 0 18px 50px rgba(9, 22, 38, .35); border: 1px solid var(--line); }
dialog.tour.tour-centered .tour-card { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px)); padding: 1.75rem 1.5rem 1.25rem; }
.tour-card.tour-in { animation: tour-in .2s ease-out; }
@keyframes tour-in { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: 0 0; } }
.tour-count { margin: 0 0 .25rem; color: var(--muted); font-size: .8rem; font-weight: 600; letter-spacing: .02em; }
.tour-title { margin: 0 2rem .4rem 0; font-size: 1.15rem; color: var(--navy); }
.tour-title:focus, .tour-title:focus-visible { outline: none; } /* programmatic focus target (tabindex=-1), announced by screen readers */
.tour-text { margin: 0 0 .75rem; font-size: .95rem; }
.tour-more { display: inline-block; margin: 0 0 .75rem; font-weight: 600; }
.tour-more[hidden] { display: none; }
.tour-dots { display: flex; gap: .35rem; margin: 0 0 .9rem; }
.tour-dots span { width: .5rem; height: .5rem; border-radius: 50%; background: #c3ccd6; }
.tour-dots span.done { background: #8fb7d6; }
.tour-dots span.on { width: 1.4rem; border-radius: 999px; background: var(--navy-2); }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.tour-nav { display: flex; gap: .5rem; margin-left: auto; }
.tour-nav .btn { min-height: 44px; }
.tour-nav [hidden] { display: none; }
.tour-skip { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: .5rem .25rem; min-height: 44px; font-weight: 600; cursor: pointer; }
.tour-skip:hover { color: var(--navy-2); }
.tour-close { position: absolute; top: .5rem; right: .5rem; width: 44px; height: 44px; border: 0; background: none; color: var(--muted); font-size: 1.6rem; line-height: 1; border-radius: 8px; cursor: pointer; }
.tour-close:hover { background: var(--info-bg); color: var(--navy); }
dialog.tour button:focus-visible, dialog.tour a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Phones: bottom sheet */
dialog.tour.tour-sheet:not(.tour-centered) .tour-card { left: 0; right: 0; bottom: 0; top: auto; width: 100%; border-radius: 16px 16px 0 0; padding: 1.1rem 1rem calc(1rem + env(safe-area-inset-bottom)); max-height: 60vh; overflow-y: auto; }
dialog.tour.tour-sheet .tour-actions .btn { flex: 1; }
dialog.tour.tour-sheet .tour-nav { flex: 1; }
@media (prefers-reduced-motion: reduce) {
  .tour-spot { transition: none; }
  .tour-card.tour-in { animation: none; }
}
@media (forced-colors: active) {
  .tour-spot { outline: 3px solid Highlight; box-shadow: none; }
  .tour-spot::after { border-color: Highlight; }
  .tour-card { border: 2px solid CanvasText; }
  .tour-dots span.on { background: Highlight; }
}

/* Project manager dropdown (dashboard, PMs and admins) */
.pm-picker { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; margin: 0 0 1rem; }
.pm-picker label { margin: 0; font-weight: 600; }
.pm-picker select { max-width: 22rem; }

/* Project tabs: wrap onto a second line instead of scrolling, so no tab (e.g. "All Projects") is ever clipped. */
.subnav-inner { flex-wrap: wrap; overflow-x: visible; row-gap: 0; }
.subnav a { flex: none; }
.subnav a.subnav-all { margin-left: auto; }

/* Key dates (customer overview) and "Milestones shown to the customer" (Access page) */
.timeline li.tbd .m-date, .timeline li.na .m-date { color: var(--muted, #5b6b7b); font-weight: 500; }
.getting-started { border: 1px dashed var(--line); border-radius: 10px; padding: 1rem 1.1rem; background: var(--info-bg); }
.getting-started .gs-title { margin: 0 0 .25rem; font-weight: 700; color: var(--navy); }
.getting-started p:last-child { margin: 0; }
.staff-hint { margin: .9rem 0 0; font-size: .85rem; color: var(--muted, #5b6b7b); }
.milestone-options { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .4rem; }
.milestone-options li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; border: 1px solid var(--line); border-radius: 8px; padding: .55rem .8rem; }
.milestone-options .milestone-name { font-weight: 600; }
.milestone-value { font-size: .9rem; color: var(--navy-2); }
.milestone-value.tbd, .milestone-value.na { color: var(--muted, #5b6b7b); }
.milestone-value.done { color: var(--ok); }
.milestone-value.hold { color: var(--danger); }
.milestone-note { font-size: .9rem; color: var(--navy-2); }
.milestone-locked { margin-left: .5rem; font-size: .75rem; font-weight: 600; color: var(--muted, #5b6b7b); background: var(--info-bg); border-radius: 999px; padding: .1rem .5rem; }
.milestone-options input[disabled] { opacity: .65; cursor: not-allowed; }

/* Overview heading: Project number (largest), then customer, then equipment in dark gray. */
.page-head h1.project-title { margin: .1rem 0 .35rem; }
.head-customer, .head-machine { margin: 0; font-size: 1.15rem; line-height: 1.4; }
.head-customer { color: var(--ink); font-weight: 600; }
.head-machine { color: #4a5563; margin-bottom: 1.25rem; }

/* Dashboard cards: Project number (largest), then customer in blue, then equipment in gray. */
.tile-main h2.tile-number { color: var(--ink); font-size: 1.25rem; font-weight: 700; margin: 0; }
.tile-customer { color: var(--navy-2); font-weight: 600; margin: .4rem 0 .1rem; }
.tile-machine { color: var(--muted); margin: 0 0 .25rem; }
.sort-picker { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
.sort-picker label { margin: 0; font-weight: 600; }
.sort-picker select { width: auto; }

/* Sign-in help */
.signin-help { margin: 1rem 0 0; font-size: .9rem; color: var(--muted); text-align: left; }
.signin-help summary { cursor: pointer; color: var(--navy-2); font-weight: 600; }
.signin-help ul { margin: .5rem 0 0; padding-left: 1.2rem; }
.signin-help li { margin: 0 0 .35rem; }

/* Help / FAQ */
.help-page h2 { margin-top: 1.6rem; }
.help-toc { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin: .75rem 0 0; font-size: .92rem; }
.faq dt { font-weight: 700; margin: .9rem 0 .2rem; color: var(--ink); }
.faq dd { margin: 0; color: var(--ink); line-height: 1.5; }
.help-contacts { padding-left: 1.2rem; }
.help-contacts li { margin: 0 0 .5rem; }
.help-contact-project { display: block; font-weight: 600; }
.help-contact-pm { display: block; }

/* ==== Mobile and tablet polish ==== */
.subnav-tabs { display: flex; align-items: center; gap: .25rem; flex: 1 1 auto; min-width: 0; }
.subnav-tabs a.subnav-all { margin-left: auto; }
.grid > .card, .project-grid > .card { margin-bottom: 0; }
.nav-toggle { display: none; gap: .45rem; }
.nav-toggle[hidden] { display: none !important; }
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after { display: block; width: 1.05rem; height: 2px; background: currentColor; border-radius: 2px; position: relative; }
.nav-toggle-bars::before, .nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bars::before { top: -5px; }
.nav-toggle-bars::after { top: 5px; }
.dz-camera { display: none; margin-left: .5rem; gap: .45rem; }
.dz-camera-icon { width: 1.1rem; height: .85rem; border: 2px solid currentColor; border-radius: 3px; position: relative; }
.dz-camera-icon::after { content: ""; position: absolute; left: 50%; top: 50%; width: .35rem; height: .35rem; border: 2px solid currentColor; border-radius: 50%; transform: translate(-50%, -50%); }
@media (pointer: coarse) {
  .dz-camera { display: inline-flex; }
  .dz-title, .dz-or { display: none; }
  .btn { min-height: 44px; }
  input[type=checkbox] { width: 1.35rem; height: 1.35rem; }
  .files td { padding-top: .7rem; padding-bottom: .7rem; }
  .toggle, .toggle-spacer { width: 2.25rem; height: 2.25rem; }
  .toggle::before { left: .85rem; top: .8rem; }
  .subnav a { min-height: 44px; display: inline-flex; align-items: center; }
}
/* Tablets: keep the header on one line. */
@media (max-width: 1000px) {
  .topbar .who { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 900px) {
  .brand-title { display: none; }
}
/* Phones */
@media (max-width: 640px) {
  .topbar { position: relative; flex-wrap: nowrap; padding: .6rem .85rem; }
  .brand-title { display: inline; font-size: .95rem; padding-left: .55rem; }
  .brand-logo { height: 24px; }
  .topbar.has-toggle .nav-toggle { display: inline-flex; }
  .topbar.has-toggle .topbar-actions { display: none; }
  .topbar.has-toggle.menu-open .topbar-actions {
    display: flex; flex-direction: column; align-items: stretch; gap: .5rem;
    position: absolute; left: 0; right: 0; top: 100%; z-index: 30; margin-top: 3px;
    background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 12px 24px rgba(11,58,102,.15); padding: .75rem .85rem 1rem;
  }
  .topbar.menu-open .topbar-actions .who { display: block; max-width: none; padding: .55rem .25rem; font-size: .95rem; overflow-wrap: anywhere; white-space: normal; }
  .topbar.menu-open .topbar-actions .btn { width: 100%; min-height: 48px; justify-content: center; font-size: 1rem; }
  .topbar.menu-open .tour-btn-text { position: static; width: auto; height: auto; clip: auto; }

  .subnav-inner { flex-wrap: wrap; padding: .5rem .85rem 0; gap: 0; }
  .project-switch { flex: 1 0 100%; margin: 0 0 .35rem; }
  .project-switch select { width: 100%; max-width: none; min-height: 44px; font-size: 1rem; }
  .subnav-project { padding: .35rem 0; }
  .subnav-tabs { flex: 1 0 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .subnav-tabs::-webkit-scrollbar { display: none; }
  .subnav-tabs a { min-height: 48px; display: inline-flex; align-items: center; padding: .7rem .85rem; flex: none; }

  .container { padding: 1rem .85rem; }
  .card { padding: 1.15rem; }
  .filter-row { flex-wrap: wrap; }
  .file-card { margin-bottom: 11rem; }
  .files th, .files td { padding-left: .5rem; padding-right: .5rem; }
  .fpath { margin-left: 0; }
  .selection-bar {
    left: 0; right: 0; bottom: 0; transform: none; width: 100%; border-radius: 14px 14px 0 0;
    padding: .75rem .85rem calc(.75rem + env(safe-area-inset-bottom, 0px)); gap: .6rem;
  }
  .sel-summary { width: 100%; display: flex; justify-content: space-between; align-items: baseline; }
  .sel-actions { width: 100%; display: grid; grid-template-columns: auto 1fr 1fr; gap: .5rem; }
  .sel-actions .btn { min-height: 48px; padding-left: .6rem; padding-right: .6rem; font-size: .92rem; }
  .dl-status { top: auto; bottom: 1rem; right: .85rem; left: .85rem; max-width: none; }
  .dz-camera { margin: .6rem 0 0; }
  .dropzone .btn { width: 100%; max-width: 20rem; }
  .upload-actions .btn, .done-form .btn { width: 100%; }
  .search .btn { min-height: 44px; }
  .inline-actions .btn { min-height: 44px; }
}
@media (max-width: 380px) { .brand-title { display: none; } }

/* ==== Previews and project search ==== */
.preview-link { flex: none; margin-left: .35rem; font-size: .8rem; font-weight: 600; padding: .1rem .55rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--navy-2); background: #fff; }
.preview-link:hover { border-color: var(--navy-2); background: var(--info-bg); }
.preview-title { margin: .4rem 0 .15rem; font-size: clamp(1.25rem, 3vw, 1.7rem); overflow-wrap: anywhere; }
.preview-meta { margin: 0 0 .9rem; }
.preview-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.preview-card { padding: 0; overflow: hidden; }
.preview-frame { display: block; width: 100%; height: min(80vh, 1100px); border: 0; background: #525659; }
.preview-note { margin: 0; padding: .6rem 1rem; font-size: .85rem; border-top: 1px solid var(--line); }
.preview-image { text-align: center; padding: 1rem; background: #f8fafc; }
.preview-image img { max-width: 100%; height: auto; max-height: 80vh; }
.preview-video { background: #111; text-align: center; }
.preview-player { display: block; width: 100%; max-height: 80vh; background: #000; }
.preview-player[hidden] { display: none; }
.preview-video-error { padding: 1.5rem 1rem; background: #fff; text-align: center; }
.preview-video-error p { margin: 0 0 .8rem; }
.search-wide { margin-bottom: 1rem; }
.search-wide input { width: min(520px, 100%); }
.search-card { margin-bottom: 2rem; }
.col-where { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.col-where a { color: var(--navy-2); }
.area-tag { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--info-bg); color: var(--navy-2); border-radius: 4px; padding: 0 .35rem; margin-right: .35rem; }
.search-empty { padding: 1rem; margin: 0; }
.overview-search { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.overview-search input { flex: 1 1 260px; }
.search-fpath { display: none; }
@media (max-width: 760px) { .search-results .col-where { display: none; } .search-fpath { display: block; margin-left: 2.6rem; } }
@media (max-width: 640px) {
  .preview-frame { height: 70vh; }
  .preview-actions .btn { flex: 1 1 auto; }
}
@media (max-width: 640px) {
  .name-cell { flex-wrap: wrap; row-gap: .3rem; }
  .name-cell .fname { flex: 1 1 10rem; min-width: 0; }
  .name-cell .badge-new, .name-cell .preview-link { margin-left: 0; }
  .search-fpath { margin-left: 0; }
}

/* ==== My account ==== */
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
.account-grid .card { margin-bottom: 0; }
.acct-email { overflow-wrap: anywhere; }
.trust-list { margin: 0; padding-left: 1.1rem; display: grid; gap: .6rem; }
.acct-note { margin: .75rem 0 0; font-size: .88rem; }
.signin-table .ip { font-variant-numeric: tabular-nums; color: var(--muted); }
.signin-table .badge { margin-left: .4rem; }
.danger-outline { color: var(--danger); border-color: #f1b7b2; }
.danger-outline:hover:not(:disabled) { border-color: var(--danger); background: var(--danger-bg); }
@media (max-width: 760px) { .account-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .signin-table th:nth-child(3), .signin-table td:nth-child(3) { display: none; }
  .everywhere-form .btn { width: 100%; }
}

/* ==== Accessibility pass ==== */
/* The real file inputs are visually hidden; show the keyboard focus on the visible "Choose files" / "Take a photo" button. */
.dz-pick:has(+ .file-input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
/* "Take a photo" only exists on touch devices; elsewhere its input must not be an invisible tab stop. */
.dz-camera-input { display: none; }
@media (pointer: coarse) { .dz-camera-input { display: block; } }
.footer a { color: var(--navy-2); }
@media (forced-colors: active) {
  a:focus-visible, button:focus-visible, select:focus-visible, summary:focus-visible, input:focus-visible, .dz-pick:has(+ .file-input:focus-visible) { outline-color: Highlight; }
  .btn { border: 1px solid ButtonText; }
}

/* Language menu */
.topbar-right { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.lang-form { position: relative; display: flex; align-items: center; margin: 0; flex: none; }
.lang-icon { position: absolute; left: .55rem; top: 50%; width: 1rem; height: 1rem; transform: translateY(-50%); pointer-events: none;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6b7a' stroke-width='1.8'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3c2.5 2.6 3.8 5.6 3.8 9s-1.3 6.4-3.8 9c-2.5-2.6-3.8-5.6-3.8-9S9.5 5.6 12 3z'/%3E%3C/svg%3E"); }
.lang-select { appearance: none; -webkit-appearance: none; font: inherit; font-size: .88rem; color: var(--ink); background: #fff
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235d6b7a' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right .55rem center / .6rem;
  border: 1px solid var(--line); border-radius: 8px; padding: .4rem 1.6rem .4rem 1.85rem; min-height: 38px; max-width: 11rem; cursor: pointer; }
.lang-select:hover { border-color: #b9c6d4; }
.lang-select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.auth-page .lang-form, .lang-form.lang-standalone { margin-left: auto; }
@media (max-width: 640px) {
  .topbar-right { gap: .4rem; }
  .lang-select { font-size: 1rem; min-height: 44px; padding-left: 1.75rem; padding-right: 1.4rem; max-width: 8.5rem; }
}
@media (max-width: 380px) {
  .lang-select { max-width: 6.75rem; }
}

/* Japanese: proper fonts and line breaking */
:root:lang(ja), :lang(ja) {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", "Noto Sans CJK JP", system-ui, sans-serif;
}
html:lang(ja) body { line-break: strict; word-break: normal; overflow-wrap: anywhere; line-height: 1.7; }
html:lang(ja) h1, html:lang(ja) h2, html:lang(ja) h3 { letter-spacing: .02em; }
html:lang(ja) .btn, html:lang(ja) .subnav-tabs a, html:lang(ja) th { word-break: keep-all; overflow-wrap: anywhere; }
/* Long compound words (German) must wrap instead of overflowing */
html:lang(de) body { overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
html:lang(de) h1, html:lang(de) h2, html:lang(de) h3, html:lang(de) .card-title { hyphens: auto; }
/* Phones, signed in: logo + language + Menu must fit on one line in every language. */
@media (max-width: 640px) {
  .topbar.has-toggle .brand-title { display: none; }
  .topbar.has-toggle .lang-select { max-width: 7.5rem; }
  .topbar.has-toggle .nav-toggle { flex: none; }
}
@media (max-width: 360px) {
  .topbar.has-toggle .nav-toggle-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Tablet portrait (iPad, 641-900px): the header actions fold into the Menu button instead of running off the screen. */
@media (min-width: 641px) and (max-width: 900px) {
  .topbar { position: relative; }
  .subnav-tabs { flex-wrap: wrap; }
  .topbar.has-toggle .nav-toggle { display: inline-flex; }
  .topbar.has-toggle .topbar-actions { display: none; }
  .topbar.has-toggle.menu-open .topbar-actions {
    display: flex; flex-direction: column; align-items: stretch; gap: .5rem;
    position: absolute; right: 0; top: 100%; z-index: 30; margin-top: 3px; width: min(22rem, 100%);
    background: #fff; border: 1px solid var(--line); border-top: 0; box-shadow: 0 12px 24px rgba(11,58,102,.15); padding: .75rem .85rem 1rem;
  }
  .topbar.menu-open .topbar-actions .who { display: block; max-width: none; padding: .55rem .25rem; overflow-wrap: anywhere; white-space: normal; }
  .topbar.menu-open .topbar-actions .btn { width: 100%; min-height: 48px; justify-content: center; }
  .topbar.menu-open .tour-btn-text { position: static; width: auto; height: auto; clip: auto; }
}
/* Touch screens: bigger tap areas for small links, pills and checkboxes. */
@media (pointer: coarse) {
  input[type=checkbox] { width: 1.75rem; height: 1.75rem; }
  .breadcrumbs a, .activity-link, .help-toc a, .footer-tour a { display: inline-flex; align-items: center; min-height: 44px; }
  .preview-link { display: inline-flex; align-items: center; min-height: 44px; padding-left: .85rem; padding-right: .85rem; }
}
/* Date fields show the keyboard focus ring on the whole control. */
input[type=date]:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

/* iPhone: the page extends under the status bar (viewport-fit=cover), so the header keeps clear of the notch / status bar and the sides. */
.env-banner { padding-top: calc(.3rem + env(safe-area-inset-top, 0px)); }
.topbar { padding-top: calc(.75rem + env(safe-area-inset-top, 0px)); padding-left: max(clamp(1rem, 4vw, 2.5rem), env(safe-area-inset-left, 0px)); padding-right: max(clamp(1rem, 4vw, 2.5rem), env(safe-area-inset-right, 0px)); }
.env-banner + .topbar { padding-top: .75rem; }
@media (max-width: 640px) {
  .topbar { padding-top: calc(.6rem + env(safe-area-inset-top, 0px)); padding-left: max(.85rem, env(safe-area-inset-left, 0px)); padding-right: max(.85rem, env(safe-area-inset-right, 0px)); }
  .env-banner + .topbar { padding-top: .6rem; }
  /* File rows: [expand] [icon] [name ...... ] on one line; New badge beside the name, Preview neatly under it. */
  .name-cell { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; column-gap: .4rem; row-gap: .1rem; }
  .name-cell .fname { flex: none; grid-column: 3; min-width: 0; }
  .name-cell .badge-new { grid-column: 4; grid-row: 1; margin-left: 0; justify-self: end; }
  .name-cell .preview-link { grid-column: 3 / 5; grid-row: 2; justify-self: start; margin-left: 0; }
  .toggle, .toggle-spacer { width: 1.5rem; }
  .files .col-check { width: 2.4rem; padding-left: .3rem; padding-right: .3rem; }
  .files .col-size { width: 4.6rem; }
  .files td.col-name, .files th.col-name { width: 100%; }
  .card.file-card { padding: 0; }
  .name-cell .ficon:not(.ficon-folder) { width: 2.2rem; }
  .toggle { height: 2.75rem; }
  .toggle::before { left: 50%; top: 50%; margin-left: -.2rem; margin-top: -.3rem; }
  .toggle-spacer { height: 1.4rem; }
}

