:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --success-bg: #ecfdf3;
  --success-text: #087443;
  --error-bg: #fef2f2;
  --error-text: #b91c1c;
  --warn-bg: #fffbeb;
  --warn-text: #92400e;
  --radius: 8px;
}

* { box-sizing: border-box; }

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

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

h1, h2, h3 { margin: 0 0 0.5em; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

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

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #14161f;
  color: #cbd0da;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.sidebar .brand {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  padding: 0 20px 20px;
}
.sidebar .brand span { display: block; font-weight: 400; font-size: 12px; color: #8890a0; }

.sidebar nav { display: flex; flex-direction: column; flex: 1; }
.sidebar nav a {
  color: #cbd0da;
  padding: 10px 20px;
  font-size: 13px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.05); text-decoration: none; }
.sidebar nav a.active { background: rgba(37,99,235,0.15); border-left-color: var(--accent); color: #fff; }

.logout-form { padding: 16px 20px 0; border-top: 1px solid rgba(255,255,255,0.08); margin-top: 12px; }
.user-chip { font-size: 12px; color: #fff; margin-bottom: 8px; }
.role-badge {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  color: #cbd0da;
  border-radius: 4px;
  font-size: 10px;
  padding: 1px 6px;
  text-transform: uppercase;
  margin-left: 4px;
}
.btn-link {
  background: none;
  border: none;
  color: #8890a0;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.btn-link:hover { color: #fff; }

.content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1200px;
}

/* Alerts */
.alert {
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 13px;
}
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert ul { margin: 0; padding-left: 18px; }

/* Cards / surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

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

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-width: 140px;
  flex: 1;
}
.stat-tile .value { font-size: 26px; font-weight: 700; }
.stat-tile .label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: #fafbfc; }
.table-wrap { overflow-x: auto; }
.strike { text-decoration: line-through; color: var(--text-muted); }

/* Badges */
.badge { display: inline-block; border-radius: 4px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.badge-green { background: var(--success-bg); color: var(--success-text); }
.badge-red { background: var(--error-bg); color: var(--error-text); }
.badge-amber { background: var(--warn-bg); color: var(--warn-text); }
.badge-gray { background: #eef0f3; color: var(--text-muted); }

/* Forms */
form label { display: block; font-size: 12px; font-weight: 600; margin: 12px 0 4px; color: var(--text-muted); }
form input[type=text], form input[type=email], form input[type=password], form input[type=date],
form input[type=datetime-local], form input[type=file], form select, form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
form .checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
form .checkbox-row input { width: auto; }
form .checkbox-row label { margin: 0; }

.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: #f4f5f7; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: var(--error-bg); border-color: #fca5a5; color: var(--error-text); }
.btn-block { width: 100%; margin-top: 18px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filter-bar .field { display: flex; flex-direction: column; }
.filter-bar label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.filter-bar input, .filter-bar select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

/* Auth screen */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #14161f, #1f2937);
}
.auth-card {
  background: #fff;
  border-radius: 12px;
  padding: 36px 32px;
  width: 340px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.auth-card h1 { font-size: 18px; margin-bottom: 4px; }

.pagination-wrap { margin-top: 16px; }
.pagination-wrap nav { font-size: 12px; }

.empty-state { color: var(--text-muted); padding: 30px 0; text-align: center; }
