:root {
  --bg: #f3f1ec;
  --surface: #fffcf7;
  --ink: #1c2420;
  --muted: #5c6a63;
  --line: #d7ddd8;
  --accent: #0f6b4c;
  --accent-2: #c45c26;
  --ok: #1f7a4c;
  --warn: #b86e00;
  --danger: #b42318;
  --paid: #4a5560;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 36, 32, 0.06);
  --font: "Segoe UI", "PT Root UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 10% -10%, #e7efe9 0%, transparent 55%),
    radial-gradient(900px 360px at 100% 0%, #f3e6d8 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 960px; margin: 0 auto; padding: 1rem; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: .85rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.02em;
  color: var(--ink);
  text-decoration: none;
}

.nav { display: flex; flex-wrap: wrap; gap: .65rem 1rem; align-items: center; }
.nav a { color: var(--muted); font-size: .95rem; }
.nav a:hover, .nav a.active { color: var(--ink); }

.meta { color: var(--muted); font-size: .85rem; }

.auth-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card { width: min(420px, 100%); }
.auth-card h1 { margin: 0 0 .35rem; font-size: 1.5rem; }
.auth-card p.lead { margin: 0 0 1.25rem; color: var(--muted); }

label { display: block; font-size: .85rem; color: var(--muted); margin: .75rem 0 .3rem; }
input, select, textarea, button {
  font: inherit;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: .65rem .75rem;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  width: auto;
  padding: .65rem 1rem;
  text-decoration: none;
}
button.secondary, .btn.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.danger { background: var(--danger); }
button:hover, .btn:hover { filter: brightness(1.05); text-decoration: none; }

.row { display: grid; gap: .75rem; }
@media (min-width: 720px) {
  .row.cols-2 { grid-template-columns: 1fr 1fr; }
  .row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.flash {
  padding: .75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
}
.flash.ok { background: #e8f5ee; color: var(--ok); }
.flash.error { background: #fdecea; color: var(--danger); }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th, .table td {
  text-align: left;
  padding: .75rem .85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: #f7f5f0;
}
.table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  padding: .2rem .5rem;
  border-radius: 999px;
  border: 1px solid transparent;
}
.badge.overdue {
  background: #f5c2c0;
  color: #7a1210;
  border-color: #e8a09c;
}
.badge.urgent { background: #fff1db; color: var(--warn); }
.badge.ok { background: #e8f5ee; color: var(--ok); }
.badge.paid { background: #d8f0e2; color: var(--ok); }
.badge.amount_unknown, .badge.unknown { background: #f3eef8; color: #6b4f8a; }

.row-paid,
.card-item.row-paid {
  background: #e8f5ee;
}
.table tr.row-paid td {
  background: #e8f5ee;
}

.row-overdue,
.card-item.row-overdue {
  background: #fde8e6;
}
.table tr.row-overdue td {
  background: #fde8e6;
  color: #5c1010;
}
.table tr.row-overdue .muted {
  color: #8a4540;
}

.dash-groups {
  display: grid;
  gap: 1.75rem;
}
.dash-group-title {
  margin: 0 0 .65rem;
  font-size: 1.05rem;
  font-weight: 700;
}
.list-mobile.dash-groups .dash-group {
  display: grid;
  gap: .75rem;
}
.list-mobile.dash-groups .dash-group-title {
  margin-bottom: 0;
}

.list-mobile { display: grid; gap: .75rem; }
.card-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  box-shadow: var(--shadow);
}
.card-item .title { font-weight: 700; margin-bottom: .25rem; }
.card-item .sub { color: var(--muted); font-size: .9rem; }
.card-item .amount { font-size: 1.15rem; font-weight: 700; margin-top: .4rem; }

@media (max-width: 719px) {
  .table-desktop { display: none; }
}
@media (min-width: 720px) {
  .list-mobile { display: none; }
}

.overdue-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem .75rem;
  margin: 0 0 1.25rem;
  padding: .85rem 1rem;
  background: #f5c2c0;
  border: 1px solid #e08b86;
  border-radius: var(--radius);
  color: #7a1210;
  font-size: 1.05rem;
}
.overdue-summary-sum {
  font-weight: 600;
  opacity: .9;
}

.lk-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  text-decoration: none;
}
.lk-favicon {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  vertical-align: middle;
}

.stack-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.muted { color: var(--muted); }
.h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.section { margin-bottom: 1.5rem; }
.inline-form { display: inline; }
.inline-form button { padding: .35rem .65rem; font-size: .85rem; }

.btn-sm { padding: .35rem .65rem; font-size: .85rem; }
.collapsible-form > summary,
.row-actions > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--accent);
  user-select: none;
}
.collapsible-form > summary::-webkit-details-marker,
.row-actions > summary::-webkit-details-marker { display: none; }
.collapsible-form > summary::before {
  content: "▸ ";
  color: var(--muted);
}
.collapsible-form[open] > summary::before { content: "▾ "; }
.row-actions {
  position: relative;
  display: inline-block;
}
.row-actions > summary.btn {
  color: var(--ink);
  font-weight: 600;
}
.row-actions[open] > .edit-panel,
.row-actions[open] > .danger-zone {
  display: block;
  margin-top: .65rem;
  min-width: min(420px, 70vw);
}
.row-actions .danger-zone {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px dashed var(--line);
}
.edit-panel { margin-top: .65rem; }
