:root {
  --brand: #D2691E;
  --brand-dark: #B85C18;
  --brand-tint: #FCEFE4;
  --ink: #221B14;
  --ink-soft: #6B5D4F;
  --paper: #F8F4EE;
  --card: #FFFFFF;
  --line: #EAE1D6;
  --field: #D9CCBD;
  --green: #2E7D52;
  --green-tint: #E3F1E8;
  --amber: #8A6220;
  --amber-tint: #F7EDD9;
  --red: #B3473E;
  --red-tint: #F6E1DE;
  --grey-tint: #EFEAE4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(34, 27, 20, .05), 0 6px 18px rgba(34, 27, 20, .05);
  --nav-h: 62px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
html { scroll-padding-top: 76px; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1 { font-size: 24px; line-height: 1.2; margin: 0; }
h2 { font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); margin: 24px 0 8px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-dark); }
:focus-visible { outline: 3px solid rgba(210, 105, 30, .4); outline-offset: 2px; }

/* ---------- Header and navigation ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar-in { max-width: 720px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { height: 32px; width: auto; display: block; }
.account { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.signout { border: none; background: none; color: var(--ink-soft); font-size: 13px; font-weight: 600; padding: 8px 4px; cursor: pointer; }
.signout:hover { color: var(--ink); }

.nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.nav:empty { display: none; }
.nav a { flex: 1; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--ink-soft); font-size: 11.5px; font-weight: 600; position: relative; }
.nav a svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav a[aria-current="page"] { color: var(--brand-dark); }
.badge { position: absolute; top: 7px; left: calc(50% + 7px); min-width: 17px; height: 17px; border-radius: 9px; padding: 0 5px; background: var(--red); color: #fff; font-size: 10.5px; line-height: 17px; text-align: center; }

.main { max-width: 720px; margin: 0 auto; padding: 20px 16px calc(var(--nav-h) + 112px + env(safe-area-inset-bottom)); }
.main.bare { padding-bottom: 40px; }

/* ---------- Common pieces ---------- */
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.head p { color: var(--ink-soft); font-size: 14px; margin-top: 3px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--brand-dark); font-weight: 600; font-size: 14px; text-decoration: none; padding: 4px 0 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1.5px solid transparent; border-radius: 11px; font-weight: 700; font-size: 16px; padding: 12px 18px; min-height: 50px; cursor: pointer; text-decoration: none; }
.btn.block { width: 100%; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--field); }
.btn.secondary:hover { border-color: var(--brand); }
.btn.danger { background: #fff; color: var(--red); border-color: #E6C3BF; }
.btn.small { min-height: 40px; padding: 7px 13px; font-size: 14px; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.spin { width: 16px; height: 16px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { margin-bottom: 16px; }
.field > label, .label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.opt { font-weight: 400; color: var(--ink-soft); }
input, select, textarea {
  width: 100%; font-size: 16px; /* 16px stops iOS from zooming in */
  background: #fff; border: 1.5px solid var(--field); border-radius: 10px; padding: 12px; min-height: 50px;
}
select {
  -webkit-appearance: none; appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(210, 105, 30, .22); border-color: var(--brand); }
input:disabled, select:disabled { background: #F4EFE9; color: var(--ink-soft); }
.invalid { border-color: var(--red) !important; }
.err { color: var(--red); font-size: 13px; margin-top: 5px; }
.hint { color: var(--ink-soft); font-size: 13px; margin-top: 5px; }
.hint.warn { color: var(--red); font-weight: 600; }

.pill { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--grey-tint); color: var(--ink-soft); white-space: nowrap; }
.pill.Pending { background: var(--amber-tint); color: var(--amber); }
.pill.Approved { background: var(--green-tint); color: var(--green); }
.pill.Rejected { background: var(--red-tint); color: var(--red); }
.notice { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; background: var(--amber-tint); color: #6E4E16; }
.notice.red { background: var(--red-tint); color: #7A2C25; }
.notice.info { background: #EEF2F7; color: #2F4560; }
.form-error { background: var(--red-tint); color: #7A2C25; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 12px; }

.seg { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: 0 -2px 14px; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; border: 1.5px solid var(--line); background: #fff; color: var(--ink-soft); border-radius: 999px; font-size: 14px; font-weight: 600; padding: 7px 13px; min-height: 38px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Sign in ---------- */
.signin { max-width: 420px; margin: 7vh auto 0; }
.signin h1 { margin-bottom: 4px; }
.signin .lead { color: var(--ink-soft); margin-bottom: 20px; }

/* ---------- Home ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 2px 0 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 10px; text-align: center; text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 24px; line-height: 1.15; }
.stat span { font-size: 12px; color: var(--ink-soft); }
.stat.alert b { color: var(--red); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Lists ---------- */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; gap: 12px; justify-content: space-between; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item > div:first-child { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.item b { font-weight: 600; }
.item .sub { display: block; color: var(--ink-soft); font-size: 13px; margin-top: 1px; }
.item > .btn { align-self: center; flex: none; }
.item .value { font-weight: 700; white-space: nowrap; text-align: right; }
.item .pill { margin-top: 5px; }
.reason { color: var(--red); font-size: 13px; margin-top: 5px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.empty { text-align: center; color: var(--ink-soft); padding: 28px 16px; font-size: 14px; }

/* ---------- Log hours ---------- */
.stepper { display: grid; grid-template-columns: 58px 1fr 58px; gap: 8px; }
.stepper input { text-align: center; font-size: 24px; font-weight: 700; padding: 8px; }
.stepper button { border: 1.5px solid var(--field); background: #fff; border-radius: 10px; font-size: 26px; cursor: pointer; min-height: 56px; }
.stepper button:active { background: var(--brand-tint); }
.chips { display: flex; gap: 8px; margin-top: 10px; }
.chip { flex: 1; border: 1.5px solid var(--line); background: var(--paper); border-radius: 999px; padding: 8px 4px; font-weight: 600; font-size: 15px; cursor: pointer; min-height: 42px; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Sticky action bar ---------- */
.actionbar { position: fixed; z-index: 15; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line); padding: 10px 16px; }
.actionbar-in { max-width: 688px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.actionbar .btn { flex: 1; }
.actionbar .btn.secondary { flex: 0 0 auto; }
.actionbar .total { flex: 0 0 auto; }
.actionbar .total small { display: block; font-size: 11.5px; color: var(--ink-soft); }
.actionbar .total b { font-size: 18px; }

/* ---------- Expenses ---------- */
.upload { display: flex; align-items: center; gap: 10px; border: 1.5px dashed #D2B9A0; border-radius: 10px; padding: 13px; cursor: pointer; background: #FFFCF8; font-weight: 600; font-size: 15px; min-height: 52px; overflow-wrap: anywhere; }
.upload:hover, .upload:focus-within { border-color: var(--brand); }
.upload.has-file { border-style: solid; border-color: var(--green); background: var(--green-tint); }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.money { position: relative; }
.money span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); font-weight: 700; }
.money input { padding-left: 28px; font-size: 20px; font-weight: 700; }
.title-input { font-size: 20px; font-weight: 700; border-color: transparent; background: transparent; padding: 6px 8px; margin-left: -8px; width: calc(100% + 8px); min-height: 44px; }
.title-input:hover:not(:disabled) { border-color: var(--field); background: #fff; }
.title-input:disabled { background: transparent; color: var(--ink); }

dialog.sheet { border: none; padding: 0; width: 100%; max-width: 560px; max-height: 92dvh; margin: auto auto 0; border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .2); background: #fff; color: var(--ink); }
dialog.sheet::backdrop { background: rgba(34, 27, 20, .45); }
dialog.sheet[open] { animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(30px); opacity: .6; } }
.sheet-head { position: sticky; top: 0; background: #fff; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet-head b { font-size: 17px; }
.sheet-close { border: none; background: var(--grey-tint); width: 34px; height: 34px; border-radius: 50%; font-size: 15px; cursor: pointer; }
.sheet-body { padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); }
dialog.confirm { border: none; border-radius: 14px; padding: 18px; max-width: 340px; box-shadow: 0 18px 50px rgba(0, 0, 0, .25); color: var(--ink); }
dialog.confirm::backdrop { background: rgba(34, 27, 20, .45); }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ---------- Loading and toasts ---------- */
.skeleton { background: linear-gradient(90deg, #EFE9E1 25%, #F7F2EC 50%, #EFE9E1 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 12px; height: 72px; margin-bottom: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.toasts { position: fixed; z-index: 60; left: 16px; right: 16px; top: calc(66px + env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: #fff; border-radius: 10px; padding: 10px 14px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .22); max-width: 480px; animation: rise .18s ease-out; }
.toast.error { background: var(--red); }

/* ---------- Larger screens: tabs move into the header ---------- */
/* ---------- Approvals, reports, manage ---------- */
.group-head { display: flex; align-items: center; gap: 10px; margin: 18px 2px 6px; }
.group-head > div { flex: 1; min-width: 0; }
.group-head .sub { display: block; color: var(--ink-soft); font-size: 13px; }
.check { display: flex; align-items: flex-start; padding-top: 2px; cursor: pointer; }
.check input, .switch input, .checklist input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--brand); margin: 0; }
.item.check-row { justify-content: flex-start; }
.item.check-row > div:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item.link { text-decoration: none; color: inherit; align-items: center; }
a.list.item.link { display: flex; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; padding: 7px 0; cursor: pointer; }
.checklist { border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; margin-top: 6px; max-height: 240px; overflow: auto; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.stats.wrap { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.stats.wrap .stat b { font-size: 18px; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { border-collapse: collapse; width: 100%; font-size: 13px; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { background: var(--brand-tint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); }
.tbl .num { text-align: right; }
.tbl tfoot td { font-weight: 700; border-bottom: none; }
.receipt-img { display: block; width: 100%; height: auto; border-radius: 8px; }

/* ---------- Weekly hours grid ---------- */
.week-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-nav b { font-size: 16px; }
.week-nav .btn { min-width: 42px; }
.week-actions { display: none; gap: 10px; }
.grid-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.grid-head { display: none !important; }
.grid-row { padding: 12px; border-bottom: 1px solid var(--line); }
.grid-project { margin-bottom: 10px; }
.grid-project select { min-height: 46px; font-weight: 600; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.day { display: block; text-align: center; margin: 0; font-weight: 600; }
.day-label { display: block; font-size: 11px; color: var(--ink-soft); line-height: 1.25; margin-bottom: 3px; font-weight: 600; }
.day small { display: block; font-size: 11px; font-weight: 400; color: var(--ink-soft); }
.day.weekend { opacity: .75; }
input.cell { padding: 0; min-height: 44px; text-align: center; font-weight: 700; border-radius: 8px; font-size: 16px; background: #FDFBF8; }
input.cell.Draft { background: var(--grey-tint); }
input.cell.Pending { background: var(--amber-tint); border-color: #EBD7B0; color: var(--amber); }
input.cell.Approved { background: var(--green-tint); border-color: #C7E2D2; color: var(--green); }
input.cell.Rejected { background: var(--red-tint); border-color: #E2A9A2; color: var(--red); }
.grid-row:not(.grid-totals):not(.grid-head) { display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 12px; }
.grid-project, .grid-row .days, .grid-reason { grid-column: 1 / -1; }
.whole { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); margin: 8px 0 0; font-weight: 600; cursor: pointer; }
.whole input { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); margin: 0; }
.grid-total { font-weight: 700; margin-top: 8px; text-align: right; }
.total-label { font-weight: 400; color: var(--ink-soft); font-size: 13px; }
.grid-actions { display: flex; gap: 2px; margin-top: 8px; }
.icon-btn { border: none; background: none; width: 38px; height: 38px; border-radius: 8px; font-size: 17px; color: var(--ink-soft); cursor: pointer; }
.icon-btn:hover { background: var(--paper); color: var(--ink); }
.icon-btn.has-note { color: var(--brand-dark); }
.grid-reason { margin-top: 6px; }
.grid-totals .label { margin-bottom: 4px; }
.grid-totals .day b { font-size: 14px; }
.grid-totals .day b.over { color: var(--red); }
.grid-totals .whole { display: none; }
.week-sum { display: flex; justify-content: flex-end; align-items: baseline; gap: 6px; }
.week-sum small { font-size: 12px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; }
.week-sum b { color: var(--brand-dark); font-size: 18px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 10px 2px 0; font-size: 12px; color: var(--ink-soft); }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; background: var(--grey-tint); }
.legend i.Pending { background: var(--amber-tint); }
.legend i.Approved { background: var(--green-tint); }
.legend i.Rejected { background: var(--red-tint); }
h2.section { font-size: 19px; letter-spacing: 0; text-transform: none; color: var(--ink); margin: 26px 0 10px; }
.count { font-size: 12px; font-weight: 600; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; margin-left: 4px; vertical-align: 2px; background: #fff; }
.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.week-card { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; cursor: pointer; box-shadow: var(--shadow); }
.week-card.static { cursor: default; }
button.week-card:hover { border-color: var(--brand-soft, var(--brand)); }
.week-card .sub { display: block; color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.week-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.actionbar.week-mobile .btn { padding: 8px 6px; font-size: 14px; min-height: 46px; flex: 1; }
.actionbar.week-mobile .btn.secondary { flex: 0 0 auto; padding: 8px 10px; }

@media (min-width: 760px) {
  .week-actions { display: flex; }
  .week-mobile { display: none; }
  .whole-mobile, .total-label, .day-label { display: none; }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .main:has(.grid-card) { max-width: 1120px; }
  .grid-row, .grid-row:not(.grid-totals):not(.grid-head), .grid-head { display: grid !important; grid-template-columns: minmax(180px, 1.5fr) minmax(0, 4fr) 86px 62px 82px; column-gap: 12px; align-items: center; padding: 10px 14px; }
  .grid-head { font-size: 12px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em; }
  .grid-project, .grid-row .days { grid-column: auto; margin: 0; }
  .grid-project { margin-bottom: 0; }
  .grid-reason { grid-column: 1 / -1; }
  .whole, .grid-total, .grid-actions { margin: 0; justify-content: center; }
  .grid-head .whole { font-size: 12px; }
  .grid-total { text-align: center; }
  .grid-totals .label { margin: 0; }
  .grid-totals .whole { display: block; }
  .week-sum { flex-direction: column; align-items: center; gap: 0; }
  input.cell { max-width: 62px; margin: 0 auto; display: block; }

  .topbar-in { max-width: 1040px; }
  .nav a span { display: flex; }
  .nav { position: static; flex: 1; border: none; padding: 0; margin-left: 18px; gap: 4px; }
  .nav a { flex: none; flex-direction: row; min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 8px; gap: 7px; }
  .nav a svg { width: 18px; height: 18px; }
  .nav a[aria-current="page"] { background: var(--brand-tint); }
  .badge { position: static; }
  .main { padding: 28px 16px 120px; }
  .actionbar { bottom: 0; }
  dialog.sheet { margin: auto; border-radius: 18px; }
  .toasts { top: 74px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}

/* expense lines grouped by client or project */
.expense-head { justify-content: space-between; align-items: baseline; gap: 12px; }
.expense-head h2 { min-width: 0; overflow-wrap: anywhere; }
.expense-head > b { white-space: nowrap; }
.tbl .group-row td { background: var(--paper, #F5EFE7); font-size: 13px; }

/* notifications */
.bell { position: relative; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; color: var(--ink-soft); }
.bell:hover, .bell[aria-current="page"] { background: var(--brand-tint); color: var(--brand-dark); }
.bell svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bell .badge { position: absolute; top: 2px; left: auto; right: 0; }
.item.unread { background: var(--brand-tint); }
.item .note-time { flex: none; color: var(--ink-soft); font-size: 12px; white-space: nowrap; }
