@import url("views/agenda.css");
@import url("views/finance.css");
@import url("views/workouts.css");
@import url("views/health.css");
@import url("views/settings.css");

/* =========================================================
   Personal Adriano — design system
   ========================================================= */

:root {
  --brand: #10b981;
  --brand-strong: #059669;
  --brand-soft: rgba(16, 185, 129, .12);
  --brand-ink: #052e22;
  --lime: #a3e635;

  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;
  --border: #e3e8ef;
  --border-strong: #cfd8e3;
  --text: #0d1520;
  --text-2: #334155;
  --muted: #6b7a90;
  --faint: #93a1b5;

  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, .12);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, .13);
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, .12);
  --success: #0f9d76;
  --success-soft: rgba(15, 157, 118, .13);

  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow-sm: 0 1px 2px rgba(13, 21, 32, .05), 0 1px 3px rgba(13, 21, 32, .04);
  --shadow-md: 0 4px 16px rgba(13, 21, 32, .07), 0 1px 3px rgba(13, 21, 32, .04);
  --shadow-lg: 0 18px 48px rgba(13, 21, 32, .18);
  --ring: 0 0 0 3px rgba(16, 185, 129, .22);

  --nav-h: 68px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light;
}

html[data-theme="dark"] {
  --brand: #34d399;
  --brand-strong: #10b981;
  --brand-soft: rgba(52, 211, 153, .14);
  --brand-ink: #04160f;

  --bg: #070b13;
  --surface: #0f1622;
  --surface-2: #131c2b;
  --surface-3: #1a2436;
  --border: #1e2a3d;
  --border-strong: #2b3a52;
  --text: #e9eff9;
  --text-2: #c2cede;
  --muted: #8fa0b8;
  --faint: #6d7f97;

  --danger: #ff6b6f;
  --danger-soft: rgba(255, 107, 111, .14);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, .15);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, .15);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, .14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .38);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
  --ring: 0 0 0 3px rgba(52, 211, 153, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 420px at 105% -10%, rgba(16, 185, 129, .10), transparent 65%),
    radial-gradient(700px 380px at -15% 0%, rgba(59, 130, 246, .06), transparent 60%);
  pointer-events: none;
}

h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-strong); text-decoration: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

