/* =============================================================
   BSGM School Office Management Portal
   style.css — Complete design system & responsive layout
   ============================================================= */

/* ─────────────────────────────────────────
   1. CSS CUSTOM PROPERTIES (Design Tokens)
───────────────────────────────────────── */
:root {
  /* Brand colours */
  --navy-950: #080f1e;
  --navy-900: #0f2044;
  --navy-800: #1a2e5c;
  --navy-700: #1e3a6e;
  --navy-600: #2348a0;
  --navy-500: #2e5fc4;
  --blue-400: #60a5fa;
  --blue-300: #93c5fd;

  /* Semantic colours */
  --success:       #10b981;
  --success-light: #d1fae5;
  --warning:       #f59e0b;
  --warning-light: #fef3c7;
  --error:         #ef4444;
  --error-light:   #fee2e2;
  --urgent:        #dc2626;
  --urgent-light:  #fecaca;
  --info:          #3b82f6;
  --info-light:    #dbeafe;

  /* Neutral palette */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --white:    #ffffff;

  /* Surface */
  --bg-page:   #f0f4f8;
  --bg-card:   #ffffff;
  --bg-panel:  #f8fafc;
  --border:    #e2e8f0;
  --border-strong: #cbd5e1;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;

  /* Sizing */
  --container-max: 1200px;
  --header-h:      64px;
  --nav-h:         52px;
  --radius-xs:     4px;
  --radius-sm:     6px;
  --radius-md:     8px;
  --radius-lg:     12px;
  --radius-xl:     16px;
  --radius-2xl:    24px;
  --radius-full:   9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 24px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.04);
  --shadow-nav: 0 2px 8px rgba(15,32,68,0.14);

  /* Transitions */
  --tx: 0.18s ease;
  --tx-slow: 0.3s ease;
}

/* ─────────────────────────────────────────
   2. RESET & BASE
───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4,h5,h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}
h2 { font-size: 1.375rem; }
h3 { font-size: 1.1rem; }

a { color: var(--navy-700); text-decoration: none; }
a:hover { text-decoration: underline; }

ul,ol { list-style: none; }

img,svg { display: block; max-width: 100%; }

button { cursor: pointer; font-family: inherit; }

input,select,textarea,button { font-family: inherit; font-size: inherit; }

/* Focus rings — accessible */
:focus-visible {
  outline: 2px solid var(--navy-500);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ─────────────────────────────────────────
   3. LAYOUT UTILITIES
───────────────────────────────────────── */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 16px;
}

/* ─────────────────────────────────────────
   4. VISIBILITY HELPERS (JS-controlled)
───────────────────────────────────────── */
/* Elements that require admin mode */
.admin-only { display: none !important; }
body.admin-mode .admin-only { display: revert !important; }

/* Conditional form fields (hidden until JS shows them) */
.conditional-field { display: none; }
.conditional-field.visible { display: block; }

/* ─────────────────────────────────────────
   5. HEADER
───────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: linear-gradient(135deg, var(--navy-950) 0%, var(--navy-800) 100%);
  box-shadow: var(--shadow-nav);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 12px;
}

.school-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--white);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.brand-tagline {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Office Mode Badge */
.office-badge {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(16,185,129,0.2);
  border: 1px solid rgba(16,185,129,0.4);
  border-radius: var(--radius-full);
  color: #6ee7b7;
  font-size: 0.75rem;
  font-weight: 600;
}

body.admin-mode .office-badge { display: flex; }

.badge-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Login/logout buttons — shown/hidden by JS */
#office-logout-btn { display: none; }
body.admin-mode #office-login-btn  { display: none; }
body.admin-mode #office-logout-btn { display: flex; }

