/* Same look as the other demos (ajera-time-budget, agency-jobs-retainers). */
:root {
  --ink: #14211f;
  --muted: #56625f;
  --paper: #f7f5ef;
  --card: #fffdf8;
  --line: #d8d7cf;
  --soft: #efece3;
  --accent: #1f5f52;
  --accent-ink: #ffffff;
  --lime: #d9f27c;
  --ok: #2f7d4f;
  --ok-bg: #e2f2e7;
  --risk: #9a6300;
  --risk-bg: #fbefd4;
  --over: #b03a23;
  --over-bg: #f9e0d9;
  --none: #6b7470;
  --none-bg: #eceae4;
  --bar: #2f7d4f;
  --shadow: 0 8px 30px rgba(25, 45, 40, .08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e9ece8; --muted: #a3aca8; --paper: #121816; --card: #1a2220; --line: #2f3a37; --soft: #222c29;
    --accent: #7cc4a8; --accent-ink: #0f1614; --ok: #7ccf9a; --ok-bg: #1d3327; --risk: #f0c060; --risk-bg: #3a2f14;
    --over: #f08a70; --over-bg: #3d2019; --none: #a3aca8; --none-bg: #252e2b; --bar: #5fb483;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--paper);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.5; overflow-x: hidden;
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 8px 12px; background: var(--ink); color: var(--paper); border-radius: 6px; }
.skip-link:focus { top: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.noscript { padding: 16px; }

.banner { background: var(--ink); color: var(--paper); font-size: 13px; padding: 8px 16px; text-align: center; }
.banner a { color: var(--lime); margin-left: 6px; white-space: nowrap; }

.app-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px); background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { display: block; font-size: 16px; line-height: 1.2; }
.brand .sub { color: var(--muted); font-size: 13px; }
.logo { width: 30px; height: 30px; border-radius: 7px; background: var(--accent); flex: none;
  background-image: linear-gradient(to top, var(--lime) 0 60%, transparent 60%), linear-gradient(to top, var(--lime) 0 40%, transparent 40%), linear-gradient(to top, var(--lime) 0 25%, transparent 25%);
  background-size: 5px 18px; background-repeat: no-repeat; background-position: 7px 6px, 13px 6px, 19px 6px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; color: var(--muted); font-weight: 600; }
.tabs button:hover { background: var(--soft); color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }

main { padding: 20px clamp(16px, 4vw, 40px) 40px; max-width: 1280px; margin: 0 auto; outline: none; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.lede { color: var(--muted); margin: 0 0 16px; max-width: 80ch; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grid2 > .panel { margin-bottom: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 14px; }
.toolbar label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.weeknav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.weeknav strong { min-width: 170px; text-align: center; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; min-height: 38px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; font-weight: 600; text-decoration: none;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 6px 8px; border-radius: 6px; font-size: 16px; line-height: 1; }
.icon-btn:hover { background: var(--soft); color: var(--over); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }
.linklike { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }

input[type="text"], input[type="number"], input[type="date"], input:not([type]), select {
  border: 1px solid var(--line); background: var(--card); border-radius: 7px; padding: 7px 9px; min-height: 36px; max-width: 100%;
}
input.bad { border-color: var(--over); background: var(--over-bg); }
select { padding-right: 24px; }
input.pct { width: 64px; text-align: right; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok, .pill.approved, .pill.complete { background: var(--ok-bg); color: var(--ok); }
.pill.risk { background: var(--risk-bg); color: var(--risk); }
.pill.over { background: var(--over-bg); color: var(--over); }
.pill.none, .pill.draft { background: var(--none-bg); color: var(--none); }
.pill.submitted { background: #e3ecf8; color: #2c5d99; }
@media (prefers-color-scheme: dark) { .pill.submitted { background: #1d2a3d; color: #8db6ea; } }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
thead th { background: var(--soft); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tfoot th, tfoot td { border-top: 2px solid var(--line); border-bottom: 0; font-weight: 700; background: var(--soft); }

/* Timesheet grid */
.ts td, .ts th { padding: 6px 6px; }
.ts .col-proj { min-width: 260px; }
.ts .col-proj select { width: 100%; }
.ts .col-phase select { min-width: 88px; }
.ts th.day { text-align: center; min-width: 58px; }
.ts th.day small { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; }
.ts th.day.weekend, .ts td.weekend { background: color-mix(in srgb, var(--soft) 55%, transparent); }
.ts input.h { width: 56px; text-align: right; padding: 6px 6px; font-variant-numeric: tabular-nums; }
.ts input.h:disabled { background: transparent; border-color: transparent; color: var(--ink); }
.ts .rowtotal { font-weight: 700; }
.ts .overday { color: var(--over); }
.ts .sticky { position: sticky; left: 0; background: var(--card); z-index: 1; }
.ts thead .sticky, .ts tfoot .sticky { background: var(--soft); }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .value.over { color: var(--over); }
.kpi .value.risk { color: var(--risk); }

/* Budget bar: fill is fee used, tick is % complete */
.bar { position: relative; height: 10px; background: var(--soft); border-radius: 999px; overflow: visible; min-width: 90px; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--bar); max-width: 100%; }
.bar.risk .fill { background: var(--risk); }
.bar.over .fill { background: var(--over); }
.bar.none .fill { background: var(--none); }
.bar .tick { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1px; background: var(--ink); border-radius: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin: 6px 0 12px; }
.legend i { display: inline-block; width: 18px; height: 8px; border-radius: 4px; background: var(--bar); vertical-align: middle; margin-right: 5px; }
.legend i.tick { width: 3px; height: 14px; background: var(--ink); border-radius: 2px; }

.attention { list-style: none; margin: 0; padding: 0; }
.attention li { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.attention li:last-child { border-bottom: 0; }
.attention .what { flex: 1; min-width: 160px; }

.detail-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.report { background: var(--soft); border-radius: 8px; padding: 12px 14px; margin-top: 12px; }
.report ul { margin: 6px 0 0; padding-left: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px; transition: all .2s; max-width: calc(100vw - 32px); z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.app-footer { padding: 16px clamp(16px, 4vw, 40px) 32px; color: var(--muted); font-size: 13px; text-align: center; }

@media (max-width: 640px) {
  body { font-size: 14px; }
  .app-header { position: static; }
  .weeknav strong { min-width: 0; width: 100%; order: -1; text-align: left; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 20px; }
  th, td { padding: 6px 8px; }
  /* Timesheet becomes one card per row: project and phase on top, seven day boxes below. */
  .ts-wrap { border: 0; overflow: visible; }
  .ts, .ts tbody, .ts tfoot { display: block; }
  .ts thead { display: none; }
  .ts tr { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px 4px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .ts td, .ts th { border: 0; padding: 0; background: none !important; }
  .ts .sticky { position: static; }
  .ts td.col-proj { grid-column: 1 / 6; min-width: 0; }
  .ts td.col-phase { grid-column: 6 / 8; }
  .ts td.col-phase select { width: 100%; min-width: 0; }
  .ts td.day::before { content: attr(data-d); display: block; font-size: 11px; color: var(--muted); text-align: center; }
  .ts input.h { width: 100%; padding: 6px 2px; text-align: center; }
  .ts td.rowtotal { grid-column: 1 / 7; text-align: left; font-size: 13px; }
  .ts td.rowtotal::before { content: "Row total "; font-weight: 500; color: var(--muted); }
  .ts td.empty { grid-column: 1 / -1; }
  .ts tfoot tr { border-bottom: 0; }
  .ts tfoot th { grid-column: 1 / -1; }
  .ts tfoot td.day { text-align: center; }
  .ts tfoot td[data-gt] { grid-column: 1 / -1; text-align: left; }
  .ts tfoot td[data-gt]::before { content: "Week total "; font-weight: 500; color: var(--muted); }
  .ts tfoot td:last-child:not([data-gt]) { display: none; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media print {
  .banner, .app-header .tabs, .app-footer, .actions, .toolbar button { display: none !important; }
  .panel { box-shadow: none; }
}