::selection { background: var(--brand-soft); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================ Layout ============================ */

.app {
  min-height: 100dvh;
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 18px 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, background .2s ease;
}
.appbar.is-scrolled { border-bottom-color: var(--border); }

.appbar-main { flex: 1; min-width: 0; }
.appbar-eyebrow {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1px;
}
.appbar-title {
  font-size: 22px;
  font-weight: 760;
  letter-spacing: -.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar-actions { display: flex; gap: 8px; align-items: center; }

.view {
  flex: 1;
  padding: 4px 18px calc(var(--nav-h) + 96px + env(safe-area-inset-bottom));
  outline: none;
}
.view > * { animation: rise .34s var(--ease) backwards; }
.view > *:nth-child(2) { animation-delay: .03s; }
.view > *:nth-child(3) { animation-delay: .06s; }
.view > *:nth-child(4) { animation-delay: .09s; }
.view > *:nth-child(n+5) { animation-delay: .12s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-center { display: flex; align-items: center; gap: 10px; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.spacer { flex: 1; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.strong { font-weight: 650; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 2px -4px;
}
.section-title a, .section-title button { font-size: 12.5px; font-weight: 650; color: var(--brand-strong); background: none; border: 0; padding: 4px; cursor: pointer; }

/* ============================ Bottom nav ============================ */

.tabbar {
  position: fixed;
  z-index: 40;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(calc(100% - 24px), 560px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 7px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 2px 6px;
  border: 0;
  background: none;
  color: var(--faint);
  border-radius: 15px;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}
.tab svg { width: 21px; height: 21px; stroke-width: 1.9; }
.tab span { font-size: 10.5px; font-weight: 620; letter-spacing: .01em; }
.tab:active { transform: scale(.94); }
.tab.is-active { color: var(--brand-strong); background: var(--brand-soft); }
html[data-theme="dark"] .tab.is-active { color: var(--brand); }

/* ============================ Buttons ============================ */

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-bd: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  border-radius: 13px;
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 14.5px;
  font-weight: 640;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s ease, filter .18s ease, background .18s ease, border-color .18s ease;
  user-select: none;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { filter: brightness(.985); }
.btn:active { transform: scale(.975); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  --btn-bg: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
  --btn-fg: #fff;
  --btn-bd: transparent;
  box-shadow: 0 6px 16px rgba(16, 185, 129, .28);
}
html[data-theme="dark"] .btn-primary { --btn-fg: #03251a; box-shadow: 0 6px 18px rgba(16, 185, 129, .18); }

.btn-soft { --btn-bg: var(--brand-soft); --btn-fg: var(--brand-strong); --btn-bd: transparent; }
html[data-theme="dark"] .btn-soft { --btn-fg: var(--brand); }

.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); }
.btn-ghost:hover { --btn-bg: var(--surface-2); }

.btn-danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-bd: transparent; }

.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 11px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-lg { height: 50px; font-size: 15.5px; border-radius: 15px; }
.btn-block { width: 100%; }
.btn-icon {
  width: 42px; height: 42px; padding: 0; border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer; transition: transform .12s ease, background .18s ease;
  flex: none;
}
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon:active { transform: scale(.94); }
.btn-icon.is-active { color: var(--brand-strong); background: var(--brand-soft); border-color: transparent; }

.fab {
  position: fixed;
  right: max(18px, calc(50% - 390px + 18px));
  bottom: calc(var(--nav-h) + 26px + env(safe-area-inset-bottom));
  z-index: 35;
  height: 52px;
  padding: 0 20px 0 16px;
  border-radius: 18px;
  border: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 680;
  font-size: 14.5px;
  color: #fff;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
  box-shadow: 0 10px 26px rgba(16, 185, 129, .38);
  cursor: pointer;
  transition: transform .15s var(--ease);
}
html[data-theme="dark"] .fab { color: #03251a; }
.fab svg { width: 20px; height: 20px; }
.fab:active { transform: scale(.95); }

/* ============================ Cards ============================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 12px;
}
.card-title { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-link { font-size: 12.5px; font-weight: 650; color: var(--brand-strong); background: none; border: 0; cursor: pointer; }

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 20px;
  color: #eafff7;
  background:
    radial-gradient(140% 120% at 100% 0%, rgba(163, 230, 53, .22), transparent 55%),
    linear-gradient(150deg, #0b3b2c 0%, #072019 55%, #06140f 100%);
  border: 1px solid rgba(255, 255, 255, .07);
  box-shadow: 0 16px 36px rgba(4, 30, 22, .3);
}
.hero::after {
  content: "";
  position: absolute; right: -60px; top: -60px; width: 220px; height: 220px;
  border-radius: 50%; border: 1px solid rgba(163, 230, 53, .18);
  box-shadow: 0 0 0 34px rgba(163, 230, 53, .045), 0 0 0 68px rgba(163, 230, 53, .025);
  pointer-events: none;
}
.hero-label { font-size: 12px; font-weight: 620; letter-spacing: .07em; text-transform: uppercase; color: rgba(214, 255, 236, .62); }
.hero-value { font-size: 32px; font-weight: 780; letter-spacing: -.03em; line-height: 1.15; margin-top: 2px; }
.hero-row { display: flex; gap: 18px; margin-top: 16px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero-mini { display: flex; flex-direction: column; gap: 1px; }
.hero-mini b { font-size: 15px; font-weight: 700; }
.hero-mini span { font-size: 11.5px; color: rgba(214, 255, 236, .6); }
.hero-actions { position: relative; z-index: 1; display: flex; gap: 8px; margin-top: 16px; }
.hero-actions .btn { --btn-bg: rgba(255, 255, 255, .1); --btn-fg: #eafff7; --btn-bd: rgba(255, 255, 255, .14); backdrop-filter: blur(8px); height: 38px; font-size: 13px; border-radius: 11px; }
.hero-actions .btn-primary { --btn-bg: var(--lime); --btn-fg: #10240a; --btn-bd: transparent; }

/* ============================ Stats ============================ */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  box-shadow: var(--shadow-sm);
}
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.stat-label { font-size: 11.5px; font-weight: 620; color: var(--muted); letter-spacing: .01em; }
.stat-value { font-size: 21px; font-weight: 760; letter-spacing: -.025em; line-height: 1.2; }
.stat-value small { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat-sub { font-size: 11.5px; color: var(--faint); }
.stat-ico {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-strong); flex: none;
}
.stat-ico svg { width: 15px; height: 15px; }
.stat-ico.warn { background: var(--warn-soft); color: var(--warn); }
.stat-ico.danger { background: var(--danger-soft); color: var(--danger); }
.stat-ico.info { background: var(--info-soft); color: var(--info); }

/* ============================ Lists ============================ */

.list { display: flex; flex-direction: column; }
.list > .item + .item { border-top: 1px solid var(--border); }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--surface);
  cursor: pointer;
  transition: background .15s ease;
  text-align: left;
  border: 0;
  width: 100%;
  color: inherit;
}
.item:hover { background: var(--surface-2); }
.item:active { background: var(--surface-3); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 14.5px; font-weight: 620; letter-spacing: -.01em; display: flex; align-items: center; gap: 7px; }
.item-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.item-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.item-amount { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.item-chevron { color: var(--faint); flex: none; }
.item-chevron svg { width: 17px; height: 17px; }

.avatar {
  width: 46px; height: 46px; border-radius: 15px; flex: none;
  object-fit: cover; background: var(--surface-3);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: var(--brand-strong);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 34px; height: 34px; border-radius: 11px; font-size: 12px; }
.avatar.lg { width: 78px; height: 78px; border-radius: 24px; font-size: 25px; }

/* ============================ Badges ============================ */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 660; letter-spacing: .01em;
  background: var(--surface-3); color: var(--muted);
  white-space: nowrap;
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-strong); }
html[data-theme="dark"] .badge.brand { color: var(--brand); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  cursor: pointer; white-space: nowrap;
}
.chip.is-active { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }
html[data-theme="dark"] .chip.is-active { color: var(--brand); }

/* ============================ Forms ============================ */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label {
  font-size: 12.5px; font-weight: 640; color: var(--text-2);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.field .hint { font-size: 11.5px; color: var(--faint); }
.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  color: var(--text);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
  appearance: none;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7a90' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 18px;
  padding-right: 36px;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); background: var(--surface); box-shadow: var(--ring);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input[type="date"], .input[type="time"], .input[type="datetime-local"] { min-height: 46px; }
.field-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.field-row-3 { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.input-group { position: relative; }
.input-group .input { padding-left: 40px; }
.input-group svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); pointer-events: none; }

