* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f5f7;
  color: #1c1e21;
}
a { color: #2456ff; text-decoration: none; }
button { font-family: inherit; }

/* ---------- Login screen ---------- */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #14161a;
}
.login-card { background: #fff; padding: 36px; border-radius: 10px; width: 320px; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p { color: #888; font-size: 13px; margin: 0 0 20px; }
.login-error {
  background: #fdecec; color: #a3271b; border: 1px solid #f5c2bd;
  padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; display: none;
}
.login-error.show { display: block; }

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

.admin-sidebar {
  width: 220px; background: #14161a; color: #fff;
  display: flex; flex-direction: column; padding: 24px 0; flex-shrink: 0;
}
.admin-brand { font-weight: 700; letter-spacing: 0.06em; padding: 0 24px 24px; font-size: 15px; }
.admin-brand span { display: block; font-weight: 400; opacity: 0.55; font-size: 12px; letter-spacing: 0.08em; margin-top: 2px; }
.admin-sidebar nav { display: flex; flex-direction: column; flex: 1; }
.admin-sidebar nav button {
  all: unset; cursor: pointer; color: #c8cad0; padding: 12px 24px; font-size: 14px;
}
.admin-sidebar nav button:hover { background: #1f2228; color: #fff; }
.admin-sidebar nav button.active { background: #2456ff; color: #fff; }
.admin-sidebar nav button .badge {
  display: inline-block; background: #d93025; color: #fff; border-radius: 100px;
  font-size: 11px; padding: 1px 7px; margin-left: 6px;
}
.admin-logout { all: unset; cursor: pointer; padding: 12px 24px; font-size: 13px; color: #9a9da5; }
.admin-logout:hover { color: #fff; }

.admin-main { flex: 1; padding: 32px 40px; max-width: 980px; overflow-y: auto; }

h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 24px 0 12px; }
.admin-subtitle { color: #666; margin: 0 0 24px; font-size: 14px; }

.admin-flash { padding: 12px 16px; border-radius: 6px; margin-bottom: 20px; font-size: 14px; display: none; }
.admin-flash.show { display: block; }
.admin-flash.success { background: #e5f7e9; color: #146c2e; border: 1px solid #b6e6c2; }
.admin-flash.error { background: #fdecec; color: #a3271b; border: 1px solid #f5c2bd; }

.admin-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-block; padding: 9px 16px; border-radius: 6px; background: #2456ff;
  color: #fff; border: none; font-size: 14px; cursor: pointer;
}
.btn:hover { background: #1a41d1; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-secondary { background: #e6e7eb; color: #1c1e21; }
.btn-secondary:hover { background: #d7d9de; }
.btn-danger { background: #d93025; }
.btn-danger:hover { background: #b3261e; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 8px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #eee; font-size: 14px; vertical-align: top; }
th { background: #fafafa; font-weight: 600; color: #444; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.row-actions { white-space: nowrap; display: flex; gap: 6px; }
.status-pill { display: inline-block; padding: 2px 9px; border-radius: 100px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.status-active, .status-new { background: #e5f7e9; color: #146c2e; }
.status-inactive, .status-read { background: #f1f1f2; color: #777; }
.status-handled { background: #e6effd; color: #1a41d1; }

.admin-card { background: #fff; border-radius: 8px; padding: 28px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); max-width: 640px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 16px 0 6px; color: #333; }
label:first-of-type { margin-top: 0; }
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid #d5d7dc; border-radius: 6px; font-size: 14px; font-family: inherit;
}
textarea { resize: vertical; }
.field-hint { font-size: 12px; color: #888; margin-top: 4px; }
.form-actions { margin-top: 24px; display: flex; gap: 10px; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 720px; }
.dashboard-tile { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); cursor: pointer; border: none; text-align: left; }
.dashboard-tile .count { font-size: 30px; font-weight: 700; }
.dashboard-tile .label { color: #777; font-size: 13px; margin-top: 4px; }

/* ---------- Modal (edit forms) ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 10px; padding: 28px; width: 100%; max-width: 620px;
  max-height: 88vh; overflow-y: auto;
}
.modal-box h2 { margin-top: 0; }

.loading-msg, .empty-msg { color: #888; font-size: 14px; padding: 20px 0; }
.spinner-inline { display: inline-block; width: 14px; height: 14px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
