:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --surface: #ffffff;
  --ink: #18201b;
  --muted: #69736c;
  --line: #dce2d8;
  --accent: #0d7c66;
  --accent-dark: #075f4d;
  --warn: #ad4e16;
  --status-draft-bg: #eef1ee;
  --status-draft-fg: #5b655f;
  --status-awaiting-bg: #e7f0fb;
  --status-awaiting-fg: #1d5c9c;
  --status-overdue-bg: #fbe8e6;
  --status-overdue-fg: #b3311d;
  --status-paid-bg: #e7f5ef;
  --status-paid-fg: #075f4d;
  --radius-sm: 6px;
  --radius-md: 8px;
  --shadow-sm: 0 4px 14px rgba(24, 32, 27, 0.06);
  --shadow: 0 18px 50px rgba(24, 32, 27, 0.09);
}

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.invoice-wide, .invoice-lines { grid-column: 1 / -1; min-width: 0; }
.invoice-lines { display: grid; gap: 8px; }
.invoice-lines-head,
.invoice-line { display: grid; grid-template-columns: minmax(160px, 3fr) minmax(64px, 0.6fr) minmax(100px, 0.9fr) minmax(130px, 0.9fr) minmax(90px, 0.8fr) 36px; gap: 12px; align-items: center; }
.invoice-lines-head { padding-bottom: 6px; color: var(--muted); font-size: 0.78rem; font-weight: 750; text-transform: uppercase; }
.invoice-line { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.invoice-line input, .invoice-line select { width: 100%; min-width: 0; }
.invoice-line-amount { display: flex; align-items: center; min-height: 42px; font-weight: 750; }
.invoice-line .icon-button { justify-self: center; }
#businessSettingsForm label { min-width: 0; }
.invoice-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.invoice-actions a { text-decoration: none; display: inline-block; color: var(--ink); }
.invoice-total { font-weight: 600; line-height: 1.7; }
textarea { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 10px; width: 100%; resize: vertical; background: white; color: var(--ink); }
[hidden] { display: none !important; }
.bank-settings { border-top: 1px solid var(--line); padding: 14px 0; }
.bank-settings summary { cursor: pointer; font-weight: 600; }
.bank-settings-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding-top: 16px; }
#invoiceMessage:empty, #businessSettingsMessage:empty { display: none; }
#currencyReviewNotice:empty { display: none; }
#currencyReviewNotice { padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--warn); }
button:disabled { opacity: 0.6; cursor: wait; }
@media (max-width: 1100px) {
  .invoice-lines-head { display: none; }
  .invoice-line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoice-line > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 600px) { .invoice-line { grid-template-columns: minmax(0, 1fr); } }

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.login-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #17211c;
}

.login-card {
  width: min(360px, 90vw);
  padding: 36px 32px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card h1 {
  margin: 0 0 12px;
}

.login-copy {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-card .primary-button {
  width: 100%;
}

.login-status {
  margin: 14px 0 0;
  min-height: 1.1em;
  color: var(--warn);
  font-size: 0.85rem;
}

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 28px 20px;
  background: #17211c;
  color: #f6faf5;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

.eyebrow {
  margin: 0 0 6px;
  color: #779187;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #a9c9bd;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 34px;
  font-size: 1.55rem;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
}

h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  font-size: 1rem;
}

h3 .icon {
  width: 16px;
  height: 16px;
  color: var(--accent-dark);
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.text-button,
.primary-button,
.secondary-button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 12px;
  background: transparent;
  color: #dce8e1;
  text-align: left;
}

.nav-item .icon {
  color: #a9c9bd;
}

.nav-item.active .icon,
.nav-item:hover .icon {
  color: #ffffff;
}

.nav-item.active,
.nav-item:hover {
  background: #24352d;
  color: #ffffff;
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  color: #a9c9bd;
  font-size: 0.85rem;
}

.text-button {
  padding: 0;
  background: transparent;
  color: #b8e5d7;
  text-align: left;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.period-controls {
  display: flex;
  align-items: end;
  gap: 12px;
}

.auth-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-controls span {
  max-width: 220px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

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

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  accent-color: var(--accent);
}

.primary-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 15px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

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

.secondary-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 9px 13px;
  background: #eef3ee;
  color: var(--ink);
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.metric-grid,
.report-grid,
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.panel,
.client-card,
.connection-card,
.report-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric span,
.report-grid span {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
}

.metric span .icon,
.report-grid span .icon {
  width: 15px;
  height: 15px;
  color: var(--accent-dark);
}

.report-grid .net span .icon {
  color: inherit;
}

.metric strong,
.report-grid strong {
  font-size: 1.5rem;
}

.metric small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.reconcile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.reconcile-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.reconcile-review {
  position: sticky;
  top: 28px;
}

.reconcile-table tr.selected-row td {
  background: #eef6f1;
}

.reconcile-table td:nth-child(2) {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-amount {
  font-size: 1.05rem;
}

.debit {
  color: var(--status-overdue-fg);
}

.credit {
  color: var(--accent-dark);
}

.review-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 0;
  padding: 18px;
}

.review-details dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: uppercase;
}

.review-details dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
}

