:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-ink: #ffffff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.nav { display: flex; align-items: center; gap: 0.75rem; }
.nav .user { color: var(--muted); font-size: 0.9rem; }
.inline { display: inline; margin: 0; }
.container { max-width: 1000px; margin: 0 auto; padding: 1.5rem; }
h1 { font-size: 1.6rem; }
.project-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.project-head h1 { margin: 0; }
h2 { font-size: 1.2rem; margin-top: 2rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: #b91c1c; background: #fee2e2; padding: 0.5rem 0.75rem; border-radius: 6px; }
code { background: #eef0f3; padding: 0.1rem 0.35rem; border-radius: 4px; }

.btn {
  display: inline-block; padding: 0.4rem 0.8rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  text-decoration: none; cursor: pointer; font-size: 0.9rem;
}
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.82rem; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); width: 100%; }
.btn-ghost { background: transparent; }
.btn-danger { color: #b91c1c; border-color: #fca5a5; background: transparent; }
.btn-danger:hover { background: #fee2e2; }
.btn:hover { filter: brightness(0.97); }

.badge {
  display: inline-block; background: var(--accent); color: #fff;
  padding: 0.1rem 0.5rem; border-radius: 5px; font-size: 0.8rem; font-weight: 700;
}

.manager-section { margin-top: 1.5rem; }
.manager-head {
  margin: 0 0 0.75rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--line);
  font-size: 1.05rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.proj-name { margin: -0.4rem 0 0.15rem; font-size: 1.02rem; font-weight: 600; color: var(--ink); }
.proj-folder { margin: 0 0 0.6rem; }

#proj-search {
  width: 280px; margin: 0.25rem 0 0.5rem; padding: 0.45rem 0.7rem;
  border: 1px solid var(--line); border-radius: 6px; font-size: 0.9rem;
  background: var(--card); color: var(--ink);
}
#proj-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem; text-decoration: none; color: inherit;
}
.project-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.kpis { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-bottom: 0.5rem; }
.kpi { display: flex; flex-direction: column; }
.kpi-val { font-size: 1.3rem; font-weight: 700; }
.kpi-lbl { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

table.data { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 8px; overflow: hidden; }
table.data th, table.data td { padding: 0.5rem 0.7rem; text-align: left; border-bottom: 1px solid var(--line); }
table.data th { background: #fafbfc; font-size: 0.82rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
table.data th[data-sort] { cursor: pointer; user-select: none; }
table.data th[data-sort]:hover { color: var(--accent); }

/* Archived reports: kept forever, dimmed out of the way */
tr.row-archived td { opacity: 0.55; }
.badge-archived {
  display: inline-block; background: var(--line); color: var(--muted);
  padding: 0 0.4rem; border-radius: 4px; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.04em; vertical-align: middle;
}
.row-actions { white-space: nowrap; }
.row-actions .inline { margin-left: 0.35rem; }
table.data tr:last-child td { border-bottom: none; }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.chart-box { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 2rem; width: 320px; box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  display: flex; flex-direction: column; gap: 0.75rem;
}
.login-card h1 { margin: 0; font-size: 1.4rem; }
.login-card label { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); gap: 0.25rem; }
.login-card input {
  padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 6px; font-size: 1rem;
}

/* Markdown reports */
.markdown { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem 2rem; }
.markdown table { border-collapse: collapse; }
.markdown table th, .markdown table td { border: 1px solid var(--line); padding: 0.35rem 0.6rem; }
.markdown pre { background: #0f172a; color: #e2e8f0; padding: 1rem; border-radius: 8px; overflow-x: auto; }
