:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --text: #171923;
  --muted: #6b7280;
  --muted-light: #9ca3af;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --border: #e5e7eb;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 8px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

/* Navbar */

.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.navbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
}

.navbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.navbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}

.navbar nav a:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.navbar nav a.active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* Layout */

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

/* Auth screen */

.auth-body {
  background: linear-gradient(160deg, #eef2ff 0%, #f4f5fb 45%);
  min-height: 100vh;
}

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.auth-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  font-weight: 800;
  font-size: 1.3rem;
  margin: 0 auto 18px;
}

.auth-card h1 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.auth-card p.subtitle {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 26px;
  font-size: 0.9rem;
}

.auth-card form {
  text-align: left;
}

/* Forms */

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
  margin-top: 16px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

select:disabled {
  background: #f3f4f6;
  color: var(--muted-light);
  cursor: not-allowed;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(0.98); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

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

.btn-secondary:hover {
  background: #f9fafb;
  border-color: var(--muted-light);
}

.btn-block { width: 100%; margin-top: 22px; }

/* Tables */

.table-wrap {
  overflow-x: auto;
  margin: -4px;
  padding: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

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

td:nth-child(2) { white-space: normal; }

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

tbody tr:hover { background: #fafafb; }
tbody tr:last-child td { border-bottom: none; }

.actions a {
  margin-right: 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
}

.actions a:hover { text-decoration: underline; }

/* Messages / errors */

.errorlist {
  color: var(--error-text);
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  font-size: 0.83rem;
}

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.messages li {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}

.messages li.success { background: var(--success-bg); color: var(--success-text); }
.messages li.error { background: var(--error-bg); color: var(--error-text); }

/* Page header */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 1.5rem;
}

/* Stats */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
  margin-top: 4px;
  letter-spacing: -0.02em;
}

/* Mobile */

@media (max-width: 640px) {
  .container { padding: 20px 14px 48px; }
  .card { padding: 20px; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header > div { display: flex; gap: 8px; flex-wrap: wrap; }
  .btn, .btn-secondary { flex: 1; text-align: center; }
}
