/* ===================================================================
   Sat-Crop School Management System — Design System
   =================================================================== */

:root{
  --brand-1: #4f46e5;
  --brand-2: #7c3aed;
  --brand-3: #06b6d4;
  --brand-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #06b6d4 100%);
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-blue: #3b82f6;
  --accent-pink: #ec4899;

  --bg: #f4f5fb;
  --bg-elevated: #ffffff;
  --bg-soft: #eef0fb;
  --border: #e5e7f2;
  --text-1: #14162b;
  --text-2: #565a75;
  --text-3: #8a8ea8;
  --sidebar-bg: #14152b;
  --sidebar-text: #b9bbd6;
  --shadow-sm: 0 1px 2px rgba(20,22,43,.06);
  --shadow-md: 0 8px 24px rgba(20,22,43,.08);
  --shadow-lg: 0 16px 48px rgba(20,22,43,.14);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
}

[data-theme="dark"]{
  --bg: #0f1022;
  --bg-elevated: #181934;
  --bg-soft: #1f2142;
  --border: #2b2d55;
  --text-1: #f2f2fb;
  --text-2: #b6b8d6;
  --text-3: #7c7fa3;
  --sidebar-bg: #0b0c1c;
  --sidebar-text: #9a9dc4;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.45);
}

*,*::before,*::after{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
a{ color: inherit; text-decoration: none; }
ul{ list-style: none; margin:0; padding:0; }
button{ font-family: inherit; cursor: pointer; }
input, select, textarea{ font-family: inherit; }
::-webkit-scrollbar{ width:8px; height:8px; }
::-webkit-scrollbar-thumb{ background: var(--border); border-radius: 8px; }

/* ---------- Loading Splash ---------- */
#splash{
  position: fixed; inset:0; z-index: 9999;
  background: var(--brand-gradient);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:16px;
  color:#fff; transition: opacity .5s ease, visibility .5s ease;
}
#splash .splash-logo{
  width:84px; height:84px; border-radius: 22px; background: rgba(255,255,255,.15);
  display:flex; align-items:center; justify-content:center; font-size:38px; font-weight:800;
  backdrop-filter: blur(6px); box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: floaty 2.4s ease-in-out infinite;
}
#splash .splash-logo img{ width:58px; height:58px; }
@keyframes floaty{ 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-10px);} }
#splash h1{ margin:0; font-size:22px; font-weight:800; letter-spacing:.2px; }
#splash p{ margin:0; opacity:.85; font-size:13px; }
#splash.hidden{ opacity:0; visibility:hidden; pointer-events:none; }

/* ---------- Auth Screen ---------- */
#authScreen{
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  background: var(--brand-gradient); padding:20px; position:relative; overflow:hidden;
}
#authScreen::before, #authScreen::after{
  content:""; position:absolute; border-radius:50%; background: rgba(255,255,255,.08);
}
#authScreen::before{ width:480px; height:480px; top:-160px; left:-160px; }
#authScreen::after{ width:360px; height:360px; bottom:-140px; right:-100px; }
.auth-card{
  position:relative; z-index:1; width:100%; max-width:960px; background: var(--bg-elevated);
  border-radius: 28px; box-shadow: var(--shadow-lg); display:grid; grid-template-columns: 1.1fr 1fr; overflow:hidden;
}
.auth-hero{
  background: linear-gradient(160deg, rgba(79,70,229,.95), rgba(124,58,237,.9)), url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400"><circle cx="50" cy="50" r="2" fill="white" opacity="0.3"/></svg>');
  color:#fff; padding:48px 40px; display:flex; flex-direction:column; justify-content:space-between; gap:24px;
}
.auth-hero .brand{ display:flex; align-items:center; gap:12px; font-weight:800; font-size:20px; }
.auth-hero .brand .logo-mark{ width:44px; height:44px; border-radius:12px; background: rgba(255,255,255,.18); display:flex; align-items:center; justify-content:center; font-weight:900; }
.auth-hero .brand .logo-mark img{ width:30px; height:30px; }
.auth-hero h2{ font-size:30px; line-height:1.25; margin:0; font-weight:800; }
.auth-hero p{ opacity:.85; margin:0; font-size:14px; line-height:1.6; }
.auth-hero .feature-list{ display:flex; flex-direction:column; gap:10px; }
.auth-hero .feature-list li{ display:flex; align-items:center; gap:10px; font-size:13.5px; opacity:.92; }
.auth-hero .feature-list li .dot{ width:20px; height:20px; border-radius:6px; background: rgba(255,255,255,.2); display:flex; align-items:center; justify-content:center; font-size:11px; }

