:root {
  --navy: #0B1A3F;
  --navy-2: #112453;
  --accent: #1A82FF;
  --accent-strong: #0F6FE6;
  --accent-hi: #64ADFF;
  --ink: #0B1222;
  --body: #3B4458;
  --muted: #667085;
  --bg: #F4F6FA;
  --card: #FFFFFF;
  --line: #E4E8F0;
  --danger: #B42318;
  --radius: 16px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --header-h: 60px;
  --action-h: 0px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--body);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3 { color: var(--ink); margin: 0; letter-spacing: -0.02em; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: var(--navy);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.app-header-inner {
  max-width: 1180px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.brand img { height: 28px; width: auto; }
.header-title {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,.78);
  margin-left: auto;
}
.header-pill {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-hi);
  border: 1px solid rgba(26,130,255,.38);
  background: rgba(26,130,255,.14);
  padding: 3px 8px;
  border-radius: 999px;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}
.notice {
  background: #EEF5FF;
  border: 1px solid #D3E4FF;
  color: var(--navy-2);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 18px;
}
.layout {
  display: grid;
  gap: 20px;
}
@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(320px, 420px) 1fr; align-items: start; }
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.panel h2 {
  font-size: 18px;
  font-weight: 750;
  margin-bottom: 4px;
}
.panel .lede {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 6px;
}
.hint { font-weight: 500; color: var(--muted); }
.field { margin-bottom: 14px; }
input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,130,255,.18);
}
textarea { min-height: 84px; resize: vertical; }
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hours-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 560px) {
  .hours-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 980px) {
  .hours-grid { grid-template-columns: repeat(4, 1fr); }
}
.hour-cell {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 8px 10px;
  background: #F9FAFC;
}
.hour-cell.is-friday { border-color: #C9DBFF; background: #F3F8FF; }
.hour-day {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}
.hour-date {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  min-height: 14px;
}
.hour-cell input {
  padding: 8px 8px;
  font-variant-numeric: tabular-nums;
}

.totals-bar {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 12px 14px;
  background: var(--navy);
  color: #fff;
  border-radius: 12px;
  font-size: 14px;
}
.totals-bar strong { font-variant-numeric: tabular-nums; }
.totals-bar span { color: rgba(255,255,255,.7); }
.totals-bar b { color: #fff; font-weight: 700; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
}
.btn-primary { background: var(--accent-strong); color: #fff; }
.btn-primary:hover { background: #0C63CE; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-2); }
.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--bg); }
.btn.is-disabled, a.btn.is-disabled {
  opacity: .45;
  pointer-events: none;
}
.status {
  min-height: 20px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--navy-2);
}

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  margin-bottom: 8px;
}
.history-head h2 { font-size: 16px; }
.linkish {
  background: none;
  border: 0;
  color: var(--accent-strong);
  font-weight: 600;
  font-size: 13px;
  padding: 0;
}
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.history-item {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.history-item:hover { border-color: #C9DBFF; }
.history-title { color: var(--ink); font-weight: 650; font-size: 14px; }
.history-meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.history-empty { color: var(--muted); font-size: 13px; margin: 0; }

.preview-pane { min-width: 0; }
.invoice-shell {
  background: #E8ECF3;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  overflow: auto;
}
.invoice {
  background: #fff;
  color: var(--ink);
  width: 100%;
  min-width: 640px;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 44px 36px;
  box-shadow: 0 18px 40px -24px rgba(11,18,34,.35);
}
.invoice-top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  border-bottom: 3px solid var(--navy);
  padding-bottom: 18px;
  margin-bottom: 22px;
}
.invoice-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 4px;
}
.invoice h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}
.meta { text-align: right; font-size: 13px; color: var(--body); }
.meta div { margin: 0 0 2px; }
.meta b { color: var(--ink); font-weight: 700; }

.parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 22px;
  font-size: 13.5px;
  line-height: 1.45;
}
.party-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.party-name { font-weight: 700; color: var(--ink); font-size: 15px; }
.party p { margin: 0; white-space: pre-line; }

table.lines {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-bottom: 8px;
}
table.lines th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding: 0 8px 8px 0;
}
table.lines th.num, table.lines td.num { text-align: right; padding-right: 0; white-space: nowrap; }
table.lines .col-num { width: 1%; padding-left: 12px; }
table.lines td {
  padding: 10px 8px 10px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.desc { font-weight: 650; }
.hours-mini {
  width: 100%;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--body);
}
.hours-mini td { border: 0; padding: 2px 8px 2px 0; }
.hours-mini td.num { font-variant-numeric: tabular-nums; }

.summary {
  margin-top: 8px;
  margin-left: auto;
  width: 260px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0;
  font-size: 13.5px;
}
.summary-row.total {
  border-top: 2px solid var(--navy);
  margin-top: 4px;
  padding-top: 10px;
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
}

.notes {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.notes h3 { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.notes p { margin: 0; white-space: pre-wrap; }

.invoice-foot {
  margin-top: 28px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 979px) {
  :root { --action-h: 76px; }
  body { padding-bottom: var(--action-h); }
  .mobile-actions {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    display: flex;
    gap: 8px;
  }
  .mobile-actions .btn { flex: 1; }
  .desktop-only { display: none !important; }
  .invoice-shell { overflow: visible; padding: 0; background: transparent; border: 0; }
  .invoice {
    min-width: 0;
    padding: 22px 16px 20px;
    box-shadow: 0 10px 28px -20px rgba(11,18,34,.35);
    border: 1px solid var(--line);
    border-radius: 12px;
  }
  .invoice-top {
    flex-direction: column;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 16px;
  }
  .meta { text-align: left; }
  .invoice h1 { font-size: 26px; }
  .parties { grid-template-columns: 1fr; gap: 16px; }
  table.lines { font-size: 12.5px; }
  table.lines td { padding: 8px 6px 8px 0; }
  table.lines .col-num { display: none; }
  .summary { width: 100%; }
  .preview-pane { scroll-margin-top: calc(var(--header-h) + 12px); padding-top: 8px; }
  #invoicePreview { scroll-margin-top: calc(var(--header-h) + 12px); }
}
@media (max-width: 640px) {
  .header-title { display: none; }
  .brand img { height: 24px; }
  .app-header-inner { padding: 0 14px; }
  .wrap { padding: 14px 14px 32px; }
}
@media (min-width: 980px) {
  .mobile-actions { display: none; }
  #newWeekRowMobile { display: none; }
}

@media print {
  :root { --action-h: 0px; }
  body { background: #fff; padding: 0; color: #000; }
  .app-header, .notice, .form-pane, .mobile-actions, .no-print { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .layout { display: block; }
  .preview-pane, .invoice-shell {
    background: transparent;
    border: 0;
    padding: 0;
    border-radius: 0;
    overflow: visible;
  }
  .invoice {
    min-width: 0;
    max-width: none;
    padding: 0;
    box-shadow: none;
  }
  a { color: inherit; text-decoration: none; }
  @page { margin: 0.6in; size: letter; }
}
