:root {
  --canvas: #EEF0F3;
  --surface: #FFFFFF;
  --surface-2: #F5F7FA;
  --ink: #1B2638;
  --muted: #67758C;
  --line: #D8DEE7;
  --navy: #1B2638;
  --steel: #33598C;
  --steel-soft: #E5EDF7;
  --gold: #B07D2B;
  --gold-soft: #F6ECD6;
  --success: #2E7D52;
  --alert: #C0392B;
  --radius: 5px;
  --font-display: 'Hanken Grotesk', system-ui, sans-serif;
  --font-body: 'Hanken Grotesk', system-ui, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--navy);
  color: #D7DEEA;
  padding: 24px 0;
  flex-shrink: 0;
}

.brand {
  padding: 0 20px 24px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #FFFFFF;
  border-bottom: 1px solid rgba(215, 222, 234, 0.15);
  margin-bottom: 8px;
}

.brand::before {
  content: '■';
  color: var(--gold);
  margin-right: 8px;
}

.nav-link {
  display: block;
  padding: 10px 20px;
  color: #D7DEEA;
  text-decoration: none;
  transition: all 0.15s ease;
  position: relative;
  font-weight: 500;
}

.nav-link:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: #FFFFFF;
  background: rgba(229, 237, 247, 0.08);
  border-left: 3px solid var(--gold);
  padding-left: 17px;
}

.main {
  flex: 1;
  padding: 24px 28px;
  overflow-x: auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(27, 38, 56, 0.06);
  margin-bottom: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.ledger {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.ledger thead {
  background: var(--surface-2);
}

.ledger th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.ledger td {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

.ledger tbody tr {
  transition: background 0.1s ease;
}

.ledger tbody tr:hover {
  background: var(--surface-2);
}

.ledger-row td {
  height: 52px;
}

.amount {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 600;
}

.overdue {
  display: inline-block;
  padding: 4px 10px;
  background: var(--alert);
  color: white;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-tag.available {
  background: rgba(46, 125, 82, 0.1);
  color: var(--success);
}

.status-tag.leased {
  background: rgba(51, 89, 140, 0.1);
  color: var(--steel);
}

.status-tag.maintenance {
  background: rgba(176, 125, 43, 0.1);
  color: var(--gold);
}

.status-tag.ended {
  background: rgba(103, 117, 140, 0.1);
  color: var(--muted);
}

.priority-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

.priority-tag.low {
  background: rgba(103, 117, 140, 0.1);
  color: var(--muted);
}

.priority-tag.medium {
  background: rgba(51, 89, 140, 0.1);
  color: var(--steel);
}

.priority-tag.high {
  background: rgba(176, 125, 43, 0.1);
  color: var(--gold);
}

.priority-tag.urgent {
  background: rgba(192, 57, 43, 0.1);
  color: var(--alert);
}

.pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

.pill-open {
  background: rgba(51, 89, 140, 0.1);
  color: var(--steel);
}

.pill-scheduled {
  background: rgba(176, 125, 43, 0.1);
  color: var(--gold);
}

.pill-in_progress {
  background: rgba(51, 89, 140, 0.15);
  color: var(--steel);
}

.pill-closed {
  background: rgba(103, 117, 140, 0.1);
  color: var(--muted);
}

.pill-due {
  background: rgba(176, 125, 43, 0.1);
  color: var(--gold);
}

.pill-paid {
  background: rgba(46, 125, 82, 0.1);
  color: var(--success);
}

.pill-overdue {
  background: rgba(192, 57, 43, 0.1);
  color: var(--alert);
}

form {
  max-width: 600px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--steel);
  box-shadow: 0 0 0 3px rgba(51, 89, 140, 0.1);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.form-group {
  margin-bottom: 18px;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  background: var(--steel);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.1s ease;
  font-family: var(--font-body);
}

.btn:hover {
  background: #2a4a73;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-2 {
  display: inline-block;
  padding: 10px 18px;
  background: white;
  color: var(--steel);
  border: 1px solid var(--steel);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  font-family: var(--font-body);
}

.btn-2:hover {
  background: var(--steel-soft);
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

a {
  color: var(--steel);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

table {
  font-variant-numeric: tabular-nums;
}

*:focus-visible {
  outline: 2px solid var(--steel);
  outline-offset: 2px;
}

/* polish v2 */
.page-head{ display:flex; align-items:flex-end; justify-content:space-between; gap:1rem;
  margin-bottom:1.5rem; padding-bottom:1rem; border-bottom:1px solid var(--line); flex-wrap:wrap; }
.page-head h1{ margin:0; }
.eyebrow{ font-size:.72rem; font-weight:700; letter-spacing:.14em; text-transform:uppercase; color:var(--gold); margin-bottom:.35rem; }

.stats{ display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:14px; margin-bottom:20px; }
.stat{ background:var(--surface); border:1px solid var(--line); border-left:3px solid var(--steel);
  border-radius:var(--radius); padding:16px 18px; box-shadow:0 1px 2px rgba(27,38,56,.06);
  transition:transform .12s ease, box-shadow .12s ease; }
.stat:hover{ transform:translateY(-2px); box-shadow:0 6px 18px rgba(27,38,56,.10); }
.stat.is-gold{ border-left-color:var(--gold); }
.stat.is-alert{ border-left-color:var(--alert); }
.stat.is-success{ border-left-color:var(--success); }
.stat-label{ font-size:.72rem; font-weight:600; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); margin-bottom:8px; }
.stat-value{ font-size:1.9rem; font-weight:700; line-height:1; color:var(--navy); font-variant-numeric:tabular-nums; }
.stat.is-alert .stat-value{ color:var(--alert); }
.stat-sub{ font-size:.78rem; color:var(--muted); margin-top:8px; }

.barstat{ display:flex; flex-direction:column; gap:22px; }
.bar-head{ display:flex; justify-content:space-between; align-items:baseline; margin-bottom:8px; }
.bar-title{ font-weight:600; font-size:.95rem; color:var(--ink); }
.bar-figure{ font-variant-numeric:tabular-nums; font-weight:700; font-size:1.15rem; color:var(--navy); }
.bar-figure small{ font-weight:600; color:var(--muted); font-size:.78rem; }
.bar-track{ display:flex; height:14px; border-radius:7px; overflow:hidden; background:var(--surface-2); border:1px solid var(--line); }
.bar-seg{ height:100%; }
.bar-legend{ display:flex; gap:16px; margin-top:10px; flex-wrap:wrap; }
.bar-key{ display:flex; align-items:center; gap:6px; font-size:.8rem; color:var(--muted); }
.bar-key .dot{ width:9px; height:9px; border-radius:2px; display:inline-block; }

.row-actions{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.row-actions form{ display:inline; margin:0; }

.pill-active{ background: rgba(46,125,82,0.1); color: var(--success); }
.pill-ended{ background: rgba(103,117,140,0.1); color: var(--muted); }
.status-tag.house, .status-tag.unit, .status-tag.townhouse, .status-tag.commercial,
.status-tag.apartment, .status-tag.condo{ background: rgba(51,89,140,0.08); color: var(--steel); }

@media (max-width: 820px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 16px 0;
  }

  .main {
    padding: 20px 16px;
  }

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

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}