/* ─────────────────────────────────────────
   6. TAB NAVIGATION
───────────────────────────────────────── */
.tab-nav {
  position: sticky;
  top: var(--header-h);
  z-index: 90;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-nav-inner {
  display: flex;
  min-width: max-content;
  height: var(--nav-h);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 18px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color var(--tx), border-color var(--tx), background var(--tx);
  position: relative;
}

.tab-btn:hover {
  color: var(--navy-700);
  background: var(--gray-50);
}

.tab-btn.active {
  color: var(--navy-700);
  border-bottom-color: var(--navy-700);
  font-weight: 600;
}

.tab-icon { font-size: 1rem; }

/* Admin tab — hidden until admin mode */
.admin-tab { display: none; }
body.admin-mode .admin-tab { display: flex; }

/* ─────────────────────────────────────────
   7. OFFICE MODE BANNER
───────────────────────────────────────── */
.office-banner {
  display: none;
  background: linear-gradient(90deg, #064e3b, #065f46);
  border-bottom: 1px solid #047857;
}

body.admin-mode .office-banner { display: block; }

.banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  gap: 12px;
  font-size: 0.8rem;
  color: #a7f3d0;
}

/* ─────────────────────────────────────────
   8. MAIN CONTENT & TABS
───────────────────────────────────────── */
.main-content { padding-bottom: 48px; }

.tab-section { display: none; }
.tab-section.active { display: block; }

.tab-section > .container { padding-top: 28px; }

/* ─────────────────────────────────────────
   9. PAGE HEADER (section title bar)
───────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-header-text { flex: 1; }

.page-header-text h2 { font-size: 1.4rem; margin-bottom: 3px; }

.page-subtitle { color: var(--text-secondary); font-size: 0.875rem; }

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 4px;
}

/* ─────────────────────────────────────────
   10. BUTTONS
───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1;
  transition: background var(--tx), color var(--tx), border-color var(--tx),
              box-shadow var(--tx), transform 0.1s;
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Sizes */
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-full { width: 100%; }

/* Variants */
.btn-primary {
  background: var(--navy-700);
  color: var(--white);
  border-color: var(--navy-700);
}
.btn-primary:hover:not(:disabled) {
  background: var(--navy-900);
  border-color: var(--navy-900);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--white);
  color: var(--navy-700);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--navy-500);
}

.btn-danger {
  background: var(--error);
  color: var(--white);
  border-color: var(--error);
}
.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-ghost {
  background: transparent;
  color: var(--navy-600);
  border-color: transparent;
  padding: 4px 8px;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
}

.btn-outline-white {
  background: transparent;
  color: var(--white);
  border-color: rgba(255,255,255,0.4);
}
.btn-outline-white:hover:not(:disabled) {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.7);
}

/* Spinner state inside buttons */
.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  display: none;
}

.btn.loading .btn-text { display: none; }
.btn.loading .btn-spinner { display: block; }
.btn.loading { pointer-events: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────────────────────
   11. FORM ELEMENTS
───────────────────────────────────────── */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 28px;
  max-width: 760px;
}

.form-section {
  border: none;
  padding: 0;
  margin-bottom: 28px;
}

.form-section + .form-section { border-top: 1px solid var(--border); padding-top: 24px; }

.form-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--navy-700);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-100);
}

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.form-label.required::after {
  content: ' *';
  color: var(--error);
}

.optional-tag {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.form-control {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: var(--white);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: border-color var(--tx), box-shadow var(--tx);
  appearance: none;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--navy-600);
  box-shadow: 0 0 0 3px rgba(30,58,110,0.1);
}

.form-control:disabled, .form-control[readonly] {
  background: var(--gray-100);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-control.invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}

.form-control-sm { padding: 6px 10px; font-size: 0.8rem; }

/* Select arrow */
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint {
  font-size: 0.77rem;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.5;
}

.form-hint-box {
  background: var(--info-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.8rem;
  color: #1e40af;
  margin-top: 6px;
  line-height: 1.5;
}

.form-error {
  display: block;
  font-size: 0.77rem;
  color: var(--error);
  margin-top: 4px;
  min-height: 16px;
}

/* Form row layouts */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ─────────────────────────────────────────
   12. RADIO & CHECKBOX GROUPS
───────────────────────────────────────── */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--tx), background var(--tx);
}

.radio-option:has(input:checked) {
  border-color: var(--navy-600);
  background: #eff6ff;
}

.radio-option:hover { border-color: var(--navy-500); }

.radio-option.radio-high:has(input:checked) { border-color: var(--warning); background: var(--warning-light); }
.radio-option.radio-urgent:has(input:checked) { border-color: var(--urgent); background: var(--urgent-light); }

.radio-option input[type="radio"] { margin-top: 3px; flex-shrink: 0; accent-color: var(--navy-700); }

