/* ABO_OUF ORGANIZE - تصميم مستوحى من الصورة المرجعية
   كل أسماء الكلاسات مطابقة للـ HTML والـ JS الأصليين. */

:root {
  --bg-1: #050b1a;
  --bg-2: #0b1428;
  --panel: linear-gradient(160deg, rgba(27, 51, 96, 0.55), rgba(11, 20, 40, 0.8));
  --panel-solid: #0f1c38;
  --line: rgba(108, 199, 232, 0.18);
  --text: #fff8ea;
  --muted: rgba(255, 248, 234, 0.62);
  --gold: #f4c75b;
  --gold-2: #e0a93a;
  --sky: #6cc7e8;
  --turq: #56d5c5;
  --green: #22c55e;
  --red: #ef4444;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, 0.6);
  --glow-gold: 0 0 28px -6px rgba(244, 199, 91, 0.55);
}

body.light {
  --bg-1: #fdf8ec;
  --bg-2: #f3ead2;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --line: rgba(20, 39, 70, 0.12);
  --text: #0b1428;
  --muted: rgba(11, 20, 40, 0.6);
  --shadow: 0 10px 30px -15px rgba(20, 39, 70, 0.25);
  --glow-gold: 0 0 20px -8px rgba(224, 169, 58, 0.5);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }
body.light { color-scheme: light; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Cairo', 'Tajawal', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse at 15% 0%, rgba(59, 130, 246, 0.28), transparent 45%),
    radial-gradient(ellipse at 88% 8%, rgba(244, 199, 91, 0.2), transparent 42%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }

/* ================= شاشة الدخول ================= */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 440px;
  gap: 5%;
  align-items: center;
  padding: 50px 6%;
}
.auth-brand {
  position: relative;
  padding: 40px;
  border-radius: 32px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(11, 20, 40, 0.6));
  box-shadow: 0 0 80px -20px rgba(59, 130, 246, 0.5);
  overflow: hidden;
}
.auth-brand::after {
  content: '';
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 199, 91, 0.45), transparent 70%);
  inset-inline-start: -60px;
  bottom: -90px;
  filter: blur(10px);
}
.auth-brand h1 { font-size: clamp(30px, 4vw, 48px); line-height: 1.25; margin: 14px 0; }
.auth-brand h1 span { color: var(--gold); }
.auth-foot { margin-top: 40px; font-size: 12px; letter-spacing: 0.2em; color: var(--gold); opacity: 0.85; }
.eyebrow { font-size: 12px; letter-spacing: 0.18em; color: var(--gold); margin: 0; text-transform: uppercase; }

