/* Styled to match the Celestra Project Management System (ticket system): same palette, 8px controls,
   12px cards, pill chips, and a light sidebar like its "sidebar" navigation layout. Light is the default;
   dark uses the ticket system's dark palette. Variable names are kept so the rules below stay unchanged. */
:root {
  --bg: #f2f4f9;
  --surface: #ffffff;
  --sunken: #eaeef5;        /* ticket system --surface-2 */
  --ink: #1d2536;
  --muted: #4a5670;
  --line: #d5dce8;
  --nav: var(--surface);
  --nav-ink: var(--ink);
  --nav-muted: var(--muted);
  --hero-ink: #eef2ff;      /* sign-in brand panel text: the panel is a dark gradient in both themes */
  --hero-muted: #c7d2fe;
  --hero-soft: #a5b4fc;
  --accent: #1f5bc8;
  --accent-ink: #ffffff;
  --accent-hover: #174aa8;
  --focus: #1f5bc8;
  --link: #1f5bc8;
  --pend-fg: #875c00; --pend-bg: #fbf1d9;
  --rej-fg: #b5293c;  --rej-bg: #fbe8eb;
  --due-fg: #1f5bc8;  --due-bg: #e7eefb;
  --paid-fg: #0b7552; --paid-bg: #e2f3ec;
  --field-border: var(--line);
  --row-hover: #f5f7fb;
  --info-border: #bccdee;
  --rej-solid: #b5293c;
  --toast-bg: var(--sunken);
  --shadow: 0 4px 16px rgba(0,0,0,.12);
  --stripe: rgba(0,0,0,.02);
  --scrim: rgba(0,0,0,.45);
  color-scheme: light;
  --f-body: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-mono: ui-monospace, Consolas, Menlo, monospace;
}

/* Dark theme. Set on <html data-theme="dark"> by the profile page's Appearance setting
   (or by "Match device" when the device is in dark mode). The ticket system's dark palette. */
:root[data-theme="dark"] {
  --bg: #0f1420;
  --surface: #1a2130;
  --sunken: #232c3f;
  --ink: #e8ecf4;
  --muted: #b4bdcf;
  --line: #2e3950;
  --accent: #4f8cff;
  --accent-ink: #ffffff;
  --accent-hover: #6ba0ff;
  --focus: #6ba0ff;
  --link: #8fb5ff;
  --row-hover: #212a3c;
  --info-border: #2c4a80;
  --rej-solid: #ef5e6f;
  --shadow: 0 4px 16px rgba(0,0,0,.4);
  --stripe: rgba(255,255,255,.025);
  --scrim: rgba(0,0,0,.6);
  --pend-fg: #f0b429; --pend-bg: #2e2610;
  --rej-fg: #ef5e6f;  --rej-bg: #3a1d24;
  --due-fg: #6ba0ff;  --due-bg: #182a4a;
  --paid-fg: #35c48d; --paid-bg: #12291f;
  color-scheme: dark;
}

html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.5; margin: 0; }
a { color: var(--link); }
h1, h2, h3 { font-family: var(--f-body); margin: 0; font-weight: 600; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
p { margin: 0; }
.mono { font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--muted); }
.eyebrow { font-size: .85rem; color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* Buttons & inputs */
.btn { font: 500 .875rem/1 var(--f-body); border-radius: 8px; padding: .6rem 1rem; border: 1px solid var(--line); background: var(--sunken); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); padding-inline: .5rem; }
.btn-quiet:hover { color: var(--ink); background: transparent; text-decoration: underline; }
.btn-sm { padding: .4rem .65rem; font-size: .8rem; }
label { display: grid; gap: .3rem; font-size: .85rem; font-weight: 600; color: var(--ink); }
label .hint { font-weight: 400; color: var(--muted); }
input, select, textarea { font: 400 .9rem var(--f-body); color: var(--ink); background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; width: 100%; box-sizing: border-box; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
:root[data-theme="dark"] input::-webkit-calendar-picker-indicator { filter: invert(1); }
input[readonly] { background: var(--surface); color: var(--muted); border-color: var(--line); }
textarea { resize: vertical; min-height: 5rem; }
.err { color: var(--rej-fg); font-size: .8rem; }
.invalid { border-color: var(--rej-fg); }

/* Status tags */
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: .12rem .6rem; border-radius: 999px; white-space: nowrap; border: 1px solid currentColor; }
.s-pending { color: var(--pend-fg); background: var(--pend-bg); }
.s-rejected { color: var(--rej-fg); background: var(--rej-bg); }
.s-paid { color: var(--paid-fg); background: var(--paid-bg); }