.review-actions {
  border-top: 1px solid var(--line);
  padding: 18px;
}

.empty-review {
  display: flex;
  min-height: 250px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
}

.form-message {
  min-height: 1.2em;
  margin: 0;
  color: var(--warn);
  font-size: 0.84rem;
}

.readiness-list {
  display: grid;
}

.readiness-list > div {
  display: grid;
  grid-template-columns: 28px minmax(130px, 0.35fr) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 13px 18px;
}

.readiness-list > div:last-child {
  border-bottom: 0;
}

.readiness-list > div > span:last-child {
  color: var(--muted);
}

.readiness-icon {
  display: inline-flex;
}

.readiness-icon.complete {
  color: var(--accent);
}

.readiness-icon.blocked {
  color: var(--status-overdue-fg);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.panel-header > div {
  display: grid;
  gap: 5px;
}

.panel-subtitle,
.muted {
  color: var(--muted);
  font-size: 0.84rem;
}

.list-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  background: #fbfcfa;
}

.search-control {
  width: min(360px, 100%);
}

.search-control input {
  width: 100%;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: #ffffff;
}

.segmented-control button {
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 750;
}

.segmented-control button.active {
  background: #24352d;
  color: #ffffff;
}

.text-link {
  width: fit-content;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
}

.record-layout {
  display: grid;
  gap: 18px;
}

.record-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 20px 22px;
}

.record-heading {
  display: grid;
  gap: 7px;
}

.record-heading h3 {
  font-size: 1.3rem;
}

.record-heading p {
  margin: 0;
  color: var(--muted);
}

.record-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.record-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.record-summary > div {
  display: grid;
  gap: 6px;
  min-width: 0;
  border-right: 1px solid var(--line);
  padding: 18px 22px;
}

.record-summary > div:last-child {
  border-right: 0;
}

.record-summary span,
.record-details dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.record-summary strong {
  font-size: 1.18rem;
}

.record-details {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin: 0;
  padding: 18px 22px;
}

.record-details div {
  min-width: 0;
}

.record-details dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
}

.record-notes {
  margin: 0;
  padding: 18px 22px;
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-wrap;
}

.recurring-template-panel .panel-header {
  background: #fbfcfa;
}

.recurring-template-document {
  padding: 32px;
  background: #ffffff;
}

.recurring-template-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  border-bottom: 3px solid var(--accent);
  padding-bottom: 24px;
}

.recurring-template-heading > div:first-child,
.recurring-template-total {
  display: grid;
  gap: 5px;
}

.recurring-template-heading span,
.recurring-template-heading small,
.template-label,
.recurring-template-parties dt,
.recurring-template-summary dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.recurring-template-logo {
  width: 96px;
  height: 56px;
  object-fit: contain;
  object-position: left center;
}

.recurring-template-total {
  justify-items: end;
  text-align: right;
}

.recurring-template-total strong {
  font-size: 1.75rem;
}

.recurring-template-parties {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(180px, 0.7fr);
  gap: 30px;
  padding: 26px 0;
}

.recurring-template-parties > div,
.recurring-template-parties dl {
  min-width: 0;
}

.recurring-template-parties strong {
  display: block;
  margin-top: 6px;
}

.recurring-template-parties p,
.recurring-template-notes p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.recurring-template-parties dl,
.recurring-template-summary {
  display: grid;
  gap: 10px;
  margin: 0;
}

.recurring-template-parties dl > div,
.recurring-template-summary > div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.recurring-template-parties dd,
.recurring-template-summary dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.recurring-template-lines table {
  min-width: 680px;
}