.brand-mark {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 900;
  color: var(--bg-1);
  background: linear-gradient(135deg, #fbe3a1, #f4c75b 50%, #e0a93a);
  box-shadow: var(--glow-gold);
}
.small-mark { width: 44px; height: 44px; border-radius: 14px; font-size: 20px; }

.auth-card {
  padding: 34px 30px;
  border-radius: 28px;
  border: 1px solid rgba(244, 199, 91, 0.3);
  background: linear-gradient(180deg, rgba(20, 39, 70, 0.9), rgba(5, 11, 26, 0.95));
  box-shadow: 0 0 60px -12px rgba(244, 199, 91, 0.35);
  backdrop-filter: blur(16px);
}
body.light .auth-card { background: rgba(255, 255, 255, 0.92); }
.mobile-brand { display: none; text-align: center; font-weight: 900; font-size: 22px; color: var(--gold); margin-bottom: 14px; }
.mobile-brand span { font-size: 13px; letter-spacing: 0.25em; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: 22px;
}
.tab {
  flex: 1;
  border: 0;
  padding: 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.tab.active { background: linear-gradient(135deg, #fbe3a1, #f4c75b); color: var(--bg-1); box-shadow: var(--glow-gold); }

.field { margin-bottom: 16px; }
.field label, .label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.field input, .field select, .field textarea,
.toolbar input, .toolbar select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(108, 199, 232, 0.22);
  background: rgba(5, 11, 26, 0.6);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
body.light .field input, body.light .field select, body.light .field textarea,
body.light .toolbar input, body.light .toolbar select { background: #fff; }
.field input:focus, .field select:focus, .field textarea:focus,
.toolbar input:focus, .toolbar select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(244, 199, 91, 0.2);
}
.field textarea { min-height: 90px; resize: vertical; }

/* ================= الأزرار ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  color: var(--bg-1);
  background: linear-gradient(135deg, #fbe3a1, #f4c75b 50%, #e0a93a);
  box-shadow: var(--glow-gold);
}
.btn.primary:hover { box-shadow: 0 0 36px -4px rgba(244, 199, 91, 0.85); }
.btn.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}
body.light .btn.ghost { background: rgba(20, 39, 70, 0.05); border-color: rgba(20, 39, 70, 0.12); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.1); }
.btn.danger { color: #fecaca; border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.1); }
.btn.danger:hover { background: rgba(239, 68, 68, 0.22); }
.btn.wide { width: 100%; padding: 14px; font-size: 15px; }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 10px; }
.text-btn {
  display: block;
  margin: 14px auto 0;
  border: 0;
  background: none;
  color: var(--gold);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ================= التطبيق الرئيسي ================= */
.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 14px;
  bottom: 14px;
  right: 14px;
  width: 270px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 16px;
  border-radius: 28px;
  overflow-y: auto;
  border: 1px solid rgba(244, 199, 91, 0.35);
  background: linear-gradient(180deg, rgba(20, 39, 70, 0.95), rgba(5, 11, 26, 0.98));
  box-shadow: 0 0 50px -10px rgba(244, 199, 91, 0.35);
  transition: transform 0.3s ease;
}
body.light .sidebar { background: rgba(255, 255, 255, 0.95); }

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 6px; }
.brand b { display: block; font-size: 20px; font-weight: 900; color: var(--gold); letter-spacing: 0.04em; }
.brand small { display: block; font-size: 11px; letter-spacing: 0.3em; color: var(--gold); opacity: 0.8; }

.profile-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.profile-mini b { display: block; font-size: 14px; }
.profile-mini small { color: var(--muted); font-size: 11px; word-break: break-all; }

.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 18px;
  color: var(--bg-1);
  background: linear-gradient(135deg, #6cc7e8, #3b82f6);
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(244, 199, 91, 0.6);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.large { width: 120px; height: 120px; flex-basis: 120px; font-size: 40px; margin: 0 auto 14px; }
.profile-avatar-image { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto 14px; box-shadow: 0 0 0 3px var(--gold); }

#nav { display: flex; flex-direction: column; gap: 6px; }
.nav-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: rgba(255, 248, 234, 0.82);
  font: inherit;
  font-size: 14px;
  text-align: right;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
body.light .nav-link { color: var(--text); }
.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.nav-link.active {
  color: var(--gold);
  font-weight: 800;
  background: linear-gradient(90deg, rgba(244, 199, 91, 0.28), rgba(244, 199, 91, 0.04));
  border-color: rgba(244, 199, 91, 0.45);
  box-shadow: var(--glow-gold);
}
.nav-link.danger { color: #fca5a5; }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid rgba(255, 255, 255, 0.1); padding-top: 12px; }

.main {
  margin-right: 298px;
  min-height: 100vh;
  padding: 14px 14px 14px 0;
}
.topbar {
  position: sticky;
  top: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  margin-bottom: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(11, 20, 40, 0.7);
  backdrop-filter: blur(14px);
}
body.light .topbar { background: rgba(255, 255, 255, 0.85); }
.topbar h2 { margin: 2px 0 0; font-size: 22px; font-weight: 900; }
.topbar #menuBtn { display: none; }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  display: inline-block;
}

.content { padding: 4px 2px 30px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 26px;
  border-radius: 28px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.28), rgba(11, 20, 40, 0.3));
  box-shadow: 0 0 60px -18px rgba(59, 130, 246, 0.7);
}
.page-head h3 { margin: 0 0 6px; font-size: 26px; font-weight: 900; }
.page-head p { margin: 0; color: var(--muted); }

/* ================= الكروت والبطاقات ================= */
.panel, .item-card, .stat, .auth-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.panel { padding: 20px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 14px; font-size: 17px; font-weight: 800; }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.section-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}
.report-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* بطاقات إحصائية متدرجة بالألوان الأربعة كما في الصورة */
.stat {
  position: relative;
  overflow: hidden;
  padding: 20px;
  color: #fff;
  border: 0;
  min-height: 130px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat::before {
  content: '';
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  filter: blur(18px);
  top: -30px;
  inset-inline-start: -30px;
}
.stat:hover, .item-card:hover, .panel:hover { transform: translateY(-2px); }
.grid > .stat:nth-child(4n+1), .report-cards > .stat:nth-child(3n+1) { background: linear-gradient(135deg, #16a34a, #0f766e); box-shadow: 0 0 35px -8px rgba(22, 163, 74, 0.8); }
.grid > .stat:nth-child(4n+2), .report-cards > .stat:nth-child(3n+2) { background: linear-gradient(135deg, #2563eb, #1e3a8a); box-shadow: 0 0 35px -8px rgba(59, 130, 246, 0.8); }
.grid > .stat:nth-child(4n+3), .report-cards > .stat:nth-child(3n+3) { background: linear-gradient(135deg, #dc2626, #7f1d1d); box-shadow: 0 0 35px -8px rgba(220, 38, 38, 0.8); }
.grid > .stat:nth-child(4n+4) { background: linear-gradient(135deg, #9333ea, #4c1d95); box-shadow: 0 0 35px -8px rgba(147, 51, 234, 0.8); }
.stat .label { color: rgba(255, 255, 255, 0.85); }
.stat strong { display: block; margin: 8px 0 4px; font-size: 26px; font-weight: 900; position: relative; }
.stat small { color: rgba(255, 255, 255, 0.75); position: relative; }
.stat .label { position: relative; font-size: 13px; font-weight: 700; }
.symbol {
  position: absolute;
  top: 16px;
  inset-inline-end: 16px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  z-index: 1;
}
.stat-link { cursor: pointer; }

/* بطاقات المحافظ الملونة */
.item-card { padding: 20px; position: relative; overflow: hidden; color: #fff; border: 0; }
.item-card::before {
  content: '';
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  filter: blur(22px);
  top: -40px;
  inset-inline-end: -40px;
}
.item-card > * { position: relative; }
.item-card h3 { margin: 6px 0 10px; font-size: 18px; color: #fff; }
.item-card .label, .item-card .muted { color: rgba(255, 255, 255, 0.8) !important; }
.item-card strong { color: #fff; }
.grid > .item-card:nth-child(4n+1) { background: linear-gradient(135deg, #2563eb, #1e3a8a); box-shadow: 0 0 35px -8px rgba(59, 130, 246, 0.8); }
.grid > .item-card:nth-child(4n+2) { background: linear-gradient(135deg, #dc2626, #7f1d1d); box-shadow: 0 0 35px -8px rgba(220, 38, 38, 0.8); }
.grid > .item-card:nth-child(4n+3) { background: linear-gradient(135deg, #9333ea, #4c1d95); box-shadow: 0 0 35px -8px rgba(147, 51, 234, 0.8); }
.grid > .item-card:nth-child(4n+4) { background: linear-gradient(135deg, #f59e0b, #b45309); box-shadow: 0 0 35px -8px rgba(245, 158, 11, 0.8); }
.item-card .actions .btn.ghost { background: rgba(0, 0, 0, 0.25); border-color: rgba(255, 255, 255, 0.2); color: #fff; }
.item-card .actions .btn.danger { background: rgba(0, 0, 0, 0.3); color: #fff; border-color: rgba(255, 255, 255, 0.25); }

/* صفوف المهام والقوائم */
.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  margin-bottom: 8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.2s;
}
body.light .task-row { background: rgba(20, 39, 70, 0.03); }
.task-row:hover { background: rgba(255, 255, 255, 0.08); }
.task-row b { display: block; font-size: 14px; }
.task-row small { color: var(--muted); font-size: 12px; }
.task-row > strong { white-space: nowrap; }

.empty {
  padding: 30px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(244, 199, 91, 0.3);
  border-radius: 18px;
}

/* الجداول */
.table-wrap { overflow-x: auto; border-radius: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: start;
  padding: 12px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}
td { padding: 13px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
tbody tr:hover td { background: rgba(255, 255, 255, 0.03); }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.good { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.badge.bad { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
.positive { color: #4ade80; font-weight: 800; }
.negative { color: #f87171; font-weight: 800; }
.good { color: #4ade80; }
.bad { color: #f87171; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar input { flex: 1 1 240px; }
.toolbar select { flex: 0 1 200px; }

/* الملف الشخصي */
.profile-layout { display: grid; grid-template-columns: 340px 1fr; gap: 16px; }
.profile-card { text-align: center; }
.profile-photo { margin-bottom: 18px; }
.profile-photo .btn { margin-top: 4px; }

/* ================= التنبيهات ================= */
.toast {
  position: fixed;
  bottom: 24px;
  inset-inline-start: 50%;
  transform: translate(-50%, 140%);
  z-index: 100;
  min-width: 260px;
  max-width: 90vw;
  padding: 14px 20px;
  border-radius: 18px;
  border: 1px solid var(--green);
  background: linear-gradient(135deg, #22c55e, #15803d);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 30px -6px rgba(34, 197, 94, 0.7);
  text-align: center;
  transition: transform 0.35s ease;
}
.toast.show { transform: translate(-50%, 0); }

/* ================= النوافذ المنبثقة ================= */
#modal {
  border: 1px solid rgba(244, 199, 91, 0.35);
  border-radius: 26px;
  padding: 0;
  width: min(560px, 92vw);
  background: transparent;
  color: var(--text);
  box-shadow: 0 0 70px -10px rgba(244, 199, 91, 0.35);
}
#modal::backdrop { background: rgba(2, 6, 18, 0.7); backdrop-filter: blur(4px); }
.modal-card {
  padding: 24px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(20, 39, 70, 0.98), rgba(5, 11, 26, 0.98));
}
body.light .modal-card { background: #fff; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { margin: 0; font-size: 20px; font-weight: 900; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ================= الموبايل والتابلت ================= */
@media (max-width: 1200px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .section-grid { grid-template-columns: 1fr; }
}
@media (max-width: 950px) {
  .sidebar { width: 240px; }
  .main { margin-right: 0; padding: 12px; }
  .topbar #menuBtn { display: grid; }
  .auth-shell { grid-template-columns: 1fr 400px; gap: 4%; padding: 25px; }
  .profile-layout { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .sidebar {
    transform: translateX(calc(100% + 30px));
    right: 8px;
    top: 8px;
    bottom: 8px;
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 10px; }
  .topbar { top: 8px; padding: 12px 14px; border-radius: 18px; }
  .topbar h2 { font-size: 18px; }
  .page-head { padding: 20px; border-radius: 22px; }
  .page-head h3 { font-size: 21px; }
  .grid, .report-cards, .form-grid { grid-template-columns: 1fr; }
  .stat strong { font-size: 22px; }
  .auth-shell { display: flex; min-height: 100vh; padding: 18px; justify-content: center; align-items: center; }
  .auth-brand { display: none; }
  .auth-card { width: 100%; max-width: 430px; padding: 25px 20px; }
  .mobile-brand { display: block; }
  .actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* رسالة الخطأ: الـ JS يضع var(--red) في style الحدود، فنحوّل الكرت لأحمر */
.toast[style*="var(--red)"] {
  background: linear-gradient(135deg, #ef4444, #991b1b);
  border-color: #ef4444;
  box-shadow: 0 0 30px -6px rgba(239, 68, 68, 0.7);
}

/* ================= إصلاحات التجاوب وتناسق الواجهات ================= */
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
button, input, select, textarea { max-width: 100%; }
.app, .main, .content, #pageContent { min-width: 0; }
.main { min-width: 0; }
.content { width: 100%; }
.grid, .section-grid, .report-cards, .form-grid, .profile-layout { min-width: 0; }
.grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.section-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.report-cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.page-head { min-width: 0; flex-wrap: wrap; }
.page-head > * { min-width: 0; }
.page-head .btn { flex: 0 0 auto; }
.item-card, .panel, .stat { min-width: 0; }
.item-card .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.item-card .actions .btn { min-width: 0; white-space: normal; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 900px; }
#modal { max-height: min(88dvh, 760px); overflow: auto; overscroll-behavior: contain; }
.modal-card { max-height: inherit; overflow-y: auto; }
.modal-head { position: sticky; top: -24px; z-index: 2; padding: 2px 0 12px; background: inherit; }
.field { min-width: 0; }
.field input, .field select, .field textarea { min-width: 0; }
.balance-edit-note { padding: 13px 15px; margin-bottom: 16px; border: 1px solid rgba(244,199,91,.32); border-radius: 14px; background: rgba(244,199,91,.08); }
.balance-edit-note strong { color: var(--gold); display: block; margin-bottom: 5px; }
.balance-edit-note p { color: var(--muted); margin: 0; line-height: 1.8; font-size: 13px; }

@media (max-width: 950px) {
  .sidebar { width: min(300px, calc(100vw - 24px)); right: 8px; top: 8px; bottom: 8px; transform: translateX(calc(100% + 24px)); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-right: 0; padding: 10px; }
  .topbar #menuBtn { display: grid; flex: 0 0 42px; }
  .auth-shell { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 20px; }
}
@media (max-width: 700px) {
  .main { padding: 8px; }
  .topbar { top: 6px; gap: 9px; padding: 10px 12px; margin-bottom: 12px; }
  .topbar h2 { font-size: 17px; }
  .topbar .eyebrow { font-size: 10px; letter-spacing: .08em; }
  .top-actions { gap: 5px; font-size: 11px; }
  .page-head { padding: 16px; gap: 12px; }
  .page-head h3 { font-size: 19px; }
  .page-head p { font-size: 12px; line-height: 1.7; }
  .page-head .btn { width: 100%; }
  .grid, .section-grid, .report-cards, .form-grid, .profile-layout { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 14px; }
  .item-card { padding: 16px; }
  .item-card .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actions .btn { flex: 1 1 120px; }
  .toolbar { display: grid; grid-template-columns: minmax(0, 1fr); }
  .toolbar input, .toolbar select { width: 100%; min-width: 0; }
  .table-wrap table { min-width: 600px; }
  #modal { width: calc(100vw - 20px); max-width: 560px; max-height: 90dvh; border-radius: 18px; }
  .modal-card { padding: 16px; border-radius: 18px; }
  .modal-head h3 { font-size: 17px; }
  .modal-actions { position: sticky; bottom: -16px; padding-top: 12px; padding-bottom: 2px; background: inherit; }
  .auth-shell { display: flex; padding: 12px; }
  .auth-card { padding: 22px 16px; }
}
@media (max-width: 360px) {
  .top-actions .muted { display: none; }
  .item-card .actions { grid-template-columns: minmax(0, 1fr); }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}


/* ABO_OUF app-like responsive refinements */
:root { --safe-bottom: env(safe-area-inset-bottom, 0px); }
body { overscroll-behavior-y: none; }
.app { min-height: 100dvh; }
.main { min-width: 0; }
.content { padding-bottom: 30px; }
.panel, .item-card, .stat { position: relative; }
.visibility-toggle { position:absolute; inset-inline-end:12px; top:10px; z-index:3; border:1px solid var(--line); background:var(--panel-solid); color:var(--muted); border-radius:9px; padding:5px 9px; font-size:11px; cursor:pointer; opacity:.78; }
.visibility-toggle:hover { opacity:1; color:var(--gold); }
.is-collapsed { min-height:48px !important; }
.is-collapsed > :not(.visibility-toggle) { display:none !important; }
.panel-title-row { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.panel-title-row h3 { margin:0; }
.association-reminders .task-row { border-bottom:1px solid var(--line); padding:12px 0; }
#mobileNav { display:none; }
#pageContent table { font-variant-numeric:tabular-nums; }
#associationTable { min-width:1150px; }
#modal { width:min(680px, calc(100vw - 32px)); max-width:680px; border:1px solid var(--line); color:var(--text); }
.modal-card { width:100%; }
input,select,textarea { font:inherit; }
button { -webkit-tap-highlight-color:transparent; touch-action:manipulation; }
@media (max-width:700px) {
  body { padding-bottom:calc(74px + var(--safe-bottom)); background-attachment:scroll; }
  .content { padding:0 0 18px; }
  .main { padding:8px 8px 18px; }
  .topbar { position:sticky; z-index:8; }
  .topbar .top-actions .small { display:none; }
  #mobileNav { display:flex; position:fixed; z-index:40; inset-inline:0; bottom:0; min-height:64px; padding:7px 8px calc(7px + var(--safe-bottom)); background:rgba(8,16,32,.96); border-top:1px solid var(--line); backdrop-filter:blur(18px); justify-content:space-around; gap:3px; }
  body.light #mobileNav { background:rgba(255,255,255,.96); }
  #mobileNav button { flex:1 1 20%; min-width:0; border:0; border-radius:12px; background:transparent; color:var(--muted); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; font-size:19px; }
  #mobileNav button small { font-size:10px; white-space:nowrap; }
  #mobileNav button.active { color:var(--gold); background:rgba(244,199,91,.10); }
  .sidebar { z-index:50; }
  .page-head { margin-bottom:12px; }
  .grid { gap:9px; }
  .stat { padding:14px; min-height:108px; }
  .stat .label { font-size:12px; }
  .stat strong { font-size:20px; overflow-wrap:anywhere; }
  .panel { padding:14px 12px; border-radius:17px; }
  .panel h3 { font-size:16px; padding-inline-end:42px; }
  .visibility-toggle { top:8px; inset-inline-end:8px; padding:4px 7px; font-size:10px; }
  .item-card .actions { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .actions .btn { min-height:38px; padding:8px 10px; font-size:12px; }
  .table-wrap { border-radius:12px; }
  .table-wrap table { min-width:720px; }
  #associationTable { min-width:1150px; }
  .field label { font-size:13px; }
  .field input,.field select,.field textarea { min-height:46px; font-size:16px; }
  #modal { width:calc(100vw - 16px); max-height:calc(100dvh - 24px); margin:auto; }
  .modal-card { padding:14px; }
  .modal-actions { bottom:-14px; }
  .modal-actions .btn { min-height:44px; }
}
@media (max-width:380px) {
  #mobileNav button small { font-size:9px; }
  .topbar h2 { font-size:15px; }
  .stat { padding:11px; }
}
@media (min-width:701px) and (max-width:1050px) {
  .grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .section-grid { grid-template-columns:minmax(0,1fr); }
}
@media print {
  body * { visibility:hidden !important; }
  #associationTable, #associationTable * { visibility:visible !important; }
  #associationTable { position:absolute; inset:0; width:100%; }
}


/* 2026-11-23: mobile-first scroll, readable notices, compact collapse controls */
html, body { height:auto !important; min-height:100%; overflow-x:hidden !important; overflow-y:auto !important; }
body { overscroll-behavior-y:auto !important; }
.app { display:block; min-height:100svh; height:auto !important; overflow:visible !important; }
.main { min-height:100svh; height:auto !important; overflow:visible !important; }
#pageContent { min-height:1px; overflow:visible !important; padding-bottom:calc(96px + env(safe-area-inset-bottom,0px)); }
.content { overflow:visible !important; }
.toast { left:50% !important; right:auto !important; inset-inline-start:auto !important; width:min(480px,calc(100vw - 24px)); min-width:0; max-width:calc(100vw - 24px); white-space:normal; overflow-wrap:anywhere; word-break:normal; line-height:1.65; text-align:center; bottom:calc(82px + env(safe-area-inset-bottom,0px)); transform:translate(-50%,160%); }
.toast.show { transform:translate(-50%,0); }
.toast[data-kind="error"] { background:linear-gradient(135deg,#ef4444,#991b1b); border-color:#ef4444; }
.toast[data-kind="success"] { background:linear-gradient(135deg,#15803d,#166534); border-color:#22c55e; }
#modal { max-height:calc(100dvh - 20px); overflow-y:auto; overscroll-behavior:contain; }
.modal-card { max-height:none !important; overflow:visible !important; }
#modalBody { min-width:0; }
.date-parts { display:grid; grid-template-columns:.8fr 1.4fr 1fr; gap:7px; }
.date-parts select { width:100%; min-width:0; min-height:44px; padding:8px 5px; border:1px solid var(--line); border-radius:12px; background:var(--panel-solid); color:var(--text); font:inherit; }
.table-tools { display:flex; flex-wrap:wrap; justify-content:flex-start; gap:7px; margin:0 0 9px; }
.progress-track { height:9px; width:100%; overflow:hidden; border-radius:20px; background:rgba(108,199,232,.14); margin:10px 0 6px; }
.progress-track span { display:block; height:100%; border-radius:inherit; background:linear-gradient(90deg,var(--sky),var(--turq),var(--gold)); transition:width .25s ease; }
.task-progress-card { align-items:flex-start; gap:14px; }
.task-main { flex:1 1 280px; min-width:0; }
.task-main small { overflow-wrap:anywhere; }
.task-actions { flex:0 1 330px; }
.savings-list { display:grid; gap:14px; margin-top:14px; }
.savings-card-head { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.savings-card-head h3 { margin:0 0 5px; }
.savings-card-head strong { color:var(--gold); font-size:22px; }
.savings-numbers { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; margin:12px 0; }
.savings-numbers span { display:grid; gap:4px; padding:10px; border:1px solid var(--line); border-radius:12px; color:var(--muted); font-size:12px; min-width:0; }
.savings-numbers b { color:var(--text); overflow-wrap:anywhere; }
.visibility-toggle { max-width:calc(100% - 16px); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.visibility-toggle.is-hidden { width:auto; max-width:150px; padding:4px 8px; font-size:10px; opacity:1; background:var(--bg-2); border-color:var(--gold); color:var(--gold); }
.is-collapsed { min-height:38px !important; padding-block:8px !important; }
#mobileNav { overflow-x:auto; overflow-y:hidden; justify-content:flex-start !important; scrollbar-width:none; }
#mobileNav::-webkit-scrollbar { display:none; }
#mobileNav button { flex:0 0 62px !important; min-width:62px !important; }
@media(max-width:700px) {
  body { padding-bottom:calc(80px + env(safe-area-inset-bottom,0px)) !important; }
  #pageContent { padding-bottom:calc(100px + env(safe-area-inset-bottom,0px)); }
  .grid, .report-cards { grid-template-columns:repeat(2,minmax(0,1fr)) !important; gap:8px; }
  .section-grid, .profile-layout, .form-grid { grid-template-columns:minmax(0,1fr) !important; }
  .stat { min-height:94px; padding:11px; }
  .stat strong { font-size:clamp(15px,4.5vw,20px); }
  .task-progress-card { display:block; }
  .task-actions { margin-top:10px; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .savings-numbers { grid-template-columns:1fr; }
  .table-wrap { overflow:visible !important; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display:block; width:100%; min-width:0 !important; }
  .table-wrap thead { position:absolute !important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
  .table-wrap tbody tr { margin:0 0 12px; padding:8px 10px; border:1px solid var(--line); border-radius:13px; background:rgba(255,255,255,.025); }
  .table-wrap tbody td { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:8px 2px; border:0; border-bottom:1px solid rgba(108,199,232,.09); text-align:start; overflow-wrap:anywhere; }
  .table-wrap tbody td:last-child { border-bottom:0; }
  .table-wrap tbody td::before { content:attr(data-label); flex:0 0 38%; max-width:42%; color:var(--muted); font-size:11px; font-weight:700; }
  .table-wrap tbody td > * { min-width:0; }
  .table-wrap .actions { justify-content:flex-start; }
  .table-tools .btn { flex:1 1 120px; }
  .toast { bottom:calc(78px + env(safe-area-inset-bottom,0px)); }
  .visibility-toggle { top:7px; inset-inline-end:7px; padding:3px 6px; font-size:9px; }
}
@media(max-width:370px) {
  .grid, .report-cards { grid-template-columns:minmax(0,1fr) !important; }
  .date-parts { gap:4px; }
  .date-parts select { font-size:13px; }
}
.task-step-list { display:grid; gap:8px; }
.task-step-row { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 12px; border:1px solid var(--line); border-radius:12px; background:rgba(255,255,255,.025); }
.task-step-row label { display:flex; align-items:center; gap:9px; min-width:0; margin:0; color:var(--text); }
.task-step-row label span { overflow-wrap:anywhere; }
.task-step-row input[type=checkbox] { width:19px; height:19px; accent-color:var(--turq); flex:0 0 auto; }

/* Final polish: collapsed data areas, dependable toast dismissal, clean mobile bar */
.table-wrap.table-collapsed { display:none !important; }
.table-tools { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin:0 0 10px; }
.table-visibility-toggle, .form-visibility-toggle {
  min-height:34px; width:auto; max-width:100%; padding:6px 12px; border-radius:10px;
  font-size:12px; line-height:1.3; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.inline-form-collapsed > :not(.form-visibility-toggle) { display:none !important; }
.inline-form-collapsed { display:flex; align-items:flex-start; min-height:42px; }
.inline-form-collapsed .form-visibility-toggle { display:inline-flex; }
.form-visibility-toggle { margin-block:2px 10px; }
.panel.is-collapsed { min-height:46px !important; padding-block:7px !important; }
.panel.is-collapsed > .visibility-toggle { position:static; display:inline-flex; width:auto; max-width:100%; }
.panel.is-collapsed > :not(.visibility-toggle) { display:none !important; }

.toast {
  left:50% !important; right:auto !important; inset-inline-start:auto !important;
  width:min(460px,calc(100vw - 24px)); min-width:0; max-width:calc(100vw - 24px);
  max-height:32dvh; overflow:auto; overflow-wrap:anywhere; white-space:normal;
  bottom:calc(82px + env(safe-area-inset-bottom,0px));
  transform:translate(-50%,18px) !important; opacity:0; visibility:hidden;
  pointer-events:none; transition:opacity .22s ease, transform .22s ease, visibility .22s ease;
}
.toast.show { transform:translate(-50%,0) !important; opacity:1; visibility:visible; }
.toast.toast-hiding { opacity:0; visibility:hidden; pointer-events:none; }

#mobileNav { border-top:1px solid rgba(255,255,255,.09) !important; border-bottom:0 !important;
  box-shadow:0 -8px 24px rgba(0,0,0,.14) !important; outline:0 !important; }
#mobileNav::before, #mobileNav::after, #mobileNav button::before, #mobileNav button::after { content:none !important; display:none !important; }
#mobileNav button { border:0 !important; outline:0 !important; box-shadow:none !important; border-bottom:0 !important; }
#mobileNav button.active { border:0 !important; box-shadow:none !important; }
body.light #mobileNav { border-top-color:rgba(20,39,70,.10) !important; }

#pageContent, .main, .content, .panel, .table-tools, .profile-layout { min-width:0; }
#pageContent { width:100%; max-width:100%; }
.page-head { align-items:center; }
.page-head > div:first-child { flex:1 1 220px; }
.page-head .btn { max-width:100%; }
.grid { align-items:stretch; }
.stat { min-width:0; overflow-wrap:anywhere; }
.stat .label, .stat small { overflow-wrap:anywhere; }
.panel h3 { overflow-wrap:anywhere; }

@media(max-width:700px) {
  #mobileNav { min-height:62px; padding:6px 6px calc(6px + env(safe-area-inset-bottom,0px)); gap:2px; }
  #mobileNav button { flex:0 0 60px !important; min-width:60px !important; min-height:48px; }
  #mobileNav button.active { background:rgba(244,199,91,.10) !important; color:var(--gold) !important; }
  #pageContent { padding-bottom:calc(104px + env(safe-area-inset-bottom,0px)); }
  .toast { bottom:calc(76px + env(safe-area-inset-bottom,0px)); padding:11px 14px; border-radius:14px; font-size:13px; }
  .table-tools { margin-bottom:8px; }
  .table-visibility-toggle, .form-visibility-toggle { min-height:32px; padding:5px 10px; font-size:11px; }
  .panel.is-collapsed { min-height:42px !important; padding:6px 9px !important; }
  .page-head { padding:14px !important; }
  .grid { gap:9px !important; }
  .stat { min-height:88px; }
}
@media(max-width:370px) {
  #mobileNav button { flex-basis:56px !important; min-width:56px !important; }
  #mobileNav button small { font-size:9px; }
}

/* Compact counters and per-item progress summaries */
.grid > .stat, .report-cards > .stat {
  min-height: 94px;
  padding: 13px 14px;
  border-radius: 15px;
  box-shadow: 0 5px 16px -10px rgba(0,0,0,.55) !important;
}
.stat strong { font-size: 21px; margin: 6px 0 3px; }
.stat .symbol { width: 34px; height: 34px; top: 10px; inset-inline-end: 10px; border-radius: 11px; font-size: 16px; }
.stat .label { font-size: 12px; padding-inline-end: 28px; }
.stat small { font-size: 10px; }
.association-progress-list { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr)); gap:12px; margin-top:14px; }
.association-progress-card { padding:14px; min-width:0; }
.association-progress-head { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.association-progress-head h3 { margin:0; min-width:0; overflow-wrap:anywhere; }
.association-progress-head strong { color:var(--gold); font-size:18px; flex:0 0 auto; }
.association-progress-card .progress-track { margin:10px 0; }
.association-progress-numbers { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; }
.association-progress-numbers span { display:grid; gap:4px; min-width:0; padding:8px 6px; border:1px solid var(--line); border-radius:10px; color:var(--muted); font-size:11px; }
.association-progress-numbers b { color:var(--text); font-size:12px; overflow-wrap:anywhere; }
@media(max-width:700px) {
  .grid, .report-cards { grid-template-columns:repeat(2,minmax(0,1fr)) !important; gap:7px; }
  .grid > .stat, .report-cards > .stat { min-height:82px; padding:10px; border-radius:12px; }
  .stat strong { font-size:clamp(14px,4vw,18px); margin:5px 0 2px; }
  .stat .label { font-size:11px; }
  .stat small { font-size:9px; }
  .stat .symbol { width:28px; height:28px; top:7px; inset-inline-end:7px; font-size:14px; }
  .savings-numbers { grid-template-columns:repeat(3,minmax(0,1fr)) !important; gap:6px; }
  .savings-numbers span { padding:8px 5px; font-size:10px; }
  .savings-numbers b { font-size:11px; }
  .association-progress-list { grid-template-columns:minmax(0,1fr); gap:9px; }
  .association-progress-card { padding:12px; }
  .association-progress-numbers span { font-size:10px; padding:7px 5px; }
  .association-progress-numbers b { font-size:11px; }
}

/* V10 — personal workspace */
.notes-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr));gap:14px;margin-top:16px}.note-card{border-inline-start:3px solid var(--gold,#e8bd54)}.note-card-head{display:flex;align-items:center;justify-content:space-between;gap:10px}.note-card p{white-space:normal;overflow-wrap:anywhere;line-height:1.8;margin:12px 0}.smart-brief{margin:14px 0;border-color:rgba(232,189,84,.35)}.smart-brief ul{padding-inline-start:22px;line-height:1.9}.profile-card textarea{width:100%;min-height:82px;resize:vertical}.profile-layout .form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}@media(max-width:640px){.profile-layout .form-grid{grid-template-columns:1fr}.profile-layout{display:block}.profile-layout>.panel{margin-bottom:14px}.notes-grid{grid-template-columns:1fr}}
