:root {
  --border: #d7d7dc;
  --bg: #f7f7f9;
  --text: #1c1c1f;
  --muted: #6b6b76;
  --primary: #2a5db0;
  --danger: #b0362a;
  --ok: #1f7a3d;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.3;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.9rem;
  padding: 0.5rem 0.9rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  margin-right: 0.4rem;
  font-size: 0.95rem;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.topbar nav a {
  color: var(--primary);
  text-decoration: none;
  padding: 0.2rem 0.1rem;
  font-size: 0.88rem;
}

.topbar nav a:hover { text-decoration: underline; }

main {
  max-width: 1150px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

h1 { font-size: 1.2rem; margin: 0.1rem 0 0.6rem; }
h2 { font-size: 1rem; margin: 1rem 0 0.4rem; }
h3 { font-size: 0.9rem; margin: 0.6rem 0 0.3rem; color: var(--muted); }

a { color: var(--primary); }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.8rem;
  margin-bottom: 0.75rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}

.stat { text-align: center; padding: 0.5rem 0.4rem; }
.stat .value { font-size: 1.25rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 0.78rem; }

.flash {
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  font-size: 0.88rem;
}
.flash-ok { background: #e3f3e6; color: var(--ok); border: 1px solid #bfe3c6; }
.flash-error { background: #fbe6e3; color: var(--danger); border: 1px solid #f0c2ba; }

form.inline { display: inline; }

label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.35rem 0 0.15rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.92rem;
  background: #fff;
  color: var(--text);
}

textarea { resize: vertical; min-height: 3rem; }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.row > div { flex: 1; min-width: 140px; }

button, .btn {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  margin: 0.1rem 0.1rem 0.1rem 0;
  line-height: 1.3;
}

button.secondary, .btn.secondary {
  background: #fff;
  color: var(--primary);
}

button.danger, .btn.danger {
  background: #fff;
  color: var(--danger);
  border-color: var(--danger);
}

button.small, .btn.small { padding: 0.2rem 0.5rem; font-size: 0.78rem; }

button:hover, .btn:hover { opacity: 0.85; }

.table-wrap { overflow-x: auto; margin-bottom: 0.75rem; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  min-width: 560px;
}

table.compact { min-width: 720px; }

th, td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.83rem;
  white-space: nowrap;
}

th { color: var(--muted); font-weight: 600; padding-top: 0.15rem; padding-bottom: 0.15rem; }

.badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
}

.status-scheduled { background: #8a8a94; }
.status-present { background: #2a5db0; }
.status-absent { background: #b0362a; }
.status-cancelled { background: #55555c; }
.status-paused { background: #c98a1c; }

.status-pending { background: #c98a1c; }
.status-paid { background: #1f7a3d; }

.actions { display: flex; flex-wrap: nowrap; gap: 0.25rem; white-space: nowrap; }
.actions form.inline { flex: 0 0 auto; }

table.wide { min-width: 980px; }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; margin-bottom: 0.5rem; }
.filters > div { min-width: 140px; }

.weekday-picker { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.2rem 0 0.4rem; }
.weekday-check {
  display: flex; align-items: center; gap: 0.25rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.2rem 0.5rem; font-size: 0.8rem; color: var(--text);
  margin: 0; cursor: pointer; background: #fff;
}
.weekday-check input { width: auto; }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

.week-nav { display: flex; justify-content: space-between; gap: 0.5rem; }

/* Spreadsheet-style professional tabs: today's workers stand out, the
   selected tab reads as "in front of" the content below it. Scrolls
   horizontally (including shift+wheel) when there are more tabs than fit. */
.tabs-wrap {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
}

.tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
  flex: 1 1 auto;
  min-width: 0;
}

.tabs-scroll-btn {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-bottom: none;
  background: #f0f0f3;
  color: var(--muted);
  border-radius: 6px 6px 0 0;
  padding: 0.3rem 0.55rem;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  margin: 0;
}
.tabs-scroll-btn:hover { background: #e4e4e9; color: var(--text); }

.tab {
  display: inline-block;
  flex: 0 0 auto;
  padding: 0.3rem 0.7rem;
  background: #e9e9ee;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  font-size: 0.82rem;
  position: relative;
  top: 2px;
  white-space: nowrap;
}

.tab-today {
  font-weight: 700;
  color: var(--text);
  background: #dbe7fb;
  border-color: #aecbf2;
}

.tab-active {
  background: #fff;
  color: var(--text);
  font-weight: 700;
  top: 0;
  border-color: var(--border);
  box-shadow: 0 -1px 0 #fff inset;
}

.tab-active.tab-today { background: #fff; border-bottom: 2px solid #fff; }

.tab:hover { text-decoration: underline; }

@media (max-width: 600px) {
  main { padding: 0.5rem; }
  .topbar { padding: 0.4rem 0.6rem; }
  th, td { font-size: 0.78rem; padding: 0.28rem 0.4rem; }
  .tab { padding: 0.25rem 0.5rem; font-size: 0.78rem; }
}
