:root {
  --amr-red: #ED1C24;
  --amr-red-dark: #B3141A;
  --amr-red-tint: #FDEAEB;
  --amr-ink: #0A0A0A;
  --amr-concrete: #6B7280;
  --amr-cement: #FAFAFA;
  --amr-steel-100: #F1F1F1;
  --border: #E5E5E5;
  --white: #FFFFFF;
  --success: #16A34A;
  --success-tint: #ECFDF5;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--amr-cement);
  color: var(--amr-ink);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--amr-ink);
  background-image: radial-gradient(circle at 20% 20%, rgba(237,28,36,0.08), transparent 40%),
                     radial-gradient(circle at 80% 80%, rgba(237,28,36,0.06), transparent 40%);
}

.login-card {
  width: 380px;
  background: var(--white);
  border-radius: 12px;
  padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.login-logo img { width: 72px; height: 72px; object-fit: contain; margin-bottom: 8px; }
.login-logo .title { font-weight: 800; font-size: 18px; letter-spacing: 0.5px; }
.login-logo .subtitle { font-size: 10px; letter-spacing: 2px; color: var(--amr-concrete); margin-top: 2px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--amr-concrete); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--amr-red);
  box-shadow: 0 0 0 3px var(--amr-red-tint);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--amr-red); color: white; }
.btn-primary:hover { background: var(--amr-red-dark); }
.btn-dark { background: var(--amr-ink); color: white; }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--amr-ink); }
.btn-outline:hover { background: var(--amr-steel-100); }
.btn-block { width: 100%; }
.btn-danger { background: #FEE2E2; color: #B91C1C; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.login-error {
  background: var(--amr-red-tint);
  color: var(--amr-red-dark);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-hint { font-size: 11px; color: var(--amr-concrete); text-align: center; margin-top: 16px; }

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

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--amr-ink);
  color: #E5E5E5;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  height: 80px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand img { width: 38px; height: 38px; object-fit: contain; }
.sidebar-brand .name { font-size: 14px; font-weight: 800; line-height: 1; }
.sidebar-brand .sub { font-size: 9px; letter-spacing: 1.5px; color: #A3A3A3; margin-top: 3px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  color: #A3A3A3;
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: white; }
.sidebar-nav a.active { background: var(--amr-red); color: white; }
.sidebar-nav .icon { width: 18px; text-align: center; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-footer .user-name { font-size: 12.5px; font-weight: 600; }
.sidebar-footer .user-role { font-size: 10.5px; color: #A3A3A3; text-transform: capitalize; }
.sidebar-footer .logout { font-size: 11.5px; color: var(--amr-red); margin-top: 8px; display: inline-block; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 72px;
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}
.topbar h1 { font-size: 17px; margin: 0; }
.topbar .date { font-size: 12px; color: var(--amr-concrete); }

.content { padding: 28px; flex: 1; }

/* ---------- Cards / grid ---------- */
.grid-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 1100px) { .grid-stats { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  position: relative;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 18px 22px;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--amr-red);
}
.stat-card .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--amr-concrete); font-weight: 600; }
.stat-card .value { font-size: 22px; font-weight: 800; margin-top: 8px; }
.stat-card .delta { font-size: 11.5px; margin-top: 6px; color: var(--success); }
.stat-card .delta.neg { color: var(--amr-red); }

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card-title { font-size: 14px; font-weight: 700; margin: 0 0 4px 0; }
.card-title-rule { height: 2px; width: 40px; background: var(--amr-red); margin-bottom: 16px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.section-header h2 { font-size: 18px; margin: 0; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--amr-concrete);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  white-space: nowrap;
}
tbody td { padding: 12px; border-bottom: 1px solid #F3F3F3; }
tbody tr:hover { background: #FAFAFA; }
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.tag-green { background: var(--success-tint); color: var(--success); }
.tag-red { background: var(--amr-red-tint); color: var(--amr-red-dark); }
.tag-gray { background: var(--amr-steel-100); color: var(--amr-concrete); }
.tag-dark { background: #E5E5E5; color: var(--amr-ink); }

.progress-bar { height: 6px; width: 100%; background: var(--amr-steel-100); border-radius: 999px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: var(--amr-red); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar input[type="text"], .toolbar select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px;
}
.toolbar .spacer { flex: 1; }

.pagination { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 14px; font-size: 12.5px; color: var(--amr-concrete); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: 12px; width: 520px; max-width: 92vw;
  max-height: 88vh; overflow-y: auto; padding: 24px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close { border: none; background: none; font-size: 20px; color: var(--amr-concrete); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- Toast ---------- */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--amr-ink); color: white; padding: 12px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); animation: toast-in 0.2s ease;
  border-left: 3px solid var(--amr-red);
}
.toast.success { border-left-color: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.empty-state { text-align: center; padding: 40px 20px; color: var(--amr-concrete); font-size: 13.5px; }
.skeleton { background: linear-gradient(90deg, #f0f0f0 25%, #f7f7f7 50%, #f0f0f0 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.badge-role { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; padding: 2px 8px; border-radius: 4px; background: var(--amr-steel-100); }
