:root {
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --card-subtle: #F8FAFC;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-muted: #64748B;
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-soft: #EEF2FF;
  --present: #16A34A;
  --present-soft: #DCFCE7;
  --absent: #DC2626;
  --absent-soft: #FEE2E2;
  --warning: #D97706;
  --warning-soft: #FEF3C7;
  --radius: 14px;
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Vector SVG System */
.svg-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.svg-icon.sm {
  width: 16px;
  height: 16px;
}

.svg-icon.lg {
  width: 24px;
  height: 24px;
}

.app-shell {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 88px;
}

.hidden {
  display: none !important;
}

/* Top Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-emblem {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.portal-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.portal-subtitle {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 1px;
}

.icon-btn {
  min-width: 42px;
  min-height: 42px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:active {
  background: var(--card-subtle);
}

.btn-discreet {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-discreet:active {
  background: var(--card-subtle);
}

/* Dropdown Menu */
.dropdown-menu {
  position: fixed;
  top: 64px;
  right: max(16px, calc((100vw - 540px) / 2 + 16px));
  width: 240px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  z-index: 50;
  padding: 8px;
}

.dropdown-user {
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.dropdown-item {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dropdown-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dropdown-item:hover {
  background: var(--bg);
}

.dropdown-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 0;
}

.text-danger {
  color: var(--absent) !important;
}

/* Main Content & Cards */
.main-content {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card,
.hero-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.section-label {
  font-family: var(--font-display);
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Status Pill */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-published {
  background: var(--present-soft);
  color: var(--present);
}

.status-draft {
  background: var(--warning-soft);
  color: var(--warning);
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metric-box {
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--border);
  background: var(--card);
}

.metric-box.present {
  background: #F0FDF4;
  border-color: #BBF7D0;
}

.metric-box.absent {
  background: #FEF2F2;
  border-color: #FECACA;
}

.metric-label {
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-box.present .metric-label,
.metric-box.present .metric-value {
  color: var(--present);
}

.metric-box.absent .metric-label,
.metric-box.absent .metric-value {
  color: var(--absent);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 700;
  margin-top: 2px;
}

/* Segmented Tabs */
.segmented-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #E2E8F0;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.seg-btn {
  min-height: 44px;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
}

.seg-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* Buttons */
.btn {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 12px;
  border: none;
  font-family: var(--font-display);
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-outline {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-success {
  background: var(--present);
  color: #FFFFFF;
}

.btn-danger {
  background: var(--absent);
  color: #FFFFFF;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-label {
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  font-family: var(--font-sans);
  font-size: 0.94rem;
  color: var(--text);
}

.search-wrapper {
  position: relative;
  width: 100%;
}

.search-wrapper .svg-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-wrapper .form-input {
  padding-left: 42px;
}

.form-textarea {
  min-height: 92px;
  resize: vertical;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-toggle {
  position: absolute;
  right: 8px;
  min-height: 36px;
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 0 10px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Student Roster & Attendance Marking Cards */
.student-item {
  padding: 14px;
  border-radius: 13px;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.student-item.card-present {
  border-left: 4px solid var(--present);
}

.student-item.card-absent {
  border-left: 4px solid var(--absent);
}

.student-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.student-name-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.seq-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.student-fullname {
  font-family: var(--font-display);
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text);
}

.roll-pill {
  font-family: var(--font-mono);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.73rem;
  padding: 2px 8px;
  border-radius: 6px;
}

.hidden-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #F1F5F9;
  color: #475569;
  font-size: 0.71rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
}

.mark-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.status-btn {
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
}

.status-btn.active-present {
  background: var(--present);
  color: #FFFFFF;
  border-color: var(--present);
}

.status-btn.active-absent {
  background: var(--absent);
  color: #FFFFFF;
  border-color: var(--absent);
}

.hide-btn {
  min-width: 82px;
  min-height: 46px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.hide-btn.active-hide {
  background: #0F172A;
  color: #FFFFFF;
  border-color: #0F172A;
}

/* Sticky Save Footer on Mark Attendance Screen */
.sticky-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

.sticky-action-inner {
  max-width: 540px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Sticky Summary Bar while scrolling Attendance */
.marking-sticky-summary {
  position: sticky;
  top: 63px;
  z-index: 25;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

/* Quick Access List */
.quick-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quick-item {
  width: 100%;
  min-height: 54px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.quick-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quick-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Public Student Name List */
.public-student-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.public-student-row {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.seq-num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 28px;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 540px;
  margin: 0 auto;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 35;
  padding: 6px 8px;
}

.nav-tab {
  min-height: 52px;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
}

.nav-tab.active {
  color: var(--primary);
}

/* Footer Branding */
.app-footer {
  text-align: center;
  padding: 20px 16px 28px;
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Toast & Modals */
.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: #0F172A;
  color: #FFFFFF;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 600;
  z-index: 80;
  max-width: 90vw;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

@media (min-width: 540px) {
  .modal-overlay {
    align-items: center;
  }
}

.modal-card {
  background: var(--card);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.turnstile-box {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px 0;
}

.badge-pill {
  font-family: var(--font-mono);
  background: var(--absent);
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}
