:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --ink: #111827;
  --muted: #667085;
  --line: #dfe3e8;
  --panel: #ffffff;
  --primary: #166f68;
  --primary-ink: #ffffff;
  --accent: #b45309;
  --bad: #b42318;
  --good: #067647;
  --warn: #b54708;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-header {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; color: var(--ink); }
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: white;
  border-radius: 7px;
}
.nav { display: flex; gap: 16px; flex: 1; }
.nav a { color: #344054; font-size: 14px; }
.logout-form { margin-left: auto; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 34px auto 64px; }
.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
h1 { font-size: 34px; line-height: 1.1; margin: 0; letter-spacing: 0; }
h2 { font-size: 18px; margin: 0; letter-spacing: 0; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 750;
}
.lead { color: var(--muted); font-size: 17px; max-width: 560px; }

.primary-button, .secondary-button, .ghost-button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 7px;
  min-height: 38px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.primary-button { background: var(--primary); color: var(--primary-ink); }
.secondary-button { background: white; color: var(--ink); border-color: #cfd6dd; }
.ghost-button { background: transparent; color: #344054; border-color: transparent; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.metric span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.metric strong { font-size: 28px; letter-spacing: 0; }

.content-band, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.list-row:first-child { border-top: 0; }
.list-row strong { display: block; }
.list-row span { color: var(--muted); font-size: 14px; }
.empty { color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #475467; font-size: 12px; text-transform: uppercase; }
tfoot th { font-size: 14px; color: var(--ink); }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f6;
  color: #475467;
}
.badge.good { color: var(--good); background: #ecfdf3; }
.badge.warn { color: var(--warn); background: #fffaeb; }
.badge.bad { color: var(--bad); background: #fef3f2; }
.badge.muted { color: #475467; background: #f2f4f7; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
label, .form-grid p, .compact-form p {
  display: grid;
  gap: 6px;
  margin: 0;
  font-weight: 650;
}
input, select, textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cfd6dd;
  border-radius: 7px;
  padding: 8px 10px;
  font: inherit;
  background: white;
}
small, .helptext { color: var(--muted); font-weight: 400; }
.wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.compact-form { margin: 0; display: grid; gap: 12px; }
.invoice-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.invoice-meta span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.help-step {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 10px;
  align-content: start;
}
.help-step span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e6f4f1;
  color: var(--primary);
  font-weight: 800;
}
.help-step p { margin: 0; color: #475467; line-height: 1.5; }
.check-list { margin: 0; padding-left: 20px; color: #344054; line-height: 1.65; }

.messages { display: grid; gap: 8px; margin-bottom: 18px; }
.message {
  border-radius: 8px;
  padding: 10px 12px;
  background: #eef2f6;
  border: 1px solid var(--line);
}
.message.success { background: #ecfdf3; border-color: #abefc6; }
.message.error { background: #fef3f2; border-color: #fecdca; }

.login-layout {
  min-height: calc(100vh - 180px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: center;
  gap: 54px;
}
.login-panel { display: grid; gap: 14px; }

@media (max-width: 850px) {
  .app-header { flex-wrap: wrap; height: auto; padding: 14px 16px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .shell { width: min(100% - 24px, 1180px); margin-top: 24px; }
  .page-title, .login-layout, .two-col { grid-template-columns: 1fr; display: grid; }
  .metric-grid, .form-grid, .invoice-meta, .help-grid { grid-template-columns: 1fr; }
  h1 { font-size: 28px; }
}
