:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #66706d;
  --line: #d7ddda;
  --paper: #f8f7f2;
  --panel: #ffffff;
  --accent: #8c0628;
  --accent-dark: #5f031a;
  --warn: #9a5a22;
  --shadow: 0 12px 28px rgba(24, 34, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.install-button {
  background: #596b9f;
}

.install-button:hover {
  background: #40527f;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0 18px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

h2 {
  font-size: 18px;
}

.top-actions,
.month-picker,
.task-form {
  display: flex;
  align-items: end;
  gap: 10px;
}

.month-picker,
.task-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.month-picker span,
.task-form label {
  display: grid;
  gap: 6px;
}

input,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 104px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  font-size: 34px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(420px, 1.6fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  padding: 16px;
}

.panel + .panel {
  margin-top: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.status-list,
.payroll-lines {
  display: grid;
  gap: 8px;
}

.payroll-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.payroll-edit-grid label {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.payroll-edit-grid input {
  width: 100%;
}

.payroll-edit-grid small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
}

.service-rate {
  min-height: 94px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfbf8;
}

.service-rate span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.service-rate strong {
  font-size: 24px;
  line-height: 1;
}

.service-rate small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-item,
.payroll-line {
  display: grid;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.status-item {
  grid-template-columns: auto 1fr auto;
}

.payroll-line {
  grid-template-columns: 1fr 1fr 1fr;
}

.payroll-line span,
.payroll-line strong {
  text-align: left;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
}

.muted {
  color: var(--muted);
}

.error {
  color: #9b2e22;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 9px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr:last-child td {
  border-bottom: 0;
}

.color-cell {
  width: 62px;
}

.swatch {
  display: inline-block;
  width: 34px;
  height: 20px;
  border-radius: 4px;
  vertical-align: middle;
}

.task-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) 150px 100px 110px minmax(180px, 1fr) minmax(180px, 1fr) auto;
  margin-bottom: 12px;
}

.task-form .wide {
  min-width: 0;
}

.delete-button {
  min-height: 32px;
  padding: 0 10px;
  background: #8d332c;
}

.delete-button:hover {
  background: #702720;
}

.receipt-field small {
  color: var(--warn);
  font-size: 12px;
  font-weight: 800;
}

.receipt-pill {
  display: inline-block;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 20px, 560px);
    padding: 14px 0 28px;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 32px;
  }

  .metric {
    min-height: 86px;
    padding: 14px;
  }

  .metric strong {
    font-size: 28px;
  }

  .summary-grid,
  .workspace,
  .task-form,
  .service-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel {
    padding: 12px;
  }

  .panel-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .status-item,
  .payroll-line {
    grid-template-columns: auto 1fr;
  }

  .status-item strong,
  .payroll-line strong {
    grid-column: 2;
  }

  .payroll-edit-grid {
    grid-template-columns: 1fr;
  }

  .task-form {
    align-items: stretch;
  }

  button,
  input,
  select {
    width: 100%;
  }
}

@media (max-width: 700px) {
  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    margin-bottom: 10px;
    padding: 8px 10px;
  }

  td {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    border-bottom: 1px solid #eef1ef;
    padding: 8px 0;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .color-cell {
    width: 100%;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .topbar,
  .summary-grid,
  .compact,
  .no-print,
  .panel:not(.payroll-panel),
  .payroll-edit-grid {
    display: none;
  }

  .panel {
    border: 0;
    box-shadow: none;
    break-inside: avoid;
  }

  .workspace {
    display: block;
    margin: 0;
  }

  .payroll-panel {
    padding: 0;
  }

  .payroll-line {
    grid-template-columns: 1.3fr 1fr 1fr;
  }
}