.check {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 0;
  font-size: 14px; cursor: pointer; line-height: 1.4;
}
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand-strong); flex: none; margin-top: 1px; }

.switch { position: relative; width: 46px; height: 27px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 99px; background: var(--border-strong);
  transition: background .2s ease; pointer-events: none;
}
.switch span::after {
  content: ""; position: absolute; width: 21px; height: 21px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform .22s var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + span { background: var(--brand-strong); }
.switch input:checked + span::after { transform: translateX(19px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }

.searchbar {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 0 13px; height: 46px;
  box-shadow: var(--shadow-sm);
}
.searchbar svg { width: 18px; height: 18px; color: var(--faint); flex: none; }
.searchbar input { flex: 1; border: 0; background: none; outline: none; font-size: 15px; min-width: 0; }
.searchbar .btn-icon { width: 30px; height: 30px; border: 0; background: var(--surface-3); }
.searchbar .btn-icon svg { width: 15px; height: 15px; color: var(--muted); }

/* ============================ Tabs ============================ */

.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  height: 36px; padding: 0 14px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 13px; font-weight: 640;
  cursor: pointer; white-space: nowrap; flex: none;
  transition: all .16s ease;
}
.tab-btn.is-active {
  background: var(--text); color: var(--bg); border-color: var(--text);
}
html[data-theme="dark"] .tab-btn.is-active { background: var(--brand); color: #04211a; border-color: var(--brand); }

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px;
  padding: 3px; background: var(--surface-3); border-radius: 13px;
}
.segmented button {
  height: 34px; border: 0; background: none; border-radius: 10px;
  font-size: 13px; font-weight: 620; color: var(--muted); cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ============================ Sheet / dialog ============================ */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 10, 18, .5);
  backdrop-filter: blur(3px);
  animation: fade .2s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed; z-index: 101;
  left: 50%; transform: translateX(-50%);
  bottom: 0;
  width: min(100%, 780px);
  max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheetUp .34s var(--ease) both;
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes sheetUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
.sheet.is-closing { animation: sheetDown .22s ease both; }
@keyframes sheetDown { to { transform: translate(-50%, 100%); opacity: .6; } }

.sheet-grab { width: 40px; height: 4px; border-radius: 99px; background: var(--border-strong); margin: 9px auto 2px; flex: none; }
.sheet-head {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.sheet-title { font-size: 17px; font-weight: 720; letter-spacing: -.02em; flex: 1; min-width: 0; }
.sheet-sub { font-size: 12.5px; color: var(--muted); }
.sheet-body { padding: 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; flex: none;
  background: var(--surface);
}
.sheet-foot .btn { flex: 1; }
.sheet-foot .btn-ghost { flex: 0 0 auto; }

.dialog-wrap {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: 22px;
  background: rgba(5, 10, 18, .5);
  backdrop-filter: blur(3px);
  animation: fade .18s ease both;
}
.dialog {
  width: min(100%, 380px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow-lg);
  animation: pop .26s var(--ease) both;
}
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.dialog h3 { font-size: 17px; font-weight: 720; letter-spacing: -.02em; margin-bottom: 6px; }
.dialog p { font-size: 14px; color: var(--muted); line-height: 1.5; }
.dialog-actions { display: flex; gap: 10px; margin-top: 20px; }
.dialog-actions .btn { flex: 1; }

/* ============================ Toast ============================ */

.toast-root {
  position: fixed; z-index: 300; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 30px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(calc(100% - 32px), 460px); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 16px; border-radius: 13px;
  background: #0f1724; color: #eef5ff;
  font-size: 13.5px; font-weight: 560;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .3);
  animation: toastIn .3s var(--ease) both;
  max-width: 100%;
}
html[data-theme="dark"] .toast { background: #1d2a3d; border: 1px solid var(--border); }
.toast svg { width: 17px; height: 17px; flex: none; color: var(--lime); }
.toast.danger svg { color: #ff8a8d; }
.toast.is-out { animation: toastOut .24s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ============================ Empty state ============================ */

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 34px 20px; gap: 6px;
}
.empty-ico {
  width: 56px; height: 56px; border-radius: 18px;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--muted);
  margin-bottom: 6px;
}
.empty-ico svg { width: 26px; height: 26px; }
.empty h4 { font-size: 15px; font-weight: 680; }
.empty p { font-size: 13px; color: var(--muted); max-width: 280px; line-height: 1.5; }
.empty .btn { margin-top: 12px; }

/* ============================ Photos ============================ */

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-cell {
  position: relative; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden;
  background: var(--surface-3); cursor: pointer; border: 0; padding: 0;
}
.photo-cell img { width: 100%; height: 100%; object-fit: cover; }
.photo-cell .photo-tag {
  position: absolute; left: 6px; bottom: 6px;
  padding: 2px 7px; border-radius: 6px;
  background: rgba(6, 14, 22, .62); color: #fff;
  font-size: 10px; font-weight: 620; backdrop-filter: blur(4px);
}
.photo-cell .photo-del {
  position: absolute; right: 5px; top: 5px; width: 24px; height: 24px;
  border-radius: 8px; border: 0; background: rgba(6, 14, 22, .62); color: #fff;
  display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(4px);
}
.photo-cell .photo-del svg { width: 13px; height: 13px; }

.photo-add {
  aspect-ratio: 3 / 4; border-radius: 12px;
  border: 1.5px dashed var(--border-strong); background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); font-size: 11.5px; font-weight: 620; cursor: pointer;
}
.photo-add svg { width: 22px; height: 22px; }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare figure { margin: 0; }
.compare .compare-img {
  aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden;
  background: var(--surface-3); display: grid; place-items: center;
  border: 1px solid var(--border);
}
.compare .compare-img img { width: 100%; height: 100%; object-fit: cover; }
.compare figcaption { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 6px; }

/* ============================ Charts ============================ */

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .axis-label { fill: var(--faint); font-size: 9px; font-weight: 560; }
.chart .line { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart-empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 13px; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); font-weight: 580; }
.legend i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }

