/* GSDFORME design system. One set of tokens + components used by every screen. */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --border: #dfe3e8; --text: #16191d; --muted: #5d6673;
  --brand: #e8590c; --brand-ink: #ffffff; --brand-soft: #fff0e6;
  --side: #171b21; --side-text: #c9ced6; --side-active: #262c35;
  --ok: #1a7f37; --ok-soft: #e6f4ea; --warn: #9a6700; --warn-soft: #fff4d6; --bad: #c62828; --bad-soft: #fdecea; --info: #0b5cad; --info-soft: #e7f0fb;
  --radius: 10px; --radius-sm: 6px; --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tap: 44px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1e232b; --border: #2c333d; --text: #e8ebef; --muted: #9aa3ae;
    --brand-soft: #3a2415; --side: #0b0d10; --side-active: #1e232b;
    --ok: #4ac26b; --ok-soft: #12301b; --warn: #e3b341; --warn-soft: #33290d; --bad: #f47067; --bad-soft: #3b1614; --info: #6cb6ff; --info-soft: #102a45;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; } .spacer { flex: 1; }
.stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* Layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: .5rem; color: #fff; font-weight: 800; letter-spacing: .02em; font-size: 1.15rem; padding: .25rem .5rem 1rem; }
.logo-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--brand); display: grid; place-items: center; color: #fff; font-size: .9rem; }
.side nav a { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border-radius: var(--radius-sm); color: var(--side-text); min-height: 40px; }
.side nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.side nav a[aria-current="page"] { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.side .org { margin-top: auto; padding: .75rem; font-size: .85rem; border-top: 1px solid #2a3038; }
.side .org strong { color: #fff; display: block; }
.ico { width: 18px; text-align: center; opacity: .9; }
.main { min-width: 0; }
.top { display: flex; gap: .75rem; align-items: center; padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.top form { flex: 1; max-width: 480px; }
.content { padding: 1.5rem; max-width: 1280px; }
.page-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.bottom-nav { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .top { padding: .6rem 1rem; }
  .content { padding: 1rem 1rem 6rem; }
  .bottom-nav { display: flex; position: fixed; inset: auto 0 0 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 10; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem 0; font-size: .72rem; color: var(--muted); min-height: 56px; justify-content: center; }
  .bottom-nav a[aria-current="page"] { color: var(--brand); }
  .bottom-nav .ico { font-size: 1.2rem; }
  .hide-mobile { display: none !important; }
}

/* Components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: .75rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap); padding: 0 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 34px; padding: 0 .7rem; font-size: .88rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field .hint, .field .err { font-size: .82rem; margin-top: .25rem; }
.field .err { color: var(--bad); }
input, select, textarea { width: 100%; min-height: var(--tap); padding: .55rem .7rem; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--brand); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
.check { display: flex; gap: .6rem; align-items: center; font-weight: 500; }
details.more > summary { cursor: pointer; color: var(--info); font-weight: 600; margin-bottom: .75rem; min-height: 32px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; } tbody tr.link:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

.kpis { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1.25rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.kpi .v { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .85rem; font-weight: 600; }
.kpi.alert .v { color: var(--bad); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .65rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .75rem; align-items: center; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: .65rem .9rem; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .big { font-size: 2rem; }
.empty h3 { color: var(--text); }
.skeleton { height: 1rem; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; margin: .6rem 0; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.error-box { background: var(--bad-soft); color: var(--bad); padding: .8rem 1rem; border-radius: var(--radius-sm); font-weight: 600; }

dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(640px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog .d-head { display: flex; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
dialog .d-head h2 { margin: 0; flex: 1; }
dialog .d-body { padding: 1.25rem; overflow-y: auto; max-height: calc(100vh - 11rem); }
dialog .d-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .9rem 1.25rem; border-top: 1px solid var(--border); }

.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: .75rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-weight: 600; max-width: 360px; }
.toast.bad { background: var(--bad); color: #fff; }
@media (max-width: 860px) { .toasts { bottom: 5rem; left: 1rem; } }

/* Auth / onboarding */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth .card { width: min(440px, 100%); padding: 2rem; }
.auth .logo { color: var(--text); padding: 0 0 1.25rem; }
.choices { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.choice { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem .8rem; cursor: pointer; font-weight: 500; min-height: var(--tap); margin: 0; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice input { width: 18px; min-height: 18px; height: 18px; accent-color: var(--brand); }
.steps { display: flex; gap: .35rem; margin-bottom: 1.25rem; } .steps span { height: 4px; flex: 1; border-radius: 2px; background: var(--border); } .steps span.on { background: var(--brand); }

/* Photos */
.photos { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.photo { position: relative; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); aspect-ratio: 4 / 3; border: 1px solid var(--border); padding: 0; cursor: pointer; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .cap { position: absolute; inset: auto 0 0 0; background: linear-gradient(transparent, rgb(0 0 0 / .7)); color: #fff; font-size: .75rem; padding: 1.2rem .5rem .35rem; text-align: left; }
.lightbox img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cal .dow { background: var(--surface-2); font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: .4rem; text-align: center; }
.cal .day { min-height: 108px; border-top: 1px solid var(--border); border-left: 1px solid var(--border); padding: .3rem; font-size: .8rem; min-width: 0; }
.cal .day:nth-child(7n+1) { border-left: 0; }
.cal .day.out { background: var(--surface-2); color: var(--muted); }
.cal .day.today .d { background: var(--brand); color: #fff; border-radius: 999px; padding: 0 .4rem; }
.cal .ev { display: block; border-radius: 4px; padding: .1rem .3rem; margin-top: .2rem; background: var(--info-soft); color: var(--info); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.cal .ev.ms { background: var(--brand-soft); color: var(--brand); }
.cal .ev.done { text-decoration: line-through; opacity: .6; }
.cal .ev.proj { background: var(--ok-soft); color: var(--ok); }
@media (max-width: 700px) { .cal .day { min-height: 70px; } .cal .ev { font-size: .68rem; } }

.feed li { align-items: flex-start; }
.feed time { white-space: nowrap; }
.attn { color: var(--bad); font-size: .85rem; font-weight: 600; }
.module { display: flex; gap: .75rem; align-items: flex-start; }
.module .grow { flex: 1; }
.progress { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ok); }
[tabindex="-1"]:focus { outline: none; }
a.kpi { color: var(--text); } a.kpi:hover { text-decoration: none; border-color: var(--brand); }
.kpi .v { overflow-wrap: normal; }
.row > .grow { flex: 1; min-width: 0; width: auto; }
@media (max-width: 860px) {
  .top form { max-width: none; }
  .top .spacer { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .kpi { padding: .8rem; }
  .kpi .v { font-size: 1.35rem; }
}
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; }
.auth .card.wide { width: min(680px, 100%); }

/* ---------- Phase 2 components ---------- */
.ok-box { background: var(--ok-soft); color: var(--ok); padding: .8rem 1rem; border-radius: var(--radius-sm); font-weight: 600; }
.warn-box { background: var(--warn-soft); color: var(--warn); padding: .8rem 1rem; border-radius: var(--radius-sm); font-weight: 600; margin: 0; }
.neg { color: var(--bad); }
.pre { white-space: pre-wrap; }
.auto { width: auto; }

/* Sign-in */
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn.oauth { gap: .6rem; }
.ms-logo { width: 16px; height: 16px; background: conic-gradient(#f25022 0 25%, #7fba00 0 50%, #00a4ef 0 75%, #ffb900 0); background: linear-gradient(90deg, #f25022 50%, #7fba00 50%) top / 100% 50% no-repeat, linear-gradient(90deg, #00a4ef 50%, #ffb900 50%) bottom / 100% 50% no-repeat; }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

/* Notifications */
.bell { position: relative; }
.bell .count { position: absolute; top: 2px; right: 2px; background: var(--bad); color: #fff; border-radius: 999px; font-size: .65rem; padding: 0 .35rem; line-height: 1.4; }
.side-user { color: var(--side-text); display: block; }

/* Line-item editors */
.lines { display: grid; gap: .4rem; }
.line, .line-head { display: grid; gap: .4rem; align-items: center; grid-template-columns: minmax(180px, 3fr) 1.1fr 1.3fr .9fr .6fr 1fr .7fr 1.1fr 36px; }
.lines.inv .line, .lines.inv .line-head { grid-template-columns: minmax(200px, 4fr) .8fr 1.2fr 1.2fr 36px; }
.line-head span { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.line input, .line select { min-height: 40px; padding: .4rem .5rem; }
.line .price { font-weight: 700; }
@media (max-width: 900px) {
  .line { grid-template-columns: 1fr 1fr 1fr; background: var(--surface-2); padding: .6rem; border-radius: var(--radius-sm); }
  .line .desc { grid-column: 1 / -1; }
  .lines.inv .line { grid-template-columns: 1fr 1fr 1fr 36px; }
}
.est-foot { align-items: start; }
.totals { width: 100%; max-width: 420px; margin-left: auto; }
.totals td { padding: .35rem .5rem; border: 0; }
.totals tr.strong td { font-weight: 800; font-size: 1.05rem; border-top: 2px solid var(--border); }
.totals tr.internal td { color: var(--muted); font-size: .85rem; }
.totals tr.internal.neg td { color: var(--bad); }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; margin: .5rem 0 1rem; border-top: 1px solid var(--border); z-index: 4; }
@media (max-width: 860px) { .sticky-actions { bottom: 56px; } }

/* Team rates */
.rate { display: flex; align-items: center; gap: .3rem; font-weight: 500; margin: 0; }
.rate input { width: 90px; min-height: 34px; padding: .2rem .4rem; }

/* Time clock */
.clock { margin-bottom: 1rem; }
.clock-time { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.clock.compact .clock-time { font-size: 1.4rem; }
.btn.big { min-height: 56px; padding: 0 1.6rem; font-size: 1.05rem; }
.tabs.compact { border: 0; margin: 0; }

/* Daily log */
dl.log { display: grid; grid-template-columns: 200px 1fr; gap: .5rem 1rem; margin: 0; }
dl.log dt { font-weight: 700; color: var(--muted); }
dl.log dd { margin: 0; }
@media (max-width: 600px) { dl.log { grid-template-columns: 1fr; } dl.log dd { margin-bottom: .6rem; } }

/* Report chart */
.chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: .4rem; height: 180px; align-items: end; margin-top: .75rem; }
.chart .col { display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart .bars { flex: 1; display: flex; gap: 2px; align-items: flex-end; width: 100%; justify-content: center; }
.chart .bar { width: 40%; min-height: 1px; border-radius: 3px 3px 0 0; }
.bar.in, .legend i.in { background: var(--ok); }
.bar.out, .legend i.out { background: var(--brand); }
.legend { font-size: .8rem; color: var(--muted); display: inline-flex; align-items: center; gap: .3rem; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: .4rem; }

/* Client-facing document */
.public { max-width: 860px; margin: 0 auto; padding: 1rem; }
.doc { padding: 1.75rem; }
.doc > * + * { margin-top: 1.1rem; }
.doc-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 3px solid var(--brand); padding-bottom: 1rem; }
.doc-meta { text-align: right; }
.doc-kind { font-size: 1.3rem; font-weight: 800; }
@media (max-width: 600px) { .doc-meta { text-align: left; } .doc { padding: 1.1rem; } }

@media print {
  body { background: #fff; color: #000; }
  .no-print, .toasts, .side, .top, .bottom-nav, .sticky-actions { display: none !important; }
  .card { border: 0; padding: 0; }
  .public { max-width: none; padding: 0; }
  .table-wrap { border: 0; }
  th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; }
}
