:root {
  --bg: #0f172a;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  /* Member theme — calm teal, friendly, mobile-app feel */
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-light: #ccfbf1;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
  /* Admin theme — dark console, brand accent, deliberately distinct from member */
  --admin-bg: #0b1220;
  --admin-sidebar: #11172a;
  --admin-sidebar-text: #aab4cc;
  --admin-accent: #e02127;
  --admin-accent-dark: #b9181d;
  --admin-card: #161d33;
  --admin-border: #232b45;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--surface-2); color: var(--text); }
body { -webkit-font-smoothing: antialiased; }

.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ─── Auth screens ─── */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg, var(--primary), #0f172a);
}
.auth-card {
  width: 100%; max-width: 440px; background: var(--surface);
  border-radius: 16px; box-shadow: var(--shadow); padding: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.brand img { height: 38px; width: auto; }
.brand h1 { font-size: 20px; margin: 0; }
.auth-card .sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.auth-title { font-size: 20px; margin: 6px 0 14px; }
.demo-box { background: var(--primary-light); border-radius: 10px; padding: 12px 14px; margin-bottom: 18px; }
.demo-box .note { color: var(--primary-dark); margin-top: 2px; }
.demo-box .flex .btn { flex: 1; }
.role-switch { display: flex; gap: 8px; margin-bottom: 18px; background: var(--surface-2); border-radius: 10px; padding: 4px; }
.role-switch button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.role-switch button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

/* ═══════════════════ MEMBER SHELL ═══════════════════
   Light, card-based, mobile-app feel: top brand bar + bottom tab bar. */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--primary); color: #fff; box-shadow: var(--shadow);
}
.appbar .title { font-weight: 600; font-size: 16px; flex: 1; }
.appbar img.mark { height: 26px; width: auto; background: #fff; padding: 3px 8px; border-radius: 6px; }
.lang-btn {
  background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.lang-btn:active { transform: scale(.96); }

.container { max-width: 1000px; margin: 0 auto; padding: 16px; padding-bottom: 88px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.bottom-nav button {
  flex: 1; border: 0; background: none; padding: 10px 4px 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: 11.5px; font-weight: 600;
}
.bottom-nav button .ic { font-size: 19px; line-height: 1; }
.bottom-nav button.active { color: var(--primary); }

/* legacy top-tab nav (still used for sub-sections inside a view if needed) */
.nav {
  display: flex; gap: 4px; overflow-x: auto; background: var(--surface);
  border-bottom: 1px solid var(--border); padding: 0 8px;
  position: sticky; top: 52px; z-index: 9;
}
.nav button {
  border: 0; background: none; padding: 14px 14px; font-size: 14px; color: var(--muted);
  cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent;
}
.nav button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ═══════════════════ ADMIN SHELL ════════════════════
   Dark console with a fixed left sidebar — deliberately distinct from
   the member app so it reads as a different, more powerful surface. */
.admin-shell { min-height: 100vh; background: var(--admin-bg); color: #e7eaf3; }
.admin-topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--admin-sidebar); border-bottom: 1px solid var(--admin-border);
}
.admin-topbar .hamburger { display: none; background: none; border: 0; color: #fff; font-size: 20px; cursor: pointer; padding: 4px 8px; }
.admin-topbar .title { font-weight: 700; font-size: 15px; flex: 1; color: #fff; letter-spacing: .2px; }
.admin-topbar .title small { display: block; font-size: 11px; font-weight: 500; color: var(--admin-accent); letter-spacing: 1px; text-transform: uppercase; }
.admin-topbar img.mark { height: 24px; width: auto; background: #fff; padding: 3px 8px; border-radius: 6px; }

.admin-body { display: flex; }
.admin-sidebar {
  width: 220px; flex-shrink: 0; background: var(--admin-sidebar);
  border-right: 1px solid var(--admin-border); min-height: calc(100vh - 49px);
  padding: 14px 10px;
}
.admin-sidebar button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: none; color: var(--admin-sidebar-text); padding: 11px 12px;
  border-radius: 8px; font-size: 14px; cursor: pointer; margin-bottom: 2px; font-weight: 500;
}
.admin-sidebar button .ic { font-size: 16px; width: 20px; text-align: center; }
.admin-sidebar button:hover { background: rgba(255,255,255,.04); color: #fff; }
.admin-sidebar button.active { background: var(--admin-accent); color: #fff; }
.admin-content { flex: 1; min-width: 0; padding: 20px; padding-bottom: 60px; max-width: 1100px; }

.admin-shell .lang-btn { background: rgba(255,255,255,.1); }
.admin-shell .card { background: var(--admin-card); border-color: var(--admin-border); color: #e7eaf3; }
.admin-shell .card h2 { color: #fff; }
.admin-shell input, .admin-shell select, .admin-shell textarea {
  background: #0f1426; border-color: var(--admin-border); color: #e7eaf3;
}
.admin-shell .field label, .admin-shell .note { color: #8b94ad; }
.admin-shell .table-wrap { background: var(--admin-card); border-color: var(--admin-border); }
.admin-shell th { background: #0f1426; color: #c8cee2; }
.admin-shell td { border-color: var(--admin-border); }
.admin-shell .stat { background: var(--admin-card); border-color: var(--admin-border); }
.admin-shell .stat .n { color: var(--admin-accent); }
.admin-shell .stat .l { color: #8b94ad; }
.admin-shell .btn { background: var(--admin-accent); }
.admin-shell .btn.secondary { background: #1c2440; color: #e7eaf3; border-color: var(--admin-border); }
.admin-shell .linkbtn { color: #7dd3fc; }

.admin-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 19; }
.admin-shell .pill { background: #1c2440; color: #93c5fd; }
.admin-shell .error { background: #3a1418; color: #fca5a5; }
.admin-shell .success { background: #122a1c; color: #86efac; }
.admin-shell .empty { color: #8b94ad; }

@media (max-width: 860px) {
  .admin-topbar .hamburger { display: inline-block; }
  .admin-sidebar {
    position: fixed; top: 49px; bottom: 0; left: 0; z-index: 21;
    transform: translateX(-100%); transition: transform .2s ease; width: 240px;
  }
  .admin-sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.4); }
  .admin-overlay.open { display: block; }
  .admin-content { padding: 14px; }
}

/* ─── Cards / forms ─── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 14px; font-size: 17px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
textarea { min-height: 84px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }

/* ─── Multi-task input (Today's tasks, up to MAX_TASKS) ─── */
.task-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.task-row .task-input { flex: 1; min-width: 140px; }
.task-row .task-status { flex: 0 0 130px; width: 130px; }
.task-row .task-remove {
  flex-shrink: 0; width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer;
}
.task-view { margin: 4px 0 0; padding-left: 20px; }
.task-view li { margin-bottom: 3px; }
.task-view .badge { margin-left: 4px; }
.admin-shell .task-row .task-remove { background: #0f1426; border-color: var(--admin-border); color: #8b94ad; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary); color: #fff; border: 0; border-radius: 10px;
  padding: 12px 18px; font-size: 15px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.small { width: auto; padding: 8px 12px; font-size: 13px; }
.linkbtn { background: none; border: 0; color: var(--primary); cursor: pointer; font-size: 14px; padding: 8px 0; }

/* ─── Stats ─── */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 520px) { .stats { grid-template-columns: 1fr; } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat .n { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat .l { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ─── Table ─── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); position: sticky; top: 0; font-weight: 600; white-space: nowrap; }
td .cellwrap { max-width: 260px; white-space: pre-wrap; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.Completed { background: #dcfce7; color: #166534; }
.badge.\.In { background: #e0f2fe; }
.badge.progress, .badge.In { background: #e0f2fe; color: #075985; }
.badge.Blocked { background: #fee2e2; color: #991b1b; }
.pill { display: inline-block; background: var(--primary-light); color: var(--primary-dark); padding: 2px 8px; border-radius: 6px; font-size: 12px; margin: 2px 2px 0 0; }

.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
@media (max-width: 720px) { .filters { grid-template-columns: 1fr 1fr; } }

.note { font-size: 13px; color: var(--muted); }
.error { background: #fee2e2; color: #991b1b; padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.success { background: #dcfce7; color: #166534; padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow); z-index: 50; max-width: 90vw;
}

.flex { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mt { margin-top: 14px; }
td.nowrap { white-space: nowrap; }
td.nowrap .linkbtn { padding: 4px 6px; }