.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 96px; margin-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; height: 100%; }
.bar-col .bar { width: 100%; border-radius: 6px 6px 3px 3px; background: var(--brand); min-height: 3px; transition: height .4s var(--ease); }
.bar-col .bar.alt { background: linear-gradient(180deg, var(--lime), var(--brand)); }
.bar-col .bar-label { font-size: 9.5px; color: var(--faint); font-weight: 560; }

/* ============================ Calendar / agenda ============================ */

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.day-cell {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 13px; padding: 7px 0 6px; display: flex; flex-direction: column;
  align-items: center; gap: 1px; cursor: pointer; color: var(--text-2);
  transition: all .16s ease;
}
.day-cell .dw { font-size: 9.5px; font-weight: 660; text-transform: uppercase; color: var(--faint); letter-spacing: .04em; }
.day-cell .dn { font-size: 15px; font-weight: 700; }
.day-cell .dd { width: 4px; height: 4px; border-radius: 50%; background: var(--brand); opacity: 0; }
.day-cell.has-events .dd { opacity: 1; }
.day-cell.is-today .dn { color: var(--brand-strong); }
.day-cell.is-active { background: var(--text); border-color: var(--text); color: var(--bg); }
.day-cell.is-active .dw, .day-cell.is-active .dn { color: inherit; }
.day-cell.is-active .dd { background: var(--bg); }
html[data-theme="dark"] .day-cell.is-active { background: var(--brand); color: #04211a; border-color: var(--brand); }

.agenda-row { display: flex; gap: 12px; align-items: stretch; }
.agenda-time {
  flex: none; width: 46px; display: flex; flex-direction: column; align-items: flex-start; padding-top: 2px;
}
.agenda-time b { font-size: 14px; font-weight: 720; letter-spacing: -.02em; }
.agenda-time span { font-size: 10.5px; color: var(--faint); }
.agenda-line { width: 2px; border-radius: 2px; background: var(--border); flex: none; position: relative; }
.agenda-line::before {
  content: ""; position: absolute; left: 50%; top: 8px; transform: translateX(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--brand-soft);
}
.agenda-body { flex: 1; min-width: 0; padding-bottom: 14px; }
.agenda-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 11px 13px; box-shadow: var(--shadow-sm);
}
.agenda-card.is-done { opacity: .62; }
.agenda-card.is-canceled { opacity: .62; }
.agenda-card.is-canceled .agenda-name { text-decoration: line-through; }
.agenda-name { font-size: 14px; font-weight: 660; }
.agenda-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ============================ Login ============================ */

