:root {
  --bg: #f4f7f4;
  --ink: #1c2b1e;
  --muted: #5b6b5e;
  --card: #fff;
  --accent: #1f7a4d;
  --line: #d5ddd6;
  --err: #9b1c1c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: #163d28;
  color: #fff;
  gap: 0.75rem;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; }
.env-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #c45c26;
}
.deployment-pilot .top { background: #1a365d; }
.deployment-pilot .env-badge { background: #2b6cb0; }
.deployment-production .top { background: #163d28; }
.deployment-production .env-badge { background: #1f7a4d; }
.top nav { margin-left: auto; }
nav a { color: #d9efe3; margin-left: 1rem; text-decoration: none; }
nav a:hover { color: #fff; }
main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem 3rem; }
.properties-page main { max-width: 1680px; }
h1 { margin-top: 0; }
.lede, .muted { color: var(--muted); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}
.narrow { max-width: 22rem; margin: 3rem auto; }
label { display: block; margin: 0.75rem 0; }
input {
  width: 100%;
  padding: 0.45rem 0.5rem;
  margin-top: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 4px;
}
button,
a.button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  box-sizing: border-box;
}
button.ghost,
a.button.ghost {
  background: #e8ece9;
  color: var(--ink);
}
.error { color: var(--err); }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 2rem;
}
.week-stats {
  grid-template-columns: repeat(6, minmax(110px, 1fr));
}
@media (max-width: 900px) {
  .week-stats { grid-template-columns: repeat(3, minmax(110px, 1fr)); }
}
.stats div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem;
}
.stats strong { display: block; font-size: 1.25rem; }
.stats span { color: var(--muted); font-size: 0.85rem; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
table.week-table { margin-top: 0.5rem; }
table.week-table th.num, table.week-table td.num { white-space: nowrap; }
table.week-table tfoot th,
table.week-table tfoot td {
  border-top: 2px solid var(--ink);
  font-weight: 700;
}
table.week-table td.week-links,
table.week-table th:last-child { white-space: nowrap; }
table.week-table a { color: var(--accent); }
form.inline-delete { display: inline; margin: 0; }
form.inline-delete button { padding: 0.2rem 0.5rem; font-size: 0.85rem; }
table.prop-list { width: 100%; table-layout: fixed; }
table.prop-list .col-addr { width: 18%; }
table.prop-list .col-town { width: 9%; }
table.prop-list .col-pc { width: 7.5rem; }
table.prop-list .col-cust { width: 14%; }
table.prop-list .col-status { width: 5.5rem; }
table.prop-list .col-bal { width: 5.6rem; }
table.prop-list .col-notes { width: auto; }
table.prop-list .col-actions { width: 7.4rem; }
table.prop-list th.bal,
table.prop-list td.bal {
  text-align: left;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding-right: 0.4rem;
}
table.prop-list td.pc { white-space: nowrap; }
table.prop-list td.addr,
table.prop-list td.cust {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.prop-list td.notes {
  white-space: pre-line;
  overflow-wrap: anywhere;
}
table.prop-list tr.stopped td { color: #1a56c4; }
table.prop-list tr.prop-row { cursor: pointer; }
table.prop-list tr.prop-row:hover td { background: #eef6f1; }
table.prop-list tr.prop-row.stopped:hover td { background: #e8eefc; }
table.prop-list a.row-link {
  color: inherit;
  text-decoration: none;
}
table.prop-list td.row-actions,
table.prop-list th.row-actions {
  text-align: right;
  white-space: nowrap;
  padding-left: 0.25rem;
  padding-right: 0.35rem;
}
table.prop-list td.row-actions { color: var(--ink); }
a.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  margin-left: 0.15rem;
  border-radius: 4px;
  background: #e8ece9;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  vertical-align: middle;
}
a.icon-btn:hover { background: var(--accent); color: #fff; }
a.icon-btn svg { width: 1.15rem; height: 1.15rem; fill: currentColor; }
.search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.search-bar .search { margin-bottom: 0; }
.search-bar > a.button { margin-left: auto; }
.q-wrap {
  position: relative;
  width: 20rem;
  max-width: 100%;
}
.q-wrap input {
  width: 100%;
  max-width: none;
  padding-right: 1.85rem;
}
button.q-clear {
  position: absolute;
  right: 0.15rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 0.1rem 0.4rem;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: none;
}
button.q-clear:hover { background: transparent; color: var(--ink); filter: none; }
.search { display: flex; gap: 0.5rem; margin-bottom: 1rem; align-items: center; }
.search input { max-width: 20rem; }
.search label.auto-space,
.search label.show-stopped {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  white-space: nowrap;
  font-size: 0.95rem;
}
.search label.show-stopped { margin-left: 1.75rem; }
.search input[type="checkbox"] {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0;
}
pre {
  white-space: pre-wrap;
  font-size: 0.85rem;
  overflow-x: auto;
}
code { font-size: 0.9em; }
.search.wrap { flex-wrap: wrap; align-items: end; gap: 0.75rem 1rem; }
.search.wrap label { margin: 0; }
.search.wrap select,
.search.wrap input {
  display: block;
  height: 2.35rem;
  padding: 0.35rem 0.5rem;
  font-size: 1rem;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.inline { display: inline; margin-left: 0.5rem; }
.ws-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 0.35rem 0 1.35rem;
}
.btn-link { margin-left: 0.75rem; color: var(--accent); }
button.small { padding: 0.2rem 0.45rem; margin: 0 0 0.15rem; }
.ok { color: var(--accent); font-weight: 600; }
tr.spacer td { background: #ececec; font-style: italic; color: var(--muted); }
tr.off-route td { background: #fff6e8; }
table.entry input[type="text"], table.entry input:not([type]), table.entry input[inputmode] {
  width: 4.5rem; padding: 0.25rem;
}
body.sheet-page main { max-width: none; padding: 0.75rem; }
.sheet-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.sheet-actions-left { display: flex; gap: 0.6rem; align-items: center; }
table.sheet {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 10.5pt;
  line-height: 1;
}
table.sheet thead { display: table-header-group; }
table.sheet tbody tr { page-break-inside: avoid; }
.sheet-banner-inner {
  display: flex;
  align-items: baseline;
  width: 100%;
  gap: 0.5rem;
  font-size: 11pt;
}
.sheet-banner-inner .left { flex: 1; text-align: left; font-weight: 600; white-space: nowrap; }
.sheet-banner-inner .center { flex: 1; text-align: center; font-weight: 700; white-space: nowrap; }
.sheet-banner-inner .right { flex: 1; text-align: right; font-weight: 600; white-space: nowrap; }
table.sheet col.col-addr { width: 20%; }
table.sheet col.col-notes { width: 30%; }
table.sheet col.col-cut { width: 4%; }
table.sheet col.col-price { width: 5%; }
table.sheet col.col-pay { width: 8%; }
table.sheet col.col-osbal { width: 5%; }
table.sheet col.col-write { width: 7%; }
table.sheet th, table.sheet td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 26px;
  height: 32px;
  max-height: 32px;
  padding: 1px 4px;
  vertical-align: middle;
  border-bottom: 1px solid #ccc;
}
table.sheet thead th {
  border-bottom: 2px solid #333;
  font-weight: 600;
}
table.sheet thead tr.sheet-banner th {
  height: 28px;
  max-height: 28px;
  line-height: 26px;
  padding: 2px 4px;
  overflow: visible;
  border-bottom: 1px solid #333;
  background: #fff;
}
table.sheet th.write-h {
  text-align: center;
  border: 1px solid #111;
  border-bottom: 2px solid #111;
}
table.sheet td.write-in {
  padding: 1px 2px;
  overflow: visible;
  background: transparent;
  border-bottom: 1px solid #ccc;
}
table.sheet td.write-in .box {
  display: block;
  height: 28px;
  border: 1px solid #111;
  box-sizing: border-box;
  background: #fff;
}
table.sheet tr.spacer td { height: 32px; max-height: 32px; line-height: 26px; }
table.sheet tr.spacer td.write-in .box { background: #ececec; }
@media print {
  header.top, .no-print, .sheet-actions { display: none !important; }
  body.sheet-page, body.sheet-page main {
    background: #fff;
    max-width: none;
    margin: 0;
    padding: 0;
  }
  table.sheet { font-size: 10pt; width: 100%; }
  table.sheet thead { display: table-header-group; }
  table.sheet tbody tr { page-break-inside: avoid; }
  table.sheet thead tr.sheet-banner th {
    height: 8mm;
    max-height: 8mm;
    line-height: 8mm;
  }
  table.sheet thead tr:not(.sheet-banner) th {
    height: 7mm;
    max-height: 7mm;
    line-height: 7mm;
  }
  table.sheet tbody th, table.sheet tbody td {
    padding: 0.3mm 0.8mm;
    height: 7.4mm;
    max-height: 7.4mm;
    line-height: 7.4mm;
  }
  table.sheet td.write-in { padding: 0.5mm 0.7mm; }
  table.sheet td.write-in .box { height: 6.4mm; }
  @page { size: A4 landscape; margin: 6mm; }
}

body.enter-page { overflow: hidden; }
body.enter-page main {
  max-width: none;
  margin: 0;
  padding: 0;
  height: calc(100vh - 52px);
  display: flex;
  flex-direction: column;
}
.enter-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.75rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.enter-bar-left { justify-self: start; }
.enter-bar-mid { justify-self: center; text-align: center; color: var(--muted); }
.enter-bar-right { justify-self: end; }
a.button:hover { color: #fff; filter: brightness(1.08); }
dialog.modal {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  max-width: 28rem;
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.35); }
.enter-status { padding: 0.25rem 0.75rem; }
.enter-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.enter-list {
  flex: 1;
  overflow: auto;
  background: #eef3ee;
  font-size: 0.85rem;
}
body.enter-page {
  --enter-cols: minmax(10rem, 1.1fr) minmax(7.5rem, 0.85fr) 6.5rem 6.5rem 6.3rem 5.6rem 6.3rem 6rem 9.5rem;
}
.elist-row {
  display: grid;
  grid-template-columns: var(--enter-cols);
  gap: 0.45rem 0.55rem;
  padding: 0.15rem 0.75rem;
  border-bottom: 1px solid #dde5dd;
  cursor: pointer;
  white-space: nowrap;
  align-items: center;
}
.elist-row:hover { background: #e2ebe3; }
.elist-row.current { background: #cfe8d4; font-weight: 600; }
.elist-row.spacer { font-style: italic; color: var(--muted); background: #ececec; }
.elist-row.attn .c-flag { color: #9b1c1c; font-weight: 700; }
.elist-row.stopped, .elist-row.suspended { color: #9b1c1c; }
.elist-empty { padding: 0.5rem 0.75rem; color: var(--muted); }
.elist-row .c-num { text-align: right; font-variant-numeric: tabular-nums; }
.enter-focus {
  flex: 0 0 auto;
  background: #fff8e8;
  border-top: 4px solid #163d28;
  border-bottom: 4px solid #163d28;
  padding: 0.5rem 0.75rem 0.65rem;
}
.focus-grid {
  display: grid;
  grid-template-columns: var(--enter-cols);
  gap: 0.45rem 0.55rem;
  align-items: start;
}
.focus-addr { font-size: 1.15rem; font-weight: 700; }
.focus-notes-lbl { display: block; margin-top: 0.25rem; font-size: 0.8rem; color: var(--muted); }
.focus-notes-lbl input { width: 100%; }
.hist-h { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }
.focus-amt input {
  width: 100%;
  font-size: 1.1rem;
  text-align: right;
  padding: 0.35rem;
}
button.toggle, button.os-btn {
  width: 100%;
  margin-top: 0.2rem;
  font-size: 1rem;
  padding: 0.4rem 0.3rem;
}
button.os-btn { background: #2b6cb0; }
.focus-pay {
  display: flex;
  gap: 0.85rem;
  justify-content: center;
  padding-top: 0.9rem;
}
.focus-flags {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stack-ctrl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.8rem;
  margin: 0;
  cursor: pointer;
}
.stack-ctrl input { margin: 0; }
#b-stop { margin-top: 0.35rem; width: 100%; }
#b-suspend { margin-top: 0.55rem; width: 100%; }
button.danger { background: #9b1c1c; }
button.warn { background: #b45309; }
button.danger.active, button.warn.active { outline: 3px solid #111; }
button.save {
  width: 100%;
  padding: 0.7rem 0.4rem;
  font-size: 1rem;
  line-height: 1.2;
}
.focus-nav button { width: 100%; margin-top: 0.25rem; }
kbd {
  font-family: inherit;
  border: 1px solid #aaa;
  border-radius: 3px;
  padding: 0 0.25rem;
  background: #f4f4f4;
}
@media (max-width: 1100px) {
  .focus-grid { grid-template-columns: 1fr 1fr 1fr; }
}
a.button.ghost:hover { color: var(--ink); filter: none; background: #dce3de; }
.prop-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.prop-head h1 { margin-bottom: 0.2rem; }
.prop-head .lede { margin: 0; }
.prop-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1rem;
  flex-wrap: wrap;
}
.prop-tabs a {
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  background: #e8ece9;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.prop-tabs a.active,
.prop-tabs a:hover { background: var(--accent); color: #fff; }
.edit-form { max-width: 58rem; }
.edit-form .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.25rem;
}
.edit-form .full { grid-column: 1 / -1; }
.edit-form label { margin: 0; }
.edit-form input,
.edit-form select,
.edit-form textarea {
  width: 100%;
  padding: 0.45rem 0.5rem;
  margin-top: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  background: #fff;
}
.edit-form textarea { min-height: 4.5rem; resize: vertical; }
.edit-form input[type="checkbox"] {
  width: auto;
  margin: 0 0.4rem 0 0;
}
.edit-form .check-row {
  display: flex;
  align-items: center;
  margin-top: 1.7rem;
}
.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
fieldset.week-flags {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.5rem 0.75rem 0.65rem;
  margin: 0;
  display: flex;
  gap: 0.9rem;
  align-items: center;
}
fieldset.week-flags legend { padding: 0 0.3rem; color: var(--muted); }
fieldset.week-flags label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
}
.invoice-create { margin-top: 0.5rem; }
.account-list { margin-top: 0.5rem; }
@media (max-width: 800px) {
  .edit-form .form-grid { grid-template-columns: 1fr; }
  .edit-form .check-row { margin-top: 0.25rem; }
  .q-wrap { width: 100%; }
}
