:root {
  --green: #0F3D2E;
  --green-light: #1A5C45;
  --gold: #C9A227;
  --gold-light: #E0C35A;
  --cream: #F8F5EE;
  --white: #FFFFFF;
  --text: #1A1A1A;
  --muted: #555555;
  --border: #DDDDDD;
  --present: #1a7a4c;
  --absent: #b33;
  --late: #c47a00;
  --excused: #1a5c8a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: var(--green);
  color: var(--white);
  padding: 1rem 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.logo {
  height: 78px;
  width: auto;
  border-radius: 50%;
  background: var(--white);
  padding: 3px;
  object-fit: contain;
  flex-shrink: 0;
}

.logo-right {
  margin-left: auto;
  height: 78px;
  border-radius: 8px;
  padding: 4px;
}

.header-text {
  flex: 1;
  min-width: 0;
}

.header-text h1 {
  font-size: 1.5rem;
  color: var(--gold);
  margin-bottom: 0.1rem;
}

.header-text p {
  font-size: 1.05rem;
  font-weight: 600;
}

.header-text span {
  font-size: 0.8rem;
  opacity: 0.85;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.2rem 1.5rem;
  flex: 1;
  width: 100%;
}

/* Tabs */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
}

.tab {
  padding: 0.55rem 1rem;
  border: 2px solid var(--green);
  background: var(--white);
  color: var(--green);
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.tab:hover, .tab.active {
  background: var(--green);
  color: var(--gold);
}

.view { display: none; }
.view.active { display: block; }

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-bottom: 1rem;
  align-items: center;
}

.toolbar input[type="text"],
.toolbar select {
  padding: 0.6rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
}

.toolbar input[type="text"] {
  flex: 1;
  min-width: 160px;
}

.label-inline {
  font-weight: 600;
  color: var(--green);
  font-size: 0.9rem;
}

.hint {
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}

/* Buttons */
.btn {
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: 0.2s;
}

.btn-gold { background: var(--gold); color: var(--green); }
.btn-gold:hover { background: var(--gold-light); }
.btn-green { background: var(--green); color: var(--white); }
.btn-green:hover { background: var(--green-light); }
.btn-outline { background: transparent; border-color: var(--green); color: var(--green); }
.btn-small { padding: 0.28rem 0.55rem; font-size: 0.75rem; border-radius: 5px; margin: 0.1rem; }
.btn-red { background: #b33; color: white; border: none; }
.btn-red:hover { background: #d44; }
.btn-blue { background: #1a5c8a; color: white; border: none; }
.btn-blue:hover { background: #2a7ab0; }

/* Table */
.table-wrapper {
  overflow-x: auto;
  background: var(--white);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(15,61,46,0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead { background: var(--green); color: var(--gold); }

th {
  padding: 0.8rem 0.6rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

td {
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

tbody tr:hover { background: #f9f7f0; }
tbody tr:nth-child(even) { background: #fafaf7; }

.result-count {
  margin-top: 0.7rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-active { background: #d4edda; color: #155724; }
.status-inactive { background: #f8d7da; color: #721c24; }

/* Mark attendance */
.mark-list {
  background: var(--white);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(15,61,46,0.1);
  overflow: hidden;
}

.mark-row {
  display: flex;
  align-items: center;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid #eee;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.mark-row:nth-child(even) { background: #fafaf7; }

.mark-name {
  flex: 1;
  min-width: 140px;
  font-weight: 600;
}

.mark-voice {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 70px;
}

.mark-status {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.mark-status label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
}

.mark-status input { display: none; }

.mark-status label.present { background: #d4edda; color: #155724; }
.mark-status label.absent { background: #f8d7da; color: #721c24; }
.mark-status label.late { background: #fff3cd; color: #856404; }
.mark-status label.excused { background: #cce5ff; color: #004085; }

.mark-status input:checked + span,
.mark-status label:has(input:checked) {
  border-color: currentColor;
  box-shadow: 0 0 0 1px currentColor;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--white);
  border-radius: 12px;
  padding: 1.6rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2 {
  color: var(--green);
  margin-bottom: 1.1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

.form-group {
  margin-bottom: 0.9rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--green);
  margin-bottom: 0.25rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 0.92rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--gold);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  margin-top: 1rem;
}

.footer {
  background: var(--green);
  color: rgba(255,255,255,0.85);
  text-align: center;
  padding: 1.1rem;
  font-size: 0.82rem;
}

.footer .gold {
  color: var(--gold);
  margin-top: 0.25rem;
}

.pct-high { color: #1a7a4c; font-weight: 700; }
.pct-mid { color: #c47a00; font-weight: 700; }
.pct-low { color: #b33; font-weight: 700; }


/* Trends */
.section-heading {
  color: var(--green);
  font-size: 1.05rem;
  margin: 1.4rem 0 0.7rem;
}

.trends-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--white);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 10px rgba(15,61,46,0.08);
  border-top: 3px solid var(--gold);
}

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--green);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.bar-track {
  background: #e8e8e8;
  border-radius: 6px;
  height: 14px;
  overflow: hidden;
  min-width: 80px;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--green);
  transition: width 0.3s;
}

.bar-fill.mid { background: var(--late); }
.bar-fill.low { background: var(--absent); }

.trends-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.5rem;
}

.trends-box {
  background: var(--white);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  box-shadow: 0 2px 10px rgba(15,61,46,0.08);
}

.trends-box h4 {
  color: var(--green);
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
}

.trends-box ul {
  list-style: none;
  font-size: 0.9rem;
}

.trends-box li {
  padding: 0.35rem 0;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
}

.trends-box li:last-child { border-bottom: none; }

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

@media print {
  .header, .tabs, .toolbar, .footer, .btn, .actions { display: none !important; }
  body { background: white; }
  .table-wrapper { box-shadow: none; }
}

@media (max-width: 768px) {
  .header-inner { flex-direction: column; text-align: center; }
  .logo { height: 68px; }
  .logo-right { margin-left: 0; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .form-row { grid-template-columns: 1fr; }
  .mark-row { flex-direction: column; align-items: flex-start; }
}
@media print {
  .tabs, .toolbar, .modal, footer, header { display: none !important; }
  #view-reports, #view-trends { display: block !important; }
  #view-trends { break-before: page; }
}