:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d7dde8;
  --accent: #0f4c81;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.wrap {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
}

.site-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 16px 0;
}

.brand { margin: 0; font-size: 1.4rem; }
.tag { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.nav-links { display: flex; gap: 14px; flex-wrap: wrap; }
.nav-links a { color: var(--accent); text-decoration: none; font-weight: 600; }
.page-content { padding: 20px 0 40px; }
.page-head h2 { margin-bottom: 6px; }
.page-head p { color: var(--muted); margin-top: 0; }

.card, .login-card, .invoice-sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.card { padding: 18px; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}
.metric-row.total { border-bottom: 0; padding-top: 14px; }
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.narrow-card { max-width: 720px; }
.stack-form { display: grid; gap: 12px; }
.stack-form label { display: grid; gap: 6px; font-weight: 600; }
input, select, textarea, button {
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
button, .button-link {
  background: var(--accent);
  color: #fff;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.button-row { display: flex; gap: 12px; margin-top: 20px; }
.button-link { padding: 10px 14px; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.login-card {
  width: min(420px, calc(100% - 24px));
  padding: 24px;
}
.alert {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}
.small-note { color: var(--muted); font-size: 0.9rem; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}
.inline-form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}
.filter-card { margin-bottom: 16px; }

table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tfoot td {
  font-weight: 600;
}

.invoice-sheet { padding: 24px; }
.invoice-header, .invoice-billto {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.invoice-meta { text-align: right; }
.summary-card pre {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
}
.summary-metrics {
  margin-top: 14px;
}

.entries-layout {
  align-items: start;
}
.entry-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.entry-actions form,
.wrap-actions form {
  margin: 0;
}
.link-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
}
.danger-link {
  color: #b42318;
}
.muted-link {
  background: #eef2f7;
  color: var(--text);
}

.status-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: capitalize;
}
.status-draft { background: #eef2ff; color: #3730a3; }
.status-finalized { background: #ecfeff; color: #155e75; }
.status-sent { background: #eff6ff; color: #1d4ed8; }
.status-paid { background: #ecfdf3; color: #166534; }

.wrap-actions {
  flex-wrap: wrap;
  align-items: center;
}
.danger-button {
  background: #b42318;
}
.meta-card {
  margin-top: 20px;
}
.meta-list {
  display: grid;
  gap: 10px;
}

.checkbox-row { display:flex; align-items:center; gap:0.5rem; font-weight:500; }
.checkbox-row input { width:auto; }

@media (max-width: 768px) {
  .nav-row, .invoice-header, .invoice-billto, .two-col {
    grid-template-columns: 1fr;
    display: grid;
  }
  .invoice-meta { text-align: left; }
  .inline-form { display: grid; }
}


.invoice-header-centered {
  align-items: start;
}
.invoice-branding {
  flex: 1;
  text-align: center;
}
.invoice-branding h2 {
  margin: 0;
  font-size: 2rem;
}
.invoice-brand-top {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
}
.invoice-logo {
  max-height: 128px;
  width: auto;
}
.invoice-address-line {
  margin: 2px 0;
}
.business-address-line {
  margin: 1px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-partial { background: #fff7ed; color: #9a3412; }
.three-col { display:grid; grid-template-columns: repeat(3, 1fr); gap:12px; }
.payment-form { margin-bottom: 18px; }
@media (max-width: 768px) { .three-col { grid-template-columns: 1fr; } }