.lock {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(16, 185, 129, .22), transparent 60%),
    var(--bg);
  gap: 8px;
  text-align: center;
}
.lock-logo { width: 64px; height: 64px; border-radius: 20px; box-shadow: var(--shadow-md); }
.lock h1 { font-size: 24px; font-weight: 780; letter-spacing: -.03em; margin-top: 8px; }
.lock p { color: var(--muted); font-size: 13.5px; max-width: 280px; }
.pin-dots { display: flex; gap: 12px; margin: 20px 0 6px; }
.pin-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border-strong); background: transparent;
  transition: all .16s ease;
}
.pin-dot.is-filled { background: var(--brand-strong); border-color: var(--brand-strong); transform: scale(1.06); }
.pin-error { color: var(--danger); font-size: 12.5px; font-weight: 600; min-height: 18px; }
.shake { animation: shake .42s ease; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
.keypad {
  display: grid; grid-template-columns: repeat(3, 72px); gap: 12px;
  margin-top: 14px; justify-content: center;
}
.key {
  width: 72px; height: 62px; border-radius: 18px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 22px; font-weight: 620; color: var(--text);
  cursor: pointer; transition: transform .1s ease, background .15s ease;
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
}
.key:active { transform: scale(.93); background: var(--surface-3); }
.key.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.key svg { width: 22px; height: 22px; }

/* ============================ Splash ============================ */

.splash {
  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: var(--bg); color: var(--muted);
  transition: opacity .35s ease;
}
.splash img { border-radius: 22px; box-shadow: var(--shadow-lg); animation: pulse 1.6s ease-in-out infinite; }
.splash p { font-size: 15px; font-weight: 680; letter-spacing: .01em; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.05); opacity: 1; } }
.splash.is-out { opacity: 0; pointer-events: none; }

/* ============================ Timer widget ============================ */

