@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap");
/* MyTeam Diary — premium SaaS, blue/white/light-grey, mobile-first */
:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-light: #eff6ff;
  --purple: #7c5cfc;
  --ink: #0b1b3a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f3f5fa;
  --card: #ffffff;
  --green: #16a34a;
  --amber: #f59e0b;
  --red: #e11d48;
  --radius: 20px;
  --shadow: 0 2px 10px rgba(11, 27, 58, .06), 0 12px 32px rgba(11, 27, 58, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Poppins", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5;
}
h1, h2, h3, h4, .page-title, .brand { font-family: "Poppins", -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--blue); text-decoration: none; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 264px; background: #fff; color: var(--ink); flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--line); box-shadow: 2px 0 14px rgba(15, 23, 42, .05);
}
/* Drawer header: dark navy block — avatar/photo (or initials), bold white
   name, and the user's own level in small caps underneath. renderSidebar
   fills this into the .logo slot every page shell already has. */
.sidebar .logo {
  background:
    radial-gradient(220px 160px at 105% -10%, rgba(124, 92, 252, .5), transparent 65%),
    radial-gradient(240px 180px at -10% 115%, rgba(37, 99, 235, .45), transparent 65%),
    linear-gradient(135deg, #0b1b3a 0%, #12275e 100%);
  color: #fff; padding: 18px 18px 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.side-brandrow { display: flex; align-items: center; gap: 9px; }
.side-logo { display: inline-flex; flex: none; }
.side-brandname { font-size: 16.5px; font-weight: 700; letter-spacing: .6px; color: #fff; white-space: nowrap; }
.side-close {
  margin-left: auto; flex: none; display: none;
  width: 32px; height: 32px; min-height: 0; padding: 0;
  background: rgba(255, 255, 255, .12); color: #fff; border: none; border-radius: 50%;
  font-size: 13px; line-height: 1; cursor: pointer; align-items: center; justify-content: center;
}
.side-userrow { display: flex; align-items: center; gap: 12px; min-width: 0; }
.side-search { padding: 14px 12px 0; }
.side-search input {
  background: #f1f5f9; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 13px; font-size: 14px; width: 100%;
}
.side-search input:focus { outline: 2px solid #bfdbfe; border-color: var(--blue); background: #fff; }
.side-ava { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; }
.side-ava-init {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--blue), var(--purple)); color: #fff; font-weight: 700; font-size: 17px;
}
.side-uinfo { display: flex; flex-direction: column; min-width: 0; }
.side-uinfo b {
  font-size: 17px; font-weight: 800; color: #fff; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-ulevel {
  font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase;
  color: #9db4dd; margin-top: 3px;
}
.sidebar nav { flex: 1; padding: 14px 12px 12px; overflow-y: auto; }
.nav-sec {
  font-size: 11px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase;
  color: #94a3b8; padding: 22px 10px 6px;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 12px 10px; margin: 2px 0;
  border-radius: 10px; color: #475569; font-weight: 500; font-size: 15px;
}
.sidebar nav a:hover { background: #f1f5f9; color: var(--ink); }
.sidebar nav a.active { background: #e3edff; color: var(--blue-dark); font-weight: 700; }
.sidebar nav a .mi { flex: none; }
.sidebar nav a .ml { min-width: 0; }
.sidebar nav a .chev { margin-left: auto; flex: none; color: #b9c6de; font-size: 19px; font-weight: 600; line-height: 1; }
.sidebar nav a.active .chev { color: var(--blue); }
/* "Stay Consistent" promo card: drawer footer block above the code/logout
   foot (design board). Light cream card, crown chip, circular arrow. */
.side-promo {
  display: flex; align-items: center; gap: 11px; margin: 12px;
  padding: 13px 14px; border-radius: 16px; color: var(--ink);
  background: linear-gradient(135deg, #fff8dc, #ffedb5);
  border: 1px solid #fde68a; box-shadow: 0 4px 14px rgba(180, 130, 0, .10);
}
.side-promo:hover { background: linear-gradient(135deg, #fff3c4, #ffe08a); color: var(--ink); }
.side-promo .sp-ico {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  background: #fff; border-radius: 50%; font-size: 19px;
  box-shadow: 0 2px 6px rgba(180, 130, 0, .18);
}
.side-promo .sp-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side-promo .sp-txt b { font-size: 14.5px; font-weight: 700; line-height: 1.25; }
.side-promo .sp-txt small { font-size: 11.5px; color: #92700c; }
.side-promo .sp-arrow {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center;
  background: #fff; border-radius: 50%; color: var(--ink);
  font-size: 19px; font-weight: 700; line-height: 1;
  box-shadow: 0 2px 6px rgba(11, 27, 58, .14);
}
.sidebar .side-foot { padding: 14px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.sidebar .side-foot a { color: var(--blue-dark); font-weight: 600; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 20px; display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 800; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.top-ava {
  width: 38px; height: 38px; border-radius: 50%; flex: none; overflow: hidden;
  display: inline-grid; place-items: center;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff; font-weight: 700; font-size: 13px; text-decoration: none;
}
.top-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bell-wrap { position: relative; display: inline-flex; }
.bell-btn {
  position: relative; width: 42px; height: 42px; min-height: 0; padding: 0;
  background: transparent; border: none; border-radius: 50%;
  font-size: 19px; line-height: 1; cursor: pointer; display: inline-grid; place-items: center;
}
@media (hover:hover) { .bell-btn:hover { background: #eef2f7; } }
.bell-dot {
  position: absolute; top: 7px; right: 8px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--red); border: 2px solid #fff;
}
.bell-panel {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 60;
  width: min(320px, 86vw); background: #fff; border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 18px 44px rgba(11, 27, 58, .18);
  overflow: hidden; text-align: left; color: var(--ink);
}
.bell-panel h4 { margin: 0; padding: 13px 16px 6px; font-size: 14px; font-weight: 700; }
.bell-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 16px; font-size: 14px; border-top: 1px solid #f1f5f9;
}
.bell-item b { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bell-item span { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 13px; }
.bell-empty { padding: 4px 16px 14px; color: var(--muted); font-size: 13.5px; }
.bell-foot {
  display: block; text-align: center; padding: 11px;
  background: var(--blue-light); color: var(--blue-dark); font-weight: 700; font-size: 14px;
}
/* Master Reminders switch at the top of the bell panel (round 26): one
   device-level push subscription drives every reminder section. */
.bell-rem {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px 12px; border-bottom: 1px solid #f1f5f9;
}
.bell-rem-info b { display: block; font-size: 14.5px; font-weight: 700; }
.bell-rem-info span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.bell-rem-btn {
  flex: none; border: none; border-radius: 99px; padding: 8px 16px; min-height: 0;
  font-size: 13.5px; font-weight: 700; cursor: pointer; background: var(--blue); color: #fff;
}
.bell-rem-btn.off { background: #fee2e2; color: #b91c1c; }
.bell-rem-btn:disabled { opacity: .6; cursor: default; }
/* Reminder banners exist only in the OFF state; when ON they don't render. */
.push-enable-btn[hidden] { display: none !important; }
/* Hamburger: ALWAYS visible (prototype keeps it on desktop too). The color
   must be set here — the global `button` rule paints text white, which made
   the ☰ glyph invisible (white on white) on the light topbar. The admin
   page's dark topbar overrides this with an inline color:#fff. */
#menuBtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; min-height: 44px; flex: none;
  background: none; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 20px; line-height: 1; padding: 0; cursor: pointer;
}
.content { padding: 22px; max-width: 1180px; width: 100%; margin: 0 auto; }
.page-title { font-size: 24px; font-weight: 800; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

/* ---------- cards / stats ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat .num { font-size: 30px; font-weight: 800; color: var(--blue-dark); }
.stat .lbl { font-size: 13px; color: var(--muted); margin-top: 2px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 20px; }
.panel h3 { margin: 0 0 12px; font-size: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--ink); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: #fff; }
tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--blue-light); color: var(--blue-dark); }
.badge.green { background: #dcfce7; color: #166534; }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.grey { background: #f1f5f9; color: #475569; }
.badge.red { background: #fee2e2; color: #991b1b; }

/* ---------- forms ---------- */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
label { font-size: 13px; font-weight: 600; color: #334155; display: block; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  font-size: 15px; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--blue); }
button, .btn {
  background: var(--blue); color: #fff; border: none; border-radius: 12px;
  padding: 11px 18px; font-size: 15px; font-weight: 600; cursor: pointer; min-height: 44px;
}
/* hover styles only where a real hover exists (touch devices keep :hover stuck
   after a tap, which turned ghost buttons solid-blue with invisible blue text) */
@media (hover:hover) {
  button:not(.btn-ghost):hover, .btn:not(.btn-ghost):hover { background: var(--blue-dark); }
  .btn-ghost:hover { background: var(--blue-light); }
}
.btn-ghost { background: #fff; color: var(--blue-dark); border: 1px solid var(--line); }
.btn-sm { padding: 7px 12px; font-size: 13px; min-height: 36px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-back.open { display: flex; }
.modal { background: #fff; border-radius: 20px; padding: 22px; width: 100%; max-width: 480px; box-shadow: var(--shadow); }
.modal h3 { margin-top: 0; }

/* ---------- toast ---------- */
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; }
.toast-msg { background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); }
.toast-msg.err { background: #991b1b; }
.toast-msg.ok { background: #166534; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, #0f1e3d 0%, #1d4ed8 100%); }
.login-card { background: #fff; border-radius: 20px; padding: 34px 30px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 4px; font-size: 26px; }
.login-card h1 span { color: var(--blue); }
.login-card p { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.login-card button { width: 100%; margin-top: 8px; }
.login-err { background: #fee2e2; color: #991b1b; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; display: none; }

/* ---------- network ---------- */
.net-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.net-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border-top: 4px solid var(--blue); }
.net-card .role-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--blue-dark); font-weight: 700; }
.net-card .name { font-size: 17px; font-weight: 700; margin: 4px 0; }
.net-card .meta { font-size: 13px; color: var(--muted); }
.net-card.me { border-top-color: var(--green); background: #f0fdf4; }

/* ---------- mobile ---------- */
@media (max-width: 899px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  /* The page title wins the topbar width: the user name ellipsizes
     instead of wrapping onto two lines and squeezing the title. */
  .topbar .brand { font-size: 17px; }
  .side-close { display: inline-flex; }
  .content { padding: 16px 14px; }
  .page-title { font-size: 20px; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; display: none; }
  .scrim.on { display: block; }
}
.empty { color: var(--muted); font-size: 14px; padding: 18px; text-align: center; }
.hist-row { background: #f8fafc; }
.hist-row td { white-space: normal; font-size: 13px; }

/* ---------- phase 2: habits / goals / planner / tree ---------- */
.prog { height: 10px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.prog > div { height: 100%; background: var(--blue); border-radius: 999px; transition: width .3s; }
.prog > div.good { background: var(--green); }
.prog > div.warn { background: var(--amber); }
.prog > div.bad { background: var(--red); }
.check-row { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.check-row:last-child { border-bottom: none; }
.check-row .nm { flex: 1; min-width: 0; }
.check-row .nm b { display: block; }
.check-row .nm small { color: var(--muted); }
.seg { display: flex; gap: 6px; }
.seg button { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.seg button.on-green { background: var(--green); }
.seg button.on-amber { background: var(--amber); }
.seg button.on-red { background: var(--red); }
.seg button:not(.on-green):not(.on-amber):not(.on-red) { background: #f1f5f9; color: #475569; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { font-size: 11px; color: var(--muted); text-align: center; text-transform: uppercase; }
.cal .day { aspect-ratio: 1; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; background: #f8fafc; color: #94a3b8; }
.cal .day.done { background: #dcfce7; color: #166534; font-weight: 700; }
.cal .day.partial { background: #fef3c7; color: #92400e; font-weight: 700; }
.cal .day.missed { background: #fee2e2; color: #991b1b; }
.cal .day.today { outline: 2px solid var(--blue); }
.streak { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: #b45309;
  background: #fef3c7; border-radius: 999px; padding: 3px 10px; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 22px; border-left: 2px solid var(--line); margin-left: 10px; }
.tree .t-node { margin: 6px 0; }
.tree .t-card { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; cursor: pointer; box-shadow: var(--shadow); font-size: 14px; }
.tree .t-card:hover { border-color: var(--blue); }
.tree .t-card.self { border-color: var(--green); background: #f0fdf4; }
.tree .t-card .tt { font-size: 11px; color: var(--muted); }
.tree .t-toggle { cursor: pointer; font-weight: 700; color: var(--blue-dark); margin-right: 2px; user-select: none; }
.preset-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.preset-bar button { min-height: 38px; font-size: 13px; }
.preset-bar button.active { background: var(--blue-dark); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--blue-dark); }

/* ---------- digital time picker ---------- */
.tp-field {
  display: flex; align-items: center; gap: 8px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 0 12px;
}
.tp-field:focus-within { outline: 2px solid #bfdbfe; border-color: var(--blue); }
.tp-field .tp-ico { font-size: 16px; line-height: 1; }
.tp-field .tp-text {
  border: none; padding: 10px 0; width: 100%; font-size: 15px; background: transparent;
}
.tp-field .tp-text:focus { outline: none; border: none; }
.tp-field.bad { border-color: var(--red); animation: tpShake .3s; }
@keyframes tpShake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.tp-back {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 90;
  display: none; align-items: flex-end; justify-content: center;
}
.tp-back.open { display: flex; }
.tp-sheet {
  background: #fff; width: 100%; max-width: 440px; padding: 18px 18px 16px;
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow);
}
@media (min-width: 640px) {
  .tp-back { align-items: center; padding: 16px; }
  .tp-sheet { border-radius: 20px; }
}
.tp-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 17px; font-weight: 800; color: var(--ink); margin-bottom: 12px;
}
.tp-x {
  background: #f1f5f9; color: var(--ink); border: none; border-radius: 50%;
  width: 36px; height: 36px; min-height: 0; padding: 0; font-size: 15px; line-height: 1;
}
.tp-type { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px; }
.tp-type .tp-hh, .tp-type .tp-mm {
  width: 68px; text-align: center; font-size: 24px; font-weight: 800;
  font-variant-numeric: tabular-nums; padding: 8px 4px;
}
.tp-colon { font-size: 24px; font-weight: 800; color: var(--ink); }
.tp-ampm { display: flex; background: #f1f5f9; border-radius: 10px; padding: 3px; margin-left: 6px; }
.tp-ampm button {
  background: transparent; color: var(--muted); border: none; border-radius: 8px;
  min-height: 0; padding: 8px 14px; font-size: 14px; font-weight: 700;
}
.tp-ampm button.on { background: var(--blue); color: #fff; }
.tp-wheels { position: relative; display: flex; gap: 4px; }
.tp-band {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  height: 44px; background: var(--blue-light); border-radius: 10px; pointer-events: none;
}
.tp-wheel {
  flex: 1; height: 220px; overflow-y: auto; scroll-snap-type: y mandatory;
  scrollbar-width: none; position: relative;
  -webkit-mask-image: linear-gradient(transparent, #000 28%, #000 72%, transparent);
          mask-image: linear-gradient(transparent, #000 28%, #000 72%, transparent);
}
.tp-wheel::-webkit-scrollbar { display: none; }
.tp-list { padding: 88px 0; }
.tp-item {
  height: 44px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600; color: var(--muted);
  font-variant-numeric: tabular-nums; scroll-snap-align: center; cursor: pointer;
  user-select: none; -webkit-user-select: none;
}
.tp-item.sel { color: var(--ink); font-size: 25px; font-weight: 800; }
.tp-w-a .tp-item { font-size: 17px; }
.tp-w-a .tp-item.sel { font-size: 20px; }
.tp-labels { display: flex; gap: 4px; margin-top: 4px; }
.tp-labels span { flex: 1; text-align: center; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.tp-clear {
  background: none; border: none; color: var(--red); font-size: 13.5px; font-weight: 600;
  min-height: 0; padding: 6px 8px; margin: 8px auto 0; display: block; cursor: pointer;
}
.tp-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }
