:root {
  --brand: #c8272d;
  --brand-dark: #a31f24;
  --brand-tint: #fdeceb;
  --ink: #1e1b1b;
  --bg: #f5f4f1;
  --card: #ffffff;
  --text: #1e1b1b;
  --muted: #75706a;
  --border: #e8e3dd;
  --danger: #8a1c1c;
  --danger-bg: #fbe9e7;
  --success: #1f8a5f;
  --success-bg: #e7f5ee;
  --radius: 12px;
  --sidebar-w: 232px;
}

html { font-size: 14.5px; }
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Montserrat', -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--brand-dark); }
a:hover { text-decoration: underline; }

/* =========================================================
   Simple topbar — used only for logged-out pages (login,
   register, landing). The app shell below replaces this once
   the person is signed in.
   ========================================================= */
.topbar { background: var(--card); border-bottom: 1px solid var(--border); }
.topbar__inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); flex-shrink: 0; }
.topbar__nav { display: flex; align-items: center; gap: 16px; }
.topbar__nav a { font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; }

/* =========================================================
   App shell — sidebar + content, used on every page once
   logged in.
   ========================================================= */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--card);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
}
.app-sidebar__brand { display: block; padding: 22px 20px 14px; }
.app-sidebar__brand img { height: 30px; display: block; }

.app-sidebar__nav { flex: 1; padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.app-sidebar__label {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--muted); margin: 14px 10px 6px;
}
.app-sidebar__nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  font-size: 0.82rem; font-weight: 600; color: var(--ink); transition: all .15s ease;
}
.app-sidebar__nav a i { font-size: 1.05rem; color: var(--muted); transition: color .15s ease; }
.app-sidebar__nav a:hover { background: var(--bg); text-decoration: none; }
.app-sidebar__nav a.active { background: var(--brand-tint); color: var(--brand-dark); }
.app-sidebar__nav a.active i { color: var(--brand); }

.app-sidebar__user {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.app-sidebar__avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem;
  flex-shrink: 0;
}
.app-sidebar__avatar--sm { width: 30px; height: 30px; font-size: 0.78rem; }
.app-sidebar__user-info { flex: 1; min-width: 0; }
.app-sidebar__user-name { font-size: 0.8rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-sidebar__user-role { font-size: 0.68rem; color: var(--muted); text-transform: capitalize; }
.app-sidebar__icon-btn {
  width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; color: var(--muted); flex-shrink: 0;
}
.app-sidebar__icon-btn:hover { background: var(--bg); color: var(--brand); }

.app-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  display: flex; align-items: center; padding: 14px 24px; background: var(--card);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
}
.app-topbar__toggle {
  display: none; background: none; border: 1px solid var(--border); border-radius: 8px;
  width: 38px; height: 38px; align-items: center; justify-content: center; font-size: 1.1rem;
  cursor: pointer; color: var(--ink);
}
.app-topbar__spacer { flex: 1; }
.app-topbar__user { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 600; color: var(--ink); }

/* Sidebar overlay + off-canvas behaviour on small screens */
.app-sidebar__backdrop { display: none; }
@media (max-width: 900px) {
  .app-sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  .app-sidebar.sidebar-open { transform: translateX(0); box-shadow: 8px 0 24px rgba(0,0,0,0.15); }
  .app-topbar__toggle { display: inline-flex; }
  .app-sidebar__backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 35;
  }
  .app-sidebar__backdrop.show { display: block; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 12px 22px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--card); cursor: pointer;
  transition: all .15s ease; line-height: 1;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.08); text-decoration: none; }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn--primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn--sm { padding: 8px 14px; font-size: 0.66rem; }
