:root {
  --bg: #f4f6f9;
  --sidebar: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --navy: #143a5c;
  --teal: #1a9b8e;
  --ok: #059669;
  --font: "DM Sans", system-ui, sans-serif;
  --sidebar-w: 248px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Auth pages */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: linear-gradient(160deg, #0f2740, #163a5c 50%, #1a4d6d);
}
.auth-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 16px;
  padding: 1.75rem; box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.auth-card h1 { font-size: 1.35rem; margin: 0.4rem 0 0.35rem; color: var(--navy); }
.auth-card .sub { color: var(--muted); font-size: 0.92rem; margin-bottom: 1.25rem; }
.brand-mini { font-weight: 700; color: var(--teal); font-size: 0.85rem; letter-spacing: .04em; text-transform: uppercase; }
label { display: block; font-size: 0.82rem; font-weight: 600; margin: 0.75rem 0 0.35rem; color: var(--navy); }
input, select, textarea {
  width: 100%; padding: 0.7rem 0.8rem; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.25); border-color: var(--blue); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: 0.75rem 1.1rem; border-radius: 10px; border: none; font-weight: 650;
  font: inherit; cursor: pointer; text-decoration: none !important;
}
.btn-primary { background: var(--blue); color: #fff; width: 100%; margin-top: 1rem; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-sm { padding: 0.5rem 0.85rem; font-size: 0.88rem; width: auto; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.auth-foot { margin-top: 1rem; font-size: 0.9rem; color: var(--muted); text-align: center; }
.banner {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  padding: 0.65rem 0.8rem; border-radius: 10px; font-size: 0.82rem; margin-bottom: 1rem;
}
.error { color: #b91c1c; font-size: 0.85rem; margin-top: 0.5rem; }

/* App shell */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 1rem 0.75rem; position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { font-weight: 700; color: var(--navy); padding: 0.4rem 0.65rem 0.9rem; font-size: 1rem; }
.sidebar .hi { font-size: 0.82rem; color: var(--muted); padding: 0 0.65rem 1rem; line-height: 1.35; }
.nav-item {
  display: flex; align-items: center; gap: 0.55rem; width: 100%;
  padding: 0.65rem 0.75rem; border-radius: 10px; border: none; background: transparent;
  color: var(--ink); font: inherit; font-weight: 500; font-size: 0.92rem; cursor: pointer; text-align: left;
}
.nav-item:hover { background: #f3f4f6; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }
.nav-group-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); padding: 0.85rem 0.75rem 0.35rem;
}
.sidebar-bottom { margin-top: auto; padding: 0.75rem 0.5rem 0.25rem; border-top: 1px solid var(--line); }
.main { flex: 1; padding: 1.5rem 1.75rem 2.5rem; max-width: 1100px; }
.crumb { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.35rem; }
.main h1 { font-size: 1.55rem; color: var(--ink); margin-bottom: 0.35rem; }
.main .desc { color: var(--muted); margin-bottom: 1.35rem; max-width: 48em; }
.cards { display: grid; gap: 1rem; margin-bottom: 1.25rem; }
@media (min-width: 720px) { .cards.two { grid-template-columns: 1fr 1fr; } }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.15rem;
}
.card h3 { font-size: 0.95rem; margin-bottom: 0.35rem; }
.card .big { font-size: 1.4rem; font-weight: 700; color: var(--navy); }
.muted { color: var(--muted); font-size: 0.9rem; }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.85rem 1rem; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .03em; background: #fafafa; }
tr:last-child td { border-bottom: none; }
.status-paid { color: var(--ok); font-weight: 650; }
.status-open { color: #b45309; font-weight: 650; }
.status-active { color: var(--blue); font-weight: 650; }
.status-done { color: var(--ok); font-weight: 650; }
.form-grid { display: grid; gap: 0.85rem; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
.view { display: none; }
.view.active { display: block; }
.hidden { display: none !important; }
@media (max-width: 800px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; border-right: none; border-bottom: 1px solid var(--line); }
}
