/* ─── MAJA BOOKS v3 ─────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --brand: #1B3A6B;
  --brand-bg: #F4F6FB;
  --accent: #4A7FC1;
  --sidebar-bg: #1B3A6B;
  --sidebar-text: #ffffff;
  --green: #166534; --green-bg: #DCFCE7;
  --amber: #92400E; --amber-bg: #FEF3C7;
  --red: #991B1B; --red-bg: #FEE2E2;
  --blue: #1E40AF; --blue-bg: #DBEAFE;
  --purple: #5B21B6; --purple-bg: #EDE9FE;
  --gray: #374151; --gray-bg: #F3F4F6;
  --border: rgba(0,0,0,0.08);
  --border-md: rgba(0,0,0,0.14);
  --bg: #ffffff;
  --bg2: #F9FAFB;
  --bg3: #F3F4F6;
  --text: #111827;
  --text2: #6B7280;
  --text3: #9CA3AF;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body { font-family: 'DM Sans', system-ui, sans-serif; font-size: 13px; color: var(--text); background: var(--brand-bg); height: 100vh; display: flex; overflow: hidden; }

/* ─── AUTH SCREEN ─── */
#auth-screen { position: fixed; inset: 0; background: var(--brand-bg); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.auth-card { background: var(--bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: 2.5rem; width: 380px; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 1.5rem; }
.auth-logo-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--brand); display: flex; align-items: center; justify-content: center; }
.auth-title { font-size: 1.4rem; font-weight: 600; color: var(--brand); }
.auth-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.auth-form h2 { font-size: 16px; font-weight: 500; margin-bottom: 1.25rem; }
.auth-switch { text-align: center; margin-top: 1rem; font-size: 12px; color: var(--text2); }
.auth-switch a { color: var(--brand); cursor: pointer; text-decoration: none; font-weight: 500; }

