:root {
  --bg: #0f172a;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--surface-2);
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); }

/* ---- Login ---- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  padding: 1rem;
}
.login-card {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.login-card h1 { margin: 0; font-size: 1.6rem; }
.login-card label { display: flex; flex-direction: column; font-size: 0.85rem; gap: 0.25rem; }
.login-card input {
  padding: 0.6rem; border: 1px solid var(--border); border-radius: 8px; font-size: 1rem;
}

/* ---- Shell ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.15rem; }
.tabs { display: flex; gap: 0.25rem; flex: 1; flex-wrap: wrap; }
.tab {
  border: none;
  background: transparent;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--muted);
}
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--primary); color: #fff; }

main { padding: 1.25rem; max-width: 1100px; margin: 0 auto; }
.footer { text-align: center; padding: 1.5rem; font-size: 0.8rem; }

/* ---- Buttons ---- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.small { padding: 0.3rem 0.55rem; font-size: 0.8rem; }

/* ---- Cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.card .value { font-size: 1.8rem; font-weight: 700; }
.card .label { color: var(--muted); font-size: 0.85rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.panel h2 { margin-top: 0; font-size: 1.1rem; }

.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.toolbar { margin-bottom: 1rem; }

input[type="date"], input[type="text"], input[type="number"], select, textarea {
  padding: 0.45rem 0.55rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.9rem; font-family: inherit;
}
label.field { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; color: var(--muted); }

/* ---- Distribution bars ---- */
.dist-row { display: grid; grid-template-columns: 160px 1fr 90px; gap: 0.5rem; align-items: center; margin: 0.4rem 0; }
.bar { background: var(--surface-2); border-radius: 6px; overflow: hidden; height: 20px; }
.bar > span { display: block; height: 100%; background: var(--primary); }

/* ---- Tables / lists ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.88rem; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
tr:hover td { background: var(--surface-2); }

.badge {
  display: inline-block; background: var(--warn); color: #fff;
  border-radius: 999px; padding: 0.05rem 0.5rem; font-size: 0.72rem; font-weight: 700;
}
.pill {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px;
  font-size: 0.75rem; background: var(--surface-2); color: var(--muted);
}
.pill.proj { background: #dbeafe; color: var(--primary-dark); }
.pill.review { background: #fef3c7; color: var(--warn); }
.pill.type { background: #e2e8f0; }

.note { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 0.6rem 0.8rem; border-radius: 8px; font-size: 0.85rem; }

.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 0.6rem 1rem; border-radius: 8px;
  box-shadow: var(--shadow); z-index: 50; font-size: 0.9rem;
}

.empty { color: var(--muted); padding: 1.5rem; text-align: center; }

@media (max-width: 640px) {
  .dist-row { grid-template-columns: 1fr; }
  .topbar { gap: 0.5rem; }
}