.recurring-template-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.45fr);
  gap: 32px;
  padding-top: 24px;
}

.recurring-template-summary .template-grand-total {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--ink);
  font-weight: 850;
}

.empty-row {
  padding: 30px 18px;
  color: var(--muted);
  text-align: center;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-state .icon {
  width: 26px;
  height: 26px;
  color: #9bad9f;
}

.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  vertical-align: -2px;
  border: 2px solid #9bad9f;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.bas-controls {
  display: flex;
  align-items: end;
  gap: 12px;
}

.quick-add {
  position: relative;
}

.quick-add-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: grid;
  gap: 2px;
  min-width: 170px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.quick-add-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  text-align: left;
}

.quick-add-menu button:hover {
  background: #eef3ee;
}

.quick-add-menu .icon {
  color: var(--accent-dark);
}

.aging-chart {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.aging-bar {
  display: flex;
  height: 34px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #eef1ee;
}

.aging-bar-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.aging-bar-segment.tone-awaiting { background: var(--status-awaiting-fg); }
.aging-bar-segment.tone-overdue-1 { background: #d97a3a; }
.aging-bar-segment.tone-overdue-2 { background: #c24a2f; }
.aging-bar-segment.tone-overdue-3 { background: var(--status-overdue-fg); }

.aging-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.aging-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.aging-legend .status-dot {
  width: 9px;
  height: 9px;
  margin-right: 0;
}

.aging-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  color: var(--muted);
}

.row-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-align: left;
}

.task-check {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.task-title {
  display: grid;
  gap: 4px;
  white-space: normal;
}

.task-title.completed strong {
  color: var(--muted);
  text-decoration: line-through;
}

.priority-high {
  color: var(--warn);
  font-weight: 800;
}

.entry-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
  padding: 18px;
}

.entry-form .primary-button {
  align-self: end;
}

.checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.checkbox-label input {
  width: auto;
}

.entry-form .checkbox-label {
  align-self: end;
}

.recurrence-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.recurrence-fields[hidden] {
  display: none;
}

.recurrence-fields legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.statement-actions {
  display: grid;
  gap: 10px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

#bills table,
#invoices table {
  min-width: 860px;
}

.totals-row td {
  font-weight: 700;
  border-top: 2px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
}

#recurring-invoices table {
  table-layout: fixed;
}

#recurring-invoices th:nth-child(1) { width: 14%; }
#recurring-invoices th:nth-child(2) { width: 20%; }
#recurring-invoices th:nth-child(3) { width: 11%; }
#recurring-invoices th:nth-child(4) { width: 13%; }
#recurring-invoices th:nth-child(5) { width: 14%; }
#recurring-invoices th:nth-child(6) { width: 13%; }
#recurring-invoices th:nth-child(7) { width: 9%; }
#recurring-invoices th:nth-child(8) { width: 120px; }

#recurring-invoices th,
#recurring-invoices td {
  padding-right: 12px;
  padding-left: 12px;
}

#recurring-invoices td:nth-child(1),
#recurring-invoices td:nth-child(2),
#recurring-invoices td:nth-child(8) {
  overflow-wrap: anywhere;
  white-space: normal;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 18px;
}

