:root {
  --primary: #0F8B8D;
  --primary-dark: #0B6E70;
  --primary-light: rgba(15, 139, 141, 0.1);
  --primary-light-hover: rgba(15, 139, 141, 0.2);
  --accent: #E85D04;
  --ink: #1B2B3A;
  --bg: #F4F6F7;
  --subtle: #EDF1F2;
  --border: #E1E6E8;
  --white: #FFFFFF;
  --success: #2EC4B6;
  --danger: #E63946;
  --warning: #FFB703;
  --card-shadow: 0 4px 20px rgba(27, 43, 58, 0.05);
  --hover-shadow: 0 10px 30px rgba(27, 43, 58, 0.08);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius: 16px;
  --border-radius-pill: 999px;
  --sidebar-width: 260px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  color: var(--ink);
  font-weight: 700;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #C4C4C4;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #A0A0A0;
}

/* App Layout */
#app-shell {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Sidebar Navigation */
.sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: var(--transition);
  z-index: 100;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo {
  background: var(--primary);
  color: var(--white);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
}

.sidebar-title h2 {
  font-size: 18px;
  line-height: 1.2;
}

.sidebar-title span {
  font-size: 11px;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-menu {
  flex: 1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #5C6F84;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--subtle);
  color: var(--ink);
}

.nav-item.active {
  background: var(--primary);
  color: var(--white);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border);
}

.school-badge-sidebar {
  background: var(--subtle);
  padding: 12px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.school-badge-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.school-badge-details {
  font-size: 11px;
  opacity: 0.7;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.content-header {
  height: 70px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.view-title h1 {
  font-size: 22px;
  color: var(--ink);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-panel {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hidden {
  display: none !important;
}

/* Global Component Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--border-radius-pill);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  user-select: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--white);
  border-color: var(--border);
  color: var(--ink);
}
.btn-secondary:hover {
  background: var(--subtle);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover {
  opacity: 0.9;
}

.btn:disabled {
  background: var(--border) !important;
  color: #9AA5AC !important;
  border-color: transparent !important;
  cursor: not-allowed;
}

.card-box {
  background: var(--white);
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  padding: 24px;
  transition: var(--transition);
}

.card-box:hover {
  box-shadow: var(--hover-shadow);
}

/* Setup Wizard Views */
.wizard-container {
  max-width: 600px;
  margin: 40px auto;
  width: 100%;
}

.wizard-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 30px;
  position: relative;
}

.wizard-steps::before {
  content: '';
  position: absolute;
  top: 15px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border);
  z-index: 1;
}

.wizard-step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  z-index: 2;
  transition: var(--transition);
}

.wizard-step-dot.active {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--white);
}

.wizard-step-dot.completed {
  border-color: var(--success);
  background: var(--success);
  color: var(--white);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.form-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  opacity: 0.8;
}

.form-control {
  border: 1.5px solid var(--border);
  border-radius: var(--border-radius-pill);
  padding: 12px 18px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--primary);
}

/* Upload zone */
.upload-zone {
  border: 2.5px dashed var(--border);
  border-radius: var(--border-radius);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--white);
  margin-bottom: 20px;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-zone svg {
  width: 48px;
  height: 48px;
  stroke: var(--primary);
  margin-bottom: 12px;
}

.upload-zone p {
  font-size: 14px;
  color: var(--ink);
  opacity: 0.7;
}

/* Setup Items Lists */
.setup-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 15px;
  padding-right: 4px;
}

.setup-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  padding: 12px 20px;
  border-radius: var(--border-radius-pill);
  border: 1px solid var(--border);
}

.setup-card-title {
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.setup-card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Toggles */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.toggle-track {
  width: 44px;
  height: 24px;
  background: #CBD5E1;
  border-radius: 999px;
  position: relative;
  transition: var(--transition);
}

.toggle-switch input {
  display: none;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--primary);
}

.toggle-thumb {
  width: 18px;
  height: 18px;
  background: var(--white);
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
}

/* Dashboard Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.metric-icon {
  background: var(--primary-light);
  color: var(--primary);
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.metric-val {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

.metric-label {
  font-size: 13px;
  color: #5C6F84;
  font-weight: 500;
}

/* Entry Modes Layout */
.entry-layout {
  display: flex;
  gap: 24px;
  height: calc(100vh - 120px);
  overflow: hidden;
}

/* Left/Middle Student/Subject list */
.entry-list-container {
  flex: 1;
  background: var(--white);
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.entry-list-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.entry-selector-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.select-control {
  background: var(--subtle);
  border: none;
  padding: 8px 16px;
  border-radius: var(--border-radius-pill);
  font-weight: 600;
  color: var(--ink);
  outline: none;
  font-family: inherit;
  cursor: pointer;
}

.entry-rows-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 16px;
  transition: var(--transition);
}

.entry-row:hover {
  background: var(--bg);
}

.entry-row.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.entry-row-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 12px;
}

.entry-row-fields {
  display: flex;
  gap: 8px;
}

/* Score Input Buttons */
.score-cell-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 48px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background: var(--primary);
  color: var(--white);
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.score-cell-btn:hover {
  opacity: 0.9;
}

.score-cell-btn.disabled {
  background: var(--subtle);
  color: #9AA5AC;
  cursor: not-allowed;
}

.score-cell-btn .cell-lbl {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.75;
}

.score-cell-btn .cell-val {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
}

.score-cell-btn.active {
  background: var(--white);
  border-color: var(--primary);
  color: var(--ink);
  box-shadow: 0 4px 10px var(--primary-light);
}

/* Right Entry Panel (Keypad) */
.entry-sidebar {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-shrink: 0;
}

.keypad-card {
  background: var(--white);
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.keypad-header {
  text-align: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.keypad-active-label {
  font-size: 13px;
  opacity: 0.7;
  font-weight: 600;
}

.keypad-active-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 52px;
  gap: 8px;
}

.key-btn {
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: var(--white);
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.15s ease;
  user-select: none;
}

.key-btn.subtle {
  background: var(--subtle);
  color: var(--ink);
}

.key-btn.accent {
  background: var(--primary-dark);
}

.key-btn:active {
  filter: brightness(0.85);
}

.key-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Info Box / Help */
.entry-help {
  font-size: 12px;
  opacity: 0.7;
  line-height: 1.5;
  padding: 12px;
  background: var(--subtle);
  border-radius: 12px;
  border-left: 4px solid var(--primary);
}

/* Ledger Screen Table */
.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  background: var(--white);
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.ledger-table th, .ledger-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.ledger-table th {
  background: var(--bg);
  font-weight: 700;
  color: var(--ink);
}

.ledger-table tbody tr:hover {
  background: var(--primary-light);
}

.grade-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  text-align: center;
}

.grade-A-plus, .grade-A, .grade-A-minus {
  background: #E8F8F5;
  color: #117A65;
}

.grade-B, .grade-C, .grade-D {
  background: #FEF9E7;
  color: #B7950B;
}

.grade-F {
  background: #FDEDEC;
  color: #CB4335;
}

.status-badge {
  font-weight: 700;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.status-pass {
  background: rgba(46, 196, 182, 0.15);
  color: var(--success);
}

.status-fail {
  background: rgba(230, 57, 70, 0.15);
  color: var(--danger);
}

/* Individual Report Card Design */
.report-card-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-preview-area {
  display: flex;
  justify-content: center;
  padding: 20px;
  background: #999;
  border-radius: var(--border-radius);
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

/* Printable Report Card Template */
.report-card-print {
  width: 210mm; /* A4 width */
  min-height: 297mm; /* A4 height */
  background: var(--white);
  padding: 20mm 15mm;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  color: #111;
  font-family: 'Inter', Arial, sans-serif;
  box-sizing: border-box;
}

.report-card-header {
  text-align: center;
  border-bottom: 3px double #333;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.report-card-school-name {
  font-size: 26px;
  font-weight: 800;
  text-transform: uppercase;
  color: #0F8B8D;
  margin-bottom: 4px;
}

.report-card-exam-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.report-card-meta {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.85;
}

.report-card-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
  font-size: 14px;
}

.info-item {
  display: flex;
  border-bottom: 1px dashed #CCC;
  padding-bottom: 4px;
}

.info-label {
  font-weight: 700;
  width: 120px;
  color: #444;
}

.info-value {
  flex: 1;
}

/* Report Card Table */
.card-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 13px;
}

.card-table th, .card-table td {
  border: 1px solid #333;
  padding: 8px 10px;
  text-align: center;
}

.card-table th {
  background: #F0F4F5;
  font-weight: 700;
}

.card-table td.subject-name {
  text-align: left;
  font-weight: 600;
}

/* Card Summary Grid */
.card-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.summary-block {
  flex: 1;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 12px;
  background: #FAFAFA;
}

.summary-block-title {
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid #DDD;
  padding-bottom: 6px;
  margin-bottom: 8px;
  text-transform: uppercase;
  color: #333;
}

.summary-block-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  row-gap: 6px;
  column-gap: 12px;
  font-size: 13px;
}

.summary-block-label {
  color: #666;
}

.summary-block-val {
  font-weight: 700;
  text-align: right;
}

/* Signatures section */
.signature-section {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  padding-top: 40px;
}

.signature-line {
  border-top: 1.5px solid #333;
  width: 150px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  padding-top: 6px;
  color: #444;
}

/* Media query for print compatibility */
@media print {
  body {
    background: white;
    color: black;
  }
  
  #app-shell {
    height: auto;
    overflow: visible;
  }

  .sidebar, .content-header, .report-card-view-header {
    display: none !important;
  }

  .main-content, .view-panel, .card-preview-area {
    padding: 0 !important;
    overflow: visible !important;
    display: block !important;
    background: transparent !important;
  }

  .report-card-print {
    box-shadow: none !important;
    margin: 0 !important;
    page-break-after: always;
    page-break-inside: avoid;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 10mm 5mm !important;
  }
  
  .report-card-print:last-child {
    page-break-after: avoid;
  }
}

/* Responsive Overrides (For normal screen view) */
@media (max-width: 900px) {
  #app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  
  .sidebar-menu {
    flex-direction: row;
    padding: 10px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  
  .nav-item {
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  .sidebar-footer, .sidebar-header {
    display: none;
  }
  
  .entry-layout {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  
  .entry-sidebar {
    width: 100%;
  }
}
