@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");
/* Shared look for every platform module. The design system (docs/design_system.md): one set of colours, used by every
   page through these variables. The company colour (--accent) comes from config.js; everything "primary" follows it. */
:root {
  --accent: #b4441c;
  /* primary = the company colour: filled buttons for the main action; text links; the selected filter / tab */
  --primary: var(--accent);
  --primary-hover: color-mix(in srgb, var(--accent) 82%, #000);
  --primary-ink: color-mix(in srgb, var(--accent) 85%, #000);      /* links and selected text (4.5:1 on white and cream) */
  --primary-soft: color-mix(in srgb, var(--accent) 11%, #fff);     /* selected chip / tab / menu item */
  --primary-line: color-mix(in srgb, var(--accent) 32%, #fff);
  /* warm neutrals: cream page, white cards, stone greys */
  --bg: #F7F5F2; --surface: #FFFFFF; --surface-2: #FAF8F6; --surface-3: #F5F1EC;
  --line: #E7E2DC; --line2: #F1EDE8; --line-strong: #D6CFC7;
  --ink: #1C1917; --ink2: #44403C; --mute: #6B645D; --faint: #A8A29E;
  /* status (meaning, not decoration): text on its soft background */
  --ok: #15803D; --ok-soft: #DCFCE7; --warn: #B45309; --warn-soft: #FEF3C7; --bad: #B91C1C; --bad-soft: #FEE2E2; --info: #1E40AF; --info-soft: #DBEAFE;
  --radius: 8px; --radius-lg: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
body { margin: 0; font: 13px/1.4 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary-ink); } a:hover { color: var(--primary-hover); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid var(--line-strong); background: #fff; border-radius: var(--radius); padding: 6px 12px; color: var(--ink2); }
button:hover:not(:disabled) { border-color: var(--faint); }
button.primary { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
button.ghost { border-color: transparent; background: transparent; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 6px 10px; background: #fff; color: var(--ink); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary-line); border-color: var(--primary); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }
:focus-visible { outline-color: var(--primary); }
.hidden { display: none !important; }

.subnav { display: flex; gap: 4px; max-width: 1200px; margin: 12px auto 0; padding: 0 16px; flex-wrap: wrap; }
.subnav button { border: 1px solid transparent; background: none; padding: 6px 12px; border-radius: 6px; color: var(--mute); }
.subnav button.on { background: #fff; border-color: var(--line); color: var(--ink); font-weight: 600; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; text-align: center; margin-left: 4px; }
.spacer { flex: 1; }
.who { color: var(--mute); font-size: 13px; text-align: right; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
main { max-width: 1200px; margin: 12px auto; padding: 0 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--mute); }

/* typeahead */
.typeahead { position: relative; }
.menu { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.08); max-height: 360px; overflow: auto; z-index: 10; }
.menu div { padding: 6px 10px; cursor: pointer; display: flex; gap: 10px; justify-content: space-between; }
.menu div.on, .menu div:hover { background: color-mix(in srgb, var(--accent) 10%, #fff); }
.menu small { color: var(--mute); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--mute); font-weight: 600; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; } tr.click:hover { background: #FBF9F7; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef1f4; color: var(--mute); white-space: nowrap; }
.warn { color: var(--warn); } .bad { color: var(--bad); } .mute { color: var(--mute); } .kbd { font-size: 11px; color: var(--mute); }
.hold { background: #fde8e8; color: var(--bad); padding: 8px 10px; border-radius: 6px; margin-top: 8px; }
.note { background: #fff8e1; padding: 8px 10px; border-radius: 6px; margin-top: 8px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button.on { background: var(--primary-soft); color: var(--primary-ink); border-color: var(--primary-line); }
.empty { text-align: center; color: var(--mute); padding: 30px; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; max-width: 90vw; }
#toast.err { background: var(--bad); }
#toast .toast-act { margin-left: 10px; background: none; border: none; color: #FDBA74; font-weight: 700; text-decoration: underline; padding: 4px 2px; cursor: pointer; font: inherit; font-weight: 700; }
dialog { border: none; border-radius: 10px; padding: 0; width: min(980px, 96vw); max-height: 90vh; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog .hd { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
dialog .bd { padding: 14px 16px; }

/* sign-in */
#plogin { max-width: 360px; margin: 12vh auto; }
#plogin h1 { color: var(--accent); font-size: 22px; }
#plogin .druva { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: #66190D; }
#plogin input { width: 100%; margin-bottom: 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tiles a { display: block; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; color: var(--ink); text-decoration: none; }
.tiles a:hover { border-color: var(--accent); }
.tiles a b { display: block; font-size: 16px; margin-bottom: 4px; color: var(--accent); }
.tiles a.soon { opacity: .55; pointer-events: none; }
/* Report a problem (form, /shared/bugs.js) */
#bugDlg { width: min(640px, 96vw); }
#bugDlg textarea { width: 100%; min-height: 170px; resize: vertical; font-size: 14px; color: var(--ink); }
.bgdrop { border: 1px dashed #D6CFC7; border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.bgdrop.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, #fff); }
.bgfiles { display: flex; gap: 8px; flex-wrap: wrap; }
.bgfiles:empty { display: none; }
.bgth { position: relative; }
.bgth img { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.bgth button { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; padding: 0; border-radius: 50%; line-height: 1; background: var(--ink); color: #fff; border: none; }

/* ------------------------------------------------------------------ the left menu (platform.js renderBar)
   Computer (900px and wider): a column on the left. body.menu-fixed = full (248px), menu-icons = icons only (68px),
   menu-slide = icons that open over the page while the mouse is on them (menu-peek). Phone: a top bar with ☰; the menu
   opens as a drawer (body.menu-open). Print: no menu. */
:root { --menu-w: 248px; --menu-rail: 68px; }
#pbar { display: flex; flex-direction: column; align-items: stretch; gap: 1px; background: #fff; z-index: 40; font-size: 13.5px; }
#pbar a, #pbar button { text-decoration: none; }
#pbar .brand { font-weight: 700; color: var(--accent); text-decoration: none; display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 8px 12px; font-size: 18px; }
#pbar .brand .pm-dv { display: flex; align-items: center; gap: 8px; color: #66190D; font-size: 22px; letter-spacing: -0.02em; }
#pbar .brand .pm-dv img { display: block; width: 30px; height: 30px; }
#pbar .brand img.pm-co { height: 36px; width: auto; display: block; }
#pbar .brand span.pm-co { font-size: 15px; }
#pbar .brand .wnshort { display: none; }
#pbar .pm-mono { display: none; width: 40px; height: 40px; margin: 0 auto 10px; align-items: center; justify-content: center; flex: none; }
#pbar .mods { display: flex; flex-direction: column; gap: 2px; }
#pbar .pm-grp { display: flex; flex-direction: column; gap: 1px; padding: 5px 0 2px; }
#pbar .pm-gt { padding: 4px 10px; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: #78716C; white-space: nowrap; }
#pbar .mods a, #pbar .pm-ft { position: relative; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 8px;
              color: #44403C; font-weight: 500; white-space: nowrap; border: none; background: transparent; width: 100%; text-align: left; font-size: 13.5px; }
#pbar .pm-ft { height: 34px; color: var(--ink2); }
#pbar .mods a svg, #pbar .pm-ft svg { flex: none; }
#pbar .mods a:hover, #pbar .pm-ft:hover { background: #F5F2EE; }
#pbar .mods a.on, #pbar .pm-ft.on { background: color-mix(in srgb, var(--accent) 12%, #fff); color: var(--accent); font-weight: 600; }
#pbar .spacer { flex: 1; min-height: 14px; }
#pbar .pm-bdg { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--primary); color: #fff;
                font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
#pbar #setLink { margin-top: 6px; border-top: 1px solid #EFEAE4; border-radius: 0 0 8px 8px; padding-top: 0; }
#wnLink .wnshort { display: none; }
#wnLink .wndot { position: absolute; top: 9px; left: 22px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
#btnInstall { color: var(--accent) !important; }
#pbar .who { display: flex; align-items: center; gap: 10px; padding: 10px 6px 4px; margin-top: 6px; border-top: 1px solid #EFEAE4; text-align: left; font-size: 12px; color: var(--mute); }
#pbar .who .pm-av { flex: none; width: 32px; height: 32px; border-radius: 16px; background: color-mix(in srgb, var(--accent) 14%, #fff); color: var(--accent);
                 font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
#pbar .who .pm-wt { min-width: 0; line-height: 1.35; }
#pbar .who .pm-nm { font-weight: 600; color: var(--ink); font-size: 13px; }
#pbar #agentState { display: inline-block; white-space: normal; }
#pbar .pm-modesw { display: flex; margin: 10px 2px 0; padding: 3px; border-radius: 9px; background: #F3EFEA; flex: none; }
#pbar .pm-modesw button { flex: 1; height: 28px; padding: 0 4px; border: none; border-radius: 7px; background: transparent; color: var(--mute); font-size: 12px; font-weight: 600; }
#pbar .pm-druva { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 10px 2px 0; font-size: 14px; font-weight: 700; color: #66190D; text-decoration: none; flex: none; }
#pbar .pm-druva img { display: block; }
#pbar .pm-modesw button[aria-checked="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(28,25,23,.12); }
#btnMenu, #btnPin, #pbarShade { display: none; }

@media (min-width: 900px) {
  body.has-menu { padding-left: var(--menu-w); }
  body.has-menu.menu-icons, body.has-menu.menu-slide { padding-left: var(--menu-rail); }
  #pbar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--menu-w); padding: 14px 12px 10px; border-right: 1px solid var(--line);
          overflow: hidden; transition: width .16s ease, box-shadow .16s ease; }
  /* on a short screen only the modules scroll: the bottom (settings, you, sign out) stays in sight */
  #pbar .mods { flex: 0 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
  #pbar .mods a { height: 33px; flex: none; }
  #pbar .pm-grp { padding: 3px 0 1px; }
  #pbar .pm-gt { padding: 4px 10px 2px; }
  #pbar .pm-ft { height: 31px; }
  #pbar .spacer { flex: 1 1 0; min-height: 8px; }
  /* Icons, and Slide Out while closed: the narrow strip */
  body.menu-icons #pbar, body.menu-slide:not(.menu-peek) #pbar { width: var(--menu-rail); padding: 16px 10px 12px; }
  body.menu-icons #pbar :is(.pm-lb, .pm-gt, .pm-wt, .pm-modesw, .brand),
  body.menu-slide:not(.menu-peek) #pbar :is(.pm-lb, .pm-gt, .pm-wt, .pm-modesw, .brand) { display: none; }
  body.menu-icons #pbar .pm-mono, body.menu-slide:not(.menu-peek) #pbar .pm-mono { display: flex; }
  body.menu-icons #pbar :is(.mods a, .pm-ft), body.menu-slide:not(.menu-peek) #pbar :is(.mods a, .pm-ft) { justify-content: center; padding: 0; }
  body.menu-icons #pbar .pm-grp + .pm-grp, body.menu-slide:not(.menu-peek) #pbar .pm-grp + .pm-grp { border-top: 1px solid #EFEAE4; margin-top: 4px; padding-top: 6px; }
  body.menu-icons #pbar .who, body.menu-slide:not(.menu-peek) #pbar .who { justify-content: center; padding: 10px 0 4px; }
  body.menu-icons #btnPin { display: flex; align-items: center; justify-content: center; margin: 8px auto 0; width: 40px; height: 30px; padding: 0;
                            border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--mute); }
  body.menu-icons #wnLink .wndot, body.menu-slide:not(.menu-peek) #wnLink .wndot { left: 30px; top: 7px; }
  body.menu-icons #pbar .pm-bdg, body.menu-slide:not(.menu-peek) #pbar .pm-bdg { position: absolute; top: 2px; right: 4px; min-width: 16px; height: 16px;
    padding: 0 4px; font-size: 9.5px; border: 2px solid #fff; box-sizing: content-box; }
  /* Slide Out, open: over the page, which doesn't move */
  body.menu-slide.menu-peek #pbar { width: var(--menu-w); box-shadow: 8px 0 24px rgba(28,25,23,.12); }
  #toast { left: calc(50% + var(--menu-w) / 2); }
  body.menu-icons #toast, body.menu-slide #toast { left: calc(50% + var(--menu-rail) / 2); }
}

@media (max-width: 899.98px) {
  /* phone / small tablet: one top bar (☰, logo, What's New, Report a Problem, Sign Out); the rest in the drawer */
  #pbar { position: sticky; top: 0; flex-direction: row; align-items: center; gap: 4px; padding: 6px 10px; border-bottom: 1px solid var(--line); min-height: 48px;
          padding-top: calc(6px + env(safe-area-inset-top, 0px)); padding-left: calc(10px + env(safe-area-inset-left, 0px)); padding-right: calc(10px + env(safe-area-inset-right, 0px)); }
  #btnMenu { display: flex; align-items: center; justify-content: center; width: 40px; height: 36px; padding: 0; color: var(--ink2); flex: none; }
  #pbar .brand { padding: 0 4px; justify-content: flex-start; }
  #pbar .brand .pm-dv b { display: none; }
  #pbar .brand .pm-dv img { width: 26px; height: 26px; }
  #pbar .brand img.pm-co { height: 30px; }
  #pbar :is(.mods, .who, .pm-modesw, .pm-druva, #setLink, #btnInstall) { display: none; }
  #pbar .spacer { min-height: 0; }
  #pbar .pm-ft { width: auto; height: 36px; padding: 0 8px; flex: none; }
  #pbar .pm-ft .pm-lb { display: none; }
  #wnLink .wnshort { display: inline; font-size: 12px; } #wnLink .wndot { top: 6px; left: 20px; }
  /* the drawer */
  body.menu-open { overflow: hidden; }
  body.menu-open #pbar { position: fixed; top: 0; left: 0; bottom: 0; width: min(290px, 86vw); flex-direction: column; align-items: stretch;
                         padding: 12px; overflow-y: auto; border-bottom: none; box-shadow: 8px 0 30px rgba(28,25,23,.2); z-index: 60;
                         padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  body.menu-open #pbar :is(.mods, .who, #setLink) { display: flex; }
  body.menu-open #pbar .pm-ft { width: 100%; height: 40px; }
  body.menu-open #pbar .pm-ft .pm-lb { display: inline; }
  body.menu-open #wnLink .wnshort { display: none; }
  body.menu-open #pbar .mods a { height: 42px; }
  body.menu-open #btnMenu { align-self: flex-start; }
  body.menu-open #pbarShade { display: block; position: fixed; inset: 0; background: rgba(28,25,23,.35); z-index: 55; }
}
@media print { body.has-menu { padding-left: 0 !important; } #pbar, #pbarShade { display: none !important; } }

/* BUG-74: iOS zooms the page in when a text box under 16px gets focus, and in the Home Screen app it stays zoomed.
   On touch screens every text box uses 16px text (desktop keeps the compact sizes). */
@media (hover: none) and (pointer: coarse) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea { font-size: 16px !important; }
}

/* FEAT-89: "A new version of the app is out" (shared/platform.js checkVersion): over the top of any page, until Refresh or Later */
#newVersion { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 1000; width: min(560px, calc(100vw - 16px));
  box-sizing: border-box; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 12px 14px; border-radius: 12px;
  background: #1E3A8A; color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); font-size: 14px; line-height: 1.35; }
#newVersion .nv-t { flex: 1 1 240px; min-width: 0; }
#newVersion .nv-b { display: flex; gap: 8px; margin-left: auto; }
#newVersion button { min-height: 40px; padding: 0 16px; border-radius: 8px; font: inherit; font-weight: 700; cursor: pointer; }
#newVersion .nv-go { background: #fff; color: #1E3A8A; border: none; }
#newVersion .nv-later { background: none; color: #fff; border: 1px solid rgba(255, 255, 255, .6); }
@media print { #newVersion { display: none !important; } }
