body {
  font-size: 15px;
}

/* ---------- Auth (login) page ---------- */

.auth-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) var(--space-md);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2xl) var(--space-xl);
}

.auth-card__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
  font-weight: 700;
  font-size: 1.1rem;
}

.auth-card__logo .icon {
  color: var(--color-accent);
  width: 26px;
  height: 26px;
}

/* ---------- Form controls ---------- */

.field {
  margin-bottom: var(--space-lg);
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--color-foreground-muted);
  margin-bottom: var(--space-xs);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-muted);
  color: var(--color-foreground);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  min-height: 44px;
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-ring);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-md);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  min-height: 0;
}

/* ---------- App shell ---------- */

.app-shell {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-inline-end: 1px solid var(--color-border);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  margin-bottom: var(--space-2xl);
}

.sidebar__logo .icon {
  color: var(--color-accent);
  width: 24px;
  height: 24px;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  flex: 1;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-md);
  color: var(--color-foreground-muted);
  font-size: 0.9rem;
  transition: background-color 150ms ease, color 150ms ease;
}

.sidebar__link .icon {
  width: 18px;
  height: 18px;
}

.sidebar__link:hover {
  background: var(--color-muted);
  color: var(--color-foreground);
}

.sidebar__link[aria-current="page"] {
  background: rgba(34, 197, 94, 0.12);
  color: var(--color-accent);
  font-weight: 600;
}

.sidebar__logout {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-md);
  color: var(--color-foreground-muted);
  background: none;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: start;
}

.sidebar__logout:hover {
  color: var(--color-destructive);
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: var(--space-xl) var(--space-2xl);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0;
  font-size: 1.5rem;
}

.page-head p {
  margin: var(--space-xs) 0 0;
  color: var(--color-foreground-muted);
  font-size: 0.9rem;
}

@media (max-width: 860px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-inline-end: none;
    border-bottom: 1px solid var(--color-border);
  }
  .sidebar__logo {
    margin-bottom: 0;
    margin-inline-end: var(--space-lg);
  }
  .sidebar__nav {
    flex-direction: row;
  }
  .sidebar__logout span {
    display: none;
  }
  .main-content {
    padding: var(--space-lg);
  }
}

/* ---------- Stat tiles ---------- */

.stat-grid {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: var(--space-2xl);
}

.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.stat-tile__label {
  color: var(--color-foreground-muted);
  font-size: 0.85rem;
  margin-bottom: var(--space-sm);
}

.stat-tile__value {
  font-size: 1.6rem;
  font-weight: 800;
}

/* ---------- Table ---------- */

.table-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: start;
  padding: var(--space-md) var(--space-lg);
  color: var(--color-foreground-muted);
  font-weight: 600;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

tbody td {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  white-space: nowrap;
}

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

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.table-actions {
  display: flex;
  gap: var(--space-sm);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--color-muted);
  border: 1px solid var(--color-border);
  color: var(--color-foreground-muted);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}

.icon-btn:hover {
  color: var(--color-foreground);
  border-color: rgba(255, 255, 255, 0.24);
}

.icon-btn .icon {
  width: 16px;
  height: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge--success { background: rgba(34, 197, 94, 0.14); color: #4ade80; }
.badge--warning { background: rgba(234, 179, 8, 0.14); color: #facc15; }
.badge--danger { background: rgba(220, 38, 38, 0.14); color: #f87171; }
.badge--neutral { background: rgba(148, 163, 184, 0.14); color: #94a3b8; }

.empty-state {
  padding: var(--space-2xl);
  text-align: center;
  color: var(--color-foreground-muted);
}

/* ---------- Panel / form card ---------- */

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.panel h2 {
  margin: 0 0 var(--space-lg);
  font-size: 1.1rem;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  bottom: var(--space-lg);
  inset-inline-end: var(--space-lg);
  z-index: 200;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  max-width: 320px;
}

.toast--success {
  background: #14532d;
  color: #bbf7d0;
}

.toast--error {
  background: #7f1d1d;
  color: #fecaca;
}