/* ---------- Login ----------
   Matches the ticket system's sign-in page: a narrow sign-in column on the left and a
   blue-to-violet brand panel with a faint grid on the right (dark in both themes). */
#login { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 460px) minmax(0, 1fr); }
.login-art {
  position: relative; overflow: hidden; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
  color: var(--hero-ink);
  background: radial-gradient(1200px 600px at -10% -10%, rgba(59, 130, 246, .55), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, rgba(139, 92, 246, .5), transparent 60%),
              linear-gradient(160deg, #0b1530, #101a3a 55%, #1a1240);
}
.login-art::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .18;
  background-image: linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: linear-gradient(180deg, #000 30%, transparent 95%); mask-image: linear-gradient(180deg, #000 30%, transparent 95%);
}
.login-art > * { position: relative; z-index: 1; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 600; font-size: 1rem; color: var(--nav-ink); }
.brand-mark { width: 1.75rem; height: 1.75rem; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.login-art .brand { color: var(--hero-ink); }
.login-art .brand-mark { background: linear-gradient(135deg, #3b82f6, #8b5cf6); color: #fff; box-shadow: 0 6px 16px rgba(59,130,246,.35); }
.login-art h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.15; color: var(--hero-ink); max-width: 520px; }
.login-art p { color: var(--hero-muted); max-width: 460px; line-height: 1.6; margin-top: .9rem; font-size: 1rem; }
.login-steps { display: grid; gap: .5rem; color: var(--hero-soft); font-size: .875rem; }
.login-steps b { color: var(--hero-ink); font-weight: 600; }
.login-panel { order: -1; display: flex; align-items: center; justify-content: center; padding: 40px 32px; background: var(--surface); border-right: 1px solid var(--line); }
.login-title { font-size: 1.6rem; }
.login-sub { margin-top: .35rem; font-size: .95rem; }
.login-form { width: 100%; max-width: 360px; display: grid; gap: 1.25rem; }
.login-form .btn-primary { justify-content: center; padding-block: .7rem; }
.login-panel > .login-form { max-width: 400px; }
.login-form .login-form { max-width: none; }
/* Error messages on the sign-in page show as tinted notices, like the ticket system's. */
.login-form .err { border: 1px solid color-mix(in srgb, var(--rej-fg) 40%, transparent); background: color-mix(in srgb, var(--rej-fg) 10%, transparent); border-radius: 10px; padding: 11px 14px; font-size: .88rem; }
.login-form .err[hidden] { display: none; }
.role-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; align-items: start; }
.role-col { display: grid; gap: .4rem; }
.role-col .role-group { margin-top: 0; padding-bottom: .15rem; border-bottom: 1px solid var(--line); }
.sso { display: grid; gap: .4rem; }
.btn-ms { justify-content: center; gap: .75rem; width: 100%; padding: 12px 16px; border-radius: 10px; font-size: .98rem; font-weight: 600; background: var(--surface); border-color: var(--line); box-shadow: 0 1px 2px rgba(0,0,0,.08); transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease; }
.btn-ms:hover:not(:disabled) { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.btn-ms:active { transform: translateY(1px); }
.sso-note { font-size: .78rem; line-height: 1.5; margin-top: .35rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.check input { width: auto; }
.linkish { background: none; border: 0; color: var(--link); font: 400 .85rem var(--f-body); cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------- App shell ---------- */
#app { min-height: 100%; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.side { background: var(--nav); color: var(--nav-ink); border-right: 1px solid var(--line); padding: 1.25rem .75rem; display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh; box-sizing: border-box; }
.nav { display: grid; gap: 2px; }
.nav button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: .6rem; padding: .52rem .78rem; border-radius: 8px; color: var(--nav-muted); font-size: .9rem; }
.nav button:hover { color: var(--nav-ink); background: var(--sunken); }
.nav button[aria-current="page"] { color: var(--nav-ink); background: var(--sunken); font-weight: 600; }
.nav button:focus-visible { outline: 2px solid var(--focus); }
.nav svg { width: 16px; height: 16px; flex: none; }
.nav .raise { background: var(--accent); color: var(--accent-ink); font-weight: 600; margin-bottom: .5rem; }
/* Section headings in the side nav (Admin). */
.nav-group { margin: 1rem .65rem .35rem; color: var(--nav-muted); font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.nav .raise:hover, .nav .raise[aria-current="page"] { background: var(--accent-hover); color: var(--accent-ink); }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: .75rem; flex: none; }

/* Top bar: account menu, top right */
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; justify-content: flex-end; align-items: center; padding: .5rem 2rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.acct { position: relative; }
.acct-btn { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: .6rem; padding: .3rem .5rem; border-radius: 8px; color: var(--ink); }
.acct-btn:hover, .acct-btn[aria-expanded="true"] { background: var(--sunken); }
.acct-btn:focus-visible { outline: 2px solid var(--focus); }
.acct-text { display: grid; text-align: right; line-height: 1.25; }
.acct-text b { font-weight: 600; font-size: .875rem; }
.acct-text span { color: var(--muted); font-size: .78rem; }
.acct-btn .chev { color: var(--muted); }
.acct-menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: .35rem 0; display: grid; z-index: 35; overflow: hidden; }
.acct-menu[hidden] { display: none; }
.acct-head { display: grid; gap: .1rem; padding: .5rem .9rem .65rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; font-size: .85rem; }
.acct-head span:last-child { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.acct-head .role-badge { color: var(--muted); }
.acct-menu button { all: unset; box-sizing: border-box; cursor: pointer; padding: .5rem .9rem; font-size: .875rem; color: var(--ink); }
.acct-menu button:hover, .acct-menu button:focus-visible { background: var(--sunken); }

main { padding: 1.75rem 2rem 3rem; min-width: 0; }
.page { max-width: 1080px; display: grid; gap: 1.25rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: .25rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.card-pad { padding: 1.1rem 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem 1.25rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); padding: .6rem 1.25rem; border-bottom: 1px solid var(--line); background: transparent; white-space: nowrap; }
td { padding: .7rem 1.25rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--row-hover); }
td .sub { display: block; color: var(--muted); font-size: .8rem; }
th.num, td.num { text-align: right; }
.empty { padding: 2rem 1.25rem; text-align: center; color: var(--muted); }
/* Form */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.25rem; }
.span-2 { grid-column: 1 / -1; }
.form-foot { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; padding: .8rem 1.25rem; border-top: 1px solid var(--line); background: var(--sunken); }
.form-body { padding: 1.25rem; display: grid; gap: 1.5rem; }
.callout { border-radius: 8px; padding: .7rem .9rem; font-size: .875rem; border: 1px solid; }
.callout.rej { background: var(--rej-bg); color: var(--rej-fg); }
.callout.info { background: var(--due-bg); color: var(--ink); border-color: var(--info-border); }

/* Profile */
.profile-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 1rem; align-items: start; }
.profile-id { display: grid; gap: .9rem; justify-items: start; }
.avatar-lg { width: 4rem; height: 4rem; font-size: 1.2rem; }
.kv { display: grid; gap: .6rem; }
.kv div { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 1rem; font-size: .875rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.docs { list-style: none; margin: 0; padding: 0; display: grid; }
.docs li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.docs li:last-child { border-bottom: 0; }
.stack { display: grid; gap: 1rem; }

/* Toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 1.25rem; background: var(--toast-bg); color: var(--ink); border: 1px solid var(--line); padding: .65rem 1rem; border-radius: 10px; font-size: .875rem; z-index: 60; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .profile-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  #login { grid-template-columns: minmax(0, 1fr); min-height: 100%; }
  .login-art { padding: 2rem 16px; }
  .login-art h1 { font-size: 1.5rem; }
  .login-steps { display: none; }
  .login-panel { order: 0; border-right: 0; padding: 2rem 16px; align-items: flex-start; }
  #app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: .6rem 16px; gap: .6rem; z-index: 20; }
  .nav { display: flex; overflow-x: auto; gap: .3rem; scrollbar-width: none; }
  .nav button { white-space: nowrap; padding: .45rem .6rem; }
  .nav .raise { margin-bottom: 0; }
  /* On phones the nav is one scrolling row: a thin divider stands in for the section heading. */
  .nav-group { margin: .35rem .15rem; font-size: 0; width: 1px; flex: none; background: var(--line); }
  .side .brand-row { display: flex; justify-content: space-between; align-items: center; }
  .topbar { position: static; padding: .4rem 16px; }
  .acct-text { display: none; }
  main { padding: 1.25rem 16px 2.5rem; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .kv div { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  td, th { padding-inline: .8rem; }
  .card-head, .card-pad, .form-body, .form-foot { padding-inline: .9rem; }
}

/* Roles & scope */
.roles { display: grid; gap: .4rem; border: 0; margin: 0; padding: 0; min-width: 0; }
.roles legend { font-size: .85rem; font-weight: 600; padding: 0; margin-bottom: .35rem; }
.role { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 .6rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--surface); font-weight: 400; }
.role input { width: auto; grid-row: span 2; margin: .2rem 0 0; }
.role b { font-weight: 600; font-size: .875rem; }
.role span { color: var(--muted); font-size: .8rem; }
.role:has(input:checked) { border-color: var(--accent); background: var(--row-hover); }
.role-group { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: .35rem; }
.role-group:first-of-type { margin-top: 0; }
.role-badge { display: inline-block; justify-self: start; font-size: .75rem; color: var(--nav-muted); }
.profile-id .role-badge { color: var(--muted); }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); max-width: 100%; overflow-x: auto; }
.seg button { font: 400 .85rem var(--f-body); border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--ink); padding: .4rem .75rem; cursor: pointer; white-space: nowrap; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
select.compact { width: auto; max-width: 100%; padding: .4rem .5rem; font-size: .85rem; }
.btn-danger { color: var(--rej-fg); border-color: var(--rej-fg); background: transparent; }
.btn-danger:hover { background: var(--rej-bg); }
.perm { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .875rem; }
.perm:last-child { border-bottom: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Notifications */
.topbar { gap: .5rem; }
.bell { position: relative; }
.bell-btn { all: unset; box-sizing: border-box; cursor: pointer; position: relative; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 8px; color: var(--muted); }
.bell-btn:hover, .bell-btn[aria-expanded="true"] { background: var(--sunken); color: var(--ink); }
.bell-btn:focus-visible { outline: 2px solid var(--focus); }
.bell-count { position: absolute; top: .15rem; right: .1rem; min-width: 1.1rem; height: 1.1rem; padding: 0 .25rem; box-sizing: border-box; border-radius: 999px; background: var(--rej-solid); color: #fff; font-size: .68rem; font-weight: 700; line-height: 1.1rem; text-align: center; }
.bell-count[hidden] { display: none; }
.note-panel { position: absolute; right: 0; top: calc(100% + 4px); width: min(380px, calc(100vw - 32px)); max-height: min(70vh, 520px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 35; overflow: hidden; }
.note-panel[hidden] { display: none; }
.note-head { display: flex; justify-content: space-between; align-items: center; padding: .65rem .9rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
.note-list { overflow-y: auto; }
.note { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: .6rem minmax(0, 1fr); gap: .6rem; width: 100%; padding: .7rem .9rem; border-bottom: 1px solid var(--line); font-size: .85rem; }
.note:last-child { border-bottom: 0; }
.note:hover, .note:focus-visible { background: var(--sunken); }
.note-dot { width: .5rem; height: .5rem; border-radius: 50%; margin-top: .35rem; background: transparent; }
.note.unread .note-dot { background: var(--accent); }
.note.unread { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.note-text { display: grid; gap: .15rem; }
.note-text span { color: var(--muted); }
.note:not(.unread) .note-text b { font-weight: 500; }
.note-when { font-size: .75rem; }
.note-empty { padding: 1rem .9rem; font-size: .85rem; }
/* Users (system admin) */
input.search { width: min(320px, 100%); padding: .4rem .6rem; font-size: .85rem; }
.btns-inline { display: inline-flex; gap: .4rem; }
tr.inactive td { color: var(--muted); }
td select.compact { min-width: 9.5rem; }

/* Attachment lists */
.files { list-style: none; margin: .3rem 0 0; padding: 0; display: grid; gap: .3rem; font-size: .875rem; }
.files li { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }

/* Appearance (profile page) */
.theme-choice { display: flex; gap: .5rem; flex-wrap: wrap; }
.theme-choice button { font: 400 .875rem var(--f-body); display: inline-flex; align-items: center; gap: .45rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: .5rem .8rem; cursor: pointer; }
.theme-choice button:hover { background: var(--sunken); }
.theme-choice button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.theme-swatch { width: 1rem; height: 1rem; border-radius: 50%; border: 1px solid var(--field-border); flex: none; }
.theme-swatch.light { background: #ffffff; }
.theme-swatch.dark { background: #0f1420; }
.theme-swatch.system { background: linear-gradient(135deg, #ffffff 50%, #0f1420 50%); }

/* ---------- Phones (up to 760px wide) ---------- */
@media (max-width: 760px) {
  /* One bar at the top: the bell and account menu sit at the right of the navigation bar. */
  .side .brand-row { min-height: 2.5rem; padding-right: 6.5rem; }
  .topbar { position: fixed; top: 0; right: 0; z-index: 25; background: transparent; border: 0; padding: .55rem 10px; }
  .bell-btn, .acct-btn .chev { color: var(--nav-muted); }
  .bell-btn:hover, .bell-btn[aria-expanded="true"], .acct-btn:hover, .acct-btn[aria-expanded="true"] { background: var(--sunken); color: var(--nav-ink); }
  /* Menus open full-width under the bar instead of off the edge of the screen. */
  .acct-menu, .note-panel { position: fixed; top: 3.3rem; left: 8px; right: 8px; width: auto; min-width: 0; max-height: calc(100vh - 4.5rem); overflow-y: auto; }

  /* 16px text in form fields stops iPhones zooming the page when a field is tapped. */
  input, select, textarea, select.compact, input.search { font-size: 16px; }

  /* Finger-sized tap targets (at least 40px). */
  .btn, .btn-sm, .seg button, select.compact, .nav button, .theme-choice button { min-height: 40px; }
  .linkish { padding: .35rem 0; }
  /* Main actions fill the width; form buttons share a row and wrap evenly. */
  .page-head > .btn-primary { width: 100%; justify-content: center; }
  .form-foot .btn { flex: 1 1 auto; justify-content: center; }
  .toolbar { gap: .5rem; }
  .toolbar > select, #whoSel, input.search { width: 100%; }
  .theme-choice button { flex: 1 1 auto; justify-content: center; }

  /* Wide tables become stacked cards: one card per row, each value labelled. */
  .stack-table thead { display: none; }
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; box-sizing: border-box; }
  .stack-table tr { padding: .75rem .9rem; border-bottom: 1px solid var(--line); }
  .stack-table tr:last-child { border-bottom: 0; }
  .stack-table td { border: 0; padding: .2rem 0; display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 0 .75rem; align-items: baseline; text-align: left; }
  .stack-table td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; }
  .stack-table td.num { text-align: left; }
  .stack-table td.card-title { display: flex; justify-content: space-between; gap: .75rem; font-weight: 600; padding-bottom: .35rem; }
  .stack-table td.card-title::before { content: none; }
  .stack-table td.empty { display: block; text-align: center; }
  .stack-table td.empty::before { content: none; }
  .stack-table tbody tr.click:hover td { background: transparent; }
  .stack-table tbody tr.click:hover, .stack-table tbody tr.click:active { background: var(--row-hover); }
  .stack-table td select.compact { width: 100%; min-width: 0; }
}
@media (max-width: 760px) {
  .stack-table td[data-label=""] { display: block; padding-top: .4rem; }
  .stack-table td[data-label=""]::before { content: none; }
  .stack-table td.card-title .sub { font-weight: 400; }
}
@media (max-width: 760px) {
  /* Every part of a value (main text and its grey second line) stays in the value column. */
  .stack-table td > * { grid-column: 2; }
  .stack-table td.card-title > *, .stack-table td[data-label=""] > * { grid-column: auto; }
}

/* ---------- Sites and check-ins (roadmap Phase 3). Built for a phone on site, at night. ---------- */
.site-list { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.site-card { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: .45rem; padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-height: 44px; transition: border-color .15s; }
.site-card:hover { border-color: var(--accent); }
.site-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.site-card-head { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; }
.site-card-meta { font-size: .85rem; }
.site-card-next { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; font-size: .9rem; }
.progress { display: block; height: 6px; background: var(--sunken); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.confirm-box { display: grid; gap: .75rem; padding: 1rem 1.1rem; border: 2px solid var(--accent); border-radius: 12px; background: var(--surface); }
.confirm-box .btns { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
.confirm-box .btn { min-height: 48px; padding-inline: 1.2rem; }
.warn-text { color: var(--pend-fg); background: var(--pend-bg); padding: .5rem .7rem; border-radius: 8px; font-size: .9rem; }
.ms-list { list-style: none; margin: 0; padding: 0; display: grid; }
.ms { display: flex; gap: .75rem; align-items: center; padding: .6rem 0; border-top: 1px solid var(--line); }
.ms:first-child { border-top: 0; }
.ms-dot { flex: none; width: 1.9rem; height: 1.9rem; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; border: 2px solid var(--line); color: var(--muted); }
.ms-text { flex: 1; display: grid; gap: .1rem; }
.ms-detail { font-size: .82rem; color: var(--muted); }
.ms-done .ms-dot { background: var(--paid-bg); color: var(--paid-fg); border-color: var(--paid-fg); }
.ms-waiting .ms-dot { background: var(--pend-bg); color: var(--pend-fg); border-color: var(--pend-fg); }
.ms-waiting .ms-detail { color: var(--pend-fg); font-weight: 600; }
.ms-failed .ms-dot { background: var(--rej-bg); color: var(--rej-fg); border-color: var(--rej-fg); }
.ms-failed .ms-detail { color: var(--rej-fg); font-weight: 600; }
.ms-next .ms-dot { border-color: var(--accent); color: var(--ink); }
.ms-next .ms-text b { color: var(--ink); }
.ms-skipped, .ms-todo { color: var(--muted); }
/* Tapping a pending check-in records it: the row is the button, the confirmation opens under it. */
.ms-hint { font-size: .85rem; }
.ms-pick { all: unset; box-sizing: border-box; flex: 1; min-width: 0; display: flex; gap: .75rem; align-items: center; cursor: pointer;
  margin: -.35rem -.6rem; padding: .35rem .6rem; border-radius: 8px; min-height: 44px; transition: background .15s; }
.ms-pick:hover { background: var(--row-hover); }
.ms-pick:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.ms-next .ms-pick { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.ms-next .ms-pick:hover { background: color-mix(in srgb, var(--accent) 13%, transparent); }
/* Standalone check-ins: recorded at any time, apart from the sequence. */
.ms-any .ms-dot { border-style: dashed; border-color: var(--accent); color: var(--ink); }
.ms-any-tag { margin-left: .35rem; font-size: .7rem; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); vertical-align: 1px; }
.ms-standalone.ms-done .ms-any-tag { color: var(--muted); background: var(--sunken); }
.ms-any .ms-cta { color: var(--muted); font-weight: 500; }
.ms-cta { flex: none; color: var(--accent); font-weight: 600; font-size: .85rem; white-space: nowrap; }
.ms-open { flex-wrap: wrap; }
.ms-open .ms-pick { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.ms-open .confirm-box { flex: 1 1 100%; margin-top: .5rem; }
@media (max-width: 760px) {
  .site-list { grid-template-columns: 1fr; }
  /* The record button stays within thumb reach at the bottom of the screen while scrolling the list. */
}

/* ---------- Problems and tickets (roadmap Phase 4) ---------- */
.problem-list { list-style: none; margin: 0; padding: 0; display: grid; }
.problem-list > li { border-top: 1px solid var(--line); }
.problem-list > li:first-child { border-top: 0; }
.problem-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .6rem 0; width: 100%; }
.problem-row > span:first-child { display: grid; gap: .1rem; min-width: 0; }
.problem-row .sub { color: var(--muted); font-size: .82rem; }
.click-row { all: unset; box-sizing: border-box; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .6rem 0; width: 100%; min-height: 44px; }
.click-row:hover b { text-decoration: underline; }
.click-row:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.problem-form { border: 1px solid var(--line); border-radius: 12px; padding: 1rem; background: var(--sunken); }
.problem-form .btns { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
.problem-form .btn { min-height: 44px; }
/* Site page tabs: Milestones / Tickets */
.site-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: -.25rem; }
.site-tabs button { font: 600 .95rem var(--f-body); color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: .6rem .9rem; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; }
.site-tabs button:hover { color: var(--ink); }
.site-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.site-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px 6px 0 0; }
.tab-count { font: 500 .75rem var(--f-body); color: var(--muted); background: var(--sunken); border-radius: 999px; padding: .05rem .45rem; }
.site-tabs button[aria-selected="true"] .tab-count { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.seg-field { border: 0; padding: 0; margin: 0; display: grid; gap: .35rem; }
.seg-field legend { font-weight: 600; margin-bottom: .35rem; }
.ticket-list { display: grid; gap: .5rem; }
.ticket-row { all: unset; box-sizing: border-box; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-height: 44px; transition: border-color .15s; }
.ticket-row:hover { border-color: var(--accent); }
.ticket-row:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ticket-row-main { display: grid; gap: .15rem; min-width: 0; }
.ticket-row-main .sub { color: var(--muted); font-size: .82rem; }
.thread { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.msg-item { padding: .7rem .85rem; border-radius: 10px; border: 1px solid var(--line); display: grid; gap: .3rem; max-width: 85%; }
.msg-item.theirs { background: var(--surface); justify-self: start; }
.msg-item.mine { background: var(--sunken); justify-self: end; }
.msg-head { display: flex; justify-content: space-between; gap: 1rem; font-size: .82rem; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .msg-item { max-width: 100%; }
  .ticket-row, .problem-row, .click-row { flex-wrap: wrap; }
}