.timer-widget {
  position: fixed; z-index: 60;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 82px + env(safe-area-inset-bottom));
  width: min(calc(100% - 36px), 380px);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: #0b1520; color: #e9f7ff;
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: var(--shadow-lg);
  animation: rise .3s var(--ease) both;
}
.timer-widget.is-done { background: linear-gradient(135deg, #0e3b2c, #062019); border-color: rgba(163, 230, 53, .4); }
.timer-ring { width: 44px; height: 44px; flex: none; position: relative; display: grid; place-items: center; }
.timer-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer-ring .t-val { font-size: 11.5px; font-weight: 720; letter-spacing: -.02em; }
.timer-info { flex: 1; min-width: 0; }
.timer-info b { display: block; font-size: 13px; font-weight: 660; }
.timer-info span { font-size: 11px; opacity: .65; }
.timer-widget .btn-icon { background: rgba(255, 255, 255, .1); border-color: transparent; color: #e9f7ff; width: 34px; height: 34px; border-radius: 10px; }

/* ============================ Misc ============================ */

.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 620; text-align: right; }

.divider { height: 1px; background: var(--border); margin: 4px 0; }

.note {
  display: flex; gap: 10px; padding: 12px 14px;
  background: var(--info-soft); color: var(--text-2);
  border-radius: 13px; font-size: 12.5px; line-height: 1.5;
}
.note svg { width: 17px; height: 17px; color: var(--info); flex: none; margin-top: 1px; }
.note.warn { background: var(--warn-soft); }
.note.warn svg { color: var(--warn); }

.exercise-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.exercise-row + .exercise-row { border-top: 1px solid var(--border); }
.exercise-num {
  width: 26px; height: 26px; border-radius: 8px; background: var(--surface-3);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700; color: var(--muted); flex: none;
}
.exercise-main { flex: 1; min-width: 0; }
.exercise-name { font-size: 14px; font-weight: 620; }
.exercise-spec { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.workout-day-head {
  display: flex; align-items: center; gap: 9px; margin-bottom: 2px;
}
.day-letter {
  width: 30px; height: 30px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-weight: 760; font-size: 14px;
  background: var(--brand-soft); color: var(--brand-strong);
}
html[data-theme="dark"] .day-letter { color: var(--brand); }

.metric-pill {
  display: flex; align-items: baseline; gap: 5px; padding: 8px 12px;
  background: var(--surface-2); border-radius: 11px; border: 1px solid var(--border);
}
.metric-pill b { font-size: 16px; font-weight: 740; letter-spacing: -.02em; }
.metric-pill span { font-size: 10.5px; color: var(--muted); }

.file-drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 22px; border: 1.5px dashed var(--border-strong); border-radius: 16px;
  background: var(--surface-2); color: var(--muted); font-size: 13px; cursor: pointer; text-align: center;
}
.file-drop svg { width: 26px; height: 26px; }
.file-drop strong { color: var(--text); font-size: 14px; }

/* ============================ Responsive ============================ */

@media (min-width: 620px) {
  .view { padding-left: 24px; padding-right: 24px; }
  .appbar { padding-left: 24px; padding-right: 24px; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .sheet { bottom: 12px; border-radius: 26px; max-height: 88dvh; border-bottom: 1px solid var(--border); }
  .sheet.is-closing { animation: sheetDownDesk .22s ease both; }
  @keyframes sheetDownDesk { to { transform: translate(-50%, 30px); opacity: 0; } }
}

@media (min-width: 900px) {
  .app { max-width: 880px; }
  .view { padding-bottom: 120px; }
  .tabbar { width: 560px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================ Print ============================ */
@media print {
  .appbar, .tabbar, .fab, .timer-widget, .toast-root, #sheet-root, #dialog-root { display: none !important; }
  .app { max-width: none; }
  .view { padding: 0; }
  body { background: #fff; color: #000; }
}

/* ============================ Dashboard extras ============================ */

.hero-delta {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 99px;
  background: rgba(163, 230, 53, .16);
  color: #d9f99d; font-size: 11.5px; font-weight: 680;
  border: 1px solid rgba(163, 230, 53, .18);
}
.hero-delta.down { background: rgba(255, 138, 141, .14); color: #ffb4b6; border-color: rgba(255, 138, 141, .2); }

.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.quick {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 4px 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-sm);
  font-size: 10.5px; font-weight: 640; color: var(--text-2);
  cursor: pointer; transition: transform .14s var(--ease), background .18s ease;
}
.quick:active { transform: scale(.95); }
.quick-ico {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-strong);
}
html[data-theme="dark"] .quick-ico { color: var(--brand); }
.quick-ico.info { background: var(--info-soft); color: var(--info); }
.quick-ico.lime { background: rgba(163, 230, 53, .18); color: #65a30d; }
html[data-theme="dark"] .quick-ico.lime { color: var(--lime); }
.quick-ico.violet { background: rgba(139, 92, 246, .14); color: #7c3aed; }
html[data-theme="dark"] .quick-ico.violet { color: #a78bfa; }

.alert-ico {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--muted);
}
.alert-ico.danger { background: var(--danger-soft); color: var(--danger); }
.alert-ico.warn { background: var(--warn-soft); color: var(--warn); }
.alert-ico.info { background: var(--info-soft); color: var(--info); }

.time-col {
  flex: none; width: 48px; display: flex; flex-direction: column;
  align-items: flex-start; gap: 1px;
}
.time-col b { font-size: 14px; font-weight: 720; letter-spacing: -.02em; }
.time-col span { font-size: 10.5px; color: var(--faint); }

button.stat {
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  transition: transform .14s var(--ease), border-color .18s ease;
}
button.stat:active { transform: scale(.975); }
button.stat:hover { border-color: var(--border-strong); }

.welcome-card {
  background:
    radial-gradient(120% 140% at 100% 0%, var(--brand-soft), transparent 60%),
    var(--surface);
  border-color: color-mix(in srgb, var(--brand) 26%, var(--border));
}

/* ============================ Aluno — detalhe ============================ */

.student-hero { padding: 18px; }
.student-name { font-size: 21px; font-weight: 760; letter-spacing: -.03em; line-height: 1.15; }

.contact-row { display: flex; gap: 7px; margin-top: 14px; flex-wrap: wrap; }
.contact-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; font-weight: 620; color: var(--text-2);
}
.contact-btn svg { width: 15px; height: 15px; }
.contact-btn.wa { background: rgba(37, 211, 102, .12); color: #0f9d58; border-color: transparent; }
html[data-theme="dark"] .contact-btn.wa { color: #4ade80; }

.mini-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
}
.mini-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mini-stat span { font-size: 10.5px; font-weight: 620; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mini-stat b { font-size: 14px; font-weight: 700; letter-spacing: -.015em; }
.mini-stat small { font-size: 11px; color: var(--faint); display: flex; align-items: center; gap: 4px; }

.notes-box {
  display: flex; gap: 8px; margin-top: 14px; padding: 10px 12px;
  background: var(--surface-2); border-radius: 12px;
  font-size: 12.5px; color: var(--text-2); line-height: 1.45;
}
.notes-box svg { color: var(--muted); flex: none; margin-top: 1px; }

.tab-btn svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }

/* ============================ Login ============================ */

.login-form {
  width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 12px;
  margin-top: 20px; text-align: left;
}
.login-form .input { background: var(--surface); height: 50px; font-size: 16px; box-shadow: var(--shadow-sm); }
.login-form .btn-block { max-width: none; margin-top: 2px; }
.login-pass { position: relative; }
.login-pass .input { padding-right: 48px; }
.login-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer;
}
.login-eye:active { background: var(--surface-3); }
.login-error { min-height: 18px; color: var(--danger); font-size: 12.5px; font-weight: 620; text-align: center; }
.login-hint {
  max-width: 320px; margin-top: 6px; padding: 9px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px;
  font-size: 11.5px; color: var(--muted); line-height: 1.5;
}
.login-hint b { color: var(--text-2); font-weight: 700; }
.lock .btn-ghost { margin-top: 2px; }

/* Abas do aluno: 4 opções cabem na largura do celular */
.student-tabs { gap: 5px; }
.student-tabs .tab-btn { padding: 0 8px; font-size: 12.5px; flex: 1 1 0; min-width: 0; text-align: center; }

/* Abas do aluno (5) e do financeiro (4) cabem na tela */
.student-tabs {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px; overflow: visible;
}
.student-tabs .tab-btn {
  padding: 0 4px; font-size: 11.5px; text-align: center;
  height: 34px; min-width: 0; overflow: hidden; text-overflow: ellipsis;
}

#fin-tabs {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px; overflow: visible;
}
#fin-tabs .tab-btn { padding: 0 4px; font-size: 12px; text-align: center; min-width: 0; }
@media (max-width: 430px) {
  #fin-tabs .tab-btn svg { display: none; }
}
