:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1c2434;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #3b5bdb;
  --brand-dark: #2f49b0;
  --green: #2f9e44;
  --green-bg: #e6f4ea;
  --red: #e03131;
  --red-bg: #fcebea;
  --amber: #f08c00;
  --amber-bg: #fff4e0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { 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;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Auth screen ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card .sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.auth-logo { height: 36px; width: auto; display: block; margin: 0 auto 16px; }

/* ---------- Brand / logo ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand .logo { height: 20px; width: auto; display: block; }

/* ---------- Google sign-in ---------- */
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn-google {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: var(--ink); border: 1px solid var(--line);
}
.btn-google:hover { background: #f8f9fb; }
.btn-google svg { flex-shrink: 0; }
.btn-ghost.linked { color: var(--green); cursor: default; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 16px;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.15);
}
textarea { resize: vertical; min-height: 64px; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  font-family: inherit;
}
.btn-primary { background: var(--brand); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-approve { background: var(--green-bg); color: var(--green); }
.btn-reject { background: var(--red-bg); color: var(--red); }
.btn-ghost { background: transparent; color: var(--muted); }

.toggle-link { text-align: center; margin-top: 8px; font-size: 14px; }
.msg { font-size: 13px; margin: 0 0 16px; min-height: 18px; }
.msg.error { color: var(--red); }
.msg.ok { color: var(--green); }

.role-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.role-toggle label {
  flex: 1; text-align: center; padding: 10px; border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; margin: 0; font-weight: 500;
}
.role-toggle input { display: none; }
.role-toggle input:checked + span { color: var(--brand); font-weight: 700; }
.role-toggle label:has(input:checked) { border-color: var(--brand); background: rgba(59,91,219,0.06); }

/* ---------- App shell ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { font-weight: 700; font-size: 16px; }
.topbar .who { color: var(--muted); font-size: 13px; margin-right: 12px; }
.container { max-width: 960px; margin: 0 auto; padding: 24px; }
.grid { display: grid; gap: 20px; }
@media (min-width: 720px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card h2 { margin: 0 0 16px; font-size: 16px; }

.hub-card {
  display: block; color: inherit; transition: box-shadow .15s, transform .15s;
}
.hub-card:hover {
  text-decoration: none; box-shadow: 0 4px 14px rgba(16,24,40,0.12), 0 1px 2px rgba(16,24,40,0.06);
  transform: translateY(-1px);
}
.hub-card h2 { font-size: 18px; }

/* ---------- Balances ---------- */
.balances { display: flex; gap: 12px; flex-wrap: wrap; }
.balance {
  flex: 1; min-width: 90px; text-align: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 14px;
}
.balance .num { font-size: 26px; font-weight: 700; }
.balance .lbl { font-size: 12px; color: var(--muted); text-transform: capitalize; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
td.actions { white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; padding: 16px 0; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav span { font-weight: 600; min-width: 130px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding-bottom: 4px; }
.cal-cell {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  font-size: 13px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
}
.cal-cell.empty { border: none; background: transparent; }
.cal-cell.weekend { background: #f8f9fb; color: var(--muted); }
.cal-cell.approved { background: var(--green-bg); color: var(--green); font-weight: 700; border-color: transparent; }
.cal-cell.pending { background: var(--amber-bg); color: var(--amber); font-weight: 700; border-color: transparent; }
.cal-cell.today { outline: 2px solid var(--brand); outline-offset: -2px; }
.cal-legend { display: flex; gap: 16px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.cal-legend .dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.cal-legend .dot.approved { background: var(--green); }
.cal-legend .dot.pending { background: var(--amber); }

/* ---------- Status pills ---------- */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.pending { background: var(--amber-bg); color: var(--amber); }
.pill.approved { background: var(--green-bg); color: var(--green); }
.pill.rejected { background: var(--red-bg); color: var(--red); }

/* ---------- Weekly reports ---------- */
.navlink { font-size: 13px; font-weight: 600; margin-right: 14px; }
.navlink.active { color: var(--ink); cursor: default; padding-bottom: 2px; border-bottom: 2px solid var(--brand); }

.rating { display: flex; gap: 8px; margin-bottom: 16px; }
.rating button {
  flex: 1; background: #fff; border: 1px solid var(--line);
  padding: 10px 0; font-weight: 700; color: var(--muted);
}
.rating button.sel { background: var(--brand); border-color: var(--brand); color: #fff; }

.report-item {
  border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 10px; background: #fff;
}
.report-item summary {
  cursor: pointer; padding: 12px 14px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  list-style: none;
}
.report-item summary::-webkit-details-marker { display: none; }
.report-row {
  padding: 12px 14px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--red-bg); border-color: transparent;
}
.report-text {
  white-space: pre-wrap; font-size: 14px; padding: 12px 14px;
  border-top: 1px solid var(--line); color: var(--ink);
}
.pill.submitted { background: var(--green-bg); color: var(--green); }
.pill.missing { background: var(--red-bg); color: var(--red); }
.pill.prod { background: rgba(59, 91, 219, 0.1); color: var(--brand); }
