:root {
  --primary: #0f172a;
  --secondary: #1e293b;
  --accent: #f97316;
  --bg: #f8fafc;
  --white: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 18px;
  --success: #16a34a;
  --warning: #ca8a04;
  --danger: #dc2626;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

body {
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  border: none;
  background: none;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.offline-banner {
  width: 100%;
  text-align: center;
  padding: 0.5rem;
  background-color: var(--warning);
  color: #fff;
  font-weight: bold;
  font-size: 0.9rem;
}

#app {
  display: flex;
  min-height: 100vh;
}

#sidebar {
  position: fixed;
  left: -280px;
  top: 0;
  width: 280px;
  height: 100%;
  background: var(--primary);
  color: #fff;
  z-index: 1000;
  transition: 0.3s;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

#sidebar.active {
  left: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.logo-box {
  width: 55px;
  height: 55px;
  border-radius: 16px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex-grow: 1;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 14px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active-tab {
  background: rgba(255, 255, 255, 0.1);
}

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: 0.3s;
  z-index: 900;
}

#overlay.active {
  opacity: 1;
  visibility: visible;
}

#content {
  width: 100%;
}

#topbar {
  position: sticky;
  top: 0;
  z-index: 500;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

#topbar .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem;
}

#topbar .left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  width: 100%;
}
#topbar .titles {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  width: 100%;
}

#topbar button {
  width: 42px;
  height: 42px;
  aspect-ratio: 1/1;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--bg);
  font-size: 1.2rem;
}

#pageTitle {
  font-size: 1.1rem;
}

#pageSubtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

main {
  padding: 1rem;
  padding-bottom: 7rem;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.welcome-card {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border-radius: 24px;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.welcome-card h2 {
  font-size: 1.3rem;
}

.welcome-card p {
  color: #cbd5e1;
  margin-top: 0.3rem;
}

.welcome-card i {
  font-size: 3rem;
  color: var(--accent);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: #fff;
  border-radius: 20px;
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.stat-card i {
  font-size: 1.8rem;
  color: var(--accent);
}

.stat-card h3 {
  margin-top: 0.8rem;
  font-size: 1.1rem;
}

.stat-card p {
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.card {
  background: #fff;
  border-radius: 20px;
  padding: 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card-header {
  margin-bottom: 1.2rem;
}

.card-header.space-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-primary:hover {
  background-color: var(--secondary);
}

.muted-text {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.activity-icon {
  width: 45px;
  height: 45px;
  border-radius: 12px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--primary);
}

/* Generic List Cards for Members, Loans, Attendance */
.list-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.list-card:last-child {
  border-bottom: none;
}

.avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--primary);
}

.list-info {
  flex: 1;
  margin-left: 1rem;
}

.list-info h4 {
  font-size: 1rem;
  color: var(--text);
}

.list-info p {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.status-badge {
  font-size: 0.75rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-weight: bold;
  height: fit-content !important;
}

.status-active {
  background: #dcfce7;
  color: #166534;
}

.status-inactive {
  background: #fee2e2;
  color: #991b1b;
}

.status-warning {
  background: #fef3c7;
  color: #92400e;
}

#bottomNav {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 0.7rem 0;
  z-index: 600;
}

#bottomNav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--muted);
}

#bottomNav a i {
  font-size: 1.4rem;
}

.active-tab {
  color: var(--accent) !important;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-size: 0.95rem;
  background: var(--bg);
  border-radius: 12px;
}

.loading {
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  font-style: italic;
}

@media (min-width: 992px) {
  #sidebar {
    left: 0;
  }
  #content {
    margin-left: 280px;
  }
  #menuBtn,
  #overlay,
  #bottomNav {
    display: none;
  }
  main {
    max-width: 1400px;
    padding: 2rem;
  }
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Append these to your existing style.css */

#loginScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  width: 100%;
}

.login-box {
  background: var(--white);
  padding: 2.5rem;
  border-radius: 24px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 400px;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: bold;
}

.form-control {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  transition: 0.2s;
}

.form-control:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

/* Toast Notifications */
#toastContainer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 1rem 1.5rem;
  border-radius: 12px;
  color: white;
  font-size: 0.9rem;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease forwards;
}

.toast-success {
  background-color: var(--success);
}
.toast-error {
  background-color: var(--danger);
}
.toast-info {
  background-color: var(--primary);
}
.toast-warning {
  background-color: var(--warning);
  color: #000;
}

#syncIndicator {
  display: none;
  animation: spin 1s linear infinite;
  font-size: 1.2rem;
  color: var(--muted);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  padding: 1rem;
  transition: all 0.3s ease-in-out;
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  padding: 1.5rem;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.modal-header h3 {
  font-size: 1.2rem;
  color: var(--primary);
}

.close-modal-btn {
  font-size: 1.4rem;
  color: var(--muted);
  transition: color 0.2s;
}

.close-modal-btn:hover {
  color: var(--danger);
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: bold;
  margin-bottom: 0.4rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--white);
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.full-width {
  width: 100%;
  justify-content: center;
}

/* Modal Tab Components */
.form-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  font-weight: bold;
  white-space: nowrap;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--primary);
  color: var(--white);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.info-alert {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #ffedd5;
  padding: 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

/* --- CUSTOM DIALOG ENGINE SYSTEM --- */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  animation: fadeIn 0.25s forwards;
}
.dialog-box {
  background: #ffffff;
  width: 90%;
  max-width: 420px;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: scale(0.9);
  animation: scaleUp 0.25s forwards;
}
.dialog-box h3 {
  margin-top: 0;
  color: var(--dark);
  font-size: 1.25rem;
}
.dialog-box p {
  color: #64748b;
  font-size: 0.95rem;
  margin: 0.75rem 0 1.5rem;
  line-height: 1.5;
}
.dialog-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 1rem;
  outline: none;
}
.dialog-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
.dialog-btn {
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}
.dialog-btn-cancel {
  background: #f1f5f9;
  color: #64748b;
}
.dialog-btn-cancel:hover {
  background: #e2e8f0;
}
.dialog-btn-confirm {
  background: var(--primary);
  color: #fff;
}
.dialog-btn-confirm:hover {
  filter: brightness(0.9);
}
.dialog-btn-danger {
  background: var(--danger);
  color: #fff;
}

/* --- SETTINGS TAB LAYOUT --- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}
.settings-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid #f1f5f9;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.settings-card h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0;
  font-size: 1.1rem;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 0.75rem;
  color: var(--dark);
}
.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 0.5rem;
}
.toggle-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}
@keyframes scaleUp {
  to {
    transform: scale(1);
  }
}
