/* =====================================================
   Jacto Jio CRM — Editorial styling
   Warm cream + deep ink + terracotta accents
   ===================================================== */

:root {
  --bg: #F5F1E8;
  --bg-card: #FDFBF5;
  --bg-elev: #FFFFFF;
  --ink: #1A2B3C;
  --ink-soft: #4A5B6C;
  --ink-muted: #8A95A0;
  --line: #E5DFD0;
  --line-strong: #D1C8B0;
  --accent: #B85C2C;       /* terracotta */
  --accent-soft: #F4E4D6;
  --accent-deep: #8B3F1A;
  --gold: #C9962B;
  --green: #4A7B5C;
  --red: #B33A3A;
  --shadow-sm: 0 1px 2px rgba(26,43,60,.04);
  --shadow-md: 0 4px 16px rgba(26,43,60,.06);
  --shadow-lg: 0 12px 40px rgba(26,43,60,.10);
  --radius: 4px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Manrope', -apple-system, sans-serif;
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* Subtle paper texture overlay */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(26,43,60,.018) 1px, transparent 1px);
  background-size: 3px 3px;
  z-index: 0;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
  background: var(--ink);
  color: #E8E1D0;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 28px;
  margin-bottom: 28px;
  border-bottom: 1px solid rgba(232,225,208,.12);
}

.brand-mark {
  width: 42px; height: 42px;
  background: var(--accent);
  color: #FDFBF5;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -.02em;
}

.brand-text { display: flex; flex-direction: column; }
.brand-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -.02em;
  color: #FDFBF5;
}
.brand-sub {
  font-size: 11px;
  color: #8E8472;
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-top: 2px;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  background: transparent;
  border: none;
  color: #B5AC97;
  text-align: left;
  padding: 11px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all .15s ease;
}
.nav-item:hover { color: #FDFBF5; background: rgba(232,225,208,.05); }
.nav-item.active {
  color: #FDFBF5;
  background: rgba(184,92,44,.18);
}
.nav-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  opacity: .35;
}
.nav-item.active .nav-dot {
  background: var(--accent);
  opacity: 1;
  box-shadow: 0 0 8px var(--accent);
}

.sidebar-footer {
  padding-top: 24px;
  border-top: 1px solid rgba(232,225,208,.12);
}
.state-tag {
  display: inline-block;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  color: #FDFBF5;
  padding: 4px 0;
}
.footer-meta {
  font-size: 11px;
  color: #6E6655;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ===================== MAIN ===================== */
.main {
  padding: 40px 48px 80px;
  position: relative;
  z-index: 1;
  min-width: 0;
}

.view { display: none; animation: fadeIn .3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 36px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--ink-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.page-title {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 500;
  letter-spacing: -.025em;
  color: var(--ink);
  font-variation-settings: "opsz" 144;
}

.head-actions { display: flex; gap: 10px; }

/* ===================== BUTTONS ===================== */
.btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .15s ease;
  letter-spacing: .01em;
}
.btn-primary {
  background: var(--ink);
  color: #FDFBF5;
}
.btn-primary:hover { background: var(--accent-deep); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--ink); border-color: var(--ink); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid #E5C0C0;
}
.btn-danger:hover { background: var(--red); color: #FDFBF5; border-color: var(--red); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  width: 32px; height: 32px;
  border-radius: var(--radius);
  font-size: 22px;
  cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }

/* ===================== STAT CARDS ===================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 36px;
}

.stat-card {
  background: var(--bg-card);
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
.stat-card.accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #FDFBF5;
}
.stat-card.accent .stat-label,
.stat-card.accent .stat-sub { color: rgba(253,251,245,.75); }

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-muted);
  font-weight: 600;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 500;
  letter-spacing: -.03em;
  line-height: 1.1;
  font-variation-settings: "opsz" 144;
}
.stat-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* ===================== PANELS ===================== */
.two-col {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  padding: 26px 28px;
  margin-bottom: 24px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.panel h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -.015em;
  color: var(--ink);
}
.panel-sub {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-muted);
}

