:root { --orange: #f26822; --black: #0d0d0d; --bg: #f5f4f2; --line: #ddd; }
* { box-sizing: border-box; }
body { margin: 0; font-family: "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: #1c1c1c; }
header.site { background: var(--black); color: #fff; display: flex; align-items: center; gap: 18px; padding: 10px 24px; }
header.site img { height: 52px; }
header.site h1 { font-size: 16px; letter-spacing: 2px; text-transform: uppercase; font-weight: 600; margin: 0; flex: 1; }
header.site h1 span { color: var(--orange); }
header.site .who { font-size: 12.5px; color: #bbb; text-align: right; }
header.site .who b { color: #fff; display: block; }
.tabs { background: #1c1c1c; padding: 0 24px; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.tabs a { color: #bbb; padding: 12px 16px; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; text-decoration: none; border-bottom: 3px solid transparent; }
.tabs a.active, .tabs a:hover { color: #fff; border-bottom-color: var(--orange); }
.tabs form { margin-left: auto; }
.tabs button.linkish { background: none; border: none; color: #bbb; padding: 12px 16px; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; cursor: pointer; }
.tabs button.linkish:hover { color: #fff; }
main { max-width: 1080px; margin: 24px auto; padding: 0 16px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: #777; font-size: 12.5px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.card-name { font-size: 17px; font-weight: 700; }
.card-title { color: #666; font-size: 13px; margin: 2px 0 12px; }
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.card-grid span { display: block; font-size: 11px; text-transform: uppercase; color: #888; }
.card-grid b { font-size: 15px; }
button, .btn { font-family: inherit; background: var(--orange); color: #fff; border: none; border-radius: 6px; padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
.btn-line { background: #fff; color: var(--orange); border: 1.5px solid var(--orange); border-radius: 6px; padding: 7px 13px; font-size: 13px; font-weight: 600; text-decoration: none; display: inline-block; cursor: pointer; }
button.danger { background: #a11212; }
.notice { margin: 14px 0; padding: 12px 16px; border-radius: 8px; font-size: 14px; }
.notice.warn { background: #fff3e6; border: 1px solid #f0c08a; }
.notice.ok { background: #eef7ee; border: 1px solid #b5d9b5; }
.notice.err { background: #fff0f0; border: 1px solid #e3a6a6; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
select, input, textarea { padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; background: #fff; font-family: inherit; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; text-transform: uppercase; color: #666; }
.pill { padding: 2px 9px; border-radius: 999px; font-size: 11.5px; background: #eee; white-space: nowrap; }
.pill.ok { background: #d9efd9; color: #1e6b1e; }
.pill.warn { background: #ffe9c7; color: #8a5b00; }
.pill.alert { background: #ffd9d9; color: #a11212; }
.pill.info { background: #e3eefc; color: #1c4f9c; }
.data-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.data-table th { background: var(--black); color: #fff; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; padding: 9px 12px; }
.data-table td { padding: 8px 12px; border-top: 1px solid #eee; font-size: 13.5px; }
.data-table tr.sum td { font-weight: 700; background: #faf6f2; }
/* ---------- Zebra striping (CoreFab) ----------
   Subtle light-orange tint on alternate data rows so the all-white tables are
   easier to scan. The header is the first <tr> (it holds <th>, not <td>), so
   nth-child(even) lands on data rows only. The sum / week-sum rows set their
   own <td> background, which paints over this tint, so they keep their look.
   Scoped to .data-table — the pay-stub tables (.stub-table) are untouched, so
   printed/PDF stubs are unaffected. */
.data-table tr:nth-child(even) td { background: rgba(242, 104, 34, 0.06); }
form.panel, .panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
form.inline-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.auth-box { max-width: 420px; margin: 8vh auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.auth-box h2 { margin-top: 0; }
.auth-box form { display: flex; flex-direction: column; gap: 12px; }
.auth-box .logo { display: block; margin: 0 auto 10px; height: 64px; }
/* ---------- Pay stub ---------- */
.stub { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 28px; overflow: hidden; }
.stub-head { display: flex; align-items: center; gap: 20px; background: var(--black); color: #fff; padding: 14px 20px; }
.stub-head img { height: 60px; }
.stub-co { font-size: 12.5px; line-height: 1.5; flex: 1; }
.stub-meta { font-size: 12.5px; line-height: 1.6; text-align: right; }
.stub-meta b { color: var(--orange); letter-spacing: 1px; }
.stub-emp { display: flex; justify-content: space-between; padding: 14px 20px; font-size: 13px; line-height: 1.6; border-bottom: 2px solid var(--orange); }
.stub-emp div:last-child { text-align: right; }
.stub-table { width: 100%; border-collapse: collapse; }
.stub-table th { background: #f0ece8; text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; padding: 7px 20px; }
.stub-table td { padding: 6px 20px; font-size: 13.5px; border-top: 1px solid #f0f0f0; }
.stub-table td:nth-child(n+2), .stub-table th:nth-child(n+2) { text-align: right; }
.stub-table tr.sum td { font-weight: 700; border-top: 2px solid #ccc; }
.stub-table tr.net td { background: var(--black); color: #fff; font-size: 15px; }
.stub-table tr.net td:last-child, .stub-table tr.net td:nth-child(4) { color: var(--orange); }
.stub-foot { padding: 12px 20px; font-size: 12.5px; line-height: 1.6; }
.alert-line { background: #fff0f0; border: 1px solid #e3a6a6; color: #8c1010; border-radius: 6px; padding: 8px 12px; margin: 8px 0; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.badge.gusto { background: #e3eefc; color: #1c4f9c; }
.badge.novo { background: #d9efd9; color: #1e6b1e; }
.badge.pending { background: #ffe9c7; color: #8a5b00; }
.badge.alert { background: #ffd9d9; color: #a11212; }
.stub-actions { padding: 0 20px 16px; display: flex; gap: 10px; align-items: center; }
.payment-box { margin: 0 20px 14px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.payment-box table { width: 100%; border-collapse: collapse; }
.payment-box th { background: #f0ece8; text-align: left; font-size: 11.5px; text-transform: uppercase; padding: 7px 14px; }
.payment-box td { padding: 6px 14px; font-size: 13.5px; border-top: 1px solid #f0f0f0; }
.payment-box td:last-child { text-align: right; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
footer.site { text-align: center; color: #999; font-size: 12px; padding: 22px; }

/* ---------- Phase 3: onboarding + compliance ---------- */
.progress-wrap { display: flex; align-items: center; gap: 10px; margin: 10px 0 14px; }
.progress { flex: 1; max-width: 420px; height: 12px; background: #eee; border-radius: 999px; overflow: hidden; border: 1px solid #ddd; }
.progress-fill { height: 100%; background: var(--orange); border-radius: 999px; transition: width .2s; }
ul.checklist { list-style: none; padding-left: 0; margin: 6px 0; }
ul.checklist li { margin: 5px 0; }

/* ---------- Timesheet notes (full display, never truncated) ---------- */
.note-cell { max-width: 480px; }
.note-full, .note-preview { white-space: pre-wrap; word-break: break-word; }
details.note-more summary { cursor: pointer; list-style: none; }
details.note-more summary::-webkit-details-marker { display: none; }
details.note-more .note-toggle, details.note-more .note-toggle-hide {
  display: block; margin-top: 4px; color: #1c4f9c; font-size: 12px; font-weight: 600;
}
details.note-more .note-toggle-hide { display: none; }
details.note-more[open] .note-toggle { display: none; }
details.note-more[open] .note-toggle-hide { display: block; }
details.note-more[open] summary .note-preview { display: none; }
.actions-cell { white-space: nowrap; }
.actions-cell form { margin-left: 6px; }

/* Timesheet entry form: generous, auto-growing notes */
#entry-form .inline-fields { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
#entry-form .field-wide { width: 100%; margin-bottom: 12px; }
#entry-form textarea { width: 100%; min-height: 110px; resize: vertical; box-sizing: border-box; line-height: 1.45; }

/* ---------- Pre-filled timesheet day grid (start/end/lunch entry) ---------- */
.hours-input { width: 90px; }
.time-input { width: 120px; }
.lunch-input { width: 100px; }
.computed-hours { font-weight: 700; white-space: nowrap; }
.computed-hours.hours-bad { color: #a11212; font-weight: 600; }
tr.week-sum td { background: #f0ece8; font-weight: 600; border-top: 2px solid var(--orange); font-size: 12.5px; }
details.day-notes summary { cursor: pointer; color: #1c4f9c; font-size: 12px; font-weight: 600; list-style: none; }
details.day-notes summary::-webkit-details-marker { display: none; }
details.day-notes textarea { width: 100%; min-height: 80px; resize: vertical; box-sizing: border-box; line-height: 1.45; margin-top: 6px; }

/* ---------- "Action required" sign-in interstitial (CSP-safe, no JS) ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(13, 13, 13, 0.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 12px; border-top: 5px solid var(--orange);
  max-width: 520px; width: 100%; padding: 24px 28px; box-shadow: 0 12px 40px rgba(0,0,0,0.3); }
.modal-box h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 12px; align-items: center; margin-top: 18px; }

/* ---------- Profit & Loss (PROFIT-LOSS-SPEC A/B) ---------- */
/* Right-aligned, tabular money column used across the dashboard band, the P&L
   statement, and the expense ledger. */
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Owner-editable form grids (expense add/edit + category add). */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; align-items: end; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; text-transform: uppercase; color: #666; }
.form-grid .wide { grid-column: 1 / -1; }
/* Dashboard money band. */
.pl-band { background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--orange);
  border-radius: 10px; padding: 16px 18px; margin-bottom: 20px; }
.pl-band-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.pl-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pl-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.pl-kpi { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.pl-kpi span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #888; }
.pl-kpi b { font-size: 18px; font-variant-numeric: tabular-nums; }
.pl-kpi.pl-net { border-width: 2px; }
.pl-kpi.pl-net.pos { border-color: #1e6b1e; }
.pl-kpi.pl-net.neg { border-color: #a11212; }
.pl-kpi.pl-net.neg b { color: #a11212; }
/* P&L statement tab. */
.pl-statement .data-table { margin-bottom: 18px; }
.pl-statement .pl-net-row.neg td { color: #a11212; }
.pl-statement .pl-net-row.pos td { color: #1e6b1e; }

/* =====================================================================
   MOBILE / PWA — make the portal feel like a native app on a phone while
   staying a normal desktop site. All rules below are gated on small-screen
   media queries (or hidden by default), so desktop is unchanged.
   Verified: no horizontal overflow at 360–414px.
   ===================================================================== */

/* The hamburger lives in the header but is hidden on desktop. */
.nav-toggle { display: none; }

/* Long, wide data tables must never clip numbers on a phone. Turning the table
   into its own horizontal-scroll container (CSS-only, no markup change) keeps
   every column readable: the card scrolls sideways instead of the page. The
   zebra striping and brand colors are preserved (this only changes overflow). */
@media (max-width: 760px) {
  /* Never let the page itself scroll sideways. */
  html, body { overflow-x: hidden; max-width: 100%; }

  main { margin: 16px auto; padding: 0 12px; }

  /* ---- Header collapses; logo + title shrink to fit the bar ---- */
  header.site { gap: 12px; padding: 10px 14px; }
  header.site img { height: 40px; }
  header.site h1 { font-size: 13px; letter-spacing: 1px; }
  header.site .who { font-size: 11px; }

  /* ---- Hamburger + drawer nav ---- */
  .nav-toggle {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 44px; height: 44px; padding: 10px; margin-left: auto;
    background: none; border: 1.5px solid #444; border-radius: 8px; cursor: pointer;
  }
  .nav-toggle-bar { display: block; width: 100%; height: 2px; background: #fff; border-radius: 2px; }
  header.site .who { order: 3; flex-basis: 100%; text-align: left; }

  /* The owner has many links — the drawer is a scrollable vertical menu. */
  nav.tabs {
    display: none; flex-direction: column; align-items: stretch; gap: 0;
    padding: 0; max-height: 70vh; overflow-y: auto; border-bottom: 2px solid var(--orange);
  }
  nav.tabs.open { display: flex; }
  nav.tabs a {
    padding: 14px 18px; font-size: 14px; border-bottom: 1px solid #2a2a2a;
    border-left: 3px solid transparent;
  }
  nav.tabs a.active, nav.tabs a:hover { border-bottom-color: #2a2a2a; border-left-color: var(--orange); }
  nav.tabs form { margin-left: 0; }
  nav.tabs button.linkish { width: 100%; text-align: left; padding: 14px 18px; }

  /* ---- Tables: horizontal-scroll-in-card, numbers never clipped ---- */
  .data-table {
    display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }
  .data-table thead, .data-table tbody, .data-table tr { display: table; width: 100%; table-layout: auto; }
  .data-table th, .data-table td { white-space: nowrap; }
  /* Notes can be long — let that one column wrap inside a sensible width. */
  .data-table td.note-cell { white-space: normal; min-width: 180px; max-width: 60vw; }

  /* ---- Forms: full-width, comfortable tap targets, no overflow ---- */
  .toolbar, form.inline-row, #entry-form .inline-fields { flex-direction: column; align-items: stretch; }
  label.field, form.inline-row > * , .toolbar > * { width: 100%; }
  select, input, textarea { width: 100%; font-size: 16px; /* 16px stops iOS zoom-on-focus */ min-height: 44px; }
  textarea { min-height: 88px; }
  button, .btn, .btn-line { width: 100%; min-height: 44px; padding: 13px 16px; font-size: 15px; }
  /* Inline logout button in the drawer shouldn't be a full-width orange block. */
  nav.tabs button.linkish { width: 100%; min-height: 44px; }

  /* The timesheet day grid: keep the time/lunch inputs tappable but compact so
     the 9-column grid still scrolls cleanly inside its card. */
  .time-input, .lunch-input, .hours-input { width: auto; min-width: 110px; }
  .form-grid { grid-template-columns: 1fr; }

  /* ---- Pay stub: let the wide stub scroll horizontally, stay readable ---- */
  .stub { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .stub-head { flex-wrap: wrap; gap: 12px; padding: 12px 14px; }
  .stub-head img { height: 44px; }
  .stub-meta { text-align: left; }
  .stub-emp { flex-direction: column; gap: 10px; padding: 12px 14px; }
  .stub-emp div:last-child { text-align: left; }
  .stub-table th, .stub-table td { padding: 6px 12px; }
  .stub-actions { flex-wrap: wrap; }

  /* Cards stack to one column (the grid already does auto-fit, this just tightens). */
  .cards { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr 1fr; }

  /* Modal interstitial fits a small screen. */
  .modal-box { padding: 20px 18px; }
}

/* Phones with a notch / safe-area: pad the fixed status-bar region in
   standalone (installed) mode so the header isn't under the notch. */
@media (max-width: 760px) {
  header.site { padding-top: max(10px, env(safe-area-inset-top)); }
}
