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

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --info: #2563eb;
  --sidebar-w: 220px;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 1.25rem 1.5rem;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 0.75rem;
}

.nav-links li a {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.nav-links li a:hover { background: var(--bg); color: var(--text); }
.nav-links li.active a { background: #eff6ff; color: var(--primary); font-weight: 500; }

/* ── Main ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem;
  min-height: 100vh;
}

.page-container { max-width: 1000px; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 20px; font-weight: 600; }

/* ── Metric cards ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.metric-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.metric-value { font-size: 22px; font-weight: 600; }
.metric-value.success { color: var(--success); }
.metric-value.danger  { color: var(--danger); }
.metric-value.info    { color: var(--info); }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-header { margin-bottom: 1rem; }
.card-title { font-size: 14px; font-weight: 600; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg); }

.info-table { width: 100%; border-collapse: collapse; }
.info-table td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.info-table tr:last-child td { border-bottom: none; }
.info-table td:first-child { width: 120px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.badge-success { background: var(--success-bg); color: #14532d; }
.badge-danger  { background: var(--danger-bg);  color: #7f1d1d; }
.badge-warning { background: var(--warning-bg); color: #78350f; }

/* ── Buttons ── */
.btn {
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 9px; font-size: 12px; }

/* ── Form & Modal ── */
.input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}
.input:focus { outline: 2px solid var(--primary); border-color: transparent; }

.modal {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 440px;
  max-width: 95vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.modal::backdrop { background: rgba(0,0,0,0.4); }

.modal-form h2 { font-size: 16px; font-weight: 600; margin-bottom: 1.25rem; }
.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 500;
}
.modal-form label .input { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 1rem; }

/* ── Helpers ── */
.muted    { color: var(--muted); }
.link     { color: var(--primary); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }
.back-link { font-size: 13px; color: var(--muted); text-decoration: none; display: block; margin-bottom: 4px; }
.back-link:hover { color: var(--text); }
.empty-msg { text-align: center; color: var(--muted); padding: 2rem 0; font-size: 13px; }

/* ── Chart ── */
.chart-wrap { position: relative; height: 240px; }

/* ── Debtor list ── */
.debtor-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.debtor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
}
.debtor-row strong { display: block; font-size: 13px; }
.debtor-row .muted { font-size: 12px; }

/* ── Ay form ── */
.ay-form { display: flex; gap: 8px; align-items: center; }
.ay-form .input { width: auto; }

/* ── Blok grid ── */
.blok-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

.blok-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.blok-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.blok-ad {
  font-size: 16px;
  font-weight: 600;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}
