:root {
  --bg: #f6f7fb;
  --bg-card: #ffffff;
  --bg-muted: #f0f2f7;
  --text: #0b132a;
  --text-muted: #4b5563;
  --accent: #22c55e;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Scheherazade New', 'Amiri', 'Tajawal', system-ui, -apple-system, Segoe UI, Roboto, 'Noto Sans Arabic', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: 70px;
}
.hidden { display: none !important; }
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.2s ease-out; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.header {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 8px 16px; border-bottom: 1px solid #cbd5e1; position: sticky; top: 0; background: var(--bg);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 50;
}
.brand { margin: 0; font-weight: 700; font-size: 28px; letter-spacing: 1px; }
.subtitle { margin: 0; color: var(--text-muted); font-size: 14px; }

.container { max-width: 880px; margin: 0 auto; padding: 24px; }
@media (max-width: 600px) {
  .container { padding: 12px; }
  .card { padding: 16px; }
  .ad-container { margin-bottom: 150px; } /* User requested 150px gap on phones */
}
.card { background: var(--bg-card); border: 1px solid #cbd5e1; border-radius: 16px; padding: 20px; }
.card-title { margin: 0 0 12px; font-size: 18px; }
.mt { margin-top: 16px; }

.field-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
label { color: var(--text-muted); font-size: 14px; }
input {
  background: var(--bg-muted);
  border: 1px solid #cbd5e1;
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 16px;
}
input::placeholder { color: #5b6a82; }

.result-line { display: flex; gap: 8px; align-items: baseline; font-size: 16px; }
.result-line .label { color: var(--text-muted); }
.name-line { display: flex; gap: 8px; align-items: baseline; font-size: 16px; margin-top: 6px; }
.name { color: #0f3a36; font-weight: 700; }

.text-orange { color: #f97316; font-weight: 700; }
.small-text { font-size: 0.85em; font-weight: 400; color: var(--text-muted); }

.btn { background: var(--accent); color: #041509; border: none; border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 700; }
.btn:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid #243042; }
.btn.tiny { padding: 6px 10px; font-size: 13px; }
.btn.danger { background: var(--danger); color: #fff; }

details summary { cursor: pointer; color: var(--text); font-weight: 700; }
details .muted { color: var(--text-muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.actions { display: flex; gap: 10px; }

.table { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid #cbd5e1; border-radius: 12px; overflow: hidden; }
.table div { padding: 8px 4px; border-bottom: 1px solid #cbd5e1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table div .muted { font-size: 10px; margin-right: 4px; }
.table div:nth-child(2n+1) { background: var(--bg-muted); color: var(--text-muted); }
.table div:nth-child(2n) { background: var(--bg-card); }

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-muted);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-top: 1px solid #cbd5e1;
  z-index: 100;
  height: 60px;
}

.notes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.note { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; border: 1px solid #cbd5e1; border-radius: 12px; background: var(--bg-muted); text-align: center; }
.bill { width: 64px; height: 36px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; }
.bill-img {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  display: block;
}
.count { font-size: 1.1em; font-weight: 700; }
.fallback-bill { display: none; } /* Default hidden, shown by JS on error */
.bill.d500 { background: #3b82f6; }
.bill.d200 { background: #22c55e; }
.bill.d100 { background: #10b981; }
.bill.d50 { background: #f59e0b; }
.bill.d25 { background: #ef4444; }
.bill.d10 { background: #64748b; }
.hero { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 40px; background: #0f3a36; color: #f5f3e7; text-align: center; }
.hero-brand { font-size: 92px; font-weight: 700; letter-spacing: 2px; }
.hero-brand-img { max-width: 250px; height: auto; margin-bottom: 0px; }
.hero-sub { font-size: 64px; font-weight: 700; margin-top: -18px; }
.hero-desc { margin: 24px 0; font-size: 18px; }
.hero-btn { background: #f5f3e7; color: #0f3a36; font-size: 24px; padding: 12px 20px; min-width: 160px; }
.hero-credit { margin-top: 24px; opacity: 0.8; }

.btn-back {
  background-color: #0f3a36;
  color: #f5f3e7;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 14px;
  border-radius: 8px;
  text-decoration: none;
  border: none;
  cursor: pointer;
}
.btn-back:hover {
  background-color: #0b2d2a;
  filter: brightness(1.1);
}
.btn-back svg { width: 16px; height: 16px; }

.menu { display: flex; flex-direction: column; align-items: center; padding: 40px 20px 380px 20px; }
.menu-title { font-size: 28px; color: #0f3a36; margin-bottom: 30px; }
.menu-actions { 
  display: flex; 
  flex-direction: column; 
  gap: 16px; 
  width: 100%; 
  max-width: 400px; 
}
.menu-btn { 
  background: #0f3a36; 
  color: #f5f3e7; 
  padding: 20px;
  font-size: 20px;
  width: 100%;
  text-align: center;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.menu-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.menu-logo { margin-top: 40px; font-size: 32px; color: #0f3a36; }
@media (max-width: 600px) {
  .menu-logo { margin-bottom: -50px; }
}
.menu-logo span { margin-right: 8px; font-size: 24px; color: #0f3a36; }

/* Ad Styles */
.ad-container {
  width: 94%;
  max-width: 400px;
  position: fixed;
  bottom: 70px; /* Footer (60px) + 10px gap */
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  margin: 0;
}

.ad-card {
  background: white;
  border: 1px solid #999999; /* Thicker primary color border for better visibility */
  border-radius: 12px;
  padding: 16px;
  padding-bottom: 50px; /* Space for buttons */
  position: relative;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1); /* Stronger shadow */
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeIn 0.5s ease;
  overflow: hidden; /* Ensure corners clip */
  min-height: 140px; /* Ensure minimum height for PWA */
}

.ad-label {
  position: absolute;
  top: 1px;
  right: 1px;
  font-size: 10px;
  color: #00329f; /* Blue */
  background: #dae9fb;
  padding: 2px 6px;
  border-radius: 0px 10px 0px 0px;
  font-weight: bold;
}

.ad-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-top: 24px; /* Space from top label */
  margin-bottom: 10px;
  line-height: 1.6;
  text-align: center;
  font-family: 'Noto Naskh Arabic', system-ui, -apple-system, sans-serif; /* User requested font */
  flex-grow: 1;
}

/* PWA Specific Adjustments */
@media all and (display-mode: standalone) {
  /* Ad is fixed, standard positioning applies */
  .ad-card {
    border-width: 2px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.12); /* Even stronger shadow for app-feel */
  }
}

.ad-btn {
  background: #0f3a36;
  color: white;
  text-decoration: none;
  padding: 3px 16px;
  border-radius: 5px; /* Rounded top-left */
  text-align: center;
  font-weight: bold;
  font-size: 13px;
  position: absolute;
  bottom: 5px;
  right: 5px;
  min-width: 100px;
  font-family: 'Noto Naskh Arabic', system-ui, -apple-system, sans-serif;
}


.ad-footer-btn {
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
  padding: 8px 16px;
  border-radius: 0 12px 0 0; /* Rounded top-right */
  text-decoration: none;
  border-top: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  position: absolute;
  bottom: 0;
  left: 0;
  font-weight: bold;
  min-width: 80px;
  text-align: center;
  font-family: 'Noto Naskh Arabic', system-ui, -apple-system, sans-serif;
}

.centered-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 120px);
}

/* --- Notification System --- */

/* Notification Trigger */
.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.2s;
}
.btn-icon:hover {
  background: rgba(0,0,0,0.05);
}
.badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg);
  animation: blink 1s infinite;
}

@keyframes blink {
  0% { opacity: 1; }
  50% { opacity: 0; }
  100% { opacity: 1; }
}

/* Top Banner */
.top-banner {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 500px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  border-radius: 16px;
  padding: 16px;
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.banner-content { display: flex; gap: 12px; align-items: flex-start; flex: 1; }
.banner-icon { font-size: 24px; }
.banner-text { display: flex; flex-direction: column; font-size: 14px; color: var(--text); }
.banner-text strong { margin-bottom: 4px; font-size: 16px; }
.banner-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); padding: 4px; }

@keyframes slideDown {
  from { transform: translate(-50%, -100px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* Sidebar & Overlay */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s;
}
.notif-sidebar {
  position: fixed;
  top: 0;
  left: 0; /* Slide from Left */
  bottom: 0;
  width: 300px;
  max-width: 80%;
  background: var(--bg-card);
  z-index: 1001;
  box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.notif-sidebar.open { transform: translateX(0); }
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-header h3 { margin: 0; font-size: 20px; color: #0f3a36; }
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}
.notif-item {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg);
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid transparent;
}
.notif-item:hover { background: #e2e8f0; }
.notif-item.unread { border-right: 3px solid var(--accent); background: #f0fdf4; }
.notif-item.read { background: var(--bg-muted); border-right: 3px solid transparent; }
.notif-item h4 { margin: 0 0 6px; font-size: 15px; }
.notif-item p { margin: 0; font-size: 13px; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-time { font-size: 11px; color: #94a3b8; margin-top: 6px; display: block; }

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s;
}
.modal-card {
  background: var(--bg-card);
  width: 100%;
  max-width: 400px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-header {
  padding: 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}
.modal-header h3 { margin: 0; font-size: 18px; color: #0f3a36; }
.modal-body { padding: 24px; font-size: 16px; line-height: 1.6; color: var(--text); }
@keyframes scaleUp {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Update Modal */
.update-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border-radius: 20px;
  padding: 24px;
  z-index: 3000;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}