/* ─── LAYOUT ─── */
#app { flex-direction: column !important; }
.app-body { display: flex; flex: 1; overflow: hidden; }
#app { display: flex; width: 100%; height: 100vh; overflow: hidden; }
.app-body { display: flex; flex: 1; overflow: hidden; }
.sidebar { width: 210px; background: var(--sidebar-bg); display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; transition: width .2s; }
.sidebar-header { padding: 16px 14px 12px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand { display: flex; align-items: center; gap: 9px; }
.sidebar-logo { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,0.15); display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.sidebar-logo img { width: 32px; height: 32px; object-fit: cover; border-radius: 8px; }
.sidebar-name { font-size: 14px; font-weight: 600; color: var(--sidebar-text); }
.sidebar-sub { font-size: 10px; color: rgba(255,255,255,0.5); margin-top: 1px; }
.sidebar-section { padding: 14px 14px 4px; font-size: 9px; font-weight: 600; color: var(--sidebar-section-color, rgba(255,255,255,0.35)); text-transform: uppercase; letter-spacing: .08em; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; margin: 1px 8px; border-radius: var(--radius); cursor: pointer; color: var(--sidebar-item-color, rgba(255,255,255,0.65)); font-size: 12px; border: none; background: none; width: calc(100% - 16px); text-align: left; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--sidebar-item-hover, rgba(255,255,255,0.1)); color: var(--sidebar-name-color, #fff); }
.nav-item.active { background: var(--sidebar-item-active, rgba(255,255,255,0.18)); color: var(--sidebar-name-color, #fff); font-weight: 500; }
.nav-item i { font-size: 15px; flex-shrink: 0; width: 18px; }
.sidebar-bottom { margin-top: auto; padding: 12px 8px; border-top: 1px solid rgba(128,128,128,0.2); }
.nav-item-sm { padding: 6px 10px; font-size: 11px; }

/* ─── MAIN ─── */
.main { flex: 1; display: flex; flex-direction: column; overflow: auto; min-width: 0; }
.topbar { background: var(--bg); border-bottom: 1px solid var(--border); padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 10px; box-shadow: var(--shadow); }
.topbar-left h1 { font-size: 15px; font-weight: 600; }
.topbar-left p { font-size: 11px; color: var(--text2); margin-top: 1px; }
.topbar-right { display: flex; gap: 6px; align-items: center; }
.content { flex: 1; overflow-y: auto; padding: 18px 20px; }

/* ─── COMPONENTS ─── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--bg); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.stat-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; margin-bottom: 8px; }
.stat-label { font-size: 11px; color: var(--text2); margin-bottom: 4px; }
.stat-value { font-size: 19px; font-weight: 600; }
.stat-sub { font-size: 10px; color: var(--text3); margin-top: 2px; }

.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-title { font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }

.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.g4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; }

.fr { margin-bottom: 8px; }
.fr label { display: block; font-size: 11px; font-weight: 500; color: var(--text2); margin-bottom: 3px; }
input, select, textarea { width: 100%; height: 32px; padding: 0 10px; border: 1px solid var(--border-md); border-radius: var(--radius); background: var(--bg); color: var(--text); font-size: 12px; font-family: inherit; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(27,58,107,0.08); }
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }

.btn { height: 32px; padding: 0 14px; border: 1px solid var(--border-md); border-radius: var(--radius); background: var(--bg); color: var(--text); font-size: 12px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-family: inherit; transition: all .15s; white-space: nowrap; }
.btn:hover { background: var(--bg2); border-color: var(--border-md); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-success { background: var(--green-bg); color: var(--green); border-color: #86EFAC; }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: #FCA5A5; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 11px; }
.btn-xs { height: 22px; padding: 0 8px; font-size: 10px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { width: 30px; height: 30px; padding: 0; justify-content: center; border-radius: var(--radius); }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 500; white-space: nowrap; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-purple { background: var(--purple-bg); color: var(--purple); }
.b-gray { background: var(--gray-bg); color: var(--gray); }

/* ─── TABLE ─── */
.table-wrap { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: visible; box-shadow: var(--shadow); position: relative; }
.table-toolbar { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--bg2); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th { text-align: left; padding: 8px 12px; font-size: 10px; font-weight: 600; color: var(--text2); border-bottom: 1px solid var(--border); background: var(--bg2); white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; user-select: none; }
thead th:hover { background: var(--bg3); }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border: none; }
tbody tr:hover { background: var(--bg2); }
tbody td { padding: 9px 12px; vertical-align: middle; }
.td-overflow { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── AVATAR ─── */
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; flex-shrink: 0; }
.name-cell { display: flex; align-items: center; gap: 8px; }
.name-main { font-weight: 500; font-size: 12px; }
.name-sub { font-size: 10px; color: var(--text3); }

/* ─── OVERLAY / MODAL ─── */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 9000; align-items: flex-start; justify-content: center; padding: 2rem 1rem; overflow-y: auto; }
.overlay.open { display: flex; }
.modal { background: var(--bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: 20px 24px; width: 100%; max-width: 560px; margin: auto; position: relative; z-index: 9001; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }
.modal h2 { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ─── FORM ─── */
hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.section-label { font-size: 11px; font-weight: 600; color: var(--brand); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; margin-top: 4px; padding-left: 2px; border-left: 3px solid var(--brand); padding-left: 8px; }

/* ─── INLINE ELEMENTS ─── */
.br-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 12px; border-bottom: 1px solid var(--border); }
.br-row:last-child { border: none; }
.br-l { color: var(--text2); }
.br-v { font-weight: 500; }
.hl { background: var(--bg2); border-radius: var(--radius); padding: 8px 12px; margin: 6px 0; display: flex; justify-content: space-between; align-items: center; }
.hl-green { background: var(--green-bg); }
.hl-blue { background: var(--blue-bg); }
.hl-amber { background: var(--amber-bg); }

.info-box { background: var(--blue-bg); border-radius: var(--radius); padding: 9px 12px; font-size: 11px; color: var(--blue); margin-bottom: 12px; line-height: 1.6; border-left: 3px solid var(--brand); }
.warn-box { background: var(--amber-bg); border-radius: var(--radius); padding: 9px 12px; font-size: 11px; color: var(--amber); margin-bottom: 12px; border-left: 3px solid #D97706; }
.success-box { background: var(--green-bg); border-radius: var(--radius); padding: 9px 12px; font-size: 11px; color: var(--green); margin-bottom: 12px; border-left: 3px solid #16A34A; }

/* ─── PROGRESS ─── */
.progress-bar { background: var(--bg3); border-radius: 999px; height: 5px; overflow: hidden; margin-top: 4px; }
.progress-fill { height: 100%; border-radius: 999px; transition: width .3s; }

/* ─── SEARCH ─── */
.search-wrap { position: relative; }
.search-wrap i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--text3); pointer-events: none; }
.search-wrap input { padding-left: 28px; }

/* ─── TOAST ─── */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: var(--radius-lg); font-size: 12px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(10px); transition: all .25s; pointer-events: none; max-width: 300px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #166534; }
.toast.error { background: #991B1B; }
.toast.warn { background: #92400E; }

/* ─── THEME PICKER ─── */
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.theme-swatch { height: 36px; border-radius: var(--radius); cursor: pointer; border: 3px solid transparent; transition: all .15s; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 500; color: #fff; }
.theme-swatch.active { border-color: var(--text); transform: scale(1.05); }
.theme-swatch:hover { transform: scale(1.05); }

/* ─── PAYSLIP PRINT ─── */
.payslip-doc { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; font-size: 12px; }
.payslip-header { text-align: center; border-bottom: 2px solid var(--brand); padding-bottom: 12px; margin-bottom: 14px; }
.payslip-table { width: 100%; font-size: 11px; }
.payslip-table td { padding: 4px 0; vertical-align: top; }
.payslip-table td:last-child { text-align: right; font-weight: 500; }
.payslip-section { font-size: 10px; font-weight: 600; color: var(--text2); text-transform: uppercase; padding: 8px 0 3px; border-top: 1px solid var(--border); letter-spacing: .04em; }
.payslip-total { border-top: 2px solid var(--text); padding-top: 6px; font-weight: 600; font-size: 13px; }

/* ─── BATCH INPUT ─── */
.batch-inp { height: 26px; font-size: 11px; padding: 0 5px; width: 54px; text-align: right; border-radius: var(--radius); border: 1px solid var(--border-md); }

/* ─── STATUS DOT ─── */
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }

/* ─── TABS ─── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 14px; }
.tab-btn { padding: 7px 14px; font-size: 12px; font-weight: 500; cursor: pointer; border: none; background: none; color: var(--text2); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .15s; }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── FILTER ROW ─── */
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-row select, .filter-row input:not([type="checkbox"]):not([type="radio"]):not([type="range"]) {
  height: 34px;
  font-size: 12px;
  width: 100%;
  min-width: 80px;
  box-sizing: border-box;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 3px; }

/* ─── MISC ─── */
.mono { font-family: 'DM Mono', monospace; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.text-brand { color: var(--brand); }
.text-muted { color: var(--text2); }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.gap-2 { gap: 8px; }
.flex { display: flex; align-items: center; }
.flex-1 { flex: 1; }

/* ─── LAW ─── */
.law-item { border-bottom: 1px solid var(--border); padding: 6px 0; }
.law-item:last-child { border: none; }

/* ─── VOID badge ─── */
.void-row { opacity: 0.45; }
.void-row td { text-decoration: line-through; }

/* ─── ATTENDANCE ─── */
.att-punch { background: var(--bg2); border-radius: var(--radius); padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; font-size: 12px; margin-bottom: 6px; border: 1px solid var(--border); }

/* ─── PASSWORD MODAL ─── */
.pwd-modal { position: relative; z-index: 9002; /* above overlay */ }
.pwd-modal-IGNORE { max-width: 360px; }

/* ─── FORCE MAJA BOOKS ALWAYS WHITE ─── */
#sidebar .maja-books-name {
  color: #ffffff !important;
  text-shadow: 0 1px 3px rgba(0,0,0,0.35) !important;
}
/* Orange theme — nav items black, MAJA Books white */
.nav-item { color: var(--sidebar-item-color, rgba(255,255,255,0.65)); }
.nav-item.active { color: var(--sidebar-name-color, #fff) !important; }

/* Smart dropdown — opens upward when near bottom of viewport */
.row-dd.open-up {
  bottom: 26px !important;
  top: auto !important;
}
/* Ensure row-action-wrap doesn't clip dropdown */
.row-action-wrap {
  position: relative;
  display: inline-block;
  z-index: 100;
}
.row-action-wrap:hover {
  z-index: 1001;
}

/* ─── AUTH SCREEN INPUTS ─────────────────────────────────────────────────── */
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
  width: 100% !important;
  height: 42px !important;
  padding: 0 12px !important;
  font-size: 14px !important;
  border: 1.5px solid #E5E7EB !important;
  border-radius: 8px !important;
  background: #FAFAFA !important;
  color: #111 !important;
  box-sizing: border-box !important;
  display: block !important;
  pointer-events: all !important;
  cursor: text !important;
  outline: none !important;
  -webkit-appearance: none !important;
}
.auth-form input:focus {
  border-color: #1B3A6B !important;
  background: #fff !important;
  box-shadow: 0 0 0 3px rgba(27,58,107,0.12) !important;
}
.auth-form .fr {
  margin-bottom: 14px !important;
}
.auth-form label {
  display: block !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #374151 !important;
  margin-bottom: 6px !important;
}
.auth-form .btn {
  width: 100% !important;
  height: 44px !important;
  font-size: 14px !important;
  justify-content: center !important;
  margin-top: 4px !important;
}