.radio-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.radio-label strong { font-size: 0.875rem; }
.radio-label small { font-size: 0.77rem; color: var(--text-secondary); }

/* Period checkbox grid */
.period-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.period-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  transition: border-color var(--tx), background var(--tx), color var(--tx);
}

.period-chip:has(input:checked) {
  border-color: var(--navy-600);
  background: var(--navy-700);
  color: var(--white);
}

.period-chip input { display: none; }

/* Leave Type grid */
.leave-type-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.leave-type-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  transition: border-color var(--tx), background var(--tx);
}

.leave-type-btn:has(input:checked) {
  border-color: var(--navy-700);
  background: #eff6ff;
  color: var(--navy-700);
}

.leave-type-btn input { display: none; }

/* Submission Type Cards */
.submission-type-section {
  margin-bottom: 20px;
}

.type-card-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.type-card {
  display: block;
  cursor: pointer;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  transition: border-color var(--tx), box-shadow var(--tx);
}

.type-card:has(input:checked) {
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(30,58,110,0.1);
}

.type-card input { display: none; }

.type-card-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
}

.type-icon { font-size: 1.6rem; flex-shrink: 0; }

.type-text { display: flex; flex-direction: column; gap: 2px; }
.type-text strong { font-size: 0.9rem; }
.type-text small { font-size: 0.77rem; color: var(--text-secondary); line-height: 1.4; }

/* Form actions bar */
.form-actions {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-disclaimer {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.5;
}

/* ─────────────────────────────────────────
   13. INFO BANNERS
───────────────────────────────────────── */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--warning-light);
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  line-height: 1.5;
  color: #78350f;
}

.info-banner-info {
  background: var(--info-light);
  border-color: #bfdbfe;
  color: #1e40af;
}

/* ─────────────────────────────────────────
   14. FILTER ROW
───────────────────────────────────────── */
.filter-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }

/* Filter chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.chip {
  padding: 5px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--white);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--tx), background var(--tx), color var(--tx);
}

.chip:hover { border-color: var(--navy-500); color: var(--navy-700); }
.chip.active { background: var(--navy-700); border-color: var(--navy-700); color: var(--white); }

/* ─────────────────────────────────────────
   15. NOTICE BOARD
───────────────────────────────────────── */
.notices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.notice-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--tx), transform var(--tx);
}

.notice-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.notice-card.priority-urgent { border-left: 4px solid var(--urgent); }
.notice-card.priority-important { border-left: 4px solid var(--warning); }
.notice-card.priority-normal { border-left: 4px solid var(--border-strong); }

.notice-card.status-unpublished { opacity: 0.65; border-style: dashed; }
.notice-card.status-archived { opacity: 0.5; }

.notice-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 10px;
}

.notice-card-badges { display: flex; gap: 6px; flex-wrap: wrap; }

.notice-card-actions { display: flex; gap: 4px; flex-shrink: 0; }

.notice-card-body { padding: 0 16px 14px; }

.notice-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.3;
}

.notice-description {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.55;
  white-space: pre-line;
}

.notice-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--gray-100);
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 4px;
}

