:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --success: #16a34a;
  --border: #e2e8f0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', 'Noto Sans Devanagari', Arial, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ==========================================
   NAVY BLUE ACCORDION SIDEBAR
   ========================================== */
.sidebar {
  width: 265px;
  background: #0a192f;
  color: #e2e8f0;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  flex-shrink: 0;
  border-right: 1px solid #172a45;
  box-shadow: 3px 0 15px rgba(2, 12, 27, 0.25);
}

.brand-box {
  padding: 8px 6px 16px;
  border-bottom: 1px solid #1d3557;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-logo-img { max-width: 195px; max-height: 48px; object-fit: contain; }
.brand-fallback { align-items: center; gap: 10px; font-size: 20px; font-weight: 800; color: #fff; }
.nav-label { font-size: 11px; font-weight: 700; color: #64748b; letter-spacing: 0.8px; padding: 8px 12px 4px; }

.menu-btn {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-radius: 9px; cursor: pointer; color: #cbd5e1;
  font-size: 14.5px; font-weight: 600; transition: all 0.2s ease; user-select: none;
}
.menu-btn:hover, .menu-btn.expanded { background: #13294b; color: #ffffff; }
.menu-btn.active { background: #2563eb !important; color: #ffffff !important; box-shadow: 0 3px 10px rgba(37, 99, 235, 0.35); }
.menu-left { display: flex; align-items: center; gap: 12px; }
.menu-left i { width: 20px; text-align: center; font-size: 16px; color: #93c5fd; }
.menu-btn.active .menu-left i, .menu-btn.upgrade-nav .menu-left i { color: #ffffff; }
.menu-arrow { font-size: 11px; color: #64748b; transition: transform 0.22s ease; }
.menu-btn.expanded .menu-arrow { transform: rotate(180deg); color: #93c5fd; }

.submenu {
  display: none; flex-direction: column; gap: 3px;
  margin: 4px 0 6px 10px; padding-left: 10px; border-left: 2px solid #1d3557;
}
.submenu.open { display: flex; }
.sub-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; border-radius: 7px; cursor: pointer; color: #94a3b8;
  font-size: 13.5px; font-weight: 500; transition: 0.15s;
}
.sub-item span { display: flex; align-items: center; gap: 10px; }
.sub-item i { width: 16px; text-align: center; font-size: 13px; color: #60a5fa; }
.sub-item:hover { background: #172a45; color: #ffffff; }
.sub-item.active { background: #2563eb !important; color: #ffffff !important; }
.sub-item.active i { color: #ffffff !important; }
.js-lock { font-size: 11px !important; color: #f59e0b !important; width: auto !important; }

.danger-nav { color: #fca5a5 !important; }
.danger-nav .menu-left i { color: #f87171 !important; }
.upgrade-nav { background: linear-gradient(90deg, #f59e0b, #ea580c) !important; color: #ffffff !important; margin-top: 6px; }

/* ==========================================
   MAIN AREA & GRADIENT NAVY BLUE HEADER
   ========================================== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: linear-gradient(90deg, #0a192f 0%, #112d57 55%, #1d4ed8 100%);
  color: #ffffff; border-bottom: 1px solid #1e3a8a; padding: 12px 24px;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  position: sticky; top: 0; z-index: 40; box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}
.header-school-info { display: flex; align-items: center; gap: 12px; }
.header-school-logo {
  height: 40px; width: 40px; border-radius: 8px; object-fit: cover;
  background: #ffffff; padding: 2px; border: 1.5px solid rgba(255, 255, 255, 0.35);
}
.header-default-icon {
  height: 38px; width: 38px; border-radius: 8px; background: rgba(255, 255, 255, 0.14);
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fbbf24;
}
.header-school-title { font-size: 16.5px; font-weight: 700; color: #ffffff; display: block; }
.header-user-email { font-size: 12px; color: #bfdbfe; }
.user-area { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.header-lang-select {
  padding: 6px 10px; border-radius: 7px; font-weight: 600; font-size: 12.5px;
  background: rgba(255, 255, 255, 0.15); color: #ffffff; border: 1px solid rgba(255, 255, 255, 0.3); cursor: pointer;
}
.header-lang-select option { color: #0f172a; background: #ffffff; }
.status-pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; background: #fee2e2; color: var(--danger); }
.status-pill.active { background: #dcfce7; color: var(--success); }
.sync-pill { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: #eff6ff; color: var(--primary); font-weight: 600; }

/* Buttons */
.btn { padding: 8px 14px; border: none; border-radius: 7px; font-weight: 600; cursor: pointer; font-size: 13px; transition: 0.15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: #d97706; color: #fff; }
.btn-upgrade { background: #f59e0b; color: #fff; }
.btn-outline { background: #fff; border: 1px solid #cbd5e1; color: var(--text); }
.btn-outline:hover { background: #f8fafc; }
.btn-header-logout { background: rgba(255, 255, 255, 0.15); color: #ffffff; border: 1px solid rgba(255, 255, 255, 0.3); }
.btn-header-logout:hover { background: rgba(239, 68, 68, 0.85); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Content & Cards */
.content { padding: 20px; flex: 1; overflow-y: auto; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; margin-bottom: 18px; box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; flex-wrap: wrap; gap: 10px; border-bottom: 1px solid var(--border); padding-bottom: 10px;
}
.card-header h2 { font-size: 17.5px; }
.muted-sm { font-size: 12px; color: var(--muted); }

/* Forms & Tables */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12.5px; font-weight: 600; color: #334155; }
.form-group input, .form-group select {
  padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13.5px; background: #fff;
}
.form-group input:disabled, .form-group select:disabled { background: #f1f5f9; color: #475569; cursor: not-allowed; }

.table-wrap { overflow-x: auto; border: 1px solid #cbd5e1; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
th, td { padding: 8px 9px; border: 1px solid #cbd5e1; text-align: left; color: #000; }
th { background: #f1f5f9; font-weight: 700; color: #0f172a; }

/* Subject Checkboxes & Filters */
.sub-category { margin-bottom: 14px; padding: 12px; background: #f8fafc; border-radius: 8px; border: 1px solid var(--border); }
.sub-category h4 { font-size: 13.5px; margin-bottom: 8px; color: var(--primary); }
.check-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip {
  display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #cbd5e1;
  padding: 5px 9px; border-radius: 6px; font-size: 12.5px; cursor: pointer;
}
.col-filter-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 12px; }
.bulk-bar {
  display: flex; align-items: center; gap: 10px; background: #fef3c7; border: 1px solid #f59e0b;
  padding: 8px 14px; border-radius: 8px; margin-bottom: 10px; flex-wrap: wrap;
}

/* Excel Grid */
.grid-scroll { max-height: 60vh; overflow: auto; border: 1px solid #cbd5e1; border-radius: 8px; }
.excel-table th { position: sticky; top: 0; z-index: 10; background: #0f172a; color: #fff; white-space: nowrap; font-size: 12px; }
.excel-table td { white-space: nowrap; padding: 4px 6px; font-size: 12.5px; }
.excel-input { width: 100%; min-width: 90px; padding: 4px 6px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 12.5px; }
.excel-input:focus { outline: 2px solid var(--primary); background: #eff6ff; }
.tt-cell select { width: 100%; padding: 4px; font-size: 12px; margin-bottom: 4px; border: 1px solid #cbd5e1; border-radius: 4px; }
.tt-break { background: #fef3c7; text-align: center; font-weight: 700; color: #92400e; }

/* Goswara & Tabs */
.goswara-table th { background: #0f172a; color: #fff; text-align: center; font-size: 12.5px; border: 1px solid #000; }
.goswara-table td { text-align: center; font-size: 13px; border: 1px solid #000; color: #000; }
.goswara-table td:first-child { text-align: left; font-weight: 600; }
.row-subtotal { background: #e0f2fe !important; font-weight: 700; }
.row-grandtotal { background: #fef08a !important; font-weight: 800; font-size: 13.5px; }
.tab-bar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }

/* Dashboard KPI & Charts */
.lock-banner-pro {
  background: linear-gradient(90deg, #eff6ff, #fef3c7); border: 1px solid #bfdbfe;
  padding: 16px 20px; border-radius: 12px; margin-bottom: 18px;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card { background: #fff; border-radius: 12px; padding: 16px 18px; border-left: 5px solid #2563eb; box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05); }
.kpi-blue { border-left-color: #2563eb; } .kpi-indigo { border-left-color: #4f46e5; }
.kpi-pink { border-left-color: #ec4899; } .kpi-green { border-left-color: #16a34a; }
.kpi-label { font-size: 12px; font-weight: 700; color: #64748b; text-transform: uppercase; }
.kpi-val { font-size: 26px; font-weight: 800; color: #0f172a; margin: 4px 0; }
.kpi-sub { font-size: 12px; color: #64748b; }
.charts-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 14px; }
.chart-title { font-size: 14px; font-weight: 700; color: #1e293b; margin-bottom: 10px; }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.65); display: none; justify-content: center; align-items: center; z-index: 100; padding: 15px; }
.modal { background: #fff; border-radius: 12px; max-width: 560px; width: 100%; padding: 22px; position: relative; max-height: 90vh; overflow-y: auto; }
.close-btn { position: absolute; top: 12px; right: 16px; font-size: 22px; cursor: pointer; color: var(--muted); }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
.plan-box { border: 2px solid var(--border); border-radius: 10px; padding: 14px; text-align: center; cursor: pointer; }
.plan-box.selected { border-color: var(--primary); background: #eff6ff; }
.price { font-size: 24px; font-weight: 700; color: var(--primary); margin: 6px 0; }
.tag { font-size: 11px; background: var(--success); color: #fff; padding: 2px 8px; border-radius: 10px; }

/* ==========================================
   PRINT & PDF STANDARD LAYOUTS (100% DARK, NO CUT-OFF)
   ========================================== */
.print-doc-header {
  text-align: center; margin-bottom: 10px; color: #000; width: 100%;
}
.print-school-name { font-size: 19px; font-weight: 800; color: #000; text-transform: uppercase; }
.print-codes-row {
  display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 700;
  color: #000; border-bottom: 1.5px solid #000; padding: 3px 2px 5px; margin-bottom: 6px;
}
.print-doc-title { font-size: 14.5px; font-weight: 800; color: #000; margin-top: 2px; }

/* 1. Admit Card (Exact 4 per A4 Landscape, Zero Cut-off) */
.admit-page {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, 1fr); gap: 8px;
  width: 100%; margin-bottom: 16px; break-after: page; page-break-after: always;
}
.admit-card {
  border: 1.8px solid #000; border-radius: 4px; padding: 8px; background: #fff;
  color: #000; font-size: 11px; display: flex; flex-direction: column; justify-content: space-between;
  overflow: hidden;
}
.admit-header { text-align: center; border-bottom: 1.5px solid #000; padding-bottom: 4px; margin-bottom: 5px; }
.admit-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; margin-bottom: 5px; font-size: 11px; }
.admit-tt { width: 100%; border-collapse: collapse; table-layout: fixed; }
.admit-tt th, .admit-tt td { padding: 2px 4px; font-size: 10px; border: 1px solid #000; color: #000; text-align: center; }
.admit-tt th { background: #e2e8f0; font-weight: 800; }
.admit-sign { display: flex; justify-content: space-between; margin-top: 12px; font-weight: 700; font-size: 10px; }

/* 2. Sitting Plan (Exact 1 Room Per Page, Equal Columns) */
.sp-room-page {
  background: #fff; border: 1px solid #94a3b8; border-radius: 8px; padding: 14px;
  margin-bottom: 20px; width: 100%; break-after: page; page-break-after: always;
}
.sp-room-page:last-child { break-after: auto; page-break-after: auto; }
.sp-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-top: 8px; }
.sp-table th, .sp-table td {
  border: 1.5px solid #000; text-align: center; padding: 5px 3px;
  font-size: 13px; font-weight: 700; color: #000; overflow-wrap: anywhere;
}
.sp-table th:first-child, .sp-table td.sp-sn { width: 38px; background: #000; color: #fff; }
.sp-table th { background: #000; color: #fff; }
.sp-cell-edit { cursor: pointer; background: #fffbeb; }
.sp-cell-empty { background: #fee2e2 !important; color: #991b1b; font-style: italic; font-size: 11px; }
.sp-total-bar { font-weight: 800; font-size: 14px; margin-top: 8px; color: #000; }

/* 3. Generate Slip (Proper Fit, No Right Cut-off) */
.slip-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
.slip-card { background: #fff; border: 1px solid #94a3b8; padding: 6px; break-inside: avoid; page-break-inside: avoid; }
.slip-card table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.slip-card th, .slip-card td { border: 1.5px solid #000; padding: 4px 5px; text-align: center; font-weight: 700; color: #000; overflow-wrap: anywhere; }
.slip-card th { background: #000; color: #fff; font-size: 13px; }
.slip-card td:first-child { text-align: left; width: 38%; font-size: 13px; }
.slip-roll-highlight { font-size: 18px !important; font-weight: 800 !important; background: #fef9c3; font-variant-numeric: tabular-nums; }

/* 4. Docket, Checklist & Attendance Sheet Print Tables */
.docket-page {
  background: #fff; border: 1px solid #94a3b8; border-radius: 8px; padding: 18px;
  margin-bottom: 20px; color: #000; break-after: page; page-break-after: always;
}
.docket-page:last-child { break-after: auto; page-break-after: auto; }
.docket-table, .att-table, .dual-tt-table {
  width: 100%; border-collapse: collapse; table-layout: fixed; margin-top: 8px;
}
.docket-table th, .docket-table td,
.att-table th, .att-table td,
.dual-tt-table th, .dual-tt-table td {
  border: 1.5px solid #000 !important; padding: 6px 4px; text-align: center;
  color: #000 !important; font-size: 12.5px; font-weight: 600;
}
.docket-table td.docket-remark-cell { height: 28px; }
.att-table th, .dual-tt-table th { background: #e2e8f0; font-weight: 800; }
.att-table td { height: 28px; font-size: 11.5px; }
.att-table td.text-left { text-align: left; padding-left: 6px; }
.docket-footer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 30px; margin-top: 16px; font-size: 13px; font-weight: 700; }
.docket-sign-row { display: flex; justify-content: space-between; margin-top: 28px; font-size: 13px; font-weight: 700; }

/* ==========================================
   GLOBAL PRINT RULES (CLEAN A4 MARGINS)
   ========================================== */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  html, body { width: 100%; background: #fff !important; color: #000 !important; margin: 0 !important; padding: 0 !important; display: block !important; }
  .sidebar, .topbar, .no-print { display: none !important; }
  .main, .content, .card { width: 100% !important; padding: 0 !important; margin: 0 !important; border: none !important; box-shadow: none !important; overflow: visible !important; }
  .admit-page { gap: 6mm; margin: 0; }
  .sp-room-page, .docket-page { border: none !important; padding: 0 !important; margin: 0 !important; }
  .slip-grid { gap: 4mm !important; width: 100% !important; }
  .slip-card { border: none !important; padding: 0 !important; }
  .sp-table th, .sp-table td.sp-sn, .slip-card th, .goswara-table th {
    background: #000 !important; color: #fff !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .admit-tt th, .att-table th, .dual-tt-table th {
    background: #e2e8f0 !important; color: #000 !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .slip-roll-highlight { background: #fef9c3 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sp-cell-empty { background: #fff !important; color: transparent !important; }
}

@media (max-width: 1000px) { .charts-grid { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  body { flex-direction: column; }
  .sidebar { width: 100% !important; height: auto; }
  .brand-box { padding: 6px; }
  .brand-logo-img { max-height: 36px; }
}
/* Full-Page 4-in-1 Admit Card Height Fix */
@media print {
  .admit-page {
    height: 186mm !important;
    grid-template-rows: 1fr 1fr !important;
    gap: 5mm !important;
    margin: 0 !important;
    page-break-after: always;
  }
  .admit-card {
    height: 100% !important;
    padding: 10px 12px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }
  .admit-sign {
    margin-top: auto !important;
    padding-top: 22px !important;
  }
}

/* Class 1-8 Annual Marksheet Styling (A4 Portrait Format) */
.ms-page {
  background: #fff;
  border: 2px solid #000;
  padding: 16px 20px;
  margin: 0 auto 24px;
  max-width: 820px;
  color: #000;
  break-after: page;
  page-break-after: always;
}
.ms-page:last-child { break-after: auto; page-break-after: auto; }
.ms-top-banner { text-align: center; margin-bottom: 10px; }
.ms-school-title { font-size: 21px; font-weight: 800; color: #000; text-transform: uppercase; }
.ms-sub-title { font-size: 17px; font-weight: 800; color: #000; margin: 3px 0; }
.ms-class-strip {
  display: inline-block; background: #334155; color: #fff;
  padding: 3px 28px; font-size: 14px; font-weight: 700; border-radius: 3px; margin-top: 4px;
}
.ms-info-box {
  border: 1.5px solid #000; padding: 8px 12px; margin-bottom: 10px;
  font-size: 12.5px; line-height: 1.75; color: #000;
}
.ms-tables-row { display: grid; grid-template-columns: 1.25fr 1fr; gap: 6px; margin-bottom: 10px; }
.ms-table { width: 100%; border-collapse: collapse; }
.ms-table th, .ms-table td {
  border: 1.5px solid #000 !important; padding: 4px 5px; font-size: 11.5px; color: #000; text-align: center; font-weight: 600;
}
.ms-table th { background: #475569; color: #fff; font-weight: 700; }
.ms-table td.left { text-align: left; padding-left: 6px; }
.ms-total-row td { background: #334155; color: #fff !important; font-weight: 800; }
.ms-sign-row {
  display: flex; justify-content: space-between; text-align: center;
  margin-top: 45px; font-size: 12.5px; font-weight: 700; color: #000;
}
@media print {
  .ms-page {
    border: 2px solid #000 !important;
    max-width: 100% !important;
    width: 100% !important;
    height: 276mm !important;
    margin: 0 !important;
    padding: 18px 22px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
  }
  .ms-page * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .ms-info-box {
    font-size: 13.5px !important;
    line-height: 2.05 !important;
    padding: 12px 16px !important;
  }
  .ms-table th, .ms-table td {
    padding: 7px 6px !important;
    font-size: 12.5px !important;
  }
  .ms-sign-row {
    margin-top: 60px !important;
    font-size: 13.5px !important;
  }
}
/* ==========================================
   DARK NAVY-BLACK FOOTER
   ========================================== */
.app-footer {
  background: linear-gradient(90deg, #0a0f1c 0%, #0f172a 60%, #112240 100%);
  color: #e2e8f0;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  border-top: 2px solid #1e3a8a;
  font-size: 13px;
}
.footer-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-logo-link {
  display: inline-flex;
  align-items: center;
}
.footer-logo-link img {
  height: 32px;
  width: auto;
  object-fit: contain;
  display: block;
}
.footer-copy {
  color: #cbd5e1;
  font-size: 13px;
}
.footer-copy b {
  color: #ffffff;
}
.footer-links {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}
.footer-links a {
  color: #e2e8f0;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}
.footer-links a:hover {
  color: #60a5fa;
  text-decoration: underline;
}