@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #ac1f25;
  --primary-dark: #7e1419;
  --primary-darker: #530a0e;
  --primary-light: #fdf2f4;
  --primary-subtle: #fae8eb;
  --primary-glow: rgba(172, 31, 37, 0.18);
  
  --bs-primary: #ac1f25;
  --bs-primary-rgb: 172, 31, 37;
  --bs-font-sans-serif: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  --bg-app: #f4f6fa;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
}

body {
  font-family: var(--bs-font-sans-serif);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Header & Navbar */
.app-navbar {
  background: linear-gradient(135deg, #530a0e 0%, #ac1f25 60%, #87161b 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px rgba(83, 10, 14, 0.15);
}

.brand-emblem {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

/* Mobile Offcanvas Drawer */
.mobile-offcanvas {
  background: linear-gradient(180deg, #530a0e 0%, #7e1419 40%, #ac1f25 100%);
  width: 310px !important;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.35);
}

.mobile-offcanvas .nav-link {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
}

.mobile-offcanvas .nav-link:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  transform: translateX(3px);
}

.mobile-offcanvas .nav-link.active {
  background: #ffffff;
  color: var(--primary-darker) !important;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* App Body & Sidebar Layout */
.app-body-wrapper {
  display: flex;
  min-height: calc(100vh - 57px);
  position: relative;
  background-color: var(--bg-app);
}

/* Desktop Left Sidebar */
.app-sidebar {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  position: sticky;
  top: 57px;
  height: calc(100vh - 57px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  z-index: 1000;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
}

.app-sidebar::-webkit-scrollbar {
  width: 5px;
}
.app-sidebar::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
}

.sidebar-category-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 8px 12px 4px;
}

.sidebar-nav-list {
  gap: 3px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-link {
  color: #475569;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.18s ease;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  text-decoration: none;
}

.sidebar-link i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: #64748b;
  transition: color 0.18s ease;
}

.sidebar-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.sidebar-link:hover i {
  color: var(--primary);
}

.sidebar-link.active {
  background: var(--primary) !important;
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(172, 31, 37, 0.25);
}

.sidebar-link.active i {
  color: #ffffff !important;
}

/* Main Content Area */
.main-content-wrapper {
  min-width: 0; /* Prevents flex overflow issues with wide tables */
  max-width: 100%;
  flex: 1;
}

/* Premium Card Components */
.premium-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03), 0 1px 3px rgba(15, 23, 42, 0.02);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 24px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .premium-card {
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 12px;
  }
}

.premium-card:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.card-title-lg {
  font-size: 17.5px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.3px;
  margin-bottom: 2px;
}

.card-subtitle-custom {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* Stat & Metric Cards */
.stat-card-custom {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}
.stat-card-custom:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(172, 31, 37, 0.08);
}
.stat-card-custom::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3.5px;
  background: var(--primary);
}
.stat-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

/* Custom Buttons */
.btn-primary-custom {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13.5px;
  box-shadow: 0 2px 6px rgba(172, 31, 37, 0.25);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary-custom:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(172, 31, 37, 0.35);
  transform: translateY(-1px);
}

.btn-secondary-custom {
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  color: #334155;
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13.5px;
  transition: all 0.2s ease;
}
.btn-secondary-custom:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Form Controls */
.form-label-custom {
  font-size: 12.5px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 5px;
}

.form-control-custom, .form-select-custom {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--text-main);
  background-color: #ffffff;
  transition: all 0.15s ease;
}
.form-control-custom:focus, .form-select-custom:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  outline: none;
}

/* Marks Spreadsheet Grid (Frozen Header & Sticky Columns) */
.marks-grid-wrapper {
  max-height: 68vh;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  position: relative;
  background: #ffffff;
  -webkit-overflow-scrolling: touch;
}

.marks-table-custom {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13.5px;
  margin-bottom: 0;
}

.marks-table-custom th, .marks-table-custom td {
  border-width: 0 1px 1px 0;
  border-color: var(--border-color);
  padding: 8px 10px;
  vertical-align: middle;
}

.marks-table-custom thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary-light);
  color: var(--primary-darker);
  font-weight: 700;
  font-size: 12.5px;
}
.marks-table-custom thead tr:nth-child(2) th {
  top: 36px;
  z-index: 10;
}

.marks-table-custom .sticky-col-1,
.marks-table-custom .sticky-col-2,
.marks-table-custom .sticky-col-3 {
  position: sticky;
  background: #ffffff;
}

.marks-table-custom td.sticky-col-1,
.marks-table-custom td.sticky-col-2,
.marks-table-custom td.sticky-col-3 {
  z-index: 5;
}

.marks-table-custom th.sticky-col-1,
.marks-table-custom th.sticky-col-2,
.marks-table-custom th.sticky-col-3 {
  z-index: 15;
  background: var(--primary-subtle);
}

.marks-table-custom .sticky-col-1 { left: 0; width: 44px; min-width: 44px; text-align: center; }
.marks-table-custom .sticky-col-2 { left: 44px; width: 130px; min-width: 130px; }
.marks-table-custom .sticky-col-3 { left: 174px; min-width: 160px; }

.marks-table-custom tbody tr:nth-child(even) td.sticky-col-1,
.marks-table-custom tbody tr:nth-child(even) td.sticky-col-2,
.marks-table-custom tbody tr:nth-child(even) td.sticky-col-3 {
  background: #fafbfc;
}

.marks-input-field {
  width: 65px;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
  font-weight: 600;
  transition: all 0.15s ease;
}
.marks-input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
  outline: none;
}

/* Map Cells */
.map-cell {
  width: 48px;
  text-align: center !important;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  transition: background 0.15s;
  border-radius: 6px;
}
.map-cell.m3 { background: var(--primary) !important; color: #ffffff !important; }
.map-cell.m2 { background: #df585e !important; color: #ffffff !important; }
.map-cell.m1 { background: #fbebee !important; color: var(--primary-dark) !important; }
.map-cell.m0 { color: #94a3b8; }
.map-cell:hover { opacity: 0.88; transform: scale(0.96); }

/* Document & Reports Container */
.report-sheet-view {
  background: #ffffff;
  padding: 44px 50px;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  font-size: 13.5px;
  max-width: 960px;
  margin: 0 auto;
  border: 1px solid var(--border-color);
}
@media (max-width: 768px) {
  .report-sheet-view {
    padding: 20px 16px;
  }
}

.doc-brand-header {
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 3px double var(--primary);
  padding-bottom: 14px;
  margin-bottom: 18px;
}
.doc-brand-logo {
  width: 58px;
  height: 58px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--primary);
  font-size: 15px;
  flex-shrink: 0;
}

/* Toast Notifications */
.toast-container-custom {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1080;
}

/* Print Styles */
@media print {
  .app-navbar, .app-sidebar, .nav-tabs-wrapper, .no-print, footer, .toast-container, .btn, .mobile-offcanvas {
    display: none !important;
  }
  body { background: #ffffff !important; }
  .app-body-wrapper { display: block !important; }
  .main-content-wrapper, main { max-width: 100% !important; padding: 0 !important; width: 100% !important; }
  section.tab { display: none !important; }
  section#tab-docs { display: block !important; }
  .report-sheet-view { box-shadow: none !important; padding: 0 !important; border: none !important; }
  .premium-card { box-shadow: none !important; border: none !important; }
  input, textarea, select { border: none !important; }
}