/* ─────────────────────────────────────────
   16. STATUS BADGES
───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-urgent    { background: var(--urgent-light); color: var(--urgent); }
.badge-important { background: var(--warning-light); color: #92400e; }
.badge-normal    { background: var(--gray-100); color: var(--gray-600); }
.badge-meeting   { background: #ede9fe; color: #5b21b6; }
.badge-event     { background: #ecfdf5; color: #065f46; }
.badge-admin     { background: #f0f9ff; color: #0c4a6e; }
.badge-holiday   { background: #fdf4ff; color: #701a75; }
.badge-general   { background: var(--gray-100); color: var(--gray-600); }

.badge-active      { background: var(--success-light); color: #065f46; }
.badge-draft       { background: var(--gray-100); color: var(--gray-500); }
.badge-archived    { background: var(--gray-200); color: var(--gray-500); }

/* Print/Leave/Sub status badges */
.badge-pending     { background: var(--warning-light); color: #92400e; }
.badge-progress    { background: var(--info-light); color: #1e40af; }
.badge-waiting     { background: #fdf4ff; color: #701a75; }
.badge-completed   { background: var(--success-light); color: #065f46; }
.badge-cancelled   { background: var(--gray-100); color: var(--gray-500); }
.badge-approved    { background: var(--success-light); color: #065f46; }
.badge-rejected    { background: var(--error-light); color: #991b1b; }
.badge-noted       { background: var(--info-light); color: #1e40af; }
.badge-assigned    { background: #ede9fe; color: #5b21b6; }
.badge-reviewed    { background: var(--info-light); color: #1e40af; }
.badge-no         { background: var(--error-light); color: #991b1b; }
.badge-yes        { background: var(--success-light); color: #065f46; }

/* ─────────────────────────────────────────
   17. DATA TABLES
───────────────────────────────────────── */
.table-wrapper {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table thead { position: sticky; top: 0; z-index: 1; }

.data-table th {
  background: var(--navy-900);
  color: rgba(255,255,255,0.88);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-50); }

.data-table .col-id { font-weight: 700; color: var(--navy-700); font-family: 'Courier New', monospace; }

.table-actions { display: flex; gap: 4px; }

.table-loading {
  display: none;
  justify-content: center;
  padding: 32px;
}
.table-loading.visible { display: flex; }

.table-empty-state {
  display: none;
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.table-empty-state.visible { display: block; }

/* ─────────────────────────────────────────
   18. OFFICE PANEL (admin section above forms)
───────────────────────────────────────── */
.office-panel {
  background: var(--bg-panel);
  border: 1.5px solid #c7d9f5;
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
}

.office-panel .page-header-text h2 {
  font-size: 1.15rem;
  color: var(--navy-800);
}

.panel-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel-divider::before,
.panel-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─────────────────────────────────────────
   19. SECTION LOADING STATE
───────────────────────────────────────── */
.section-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 24px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.section-loading.hidden { display: none; }

/* Spinner */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--navy-700);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ─────────────────────────────────────────
   20. EMPTY STATE
───────────────────────────────────────── */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
  gap: 12px;
}

.empty-state.visible { display: flex; }

.empty-icon { font-size: 3rem; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-primary); }
.empty-state p { color: var(--text-muted); font-size: 0.875rem; max-width: 320px; }

/* ─────────────────────────────────────────
   21. CONFIRMATION CARD
───────────────────────────────────────── */
.confirmation-wrapper { display: none; }
.confirmation-wrapper.visible { display: block; }

.confirmation-card {
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.confirmation-icon { font-size: 3.5rem; }

.confirmation-card h2 { font-size: 1.5rem; }

.confirmation-subtitle { color: var(--text-secondary); font-size: 0.9rem; }

/* Work ID Block */
.work-id-block {
  background: var(--gray-50);
  border: 2px dashed var(--navy-500);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.work-id-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }

.work-id-value-row { display: flex; align-items: center; gap: 10px; }

.work-id-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--navy-700);
  font-family: 'Courier New', monospace;
  letter-spacing: 0.05em;
}

/* Next steps */
.next-steps {
  width: 100%;
  text-align: left;
}

.next-steps h3 { font-size: 0.9rem; margin-bottom: 12px; }

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.85rem;
}

.step-item:last-child { border-bottom: none; }

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--navy-700);
  color: var(--white);
  font-size: 0.72rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-body { flex: 1; line-height: 1.5; color: var(--text-secondary); }
.step-body strong { color: var(--text-primary); }

.email-subject-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.email-subject-box code {
  font-size: 0.8rem;
  color: var(--navy-800);
  font-family: 'Courier New', monospace;
  flex: 1;
  word-break: break-all;
}

/* Confirmation detail */
.confirmation-detail {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.conf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  gap: 12px;
  border-bottom: 1px solid var(--gray-100);
}

.conf-row:last-child { border-bottom: none; }

.conf-label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.conf-value { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); text-align: right; }

.info-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  max-width: 380px;
}

/* ─────────────────────────────────────────
   22. OFFICE DASHBOARD
───────────────────────────────────────── */
/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--tx);
}

.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card.stat-urgent { border-left: 4px solid var(--urgent); }
.stat-card.stat-warning { border-left: 4px solid var(--warning); }

.stat-icon { font-size: 1.6rem; flex-shrink: 0; }

.stat-body { display: flex; flex-direction: column; gap: 1px; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--navy-800); line-height: 1; }
.stat-label { font-size: 0.75rem; color: var(--text-secondary); }

/* Search card */
.search-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.search-card-title { font-size: 0.9rem; margin-bottom: 10px; }

.search-row {
  display: flex;
  gap: 8px;
}

.search-row .form-control { flex: 1; }

.search-result {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  display: none;
}

.search-result.visible { display: block; }

/* Dashboard sub-tabs */
.dash-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.dash-tab {
  flex: 1;
  min-width: max-content;
  padding: 7px 14px;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--tx), color var(--tx);
}