.btn--danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--danger:hover { background: #6e1614; border-color: #6e1614; }

.flash {
  width: 100%; padding: 14px 24px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; font-size: 0.9rem; font-weight: 500;
}
.flash--success { background: var(--success); color: #fff; }
.flash--error { background: var(--danger); color: #fff; }
.flash__close {
  background: none; border: none; color: inherit; font-size: 1.05rem;
  line-height: 1; cursor: pointer; opacity: 0.85; padding: 4px; flex-shrink: 0;
}
.flash__close:hover { opacity: 1; }

.container { max-width: 1180px; margin: 0 auto; padding: 24px; }
.container--narrow { max-width: 440px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(30,27,27,0.04);
}

h1 { font-size: 1.45rem; margin: 0 0 6px; font-weight: 800; }
.text-mute { color: var(--muted); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; max-width: 100%; box-sizing: border-box;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 1rem;
  font-family: inherit; -webkit-appearance: none; appearance: none;
}
input[type="date"], input[type="file"] {
  width: 100%; max-width: 100%; box-sizing: border-box; display: block;
}

/* Dashboard "briefing" hero card */
.briefing {
  background: linear-gradient(135deg, var(--ink) 0%, #322c2c 100%); color: #fff;
  border-radius: var(--radius); padding: 24px; margin-bottom: 18px; position: relative; overflow: hidden;
}
.briefing__eyebrow { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #e8b9b9; }
.briefing__title { font-size: 1.4rem; font-weight: 800; margin: 4px 0 8px; }
.briefing__body { font-size: 0.88rem; color: #d8d3d3; max-width: 640px; }
.briefing__pill {
  display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.12);
  padding: 5px 12px; border-radius: 20px; font-size: 0.74rem; font-weight: 600; margin-top: 12px; margin-right: 8px;
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 18px 0; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 1px 2px rgba(30,27,27,0.04); display: flex; align-items: flex-start; gap: 12px;
}
.stat-card__icon {
  width: 38px; height: 38px; border-radius: 10px; background: var(--brand-tint); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0;
}
.stat-card__body { min-width: 0; }
.stat-card__label { color: var(--muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-card__value { font-size: 1.4rem; font-weight: 800; margin: 2px 0; }
.section-title { display: flex; align-items: center; gap: 8px; }
.section-title i { color: var(--brand); font-size: 1.1rem; }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
th { background: var(--bg); font-weight: 700; white-space: nowrap; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 560px; }

.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.button-row .btn { flex: 1 1 200px; text-align: center; }

.badge { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; }
.badge--user { background: #eef1ee; color: #444; }
.badge--admin { background: #e6f0ff; color: #1a4fa0; }
.badge--super_admin { background: #fdf1e6; color: #a05a1a; }
.badge--active { background: var(--success-bg); color: var(--success); }
.badge--disabled { background: var(--danger-bg); color: var(--danger); }

.brand__logo { height: 34px; display: block; }

.footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 18px 24px; color: var(--muted); font-size: 0.8rem; }
.footer__inner { max-width: 1100px; margin: 0 auto; }

/* =========================================================
   Auth shell — split branded panel + form, used on login/register
   ========================================================= */
.auth-shell { display: flex; min-height: 100vh; }
.auth-shell__panel {
  flex: 1 1 46%; max-width: 560px; background: linear-gradient(135deg, var(--ink) 0%, #322c2c 100%);
  color: #fff; padding: 56px 48px; display: flex; flex-direction: column; justify-content: center;
}
.auth-shell__logo { height: 40px; display: block; margin-bottom: 28px; }
.auth-shell__tagline { font-size: 1.7rem; font-weight: 800; line-height: 1.3; margin-bottom: 14px; }
.auth-shell__desc { color: #d8d3d3; font-size: 0.9rem; max-width: 380px; line-height: 1.6; }
.auth-shell__features { margin-top: 32px; display: flex; flex-direction: column; gap: 16px; }
.auth-shell__feature { display: flex; align-items: center; gap: 10px; font-size: 0.86rem; color: #f0ecec; }
.auth-shell__feature i { color: var(--brand); font-size: 1.25rem; flex-shrink: 0; }

.auth-shell__form { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--bg); }
.auth-shell__form-inner { width: 100%; max-width: 400px; }
.auth-shell__mobile-logo { display: none; margin-bottom: 22px; }
.auth-shell__mobile-logo img { height: 32px; }
.auth-shell__footer { color: var(--muted); font-size: 0.78rem; text-align: center; margin-top: 20px; }

@media (max-width: 900px) {
  .auth-shell__panel { display: none; }
  .auth-shell__mobile-logo { display: block; }
}

@media (max-width: 700px) {
  .container { padding: 18px 16px; }
  .app-topbar { padding: 12px 16px; }
  .card { padding: 16px; }
  h1 { font-size: 1.3rem; }
  .stat-card__value { font-size: 1.3rem; }
  .briefing { padding: 18px; }
}
