:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #16202a;
  --muted: #637083;
  --line: #dce3ea;
  --brand: #1864ab;
  --brand-2: #0ca678;
  --warn: #f08c00;
  --danger: #e03131;
  --shadow: 0 14px 35px rgba(18, 32, 47, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.3em; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(24, 100, 171, 0.12), rgba(12, 166, 120, 0.12)),
    var(--bg);
}
.login-panel {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 28px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 34px;
}
.login-panel h1 { margin: 0 0 10px; font-size: clamp(32px, 5vw, 56px); line-height: 1; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: #2b3847; font-size: 13px; font-weight: 750; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  /* Below 16px, iOS Safari zooms the whole page in on focus - this
     overrides the 13px inherited from the parent <label>. */
  font-size: 16px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(24, 100, 171, 0.13);
}
.button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}
.button.primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.button.success { border-color: var(--brand-2); background: var(--brand-2); color: #fff; }
.button.danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.button.ghost { background: transparent; }
.demo-grid { display: flex; flex-wrap: wrap; gap: 8px; grid-column: 1 / -1; }
.demo-grid button {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 700;
}

.app { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  background: #101923;
  color: #eaf2f8;
  overflow-y: auto;
}
.brand { display: flex; gap: 12px; align-items: center; padding-bottom: 18px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--brand-2);
  color: #fff;
  font-weight: 900;
}
.brand small { display: block; color: #9fb0bf; margin-top: 2px; }
nav { display: grid; gap: 6px; margin-top: 18px; }
.nav-button {
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 11px 12px;
  background: transparent;
  color: #c6d3dd;
  text-align: left;
  font-weight: 750;
}
.nav-button.active, .nav-button:hover { background: rgba(255,255,255,0.09); color: #fff; }
.workspace { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: rgba(244, 246, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.topbar h2 { margin: 0; font-size: 24px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--muted);
  font-weight: 750;
}
.content { padding: 24px; display: grid; gap: 18px; }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}
.card, .table-card, .form-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.card { padding: 18px; }
.metric-value { margin: 8px 0 4px; font-size: 30px; font-weight: 900; }
.metric-label { margin: 0; color: var(--muted); font-size: 13px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.table-card { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f8fafc; color: #526172; font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
tr:last-child td { border-bottom: 0; }
.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 9px;
  background: #edf2ff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 850;
  text-transform: capitalize;
}
.status.paid, .status.present, .status.active { background: #e6fcf5; color: #087f5b; }
.status.pending, .status.partial, .status.late { background: #fff4e6; color: #c05600; }
.status.absent, .status.overdue, .status.inactive { background: #fff5f5; color: #c92a2a; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.list { display: grid; gap: 10px; }
.notice { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.notice h4 { margin: 0 0 6px; }
.notice p { margin: 0; color: var(--muted); }
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 25, 35, 0.5);
  /* Lets the card scroll within the overlay when a form is taller than
     the screen, instead of clipping the Save button off-screen. */
  overflow-y: auto;
}
.modal-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  display: grid;
  gap: 14px;
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.25);
}
.modal-card h3 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Rows of small buttons inside toolbars and table cells */
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.btn-row .button { padding: 7px 10px; font-size: 13px; }
a.button { display: inline-flex; align-items: center; text-decoration: none; }

/* Filter bars above reports */
.filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.filter-row label { flex: 1 1 180px; min-width: 150px; }
.filter-row .button { flex-shrink: 0; }

/* Profile photos */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  object-fit: cover;
  background: #e9eef4;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.avatar-fallback { border: 1px solid var(--line); }

.notice-warn { border-left: 4px solid var(--warn); }
.mono-cell { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }
h4 { margin: 6px 0; }

/* Printable documents (report card, certificate, ID card) */
.doc-header { text-align: center; margin-bottom: 18px; }
.doc-header h2 { margin: 0 0 4px; }
.doc-header h3 { margin: 10px 0 0; }
.doc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  margin: 16px 0;
}
.doc-body { line-height: 1.9; }
.doc-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 46px;
  padding-top: 10px;
  color: var(--muted);
}
.doc-signatures span { border-top: 1px solid var(--ink); padding-top: 6px; min-width: 160px; text-align: center; }
.document-card { max-height: calc(100vh - 40px); overflow-y: auto; }

.id-card {
  width: 320px;
  max-width: 100%;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.id-card-header { padding: 12px; background: var(--brand); color: #fff; text-align: center; }
.id-card-header small { display: block; opacity: 0.85; }
.id-card-body { display: flex; gap: 12px; padding: 14px; }
.id-photo {
  display: grid;
  place-items: center;
  width: 84px;
  height: 96px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f2f5f8;
  font-size: 11px;
  overflow: hidden;
}
.id-photo img { width: 100%; height: 100%; object-fit: cover; }
.id-details h4 { margin: 0 0 6px; }
.id-details p { margin: 2px 0; font-size: 13px; }
.id-card-footer { padding: 8px; background: #f2f5f8; text-align: center; font-size: 12px; color: var(--muted); }

@media print {
  /* Printing one document: hide everything with `visibility` (which the
     target can override even though its ancestors stay hidden) rather than
     `display`, since the print target may sit inside a modal overlay. */
  body.printing * { visibility: hidden; }
  body.printing .print-target,
  body.printing .print-target * { visibility: visible; }
  body.printing .print-target {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: #fff;
  }
  /* The dimmed overlay behind a modal would otherwise print as grey. */
  body.printing .modal { background: none; padding: 0; display: block; }
  .no-print { display: none !important; }
  .table-card { overflow: visible; box-shadow: none; }
  table { min-width: 0; }
}

.menu-toggle { display: none; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  /* The nav has 20+ items - stacking it above the page content (the old
     behavior) forced mobile users to scroll past the whole menu before
     seeing anything. Instead it becomes a slide-out drawer. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 24px 0 48px rgba(0, 0, 0, 0.3);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(16, 25, 35, 0.5);
  }
  .sidebar-backdrop.visible { display: block; }
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-size: 19px;
  }
  nav { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-panel, .two-col { grid-template-columns: 1fr; }

  /* Title + badge text were wrapping onto multiple lines and inflating
     the topbar's height - force single-line with an ellipsis instead. */
  .topbar-left { min-width: 0; flex: 1; }
  .topbar-left > div { min-width: 0; }
  .topbar h2 { font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .eyebrow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top-actions { flex-shrink: 0; }
  #userBadge { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 560px) {
  .content, .topbar { padding: 16px; }
  .top-actions { gap: 8px; }
  #userBadge { display: none; }
  .metrics { grid-template-columns: 1fr; }
  .login-panel { padding: 22px; }
}