.dash-tab:hover { background: rgba(255,255,255,0.6); color: var(--text-primary); }

.dash-tab.active {
  background: var(--white);
  color: var(--navy-700);
  box-shadow: var(--shadow-xs);
}

.dash-panel { display: none; }
.dash-panel.active { display: block; }

/* ─────────────────────────────────────────
   23. MODALS
───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(3px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--tx-slow);
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--tx-slow), transform var(--tx-slow);
}

.modal.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
}

.modal-sm { max-width: 420px; }
.modal-lg { max-width: 640px; }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  color: var(--text-secondary);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--tx), color var(--tx);
}

.modal-close:hover { background: var(--gray-200); color: var(--text-primary); }

.modal-icon { font-size: 2rem; text-align: center; margin-bottom: 4px; }

.modal-title { font-size: 1.2rem; text-align: center; margin-bottom: 4px; }

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ─────────────────────────────────────────
   24. TOAST NOTIFICATIONS
───────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 500;
  min-width: 260px;
  max-width: 380px;
  pointer-events: all;
  animation: toast-in 0.25s ease forwards;
  line-height: 1.4;
}

.toast.removing { animation: toast-out 0.2s ease forwards; }

.toast-success { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.toast-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.toast-info    { background: var(--info-light); border: 1px solid #93c5fd; color: #1e40af; }
.toast-warning { background: var(--warning-light); border: 1px solid #fde68a; color: #92400e; }

.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast-msg  { flex: 1; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(24px); }
}

/* ─────────────────────────────────────────
   25. FOOTER
───────────────────────────────────────── */
.app-footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 16px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-sep { color: var(--border-strong); }

/* ─────────────────────────────────────────
   26. RESPONSIVE BREAKPOINTS
───────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  :root { --header-h: 56px; }

  .brand-tagline { display: none; }
  .brand-icon { width: 36px; height: 36px; }
  .brand-name { font-size: 0.95rem; }

  .tab-btn { padding: 0 12px; font-size: 0.78rem; }
  .tab-label { display: none; }
  .tab-icon { font-size: 1.2rem; }
  .tab-btn.active .tab-label { display: inline; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 1.3rem; }
  .stat-icon  { font-size: 1.2rem; }

  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }

  .type-card-group { grid-template-columns: 1fr; }
  .leave-type-grid { flex-direction: column; }

  .form-card { padding: 20px 16px; }
  .office-panel { padding: 16px; }

  .confirmation-card { padding: 28px 20px; }
  .work-id-value { font-size: 1.6rem; }

  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-group { width: 100%; }
  .filter-group .form-control { width: 100%; }

  .page-header { flex-direction: column; gap: 10px; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; justify-content: center; }

  .search-row { flex-direction: column; }

  .modal-content { padding: 24px 18px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }

  .dash-tabs { flex-direction: row; overflow-x: auto; }
  .dash-tab { flex-shrink: 0; }

  .notices-grid { grid-template-columns: 1fr; }

  #toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { min-width: 0; max-width: 100%; }

  .banner-inner { flex-direction: column; gap: 8px; align-items: flex-start; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────
   27. PRINT STYLES
───────────────────────────────────────── */
@media print {
  .app-header, .tab-nav, .office-banner, #toast-container,
  .modal-overlay, .modal, .page-header-actions, .filter-row,
  .table-actions, .form-actions, .app-footer { display: none !important; }

  .tab-section { display: block !important; }
  .office-panel { border: none; box-shadow: none; }
  .data-table { font-size: 0.75rem; }
}

/* ─────────────────────────────────────────
   28. UTILITY CLASSES
───────────────────────────────────────── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: 0.82rem; }
.font-mono    { font-family: 'Courier New', monospace; }
.font-bold    { font-weight: 700; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.gap-8        { gap: 8px; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.w-full       { width: 100%; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