.pagination span {
  color: var(--muted);
  font-size: 0.88rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 18px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.table-select {
  width: min(260px, 34vw);
  min-height: 34px;
  padding: 6px 8px;
  font-size: 0.86rem;
}

.number {
  text-align: right;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 10px;
  background: #e7f5ef;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.status.due {
  background: #fff2df;
  color: var(--warn);
}

.status.tone-draft {
  background: var(--status-draft-bg);
  color: var(--status-draft-fg);
}

.status.tone-awaiting {
  background: var(--status-awaiting-bg);
  color: var(--status-awaiting-fg);
}

.status.tone-overdue {
  background: var(--status-overdue-bg);
  color: var(--status-overdue-fg);
}

.status.tone-paid {
  background: var(--status-paid-bg);
  color: var(--status-paid-fg);
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-dot.tone-draft { background: var(--status-draft-fg); }
.status-dot.tone-awaiting { background: var(--status-awaiting-fg); }
.status-dot.tone-overdue { background: var(--status-overdue-fg); }
.status-dot.tone-overdue-1 { background: #d97a3a; }
.status-dot.tone-overdue-2 { background: #c24a2f; }
.status-dot.tone-paid { background: var(--status-paid-fg); }

.summary-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 15px 18px;
}

.summary-list dt {
  color: var(--muted);
  font-weight: 700;
}

.summary-list dd {
  margin: 0;
  font-weight: 850;
}

.client-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.client-card strong {
  font-size: 1rem;
}

.client-card span {
  color: var(--muted);
}

.report-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 18px;
}

.report-grid article {
  display: grid;
  gap: 8px;
  padding: 16px;
  box-shadow: none;
}

.report-grid .net {
  background: #17211c;
  color: #ffffff;
}

.report-grid .net span {
  color: #b8e5d7;
}

.value-negative {
  color: #ff9d84;
}

.import-grid,
.sync-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
}

.import-box {
  min-height: 150px;
  border: 1px dashed #9bad9f;
  border-radius: 8px;
  padding: 18px;
  background: #fbfcfa;
  color: var(--ink);
}

.import-box span {
  color: var(--muted);
  font-weight: 500;
}

.sync-source {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfa;
}

.sync-source strong {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-source strong .icon {
  color: var(--accent-dark);
}

.sync-source span {
  color: var(--muted);
  line-height: 1.45;
}

.sync-source .secondary-button {
  justify-self: start;
}

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

.connection-card {
  overflow: hidden;
}

.connection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.connection-card > p {
  margin: 0;
  padding: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.connection-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 0 18px 18px;
}

.connection-actions .text-button {
  color: var(--muted);
}

.settings-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.settings-form .primary-button {
  justify-self: start;
}

.settings-summary {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.settings-summary article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: #fbfcfa;
}

.settings-summary strong {
  display: block;
}

.settings-summary span {
  color: var(--muted);
}

.note {
  margin: 0;
  padding: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.icon-button {
  min-width: 34px;
  min-height: 34px;
  border-radius: 8px;
  background: #eef3ee;
  color: var(--ink);
  font-weight: 900;
}

.icon-button .icon {
  width: 16px;
  height: 16px;
}

.icon-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }

  .reconcile-layout {
    grid-template-columns: 1fr;
  }

  .reconcile-review {
    position: static;
  }

  .topbar,
  .period-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .report-grid,
  .card-grid,
  .two-column,
  .connection-grid,
  .import-grid,
  .sync-grid {
    grid-template-columns: 1fr;
  }

  .entry-form {
    grid-template-columns: 1fr;
  }

  #recurring-invoices table {
    min-width: 920px;
    table-layout: auto;
  }

  .recurrence-fields {
    grid-template-columns: 1fr;
  }

  .list-toolbar,
  .record-header {
    align-items: stretch;
    flex-direction: column;
  }

  .record-actions {
    justify-content: flex-start;
  }

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

  .record-summary > div:nth-child(2) {
    border-right: 0;
  }

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

  .recurring-template-parties dl {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .nav-item span {
    display: none;
  }

  .nav-item {
    padding: 10px;
  }

  th,
  td {
    padding: 11px 12px;
  }

  .segmented-control,
  .segmented-control button {
    width: 100%;
  }

  .record-summary,
  .record-details {
    grid-template-columns: 1fr;
  }

  .record-summary > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .record-summary > div:last-child {
    border-bottom: 0;
  }

  .recurring-template-document {
    padding: 20px 16px;
  }

  .recurring-template-heading,
  .recurring-template-footer {
    grid-template-columns: 1fr;
  }

  .recurring-template-heading {
    flex-direction: column;
  }

  .recurring-template-total {
    justify-items: start;
    text-align: left;
  }

  .recurring-template-parties {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .recurring-template-parties dl {
    grid-column: auto;
  }
}

.attachment-button {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  gap: 7px;
  justify-content: center;
  width: max-content;
}

.document-list {
  display: grid;
  gap: 8px;
}

.document-list article {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto 36px;
  min-height: 44px;
}

.document-list article > span {
  color: var(--muted);
  font-size: 12px;
}

.rule-fields {
  border: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 2fr) minmax(120px, 1fr) 90px;
  margin: 4px 0;
  padding: 12px;
}

.rule-fields legend {
  color: var(--muted);
  font-size: 12px;
  padding: 0 6px;
}

.sync-range {
  justify-content: flex-start;
  margin-bottom: 16px;
}

@media (max-width: 560px) {
  .document-list article,
  .rule-fields {
    grid-template-columns: 1fr;
  }
}
