/* ── reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f0ea;
  color: #1a1a1a;
  -webkit-font-smoothing: antialiased;
}

/* ── form controls ── */
input, select, textarea {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
  background: #fff;
  color: #111;
  font-family: inherit;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #1c3a2a;
  box-shadow: 0 0 0 3px rgba(28,58,42,.1);
}
button { font-family: inherit; transition: all .15s; }

/* ── scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: #c5bdb5; border-radius: 4px; }

/* ── loading screen ── */
#ft-loading {
  position: fixed; inset: 0;
  background: #1c3a2a;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 99999; gap: 16px;
  transition: opacity .4s ease;
}
#ft-loading.fade-out { opacity: 0; pointer-events: none; }
.ft-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #c9863a;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── login screen ── */
.login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #1c3a2a 0%, #2d5a3d 50%, #1c3a2a 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%; max-width: 400px;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo-img {
  max-width: 160px; max-height: 60px;
  object-fit: contain; margin-bottom: 8px;
}
.login-icon-wrap {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: #c9863a;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  box-shadow: 0 4px 16px rgba(201,134,58,.4);
}
.login-title  { font-size: 20px; font-weight: 800; color: #1c3a2a; }
.login-sub    { font-size: 12px; color: #6b7280; margin-top: 2px; }
.login-error  {
  background: #fef2f2; border: 1px solid #fca5a5;
  border-radius: 8px; padding: 10px 14px;
  margin-bottom: 16px; font-size: 13px; color: #dc2626;
}
.login-btn {
  width: 100%; padding: 12px;
  border-radius: 8px; border: none;
  background: #1c3a2a; color: #fff;
  font-size: 14px; font-weight: 700;
  cursor: pointer; margin-top: 8px;
  transition: background .15s;
}
.login-btn:hover { background: #2d5a3d; }
.login-btn:disabled { opacity: .6; cursor: default; }

/* ── password toggle ── */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 38px; }
.pw-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: #6b7280; display: flex; padding: 2px;
}

/* ── sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 100;
}
.sidebar-overlay.open { display: block; }

/* ── mobile header ── */
.mobile-header {
  display: none; align-items: center; gap: 12px;
  padding: 12px 16px; background: #1c3a2a;
  position: sticky; top: 0; z-index: 99; flex-shrink: 0;
}

/* ── sidebar ── */
.sidebar {
  flex-shrink: 0; background: #1c3a2a;
  display: flex; flex-direction: column;
  transition: width .2s ease; overflow: hidden;
}

/* ── main layout ── */
.app-shell {
  display: flex; height: 100vh;
  font-size: 14px; background: #f5f0ea; overflow: hidden;
}
.right-col {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}
.content-area { flex: 1; overflow-y: auto; padding: 28px; }

/* ── tables ── */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-radius: 10px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }

/* ── stat / summary cards ── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.summary-cards-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-bottom: 20px;
}
.card {
  background: #fff; border: 1px solid #e5e7eb;
  border-radius: 10px; padding: 16px;
}

/* ── dash chart / schedule grid ── */
.dash-lower {
  display: grid; grid-template-columns: 3fr 2fr; gap: 16px;
}

/* ── form two-col grid ── */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* ── nav button ── */
.nav-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 8px; border: none;
  background: transparent; color: #9fbeaa;
  cursor: pointer; margin-bottom: 3px;
  text-align: left; white-space: nowrap;
  transition: background .15s; position: relative;
}
.nav-btn.active { background: rgba(255,255,255,.15); color: #fff; }
.nav-btn:hover:not(.active) { background: rgba(255,255,255,.07); }

/* ── nav section divider ── */
.nav-section-label {
  padding: 8px 10px 4px;
  font-size: 10px; font-weight: 700;
  color: rgba(255,255,255,.3);
  letter-spacing: .08em; text-transform: uppercase;
}

/* ── alert banner ── */
.alert-banner {
  background: #fef2f2; border: 1px solid #fca5a5;
  border-radius: 8px; padding: 10px 14px;
  margin-bottom: 14px; display: flex; gap: 8px; align-items: center;
}

/* ── backup bar ── */
.backup-bar {
  display: flex; gap: 6px; padding: 8px 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.backup-btn {
  background: none;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 6px; padding: 5px 10px;
  color: #9fbeaa; cursor: pointer; font-size: 11px;
  display: flex; align-items: center; gap: 5px;
}
.backup-btn:hover { background: rgba(255,255,255,.07); }

/* ── user info bar at bottom of sidebar ── */
.user-bar {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 8px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #c9863a;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; overflow: hidden; }
.user-name { font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: #7aab8a; text-transform: capitalize; }
.logout-btn {
  background: none; border: none; cursor: pointer;
  color: #7aab8a; display: flex; padding: 4px;
  border-radius: 4px; flex-shrink: 0;
}
.logout-btn:hover { color: #fff; background: rgba(255,255,255,.08); }

/* ── search bar ── */
.search-wrap {
  position: relative; flex: 1; max-width: 400px;
}
.search-wrap input {
  padding-left: 34px; background: #f9fafb;
}
.search-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%); color: #9ca3af;
  display: flex; pointer-events: none;
}

/* ── species tabs ── */
.species-tabs {
  display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap;
}
.species-tab {
  padding: 5px 14px; border-radius: 20px; font-size: 12px;
  cursor: pointer; border: 1px solid #d1d5db;
  background: transparent; color: #6b7280; font-weight: 400;
  transition: all .15s;
}
.species-tab.active {
  background: #1c3a2a; color: #fff;
  border-color: #1c3a2a; font-weight: 600;
}

/* ── db error screen ── */
.db-error {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; gap: 12px; text-align: center; padding: 24px;
}

/* ── read-only notice ── */
.readonly-notice {
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 8px; padding: 9px 14px;
  margin-bottom: 14px; display: flex; gap: 8px; align-items: center;
  font-size: 12px; color: #92400e;
}

/* ── responsive ── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed !important;
    left: -240px !important; top: 0 !important; bottom: 0 !important;
    z-index: 101 !important; width: 240px !important;
    transition: left .25s ease !important;
  }
  .sidebar.mobile-open { left: 0 !important; }
  .mobile-header { display: flex !important; }
  .content-area { padding: 14px !important; }
  .dash-lower { grid-template-columns: 1fr !important; }
  .summary-cards-3 { grid-template-columns: 1fr 1fr !important; }
  .form-grid-2 { grid-template-columns: 1fr !important; }
  .login-card { padding: 28px 20px; }
}

/* ── print ── */
@media print {
  .sidebar, .mobile-header, .no-print { display: none !important; }
  .content-area { padding: 0 !important; }
  .table-wrap { overflow: visible !important; }
}