/* Group bars */
.group-bars { display: flex; flex-direction: column; gap: 18px; }
.group-row { display: flex; flex-direction: column; gap: 6px; }
.group-row-head {
  display: flex; justify-content: space-between;
  font-size: 13px; font-weight: 600;
}
.group-row-head .group-name { color: var(--ink); }
.group-row-head .group-count { color: var(--ink-muted); font-weight: 500; }
.bar-track {
  display: flex; gap: 2px; height: 32px;
}
.bar-cell {
  display: flex; align-items: center; padding: 0 10px;
  font-size: 11px; font-weight: 600; color: #FDFBF5;
  letter-spacing: .04em;
  min-width: 40px;
  transition: all .3s ease;
}
.bar-teachers { background: var(--ink); }
.bar-students { background: var(--accent); }

/* Pin list */
.pin-list { display: flex; flex-direction: column; }
.pin-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.pin-row:last-child { border-bottom: none; }
.pin-code {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--ink);
}
.pin-bar {
  height: 4px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.pin-bar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--accent);
}
.pin-num {
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Fee row */
.fee-row { display: flex; gap: 1px; background: var(--line); }
.fee-pill {
  flex: 1; padding: 18px;
  background: var(--bg-card);
  display: flex; flex-direction: column; gap: 4px;
}
.fee-pill .fee-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-muted);
  font-weight: 600;
}
.fee-pill .fee-num {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
}
.fee-pill.paid .fee-num { color: var(--green); }
.fee-pill.partial .fee-num { color: var(--gold); }
.fee-pill.pending .fee-num { color: var(--red); }

/* ===================== FILTER BAR ===================== */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-bar input,
.filter-bar select {
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease;
}
.filter-bar input:focus,
.filter-bar select:focus { border-color: var(--ink); }
.filter-bar input { min-width: 240px; flex: 1; }

/* ===================== TABLE ===================== */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--line);
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  padding: 14px 18px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-muted);
  font-weight: 700;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background .12s ease;
}
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td {
  padding: 14px 18px;
  color: var(--ink);
  vertical-align: middle;
}
.data-table td .row-name {
  font-weight: 600;
  font-size: 14px;
}
.data-table td .row-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.empty {
  text-align: center;
  padding: 60px 20px !important;
  color: var(--ink-muted);
  font-style: italic;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  border-radius: 99px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-eng { background: #E8EEF4; color: #2A4A6B; border-color: #C8D6E4; }
.badge-bio { background: #E4F0E8; color: #2D5C3E; border-color: #BFD8C8; }
.badge-com { background: #F4E8DC; color: #7A4818; border-color: #DCC4A8; }

.badge-active { background: #E4F0E8; color: #2D5C3E; }
.badge-inactive { background: #F0E4E4; color: #7C2D2D; }

.badge-paid { background: #E4F0E8; color: #2D5C3E; }
.badge-partial { background: #F8EFD0; color: #7C5C18; }
.badge-pending { background: #F0E4E4; color: #7C2D2D; }

.row-action {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  padding: 5px 11px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.row-action:hover { background: var(--ink); color: #FDFBF5; border-color: var(--ink); }

/* ===================== MODAL ===================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26,43,60,.45);
  backdrop-filter: blur(3px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  padding: 40px 20px;
  overflow-y: auto;
}
.modal-backdrop.active { display: flex; }

.modal {
  background: var(--bg-elev);
  width: 100%;
  max-width: 720px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn .25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-card);
}
.modal-head h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -.02em;
}

.form-section {
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
}
.form-section:last-of-type { border-bottom: none; }
.form-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 4px;
}
.form-section-note {
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 14px;
  font-style: italic;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  margin-top: 14px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}
.form-grid label.span-2 { grid-column: 1 / -1; }
.req { color: var(--accent); }

.form-grid input,
.form-grid select,
.form-grid textarea {
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  background: var(--bg-elev);
  font-weight: 500;
  outline: none;
  transition: border-color .15s ease;
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus { border-color: var(--ink); }
.form-grid textarea { resize: vertical; min-height: 50px; }

.modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 18px 28px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.modal-actions .spacer { flex: 1; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #FDFBF5;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transform: translateY(20px);
  transition: all .25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 16px 20px;
    gap: 16px;
  }
  .brand { padding: 0; margin: 0; border: none; }
  .nav { flex-direction: row; gap: 4px; flex-wrap: wrap; }
  .nav-item { padding: 8px 12px; font-size: 12px; }
  .sidebar-footer { display: none; }
  .main { padding: 24px 20px 60px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 16px; }
  .page-title { font-size: 32px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.span-2 { grid-column: auto; }
}