.auth-form{ padding:44px 40px; display:flex; flex-direction:column; gap:18px; }
.auth-form h3{ margin:0; font-size:24px; font-weight:800; }
.auth-form .muted{ color: var(--text-2); font-size:13.5px; margin-top:-10px; }
.role-grid{ display:grid; grid-template-columns: repeat(2,1fr); gap:10px; }
.role-card{
  border:1.5px solid var(--border); border-radius: 14px; padding:14px 12px; display:flex; flex-direction:column;
  align-items:center; gap:6px; background: var(--bg-soft); transition: all .18s ease;
}
.role-card:hover{ transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.role-card.active{ border-color: var(--brand-1); background: linear-gradient(135deg, rgba(79,70,229,.12), rgba(124,58,237,.12)); }
.role-card .emoji{ font-size:22px; }
.role-card span{ font-size:12.5px; font-weight:700; color: var(--text-1); }

.field{ display:flex; flex-direction:column; gap:6px; }
.field label{ font-size:12.5px; font-weight:700; color: var(--text-2); }
.field input, .field select{
  border:1.5px solid var(--border); border-radius:12px; padding:11px 13px; font-size:14px;
  background: var(--bg-soft); color: var(--text-1); outline:none; transition: border-color .15s ease;
}
.field input:focus, .field select:focus{ border-color: var(--brand-1); }

.btn{
  border:none; border-radius:12px; padding:12px 18px; font-weight:700; font-size:14px;
  display:inline-flex; align-items:center; justify-content:center; gap:8px; transition: all .15s ease;
}
.btn-primary{ background: var(--brand-gradient); color:#fff; box-shadow: 0 10px 24px rgba(79,70,229,.35); }
.btn-primary:hover{ filter: brightness(1.06); transform: translateY(-1px); }
.btn-outline{ background: transparent; border:1.5px solid var(--border); color: var(--text-1); }
.btn-outline:hover{ border-color: var(--brand-1); color: var(--brand-1); }
.btn-soft{ background: var(--bg-soft); color: var(--text-1); }
.btn-soft:hover{ background: var(--border); }
.btn-danger{ background: rgba(239,68,68,.1); color: var(--accent-red); }
.btn-danger:hover{ background: rgba(239,68,68,.18); }
.btn-sm{ padding:7px 12px; font-size:12.5px; border-radius:9px; }
.btn-icon{ width:38px; height:38px; border-radius:11px; padding:0; }

/* ---------- App Shell ---------- */
#app{ display:none; min-height:100vh; }
#app.active{ display:flex; }

.sidebar{
  width:264px; background: var(--sidebar-bg); color: var(--sidebar-text); flex-shrink:0;
  display:flex; flex-direction:column; height:100vh; position:sticky; top:0; overflow-y:auto; z-index:40;
  transition: transform .25s ease;
}
.sidebar-brand{ display:flex; align-items:center; gap:12px; padding:22px 20px 18px; }
.sidebar-brand .logo-mark{ width:40px; height:40px; border-radius:11px; background: var(--brand-gradient); display:flex; align-items:center; justify-content:center; font-weight:900; color:#fff; font-size:16px; flex-shrink:0; }
.sidebar-brand .txt strong{ display:block; color:#fff; font-size:14.5px; font-weight:800; line-height:1.2; }
.sidebar-brand .txt span{ font-size:11px; opacity:.65; }

.sidebar-section-label{ padding: 14px 20px 6px; font-size:10.5px; text-transform:uppercase; letter-spacing:.08em; opacity:.5; font-weight:700; }
.nav-item{
  display:flex; align-items:center; gap:12px; padding:10px 20px; margin:1px 10px; border-radius:11px;
  font-size:13.5px; font-weight:600; color: var(--sidebar-text); transition: all .15s ease; cursor:pointer; position:relative;
}
.nav-item .ic{ width:20px; height:20px; flex-shrink:0; display:flex; align-items:center; justify-content:center; opacity:.85; }
.nav-item:hover{ background: rgba(255,255,255,.06); color:#fff; }
.nav-item.active{ background: var(--brand-gradient); color:#fff; box-shadow: 0 6px 18px rgba(79,70,229,.35); }
.nav-item .badge{ margin-left:auto; background: rgba(255,255,255,.15); font-size:10.5px; padding:2px 7px; border-radius:20px; font-weight:700; }

.sidebar-footer{ margin-top:auto; padding:16px 20px; border-top:1px solid rgba(255,255,255,.08); display:flex; align-items:center; gap:10px; }
.avatar{
  width:36px; height:36px; border-radius:50%; background: var(--brand-gradient); color:#fff; font-weight:800;
  font-size:13px; display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.sidebar-footer .who{ overflow:hidden; }
.sidebar-footer .who strong{ display:block; color:#fff; font-size:12.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sidebar-footer .who span{ font-size:10.5px; opacity:.6; }

.main-wrap{ flex:1; min-width:0; display:flex; flex-direction:column; }

.topbar{
  height:68px; display:flex; align-items:center; gap:14px; padding:0 26px; background: var(--bg-elevated);
  border-bottom:1px solid var(--border); position:sticky; top:0; z-index:30;
}
.topbar .menu-toggle{ display:none; }
.topbar .page-title{ font-size:18px; font-weight:800; }
.topbar .page-sub{ font-size:12px; color: var(--text-3); margin-top:1px; }
.search-box{
  flex:1; max-width:360px; display:flex; align-items:center; gap:8px; background: var(--bg-soft);
  border:1.5px solid transparent; border-radius:12px; padding:9px 13px; color: var(--text-2); margin-left:10px;
}
.search-box input{ border:none; background:transparent; outline:none; width:100%; font-size:13.5px; color: var(--text-1); }
.topbar-actions{ margin-left:auto; display:flex; align-items:center; gap:10px; }
.icon-btn{
  width:40px; height:40px; border-radius:12px; background: var(--bg-soft); border:none; display:flex;
  align-items:center; justify-content:center; color: var(--text-2); position:relative; transition: all .15s ease;
}
.icon-btn:hover{ background: var(--border); color: var(--text-1); }
.icon-btn .dot-badge{ position:absolute; top:6px; right:6px; width:8px; height:8px; border-radius:50%; background: var(--accent-red); border:2px solid var(--bg-elevated); }

.content{ padding:26px; max-width:1500px; width:100%; margin:0 auto; }

/* ---------- Cards & Grids ---------- */
.grid{ display:grid; gap:18px; }
.grid-4{ grid-template-columns: repeat(4,1fr); }
.grid-3{ grid-template-columns: repeat(3,1fr); }
.grid-2{ grid-template-columns: repeat(2,1fr); }
@media (max-width: 1200px){ .grid-4{ grid-template-columns: repeat(2,1fr);} .grid-3{ grid-template-columns: repeat(2,1fr);} }
@media (max-width: 700px){ .grid-4,.grid-3,.grid-2{ grid-template-columns: 1fr; } }

.card{
  background: var(--bg-elevated); border:1px solid var(--border); border-radius: var(--radius-md);
  padding:20px; box-shadow: var(--shadow-sm);
}
.card-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; gap:10px; flex-wrap:wrap; }
.card-head h3{ margin:0; font-size:15.5px; font-weight:800; }
.card-head .sub{ font-size:12px; color: var(--text-3); margin-top:2px; }

.stat-card{ position:relative; overflow:hidden; }
.stat-card .icon-wrap{
  width:44px; height:44px; border-radius:13px; display:flex; align-items:center; justify-content:center; font-size:20px; margin-bottom:14px;
}
.stat-card .value{ font-size:26px; font-weight:800; line-height:1; margin-bottom:6px; }
.stat-card .label{ font-size:12.5px; color: var(--text-2); font-weight:600; }
.stat-card .trend{ position:absolute; top:20px; right:20px; font-size:11.5px; font-weight:700; padding:3px 9px; border-radius:20px; }
.trend.up{ color: var(--accent-green); background: rgba(16,185,129,.12); }
.trend.down{ color: var(--accent-red); background: rgba(239,68,68,.12); }

.bg-indigo{ background: rgba(79,70,229,.12); color: var(--brand-1); }
.bg-purple{ background: rgba(124,58,237,.12); color: var(--brand-2); }
.bg-cyan{ background: rgba(6,182,212,.12); color: var(--brand-3); }
.bg-green{ background: rgba(16,185,129,.12); color: var(--accent-green); }
.bg-amber{ background: rgba(245,158,11,.12); color: var(--accent-amber); }
.bg-red{ background: rgba(239,68,68,.12); color: var(--accent-red); }
.bg-pink{ background: rgba(236,72,153,.12); color: var(--accent-pink); }
.bg-blue{ background: rgba(59,130,246,.12); color: var(--accent-blue); }

/* ---------- Tables ---------- */
.table-wrap{ overflow-x:auto; }
table{ width:100%; border-collapse: collapse; font-size:13.5px; }
thead th{
  text-align:left; padding:10px 14px; font-size:11px; text-transform:uppercase; letter-spacing:.05em;
  color: var(--text-3); font-weight:700; border-bottom:1.5px solid var(--border); white-space:nowrap;
}
tbody td{ padding:12px 14px; border-bottom:1px solid var(--border); white-space:nowrap; }
tbody tr:last-child td{ border-bottom:none; }
tbody tr{ transition: background .12s ease; }
tbody tr:hover{ background: var(--bg-soft); }
.cell-user{ display:flex; align-items:center; gap:10px; }
.cell-user .avatar{ width:32px; height:32px; font-size:11.5px; }
.cell-user .nm{ font-weight:700; font-size:13px; }
.cell-user .sub{ font-size:11.5px; color: var(--text-3); }

.pill{ display:inline-flex; align-items:center; gap:5px; padding:4px 11px; border-radius:20px; font-size:11.5px; font-weight:700; }
.pill.green{ background: rgba(16,185,129,.12); color: var(--accent-green); }
.pill.amber{ background: rgba(245,158,11,.12); color: var(--accent-amber); }
.pill.red{ background: rgba(239,68,68,.12); color: var(--accent-red); }
.pill.blue{ background: rgba(59,130,246,.12); color: var(--accent-blue); }
.pill.gray{ background: var(--bg-soft); color: var(--text-2); }

.toolbar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:16px; }
.toolbar .search-box{ margin-left:0; max-width:280px; }
.toolbar select{ border:1.5px solid var(--border); border-radius:11px; padding:9px 12px; background: var(--bg-soft); color: var(--text-1); font-size:13px; }
.toolbar .spacer{ flex:1; }

.tabs{ display:flex; gap:4px; background: var(--bg-soft); padding:4px; border-radius:12px; width:fit-content; }
.tab-btn{ padding:8px 16px; border:none; background:transparent; border-radius:9px; font-size:12.5px; font-weight:700; color: var(--text-2); }
.tab-btn.active{ background: var(--bg-elevated); color: var(--brand-1); box-shadow: var(--shadow-sm); }

.empty-state{ text-align:center; padding:50px 20px; color: var(--text-3); }
.empty-state .emoji{ font-size:38px; margin-bottom:10px; }

/* ---------- Modal ---------- */
.modal-overlay{
  position:fixed; inset:0; background: rgba(10,10,25,.55); backdrop-filter: blur(3px); z-index:100;
  display:flex; align-items:center; justify-content:center; padding:20px; opacity:0; pointer-events:none; transition: opacity .2s ease;
}
.modal-overlay.open{ opacity:1; pointer-events:auto; }
.modal{
  background: var(--bg-elevated); border-radius: var(--radius-lg); width:100%; max-width:560px; max-height:88vh;
  overflow-y:auto; box-shadow: var(--shadow-lg); transform: translateY(14px); transition: transform .2s ease;
}
.modal-overlay.open .modal{ transform: translateY(0); }
.modal-head{ display:flex; align-items:center; justify-content:space-between; padding:20px 22px; border-bottom:1px solid var(--border); position:sticky; top:0; background: var(--bg-elevated); }
.modal-head h3{ margin:0; font-size:16.5px; font-weight:800; }
.modal-body{ padding:22px; display:flex; flex-direction:column; gap:14px; }
.modal-foot{ padding:16px 22px; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:10px; }
.form-row{ display:grid; grid-template-columns: 1fr 1fr; gap:12px; }
@media (max-width:520px){ .form-row{ grid-template-columns: 1fr; } .role-grid{ grid-template-columns: 1fr 1fr; } }

/* ---------- Toast ---------- */
#toastHost{ position:fixed; bottom:24px; right:24px; z-index:200; display:flex; flex-direction:column; gap:10px; }
.toast{
  background: var(--bg-elevated); border:1px solid var(--border); box-shadow: var(--shadow-lg); border-radius:13px;
  padding:13px 16px; display:flex; align-items:center; gap:10px; font-size:13.5px; font-weight:600; min-width:260px;
  animation: slideIn .25s ease; border-left:4px solid var(--brand-1);
}
.toast.success{ border-left-color: var(--accent-green); }
.toast.error{ border-left-color: var(--accent-red); }
@keyframes slideIn{ from{ transform: translateX(30px); opacity:0;} to{ transform: translateX(0); opacity:1; } }

/* ---------- Mobile bottom nav ---------- */
.bottom-nav{ display:none; }

@media (max-width: 980px){
  .sidebar{ position:fixed; left:0; top:0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open{ transform: translateX(0); }
  .sidebar-overlay{ display:none; position:fixed; inset:0; background: rgba(0,0,0,.4); z-index:39; }
  .sidebar-overlay.show{ display:block; }
  .topbar .menu-toggle{ display:flex; }
  .content{ padding:16px 16px 90px; }
  .auth-card{ grid-template-columns: 1fr; }
  .auth-hero{ display:none; }
  .bottom-nav{
    display:flex; position:fixed; bottom:0; left:0; right:0; height:64px; background: var(--bg-elevated);
    border-top:1px solid var(--border); z-index:40; align-items:center; justify-content:space-around; padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav .bn-item{ display:flex; flex-direction:column; align-items:center; gap:3px; font-size:9.5px; font-weight:700; color: var(--text-3); flex:1; }
  .bottom-nav .bn-item.active{ color: var(--brand-1); }
  .bottom-nav .bn-item .ic{ font-size:18px; }
}

/* ---------- Misc ---------- */
.section-title{ font-size:15.5px; font-weight:800; margin: 4px 0 14px; }
.muted{ color: var(--text-2); }
.small{ font-size:12px; }
.flex{ display:flex; align-items:center; }
.gap-8{ gap:8px; } .gap-10{ gap:10px; } .gap-14{ gap:14px; }
.between{ justify-content:space-between; }
.progress-bar{ height:8px; border-radius:20px; background: var(--bg-soft); overflow:hidden; }
.progress-bar > div{ height:100%; border-radius:20px; background: var(--brand-gradient); }
.chart-wrap{ position:relative; height:260px; }
.chart-wrap.sm{ height:200px; }
.list-row{ display:flex; align-items:center; gap:12px; padding:11px 0; border-bottom:1px solid var(--border); }
.list-row:last-child{ border-bottom:none; }
.chip{ padding:3px 10px; border-radius:20px; font-size:11px; font-weight:700; background: var(--bg-soft); color: var(--text-2); }

.fade-in{ animation: fadeIn .25s ease; }
@keyframes fadeIn{ from{ opacity:0; transform: translateY(6px); } to{ opacity:1; transform: translateY(0); } }

.calendar-grid{ display:grid; grid-template-columns: repeat(7,1fr); gap:6px; }
.calendar-cell{ aspect-ratio:1; border-radius:9px; background: var(--bg-soft); display:flex; align-items:center; justify-content:center; font-size:11.5px; font-weight:700; color: var(--text-2); }
.calendar-cell.present{ background: rgba(16,185,129,.15); color: var(--accent-green); }
.calendar-cell.absent{ background: rgba(239,68,68,.15); color: var(--accent-red); }
.calendar-cell.late{ background: rgba(245,158,11,.15); color: var(--accent-amber); }

.timetable-grid{ display:grid; grid-template-columns: 90px repeat(6,1fr); gap:6px; font-size:12px; }
.timetable-grid .tt-head{ font-weight:800; text-align:center; padding:8px 4px; color: var(--text-2); }
.timetable-grid .tt-time{ font-weight:700; color: var(--text-3); display:flex; align-items:center; padding:8px 4px; font-size:11px; }
.timetable-grid .tt-cell{ background: var(--bg-soft); border-radius:9px; padding:8px 6px; text-align:center; }
.timetable-grid .tt-cell .sub{ font-weight:700; font-size:11.5px; color: var(--text-1); }
.timetable-grid .tt-cell .tch{ font-size:10px; color: var(--text-3); margin-top:2px; }

@media print{ .sidebar,.topbar,.bottom-nav{ display:none !important; } }
