:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #d9dce1;
  --primary: #2f5fd6;
  --primary-text: #ffffff;
  --error: #b3261e;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --surface: #1e2128;
    --text: #e7e9ee;
    --muted: #9aa1ab;
    --border: #30343d;
    --primary: #6d8fff;
    --primary-text: #0c1020;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar .brand { font-weight: 600; }
.topbar nav { display: flex; align-items: center; flex-wrap: wrap; }
.topbar nav a, .topbar .user-menu a {
  color: var(--text);
  text-decoration: none;
  margin-left: 1rem;
  font-size: 0.9rem;
}
.topbar .user-menu { display: flex; align-items: center; gap: 0.25rem; color: var(--muted); font-size: 0.85rem; }

.nav-dropdown { position: relative; margin-left: 1rem; }
.nav-dropdown summary {
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary::after { content: " \25BE"; font-size: 0.7em; color: var(--muted); }
.nav-dropdown[open] summary::after { content: " \25B4"; }
.nav-dropdown .dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  display: flex;
  flex-direction: column;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  padding: 0.25rem 0;
  z-index: 30;
}
.nav-dropdown .dropdown-menu a {
  margin-left: 0;
  padding: 0.5rem 0.9rem;
  white-space: nowrap;
}
.nav-dropdown .dropdown-menu a:hover { background: var(--bg); }

.content { padding: 2rem; max-width: 960px; margin: 0 auto; }
/* Wide reports (Daily/Monthly - dozens of day/summary columns) need the
   full browser width instead of being squeezed into the standard
   960px-wide centered column that suits ordinary forms/lists. */
.content.wide { max-width: none; }

.auth-card {
  max-width: 360px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.auth-card h1 { font-size: 1.25rem; margin: 0 0 0.25rem; }
.auth-card .subtitle { color: var(--muted); margin: 0 0 1.5rem; font-size: 0.9rem; }
.auth-card form { display: flex; flex-direction: column; gap: 0.5rem; }
.auth-card label { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.auth-card input {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}
.auth-card button {
  margin-top: 1rem;
  padding: 0.6rem;
  border: none;
  border-radius: 4px;
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 600;
  cursor: pointer;
}
.error { color: var(--error); font-size: 0.85rem; }
.muted { color: var(--muted); }

h1 { font-size: 1.4rem; margin-bottom: 1rem; }
h2 { font-size: 1.1rem; margin-top: 2rem; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.data-table th, .data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.9rem;
}
.data-table th { background: var(--bg); font-weight: 600; }
.data-table tr:last-child td { border-bottom: none; }
.data-table a { color: var(--primary); }

.inline-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.inline-form input { padding: 0.3rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); }
.inline-form button, .row-actions button {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.stacked-form { display: flex; flex-direction: column; gap: 0.4rem; max-width: 480px; }
.stacked-form label { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.stacked-form input, .stacked-form select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}
.stacked-form fieldset { border: 1px solid var(--border); border-radius: 6px; margin-top: 1rem; }
.stacked-form legend { padding: 0 0.4rem; color: var(--muted); font-size: 0.85rem; }
.stacked-form button {
  margin-top: 1rem;
  padding: 0.6rem;
  border: none;
  border-radius: 4px;
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 600;
  cursor: pointer;
  max-width: 200px;
}
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.row-actions button.tab-active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
}

.dashboard h2 { margin-top: 2rem; }
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.9rem;
  margin-top: 1.5rem;
}
.tile {
  display: block;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease;
}
.tile:hover { border-color: var(--primary); }
.tile-count { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.tile-title { font-weight: 600; margin-top: 0.25rem; }
.tile-label { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.tile.tile-alert .tile-count { color: var(--primary); }

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}
.action-card {
  display: block;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease;
}
.action-card:hover { border-color: var(--primary); }
.action-title { font-weight: 600; }
.action-description { font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }
