:root {
  --bg: #f4f7f6;
  --card: #ffffff;
  --ink: #102033;
  --text: #344456;
  --muted: #687789;
  --line: #dfe8e6;
  --primary: #0f766e;
  --primary-2: #14a39a;
  --danger: #dc2626;
  --warn: #b7791f;
  --ok: #15803d;
  --shadow: 0 16px 42px rgba(12, 31, 42, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(15,118,110,.035) 1px, transparent 1px),
    linear-gradient(rgba(15,118,110,.035) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
  font-family: Inter, Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  min-height: 74px;
  padding: 0 28px;
  background: rgba(255,255,255,.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; gap: 12px; align-items: center; font-weight: 900; color: var(--ink); }
.brand span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.topbar nav { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar nav a,
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 0 15px;
  border: 0;
  border-radius: 999px;
  color: white;
  background: var(--primary);
  font-weight: 850;
  cursor: pointer;
}
.btn.ghost, .topbar nav a { color: #334155; background: #eef8f7; border: 1px solid #cfe3e0; }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.btn.danger { background: var(--danger); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.text-danger { border: 0; background: transparent; color: var(--danger); font-weight: 800; cursor: pointer; }

.container { width: min(1200px, calc(100% - 40px)); margin: 26px auto 60px; }
.page-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.eyebrow { margin: 0 0 8px; color: var(--primary); font-weight: 900; text-transform: uppercase; font-size: 12px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; color: var(--ink); font-size: clamp(30px, 4vw, 46px); line-height: 1.06; }
h2 { color: var(--ink); font-size: 22px; margin-bottom: 16px; }
.muted { color: var(--muted); line-height: 1.55; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions form { margin: 0; }
.row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.row-actions form { margin: 0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  min-height: 124px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.stat span { display: block; color: var(--muted); font-weight: 750; margin-bottom: 12px; }
.stat strong { color: var(--ink); font-size: 27px; line-height: 1.08; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.form-grid, .mini-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.mini-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: var(--ink); font-weight: 800; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(15,118,110,.1); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1180px; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; }
.badge { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 900; background: #e2e8f0; color: #334155; }
.badge.paid { background: #dcfce7; color: #166534; }
.badge.planned { background: #fef3c7; color: #92400e; }
.badge.payable { background: #fef3c7; color: #92400e; }
.badge.debt { background: #fee2e2; color: #991b1b; }

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.chip {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 7px 10px 7px 14px;
  border: 1px solid #cfe3e0;
  border-radius: 999px;
  background: #f7fbfb;
  color: var(--ink);
  font-weight: 800;
}
.chip button {
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  background: #fee2e2;
  color: var(--danger);
  font-weight: 900;
  cursor: pointer;
}

.project-list { display: grid; gap: 10px; }
.project-row, .due-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fcfc;
}
.project-row:hover, .due-row:hover { border-color: rgba(15,118,110,.45); }
.project-row strong, .due-row strong { display: block; color: var(--ink); }
.project-row small, .due-row small { display: block; color: var(--muted); margin-top: 4px; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-wrap { width: min(460px, 100%); }
.login-card {
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 34px; }
.login-card form { display: grid; gap: 14px; }
.captcha-line {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.captcha-line b {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  border-radius: 12px;
  background: #eef2f7;
  color: var(--ink);
  letter-spacing: 1px;
}
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 800; }
.alert.danger { background: #fee2e2; color: #991b1b; }

@media (max-width: 980px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 16px 20px; }
  .topbar nav { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar nav a { width: 100%; }
  .container { width: min(100% - 28px, 1200px); margin-top: 18px; }
  .page-head, .grid-2 { grid-template-columns: 1fr; flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .mini-form { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar nav { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .stat strong { font-size: 24px; }
  .project-row, .due-row { align-items: flex-start; flex-direction: column; }
  .btn, .actions, .actions form { width: 100%; }
  .row-actions { width: 100%; }
  .row-actions .btn, .row-actions form { width: auto; }
  .captcha-line { grid-template-columns: 1fr; }
}
