:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #555555;
  --border: #d0d0d0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --info: #0369a1;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Layout */

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.main {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

/* Nav */

.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.25rem;
}

.nav__brand {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
}

.nav__brand:hover {
  text-decoration: none;
}

.nav__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.nav__user {
  color: var(--text-muted);
}

/* Flash messages */

.flash {
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.flash--error {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}

.flash--success {
  background: #f0fdf4;
  color: var(--success);
  border-color: #bbf7d0;
}

.flash--info {
  background: #f0f9ff;
  color: var(--info);
  border-color: #bae6fd;
}

/* Auth card */

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  max-width: 420px;
  margin: 3rem auto;
}

.auth-card__title {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

/* Form fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.field--inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.field input[type="email"],
.field input[type="password"],
.field input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}

.field input[type="email"]:focus,
.field input[type="password"]:focus,
.field input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.field__error {
  font-size: 0.8rem;
  color: var(--danger);
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--full {
  width: 100%;
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  padding: 0.6rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  background: #f9f9f9;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td {
  border-bottom: none;
}

tr:nth-child(even) td {
  background: #fafafa;
}

/* Headings */

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Nav links */

.nav__links {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
}

.nav__links a {
  color: var(--text);
  font-weight: 500;
}

.nav__links a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Page header */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  margin-bottom: 0;
}

/* Section header (within a page) */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

.section-header h2 {
  margin-bottom: 0;
}

/* Info grid */

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.info-grid__full {
  grid-column: 1 / -1;
}

.label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}

/* Buttons extra */

.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  background: #f0f0f0;
}

.btn--sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  cursor: pointer;
  color: var(--accent);
  text-decoration: none;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-link--danger {
  color: var(--danger);
}

/* Form card & extras */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 520px;
  margin-bottom: 1.5rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.form-inline {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-inline .field {
  margin-bottom: 0;
}

.field__hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

legend {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0 0.4rem;
  color: var(--text-muted);
}

/* Table extras */

.td-actions {
  white-space: nowrap;
  text-align: right;
  font-size: 0.85rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: flex-end;
}

.num {
  text-align: right;
}

.row--pending td {
  background: #fffbeb !important;
}

.row--plan td {
  background: #f0f9ff !important;
  font-style: italic;
}

tfoot tr.subtotal td {
  font-weight: 600;
  background: #f3f4f6;
  border-top: 2px solid var(--border);
}

table.grand-total {
  margin-top: 0.5rem;
  box-shadow: none;
  border: 1px solid var(--border);
}

table.grand-total tfoot td {
  background: #e8f0fe;
  font-size: 1rem;
}

/* Badges */

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge--ok {
  background: #dcfce7;
  color: #15803d;
}

.badge--pending {
  background: #fef9c3;
  color: #854d0e;
}

/* Empty state */

.empty {
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem 0;
}

/* Hint box */

.hint-box {
  margin-top: 1.5rem;
  max-width: 400px;
}

.hint-box h3 {
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

/* Sub text */

.sub {
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Report styles */

.report-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.report-header {
  margin-bottom: 1rem;
}

.report-header h2 {
  margin-bottom: 0.25rem;
}

.report-header p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.group-heading {
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Report menu cards */

.report-menu {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.report-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.report-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  text-decoration: none;
}

.report-card h2 {
  font-size: 1rem;
  margin-bottom: 0.3rem;
  color: var(--accent);
}

.report-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* Calendar */
.calendar {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 2rem;
}

.calendar__head,
.calendar__week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calendar__head {
  background: var(--accent);
}

.calendar__dow {
  padding: 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.03em;
}

.calendar__cell {
  min-height: 90px;
  padding: 0.4rem 0.5rem;
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: top;
  background: var(--surface);
}

.calendar__cell:nth-child(7n) {
  border-right: none;
}

.calendar__cell--empty {
  background: var(--bg);
  min-height: 90px;
}

.calendar__cell--today {
  background: #eff6ff;
}

.calendar__cell--today .calendar__day-num {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar__day-num {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar__visit {
  display: block;
  font-size: 0.75rem;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  margin-bottom: 0.2rem;
  background: #dbeafe;
  color: #1d4ed8;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.calendar__visit:hover {
  background: #bfdbfe;
}

.calendar__visit--confirmed {
  background: #dcfce7;
  color: #166534;
}

.calendar__visit--confirmed:hover {
  background: #bbf7d0;
}

/* Filter bar */
.filter-bar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.filter-bar__input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
}
.filter-bar__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* Invite link */
.form-card.form-card--wide { max-width: 100%; }
.invite-link { display: flex; gap: .5rem; margin: .5rem 0 0; }
.invite-link__input {
  flex: 1;
  font-family: monospace;
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

/* Print */

@media print {
  .no-print { display: none !important; }
  .nav { display: none !important; }
  body { background: white; }
  table { box-shadow: none; }
  .group-heading { color: #000; }
}
