/* ==========================================================================
   HabitFlow — design system (Phase 6)
   A calm, focus-first productivity aesthetic: warm neutral canvas, a single
   green accent, and a deliberate visual hierarchy so sections do not read as
   identical card rows.

   Everything lives here (no inline styles) to satisfy the Content Security
   Policy (style-src 'self'). The system font stack is intentional — external
   web fonts are blocked by the CSP.
   ========================================================================== */

:root {
    /* Surfaces */
    --bg: #f5f7f4;
    --bg-tint: #eef3ee;
    --surface: #ffffff;
    --surface-2: #f7f9f6;
    --surface-3: #eef3ee;

    /* Ink */
    --ink: #16211c;
    --ink-soft: #37443d;
    --muted: #6a7872;
    --muted-2: #8b968f;

    /* Lines */
    --line: #e3e9e4;
    --line-strong: #d2dbd5;

    /* Accent */
    --accent: #1e7a58;
    --accent-strong: #155f43;
    --accent-soft: #e6f3ec;
    --accent-line: #bcdcc9;

    /* Semantic */
    --danger: #ad4130;
    --danger-soft: #fdece8;
    --danger-line: #f0c8c1;
    --warn: #8a6414;
    --warn-soft: #fdf3d9;
    --neutral-soft: #eef2ef;

    /* Shape */
    --r-xs: 7px;
    --r-sm: 9px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-pill: 999px;

    /* Elevation — subtle, two-layer */
    --sh-1: 0 1px 2px rgba(18, 34, 27, .05);
    --sh-2: 0 2px 6px rgba(18, 34, 27, .05), 0 14px 30px -20px rgba(18, 34, 27, .30);
    --sh-3: 0 20px 44px -26px rgba(18, 34, 27, .38);

    /* Rhythm */
    --max: 1080px;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    font-weight: 650;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

h1,
h2,
h3 {
    color: var(--ink);
    font-weight: 750;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0 0 12px;
}

h1 {
    font-size: clamp(1.85rem, 3.6vw, 2.35rem);
}

h2 {
    font-size: 1.3rem;
}

h3 {
    font-size: 1.08rem;
}

p {
    margin: 0 0 12px;
}

.eyebrow {
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.page-container {
    margin: 0 auto;
    max-width: var(--max);
    padding: 40px 26px 76px;
}

.section-spaced {
    margin-top: 52px;
}

.section-heading {
    align-items: baseline;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin: 0 0 18px;
}

.section-heading h2 {
    margin: 0;
}

.section-heading a {
    font-size: 0.9rem;
    white-space: nowrap;
}

.page-heading {
    align-items: flex-end;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 30px;
}

.page-heading h1 {
    margin: 0 0 6px;
}

.page-heading .muted {
    margin: 0;
}

/* --------------------------------------------------------------------------
   Header / navigation
   -------------------------------------------------------------------------- */

.site-header {
    align-items: center;
    background: rgba(245, 247, 244, .86);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin: 0 auto;
    max-width: 100%;
    padding: 14px 26px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.site-header > .brand,
.site-header > nav {
    /* keep the nav row aligned with the page content width */
    max-width: var(--max);
}

.site-header nav {
    align-items: center;
    display: flex;
    gap: 6px;
}

.brand {
    align-items: center;
    color: var(--ink);
    display: inline-flex;
    font-size: 1.06rem;
    font-weight: 800;
    gap: 10px;
    letter-spacing: -0.01em;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    align-items: center;
    background: var(--accent);
    border-radius: 9px;
    color: #fff;
    display: inline-flex;
    font-size: 0.95rem;
    font-weight: 800;
    height: 30px;
    justify-content: center;
    width: 30px;
}

.nav-link {
    border-radius: var(--r-pill);
    color: var(--ink-soft);
    font-size: 0.93rem;
    font-weight: 650;
    padding: 8px 14px;
}

.nav-link:hover {
    background: var(--surface-3);
    color: var(--ink);
    text-decoration: none;
}

.nav-link.is-active {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.site-header .logout-form {
    margin-left: 6px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 0.93rem;
    font-weight: 700;
    gap: 8px;
    justify-content: center;
    padding: 10px 18px;
    text-align: center;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}

.button:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.button:active {
    transform: translateY(0);
}

.button:focus-visible,
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.day-option:focus-within,
.today-card:focus-visible {
    outline: 3px solid rgba(30, 122, 88, .35);
    outline-offset: 2px;
}

.button-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(18, 34, 27, .12);
}

.button-primary:hover {
    background: var(--accent-strong);
}

.button-outline {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink-soft);
}

.button-outline:hover {
    border-color: var(--accent-line);
    color: var(--accent-strong);
}

.button-danger {
    background: var(--danger-soft);
    border-color: var(--danger-line);
    color: var(--danger);
}

.button-danger:hover {
    background: #fbe0da;
}

.button-full {
    width: 100%;
}

.button-sm {
    font-size: 0.85rem;
    padding: 8px 14px;
}

/* Logout is a POST form; keep it looking like a nav control. */
.logout-form {
    display: inline;
    margin: 0;
}

.site-header .logout-form .button {
    padding: 8px 16px;
}

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */

.alert {
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    font-size: 0.92rem;
    margin: 0 0 22px;
    padding: 12px 15px;
}

.alert.error {
    background: var(--danger-soft);
    border-color: var(--danger-line);
    color: #8e3225;
}

.alert.success {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent-strong);
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

label {
    display: block;
    font-size: 0.88rem;
    font-weight: 700;
    margin: 20px 0 7px;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    color: var(--ink);
    font: inherit;
    padding: 11px 13px;
    width: 100%;
}

input::placeholder,
textarea::placeholder {
    color: var(--muted-2);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30, 122, 88, .14);
    outline: 0;
}

textarea {
    resize: vertical;
}

.field {
    margin-bottom: 18px;
}

.field label,
.field legend {
    display: block;
    font-size: 0.88rem;
    font-weight: 700;
    margin: 0 0 7px;
    padding: 0;
}

.field-row {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr 1fr;
}

.tracking-panel[hidden] {
    display: none;
}

.tracking-panel > .field-help {
    grid-column: 1 / -1;
}

.field-help {
    color: var(--muted);
    font-size: 0.84rem;
    margin: 7px 0 0;
}

.field-error {
    color: var(--danger);
    font-size: 0.84rem;
    font-weight: 600;
    margin: 7px 0 0;
}

.optional {
    color: var(--muted-2);
    font-weight: 500;
}

.day-fieldset,
.reward-fieldset {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    margin: 0 0 20px;
    padding: 16px 18px 18px;
}

.day-fieldset legend,
.reward-fieldset legend {
    font-size: 0.88rem;
    font-weight: 750;
    margin-bottom: 8px;
    padding: 0 7px;
}

.reward-fieldset .field:last-child {
    margin-bottom: 0;
}

.today-card.is-loading,
.habit-card.is-loading {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity .2s ease;
}

/* Day picker grid layout */
.day-picker {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
}

.day-option {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    cursor: pointer;
    display: flex;
    font-size: 0.85rem;
    font-weight: 700;
    justify-content: center;
    margin: 0;
    padding: 10px 8px;
    transition: all .12s ease;
    user-select: none;
    color: var(--ink-soft);
}

.day-option input {
    accent-color: var(--accent);
    cursor: pointer;
    height: 16px;
    margin: 0 8px 0 0;
    width: 16px;
}

.day-option:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent-strong);
}

/* Tracking method chooser (completion / timer / quantity) */
.tracking-fieldset {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    margin: 0 0 20px;
    padding: 16px 18px 18px;
}

.tracking-fieldset legend {
    font-size: 0.88rem;
    font-weight: 750;
    margin-bottom: 10px;
    padding: 0 7px;
}

.tracking-options {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.tracking-option {
    align-items: flex-start;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    cursor: pointer;
    display: flex;
    gap: 10px;
    margin: 0;
    padding: 12px 14px;
    transition: background-color .12s ease, border-color .12s ease;
}

.tracking-option input {
    accent-color: var(--accent);
    cursor: pointer;
    flex: none;
    height: 17px;
    margin: 2px 0 0;
    width: 17px;
}

.tracking-option:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent-line);
}

.tracking-option-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tracking-option-title {
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 750;
}

.tracking-option-help {
    color: var(--muted);
    font-size: 0.79rem;
    line-height: 1.4;
}

.form-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

/* --------------------------------------------------------------------------
   Panels & generic surfaces
   -------------------------------------------------------------------------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
    padding: 28px;
}

/* --------------------------------------------------------------------------
   Stats (used by the dashboard supporting strip)
   -------------------------------------------------------------------------- */

.stat-value {
    color: var(--ink);
    font-size: 1.7rem;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    line-height: 1.1;
}

.stat-label {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 650;
}

/* --------------------------------------------------------------------------
   Dashboard — PRIMARY region (Today)
   -------------------------------------------------------------------------- */

.dashboard {
    padding-top: 34px;
}

.today-section {
    background:
        linear-gradient(180deg, var(--surface) 0%, var(--surface) 62%, var(--surface-2) 100%);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-2);
    margin-bottom: 40px;
    padding: 26px 26px 30px;
}

.today-section-head {
    align-items: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 28px;
}

.today-section-head h2 {
    font-size: 1.6rem;
    margin: 0 0 8px;
}

.date-chip {
    align-items: center;
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    border-radius: var(--r-pill);
    color: var(--accent-strong);
    display: inline-flex;
    font-size: 0.82rem;
    font-weight: 750;
    gap: 7px;
    padding: 6px 14px;
}

/* Daily progress — the most prominent progress figure. */
.progress-area {
    align-items: stretch;
    display: grid;
    gap: 16px;
    grid-template-columns: 1.5fr 1fr;
    margin-bottom: 24px;
}

.progress-hero {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 22px 24px;
}

.progress-hero-figure {
    align-items: baseline;
    display: flex;
    gap: 10px;
    margin: 0 0 12px;
}

.progress-hero-value {
    color: var(--accent);
    font-size: 2.9rem;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    line-height: 1;
}

.progress-hero-label {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
}

.progress-hero .progress-stats {
    margin-top: 16px;
}

/* Weekly — a quieter supporting summary. */
.weekly-aside {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 20px 22px;
}

.weekly-aside h3 {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    margin: 0 0 10px;
    text-transform: uppercase;
}

.weekly-aside .progress-figure {
    margin: 0 0 10px;
}

.weekly-aside .progress-figure strong {
    color: var(--ink);
    font-size: 1.5rem;
    font-variant-numeric: tabular-nums;
}

.progress-bar {
    background: var(--surface-3);
    border-radius: var(--r-pill);
    height: 11px;
    overflow: hidden;
    width: 100%;
}

.progress-fill {
    background: var(--accent);
    border-radius: var(--r-pill);
    display: block;
    height: 100%;
    width: 0;
}

.weekly-aside .progress-bar {
    height: 8px;
}

.weekly-aside .progress-fill {
    background: var(--accent-line);
}

/* Compact bar used inside today's tracking block */
.progress-bar-sm {
    height: 8px;
}

.progress-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.progress-stats li {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: 0.85rem;
    gap: 7px;
}

.progress-stats strong {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.dot {
    border-radius: 50%;
    display: inline-block;
    height: 9px;
    width: 9px;
}

.dot-pending {
    background: var(--line-strong);
}

.dot-completed {
    background: var(--accent);
}

.dot-missed {
    background: #d98b80;
}

/* Partial progress on an unfinished session (still "missed" internally) */
.dot-incomplete {
    background: var(--warn);
}

/* Supporting stat strip — compact, sits below the primary region. */
.dashboard-support {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    display: flex;
    flex-wrap: wrap;
    gap: 10px 28px;
    justify-content: space-between;
    margin-bottom: 44px;
    padding: 16px 24px;
}

.support-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 30px;
}

.support-stat {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.support-stat .stat-value {
    font-size: 1.35rem;
}

.support-stat .stat-label {
    font-size: 0.8rem;
}

/* --------------------------------------------------------------------------
   Energy Level Smart Filter — compact toolbar
   -------------------------------------------------------------------------- */

.energy-toolbar {
    align-items: flex-end;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}

.energy-filter-help {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.4;
    margin: 0;
    max-width: 320px;
    text-align: right;
}

.energy-options {
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    display: inline-flex;
    gap: 4px;
    padding: 4px;
}

.energy-option {
    border-radius: var(--r-pill);
    color: var(--ink-soft);
    font-size: 0.82rem;
    font-weight: 700;
    padding: 7px 16px;
    transition: background-color .12s ease, color .12s ease;
}

.energy-option:hover {
    background: rgba(255, 255, 255, .7);
    text-decoration: none;
}

.energy-option.is-active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(18, 34, 27, .15);
}

.energy-option.is-active:hover {
    background: var(--accent);
}

/* Larger, standalone variant used when the toolbar sits on its own line. */
.energy-toolbar.is-block {
    margin-bottom: 24px;
}

.energy-toolbar.is-block .energy-options {
    background: transparent;
    border: 0;
    border-radius: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0;
}

.energy-toolbar.is-block .energy-option {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 9px 18px;
}

.energy-toolbar.is-block .energy-option.is-active {
    border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Habit tiles / cards
   -------------------------------------------------------------------------- */

.habit-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.habit-tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    position: relative;
    transition: box-shadow .15s ease, border-color .15s ease, transform .12s ease;
}

.habit-tile:hover {
    border-color: var(--line-strong);
    box-shadow: var(--sh-2);
}

.habit-tile-head {
    align-items: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
}

.habit-title {
    align-items: flex-start;
    display: flex;
    flex: 1;
    gap: 9px;
    min-width: 0;
}

.habit-tile-head h3 {
    font-size: 1.12rem;
    letter-spacing: -0.01em;
    line-height: 1.3;
    margin: 0;
    overflow-wrap: break-word;
    word-break: normal;
}

.habit-description {
    color: var(--muted);
    font-size: 0.93rem;
    margin: 0;
}

.habit-meta {
    align-items: center;
    display: flex;
    font-size: 0.93rem;
    font-weight: 700;
    gap: 8px;
    margin: 0;
}

.meta-label {
    color: var(--muted-2);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.habit-schedule {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.day-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.day-chip {
    align-items: center;
    background: var(--surface-3);
    border-radius: var(--r-xs);
    color: var(--muted-2);
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 750;
    justify-content: center;
    min-width: 32px;
    padding: 4px 6px;
}

.day-chip.is-active {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.habit-tile-actions {
    align-items: center;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 10px;
    margin-top: auto;
    padding-top: 16px;
}

.habit-tile-actions form {
    display: inline;
    margin: 0;
}

.habit-tile-actions .button {
    font-size: 0.87rem;
    padding: 8px 15px;
}

/* --------------------------------------------------------------------------
   Pills, status & badges
   -------------------------------------------------------------------------- */

.pill {
    border-radius: var(--r-pill);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    padding: 6px 12px;
    text-transform: uppercase;
    white-space: nowrap;
}

.pill-low {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.pill-medium {
    background: var(--warn-soft);
    color: var(--warn);
}

.pill-high {
    background: var(--danger-soft);
    color: var(--danger);
}

.status-dot {
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    height: 10px;
    margin-top: 6px;
    width: 10px;
}

.status-dot-pending {
    background: var(--line-strong);
}

.status-dot-completed {
    background: var(--accent);
}

.status-dot-missed {
    background: #d98b80;
}

.status-badge {
    border-radius: var(--r-pill);
    display: inline-block;
    font-size: 0.71rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    padding: 5px 11px;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-pending {
    background: var(--neutral-soft);
    color: var(--muted);
}

.badge-completed {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.badge-missed {
    background: var(--danger-soft);
    color: var(--danger);
}

/* A missed session that still captured partial progress */
.badge-incomplete {
    background: var(--warn-soft);
    color: var(--warn);
}

/* --------------------------------------------------------------------------
   "Today" habit cards — the strongest visual presence on the dashboard
   -------------------------------------------------------------------------- */

.today-card {
    border-left: 4px solid var(--line-strong);
    gap: 10px;
    padding-left: 21px;
}

.today-card.status-completed {
    background: linear-gradient(180deg, #f4fbf7 0%, var(--surface) 70%);
    border-left-color: var(--accent);
}

.today-card.status-missed {
    border-left-color: #d98b80;
}

.today-card.status-pending {
    border-left-color: var(--accent-line);
}

.today-card.is-undoable {
    cursor: pointer;
}

.today-card.is-undoable:hover {
    box-shadow: var(--sh-2);
}

.today-card.is-undoable:focus-visible {
    outline: 3px solid rgba(30, 122, 88, .35);
    outline-offset: 2px;
}

.today-status {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.status-time {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 600;
}

.today-card-foot {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    padding-top: 4px;
}

.today-action {
    display: block;
    margin: 0;
}

.today-action .button {
    margin-top: 0;
}

.today-reveal-hint {
    color: var(--muted);
    font-size: 0.78rem;
    margin: 8px 0 0;
}

.undo-panel {
    border-top: 1px dashed var(--line-strong);
    display: none;
    margin-top: 10px;
    padding-top: 14px;
}

.today-card.is-revealed .undo-panel {
    display: block;
}

.today-card.is-revealed .today-reveal-hint,
.today-card.is-expired .undo-panel,
.today-card.is-expired .today-reveal-hint {
    display: none;
}

.undo-hint {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0 0 10px;
}

.undo-hint [data-undo-countdown] {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

/* Per-method tracking block: recorded figure + compact progress bar */
.tracking-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 12px;
}

.tracking-progress-head {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    justify-content: space-between;
}

.tracking-progress-figure {
    align-items: baseline;
    display: inline-flex;
    gap: 5px;
}

.tracking-recorded,
.timer-clock {
    color: var(--ink);
    font-size: 0.98rem;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

.timer-clock {
    letter-spacing: 0.01em;
}

.tracking-progress-target {
    color: var(--muted-2);
    font-size: 0.85rem;
    font-weight: 650;
}

/* Timer controls sit side by side, wrapping on narrow cards */
.timer-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.timer-controls .today-action {
    flex: 1 1 auto;
    min-width: 130px;
}

/* Quantity entry: a small number field paired with an Add button */
.quantity-form {
    align-items: stretch;
    display: flex;
    gap: 10px;
}

.quantity-input {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    color: var(--ink);
    flex: 1 1 auto;
    font: inherit;
    font-variant-numeric: tabular-nums;
    min-width: 0;
    padding: 10px 13px;
    width: 100%;
}

.quantity-input:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(30, 122, 88, .18);
    outline-offset: 1px;
}

.quantity-form .button {
    flex: none;
    margin-top: 0;
}

/* --------------------------------------------------------------------------
   Streak & shield
   -------------------------------------------------------------------------- */

.streak-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.streak-badge {
    align-items: center;
    background: var(--warn-soft);
    border-radius: var(--r-pill);
    color: var(--warn);
    display: inline-flex;
    font-size: 0.76rem;
    font-weight: 700;
    gap: 4px;
    padding: 5px 11px;
    white-space: nowrap;
}

.streak-badge strong {
    font-weight: 900;
}

.shield-badge {
    border-radius: var(--r-pill);
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    padding: 5px 11px;
    text-transform: uppercase;
    white-space: nowrap;
}

.shield-ready {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.shield-used {
    background: var(--neutral-soft);
    color: var(--muted);
}

.shield-progress {
    background: var(--surface-3);
    color: var(--muted);
}

/* --------------------------------------------------------------------------
   Outcomes
   -------------------------------------------------------------------------- */

.outcome-badge {
    border-radius: var(--r-pill);
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    padding: 5px 11px;
    text-transform: uppercase;
    white-space: nowrap;
}

.outcome-reward {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.outcome-consequence {
    background: var(--danger-soft);
    color: var(--danger);
}

/* --------------------------------------------------------------------------
   History tables
   -------------------------------------------------------------------------- */

.panel-table {
    padding: 6px 24px;
}

.history-table {
    border-collapse: collapse;
    width: 100%;
}

.history-table th,
.history-table td {
    border-bottom: 1px solid var(--line);
    font-size: 0.91rem;
    padding: 14px 10px;
    text-align: left;
    vertical-align: middle;
}

.history-table th {
    color: var(--muted-2);
    font-size: 0.71rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.history-table tbody tr:last-child td {
    border-bottom: 0;
}

.history-table tbody tr:hover td {
    background: var(--surface-2);
}

/* --------------------------------------------------------------------------
   Empty states
   -------------------------------------------------------------------------- */

.empty-state {
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-lg);
    margin-top: 8px;
    padding: 42px 32px;
    text-align: center;
}

.empty-icon {
    color: var(--accent);
    display: block;
    font-size: 1.7rem;
    margin-bottom: 10px;
}

.empty-state h2 {
    margin-bottom: 6px;
}

.empty-state p {
    color: var(--muted);
    margin: 0 auto 18px;
    max-width: 46ch;
}

.empty-state .button {
    margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Auth pages
   -------------------------------------------------------------------------- */

.auth-shell {
    align-items: center;
    background:
        radial-gradient(1200px 520px at 50% -10%, var(--bg-tint) 0%, var(--bg) 60%);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 28px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-3);
    max-width: 430px;
    padding: 36px;
    width: 100%;
}

.auth-card .brand {
    margin-bottom: 30px;
}

.auth-card h1 {
    font-size: 1.85rem;
    margin-bottom: 6px;
}

.auth-card .form-footer {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 24px 0 0;
    text-align: center;
}

.auth-card form {
    margin-top: 22px;
}

.auth-card form label {
    margin: 18px 0 7px;
}

.auth-card form label:first-of-type {
    margin-top: 0;
}

.auth-card form .field-help {
    margin: 6px 0 0;
}

.auth-card form .button {
    margin-top: 24px;
}

/* --------------------------------------------------------------------------
   Landing page
   -------------------------------------------------------------------------- */

.hero {
    align-items: center;
    display: grid;
    gap: 56px;
    grid-template-columns: 1.05fr 0.95fr;
    margin: 0 auto;
    max-width: var(--max);
    min-height: calc(100vh - 64px);
    padding: 40px 26px 72px;
}

.hero-copy h1 {
    font-size: clamp(2.5rem, 6vw, 4.1rem);
    letter-spacing: -0.045em;
    line-height: 1.02;
    margin: 0 0 18px;
}

.hero-copy .muted {
    font-size: 1.12rem;
    max-width: 52ch;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.hero-art {
    background: linear-gradient(160deg, var(--bg-tint) 0%, #e3efe7 100%);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    min-height: 340px;
    padding: 26px;
    position: relative;
}

.habit-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-3);
    margin: 44px auto 0;
    max-width: 300px;
    padding: 22px;
    position: relative;
    z-index: 1;
}

.habit-card .eyebrow {
    margin-bottom: 4px;
}

.habit-card h2 {
    font-size: 1.2rem;
}

.habit-row {
    align-items: center;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 12px;
    font-size: 0.95rem;
    margin-top: 12px;
    padding-top: 12px;
}

.check {
    align-items: center;
    background: var(--accent-soft);
    border-radius: 50%;
    color: var(--accent);
    display: flex;
    flex: none;
    font-size: 0.8rem;
    height: 26px;
    justify-content: center;
    width: 26px;
}

/* --------------------------------------------------------------------------
   Toasts & Notifications
   -------------------------------------------------------------------------- */

.toast-container {
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    left: 50%;
    max-width: 400px;
    pointer-events: none;
    position: fixed;
    transform: translateX(-50%);
    width: 90%;
    z-index: 9999;
}

.toast {
    align-items: center;
    animation: toast-in 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--sh-3);
    color: var(--ink);
    display: flex;
    font-size: 0.92rem;
    font-weight: 650;
    gap: 12px;
    justify-content: space-between;
    padding: 14px 18px;
    pointer-events: auto;
}

.toast.success {
    border-left: 4px solid var(--accent);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast-close {
    background: none;
    border: none;
    color: var(--muted-2);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
}

.toast-close:hover {
    color: var(--ink);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast-fade-out {
    animation: toast-out 0.3s ease forwards;
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
.progress-trend {
    margin-top: 1.25rem;
    padding: 1.25rem;
}

.mini-chart {
    min-height: 10rem;
    display: flex;
    align-items: end;
    gap: 0.75rem;
}

.mini-chart-day {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.mini-chart-track {
    height: 7rem;
    display: flex;
    align-items: end;
    border-radius: 0.5rem;
    overflow: hidden;
    background: var(--surface-3);
}

.mini-chart-fill {
    width: 100%;
    height: 0;
    min-height: 3px;
    background: var(--accent);
}

.mini-chart-value,
.mini-chart-label {
    display: block;
    font-size: 0.78rem;
}

.mini-chart-label {
    margin-top: 0.35rem;
    color: var(--muted);
}

.milestones-section {
    margin-top: 2rem;
}

.milestone-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 1rem;
}

.milestone-card {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: var(--surface);
}

.milestone-earned {
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}


@media (max-width: 860px) {
    .progress-area {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .site-header {
        align-items: center;
        flex-direction: column;
        gap: 12px;
        padding: 14px 18px;
        position: static;
    }

    .site-header nav {
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
    }

    .page-container {
        padding: 28px 18px 60px;
    }

    .hero {
        gap: 28px;
        grid-template-columns: 1fr;
        padding: 28px 18px 56px;
    }

    .hero-art {
        min-height: 260px;
    }

    .today-section {
        padding: 20px 18px 24px;
    }

    .today-section-head {
        gap: 14px;
    }

    .energy-toolbar {
        align-items: flex-end;
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .energy-filter-help {
        text-align: right;
    }

    .energy-options {
        display: flex;
        width: 100%;
    }

    .energy-option {
        flex: 1 1 auto;
        text-align: center;
    }

    .field-row {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 22px;
    }

    .panel-table {
        padding: 4px 16px;
    }

    .dashboard-support {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-heading {
        align-items: flex-start;
    }

    .history-table thead {
        display: none;
    }

    .history-table tr {
        border-bottom: 1px solid var(--line);
        display: block;
        padding: 12px 0;
    }

    .history-table tr:last-child {
        border-bottom: 0;
    }

    .history-table td {
        border: 0;
        display: flex;
        gap: 12px;
        justify-content: space-between;
        padding: 5px 0;
    }

    .history-table td::before {
        color: var(--muted-2);
        content: attr(data-label);
        font-size: 0.71rem;
        font-weight: 800;
        letter-spacing: 0.09em;
        text-transform: uppercase;
    }
}

@media (max-width: 420px) {
    .habit-grid {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 26px 20px;
    }

    .button {
        width: 100%;
    }

    .site-header .logout-form .button,
    .energy-option,
    .habit-tile-actions .button,
    .section-heading a.button {
        width: auto;
    }
}

/* --------------------------------------------------------------------------
   My Account
   -------------------------------------------------------------------------- */

.account-grid {
    display: grid;
    gap: 32px;
    grid-template-columns: 1fr;
    margin-top: 24px;
}

.account-section {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
    padding: 24px;
}

.account-section h2 {
    font-size: 1.25rem;
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.account-section--danger {
    background: var(--danger-soft);
    border-color: var(--danger-line);
}

.account-section--danger h2 {
    border-bottom-color: var(--danger-line);
    color: var(--danger);
}

.account-actions-copy {
    margin-bottom: 20px;
}

.account-preferences-actions {
    margin-top: 24px;
}

.account-grid.is-compact {
    gap: 16px;
}

.account-feedback-toast {
    background: var(--accent);
    border-radius: var(--r-md);
    bottom: 20px;
    box-shadow: var(--sh-2);
    color: #fff;
    display: none;
    padding: 12px 24px;
    position: fixed;
    right: 20px;
    z-index: 2000;
}

.account-feedback-toast.is-visible {
    display: block;
}

.profile-info {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    margin-bottom: 24px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    color: var(--muted-2);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.info-value {
    color: var(--ink);
    font-weight: 600;
}

/* Subscription Plans */
.plan-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    margin-top: 20px;
}

.plan-card {
    background: var(--bg-tint);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: border-color .15s ease;
}

.plan-card.is-current {
    border: 2px solid var(--accent);
    position: relative;
}

.current-badge {
    background: var(--accent);
    border-radius: var(--r-pill);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 10px;
    position: absolute;
    right: 12px;
    text-transform: uppercase;
    top: -10px;
}

.plan-name {
    font-size: 1.1rem;
    font-weight: 800;
    margin: 0 0 4px;
}

.plan-price {
    color: var(--accent);
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 16px;
}

.plan-features {
    flex: 1;
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
}

.plan-features li {
    font-size: 0.9rem;
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
}

.plan-features li::before {
    content: '✓';
    left: 0;
    position: absolute;
}

/* Password Toggles */
.password-field {
    position: relative;
}

.toggle-password {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0;
    position: absolute;
    right: 12px;
    top: 40px;
}

/* Modals */
.modal-overlay {
    align-items: center;
    background: rgba(18, 34, 27, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    height: 100%;
    justify-content: center;
    left: 0;
    padding: 20px;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

.modal-overlay.is-active {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-3);
    max-width: 500px;
    padding: 32px;
    width: 100%;
}

.modal-head {
    margin-bottom: 24px;
}

.modal-head h3 {
    font-size: 1.4rem;
    margin: 0 0 8px;
}

/* Preferences */
.pref-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.pref-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Dark Mode Preview */
.theme-preview-dark {
    background: #16211c !important;
    color: #f5f7f4 !important;
}

.theme-preview-dark .account-section {
    background: #1e2924 !important;
    border-color: #2c3a33 !important;
}

.theme-preview-dark .info-value, 
.theme-preview-dark h1, 
.theme-preview-dark h2, 
.theme-preview-dark h3 {
    color: #fff !important;
}

.theme-preview-dark .muted, 
.theme-preview-dark .info-label {
    color: #8b968f !important;
}

/* Demo Notice */
.demo-notice {
    background: var(--warn-soft);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--warn);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 24px;
    padding: 12px 16px;
}

@media (max-width: 760px) {
    .plan-grid {
        grid-template-columns: 1fr;
    }
}

/* Subscription and admin pages */
.billing-current {
    align-items: center;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 22px;
    padding: 24px;
}

.plan-banner {
    align-items: center;
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    border-radius: var(--r-md);
    color: var(--accent-strong);
    display: flex;
    gap: 12px 20px;
    justify-content: space-between;
    margin: 0 0 20px;
    padding: 12px 16px;
}

.plan-banner div {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.plan-banner span {
    color: var(--ink-soft);
}

.billing-current h2,
.billing-plan h2 {
    margin: 0 0 6px;
}

.billing-current .muted {
    margin: 0;
}

.plan-status,
.billing-badge {
    background: var(--neutral-soft);
    border-radius: var(--r-pill);
    color: var(--ink-soft);
    display: inline-flex;
    flex: none;
    font-size: 0.76rem;
    font-weight: 800;
    padding: 6px 12px;
    white-space: nowrap;
}

.plan-status.is-premium,
.billing-badge.status-paid {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.billing-plan-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 22px;
}

.billing-plan {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 25px;
    position: relative;
}

.billing-plan.is-current {
    border: 2px solid var(--accent);
}

.billing-plan-premium {
    background: linear-gradient(145deg, var(--surface), var(--accent-soft));
}

.billing-current-badge {
    background: var(--accent);
    border-radius: var(--r-pill);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 4px 11px;
    position: absolute;
    right: 16px;
    top: 16px;
}

.billing-price {
    color: var(--accent-strong);
    font-size: 1.65rem;
    font-weight: 850;
    margin: 2px 0 16px;
}

.billing-price span {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.billing-plan ul {
    flex: 1;
    list-style: none;
    margin: 0 0 22px;
    padding: 0;
}

.billing-plan li {
    border-bottom: 1px solid var(--line);
    padding: 9px 0 9px 24px;
    position: relative;
}

.billing-plan li::before {
    color: var(--accent);
    content: '✓';
    font-weight: 900;
    left: 2px;
    position: absolute;
}

.billing-plan-note {
    padding: 10px 0;
}

.billing-request,
.billing-history,
.admin-section {
    margin-top: 22px;
    padding: 24px;
}

.payment-instructions {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    margin-bottom: 20px;
    padding: 16px 18px;
}

.payment-instructions h3 {
    margin: 0 0 6px;
}

.payment-instructions p {
    margin: 0 0 10px;
}

.payment-instructions p:last-child {
    margin-bottom: 0;
}

.billing-form {
    max-width: 620px;
}

.payment-settings-page {
    max-width: 1040px;
}

.payment-settings-status {
    align-items: center;
    border-left: 4px solid var(--line-strong);
    display: flex;
    gap: 24px;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 22px 24px;
}

.payment-settings-status.is-ready {
    background: var(--accent-soft);
    border-left-color: var(--accent);
}

.payment-settings-status.is-warning {
    background: var(--warn-soft);
    border-left-color: var(--warn);
}

.payment-settings-status.is-off {
    background: var(--surface-2);
}

.payment-settings-status h2 {
    font-size: 1.15rem;
    margin: 10px 0 4px;
}

.payment-settings-status p {
    color: var(--muted);
    margin: 0;
}

.payment-status-indicator,
.payment-mode-pill {
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    color: var(--muted);
    display: inline-flex;
    flex: none;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    padding: 6px 11px;
    text-transform: uppercase;
}

.payment-status-indicator {
    background: var(--surface);
}

.is-ready .payment-status-indicator {
    border-color: var(--accent-line);
    color: var(--accent-strong);
}

.payment-settings-panel {
    margin: 0 auto 24px;
    max-width: 860px;
    padding: 28px;
}

.payment-settings-section-head {
    align-items: flex-start;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 24px;
}

.payment-settings-section-head h2 {
    margin: 0 0 6px;
}

.payment-settings-section-head p {
    margin: 0;
}

.payment-enable-row {
    align-items: flex-start;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    display: flex;
    gap: 12px;
    margin: 8px 0 22px;
    padding: 15px 16px;
}

.payment-enable-row input[type="checkbox"] {
    flex: none;
    margin: 4px 0 0;
}

.payment-enable-row span,
.payment-enable-row small {
    display: block;
}

.payment-enable-row small {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 400;
    margin-top: 4px;
}

.payment-settings-advanced {
    border-top: 1px solid var(--line);
    margin: 0 0 22px;
    padding-top: 17px;
}

.payment-settings-advanced summary {
    color: var(--ink);
    cursor: pointer;
    font-weight: 700;
}

.payment-settings-advanced[open] summary {
    margin-bottom: 12px;
}

.payment-settings-advanced > .field-help {
    margin-bottom: 16px;
}

.payment-settings-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.payment-settings-actions .field-help {
    margin: 0;
}

.checkbox-label {
    align-items: center;
    display: flex;
    gap: 10px;
    margin: 12px 0 0;
}

.checkbox-label input[type="checkbox"] {
    flex: none;
    margin: 0;
}

.billing-table-wrap,
.admin-table-wrap {
    overflow-x: auto;
    width: 100%;
}

.billing-table,
.admin-table {
    border-collapse: collapse;
    min-width: 720px;
    width: 100%;
}

.admin-table {
    min-width: 900px;
}

.admin-account-filters {
    align-items: flex-end;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(200px, 2fr) repeat(2, minmax(145px, 1fr)) auto;
    margin-bottom: 20px;
}

.admin-account-filters .field,
.admin-account-filters .form-actions {
    margin: 0;
}

.admin-account-filters .form-actions {
    flex-wrap: nowrap;
}

.tracking-configurations [hidden] {
    display: none;
}

.billing-table th,
.billing-table td,
.admin-table th,
.admin-table td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: middle;
}

.billing-table th,
.admin-table th {
    color: var(--muted-2);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.billing-table td,
.admin-table td {
    font-size: 0.88rem;
}

.billing-badge.status-pending {
    background: var(--warn-soft);
    color: var(--warn);
}

.billing-badge.status-admin {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.billing-badge.status-rejected {
    background: var(--danger-soft);
    color: var(--danger);
}

.billing-badge.status-failed {
    background: var(--danger-soft);
    color: var(--danger);
}

.admin-notice {
    background: var(--warn-soft);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--warn);
    margin-bottom: 20px;
    padding: 13px 16px;
}

/* --------------------------------------------------------------------------
   Manual GCash checkout
   -------------------------------------------------------------------------- */

.gcash-checkout {
    margin-top: 22px;
    padding: 24px;
}

.gcash-layout {
    align-items: start;
    display: grid;
    gap: 28px;
    grid-template-columns: auto minmax(0, 1fr);
    margin: 8px 0 24px;
}

.gcash-qr {
    text-align: center;
}

.gcash-qr img {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    display: inline-block;
    height: auto;
    max-width: 280px;
    padding: 12px;
    width: 100%;
}

.gcash-details h2 {
    margin-top: 0;
}

.gcash-account {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    display: grid;
    gap: 4px 16px;
    grid-template-columns: auto 1fr;
    margin: 0 0 20px;
    padding: 14px 16px;
}

.gcash-account dt {
    color: var(--muted-2);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.gcash-account dd {
    margin: 0;
}

.gcash-qr-preview {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.gcash-qr-preview img {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    height: auto;
    max-width: 220px;
    padding: 10px;
    width: 100%;
}

.alert.warn {
    background: var(--warn-soft);
    border-color: var(--line);
    color: var(--warn);
}

/* --------------------------------------------------------------------------
   Admin billing payment filters and verification
   -------------------------------------------------------------------------- */

.billing-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.billing-filter-tab {
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    color: var(--muted-2);
    font-size: 0.82rem;
    font-weight: 700;
    padding: 7px 14px;
    text-decoration: none;
}

.billing-filter-tab.is-active {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent-strong);
}

.review-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
}

.review-note {
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: 0.82rem;
    padding: 7px 9px;
    width: 100%;
}

.review-actions {
    display: flex;
    gap: 8px;
}

@media (max-width: 720px) {
    .gcash-layout {
        grid-template-columns: 1fr;
    }
}

.admin-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.admin-shortcuts .button {
    align-items: center;
    display: inline-flex;
    gap: 8px;
}

.admin-shortcuts span {
    background: var(--warn-soft);
    border-radius: var(--r-pill);
    color: var(--warn);
    font-size: 0.75rem;
    padding: 2px 8px;
}

.admin-summary {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-bottom: 22px;
}

.admin-billing-page {
    max-width: 1180px;
}

.billing-connection-status {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 4px solid var(--line-strong);
    border-radius: var(--r-md);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    margin-bottom: 18px;
    padding: 15px 18px;
}

.billing-connection-status.is-ready {
    background: var(--accent-soft);
    border-left-color: var(--accent);
}

.billing-connection-status.is-warning {
    background: var(--warn-soft);
    border-left-color: var(--warn);
}

.billing-connection-status.is-off {
    background: var(--surface-2);
}

.billing-connection-indicator {
    background: var(--muted-2);
    border-radius: 50%;
    flex: 0 0 10px;
    height: 10px;
}

.billing-connection-status.is-ready .billing-connection-indicator {
    background: var(--accent);
}

.billing-connection-status.is-warning .billing-connection-indicator {
    background: var(--warn);
}

.billing-connection-copy {
    display: grid;
    flex: 1;
    gap: 3px;
}

.billing-connection-copy strong {
    color: var(--ink);
    font-size: 0.9rem;
}

.billing-connection-copy span {
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.billing-metrics {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 20px;
}

.billing-disclaimer {
    background: var(--surface-2);
    border-left: 3px solid var(--accent-line);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    color: var(--muted);
    font-size: 0.77rem;
    line-height: 1.5;
    margin: 0 0 12px;
    padding: 10px 13px;
}

.billing-metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--sh-1);
    min-width: 0;
    padding: 17px;
}

.billing-metric.is-highlight {
    background: var(--accent-soft);
    border-color: var(--accent-line);
}

.billing-metric > span {
    color: var(--muted);
    display: block;
    font-size: 0.78rem;
    line-height: 1.4;
    min-height: 2.2em;
}

.billing-metric strong {
    color: var(--ink);
    display: block;
    font-size: 1.45rem;
    font-variant-numeric: tabular-nums;
    margin-top: 7px;
    overflow-wrap: anywhere;
}

.billing-metric small {
    color: var(--muted);
    display: block;
    font-size: 0.73rem;
    line-height: 1.5;
    margin-top: 6px;
}

.billing-overview-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 20px;
}

.billing-overview-panel {
    min-width: 0;
}

.billing-overview-panel > .muted {
    font-size: 0.82rem;
    margin: -2px 0 16px;
}

.billing-panel-heading {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 10px;
}

.billing-panel-heading .eyebrow {
    margin: 0 0 4px;
}

.billing-panel-heading h2 {
    font-size: 1.1rem;
    margin: 0;
}

.billing-panel-meta {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    color: var(--muted);
    flex: 0 0 auto;
    font-size: 0.7rem;
    padding: 5px 9px;
}

.billing-trend-list {
    display: grid;
    gap: 11px;
}

.billing-trend-row {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: 72px minmax(50px, 1fr) 92px 42px;
}

.billing-trend-month {
    color: var(--muted);
    font-size: 0.73rem;
    white-space: nowrap;
}

.billing-trend-bar {
    height: 8px;
}

.billing-trend-row .progress-fill {
    transition: width 450ms ease;
}

.billing-trend-row strong {
    color: var(--ink-soft);
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.billing-trend-row small {
    color: var(--muted-2);
    font-size: 0.68rem;
    text-align: right;
    white-space: nowrap;
}

.billing-detail-list {
    border-top: 1px solid var(--line);
}

.billing-detail-row {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 11px 0;
}

.billing-detail-row > span,
.billing-detail-row > strong {
    color: var(--ink-soft);
    font-size: 0.81rem;
}

.billing-detail-row > strong {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.billing-detail-row small {
    color: var(--muted);
    display: block;
    font-size: 0.69rem;
    font-weight: 400;
    margin-top: 3px;
}

.billing-detail-row-muted {
    border-bottom: 0;
    color: var(--muted);
}

.billing-outcome-list {
    border-top: 1px solid var(--line);
}

.billing-outcome-list > div {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
}

.billing-outcome-list > div:last-child {
    border-bottom: 0;
}

.billing-outcome-list span {
    align-items: center;
    color: var(--ink-soft);
    display: inline-flex;
    font-size: 0.81rem;
    gap: 8px;
}

.billing-outcome-list strong {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.billing-outcome-dot {
    background: var(--muted-2);
    border-radius: 50%;
    height: 8px;
    width: 8px;
}

.billing-outcome-dot.is-paid {
    background: var(--accent);
}

.billing-outcome-dot.is-pending {
    background: var(--warn);
}

.billing-outcome-dot.is-failed,
.billing-outcome-dot.is-rejected {
    background: var(--danger);
}

.billing-panel-footnote {
    color: var(--muted);
    font-size: 0.71rem;
    line-height: 1.5;
    margin: 12px 0 0;
}

.admin-overview-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 22px;
}

.admin-overview-card {
    align-items: flex-start;
    display: flex;
    flex-direction: column;
}

.admin-overview-card h2 {
    margin: 0 0 8px;
}

.admin-overview-card p:not(.eyebrow) {
    flex: 1;
    margin: 0 0 18px;
}

.admin-stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--sh-1);
    min-width: 0;
    padding: 16px;
}

.admin-stat span {
    color: var(--muted);
    display: block;
    font-size: 0.77rem;
    line-height: 1.4;
    min-height: 2.2em;
}

.admin-stat strong {
    display: block;
    font-size: 1.45rem;
    margin-top: 8px;
    overflow-wrap: anywhere;
}

.admin-stat small {
    color: var(--muted-2);
    display: block;
    font-size: 0.72rem;
    margin-top: 6px;
}

.sr-only {
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

.admin-access-control {
    min-width: 190px;
}

.admin-access-control summary {
    cursor: pointer;
    list-style: none;
}

.admin-access-control summary::-webkit-details-marker {
    display: none;
}

.admin-access-form {
    display: grid;
    gap: 7px;
    margin-top: 8px;
    min-width: 190px;
}

.admin-access-form input,
.admin-access-form select {
    margin: 0;
    min-width: 190px;
    padding: 8px 10px;
}

@media (max-width: 900px) {
    .admin-summary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .billing-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .billing-overview-grid {
        grid-template-columns: 1fr;
    }

    .billing-connection-status {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .admin-overview-grid {
        grid-template-columns: 1fr;
    }

    .billing-plan-grid {
        grid-template-columns: 1fr;
    }

    .plan-banner {
        align-items: flex-start;
        flex-direction: column;
    }

    .billing-current {
        align-items: flex-start;
        flex-direction: column;
    }

    .payment-settings-panel {
        padding: 20px;
    }

    .payment-settings-status {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
        padding: 19px;
    }

    .payment-settings-section-head {
        flex-direction: column;
    }

    .admin-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-account-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .billing-request,
    .billing-history,
    .admin-section {
        padding: 17px;
    }
}

@media (max-width: 420px) {
    .billing-metrics {
        grid-template-columns: 1fr;
    }

    .billing-trend-row {
        gap: 7px;
        grid-template-columns: 58px minmax(35px, 1fr) 82px;
    }

    .billing-trend-month {
        grid-row: span 2;
    }

    .billing-trend-row small {
        grid-column: 3;
    }

    .admin-summary {
        grid-template-columns: 1fr;
    }

    .admin-account-filters {
        grid-template-columns: 1fr;
    }

    .admin-account-filters .form-actions {
        flex-wrap: wrap;
    }
}

/* --------------------------------------------------------------------------
   Insights — pace-based habit forecast
   -------------------------------------------------------------------------- */

.forecast-page {
    max-width: 1120px;
}

.forecast-period {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    color: var(--ink-soft);
    font-size: 0.84rem;
    font-weight: 700;
    padding: 8px 13px;
}

.forecast-summary {
    align-items: center;
    background: linear-gradient(110deg, var(--surface) 0%, var(--bg-tint) 100%);
    display: grid;
    gap: 30px;
    grid-template-columns: minmax(0, 1fr) minmax(260px, .7fr);
    padding: 28px;
}

.forecast-summary-copy .eyebrow {
    margin-bottom: 10px;
}

.forecast-summary-copy h2 {
    font-size: clamp(1.35rem, 2.8vw, 1.8rem);
    line-height: 1.3;
    margin-bottom: 8px;
    max-width: 34ch;
}

.forecast-summary-copy .muted {
    font-size: .92rem;
    margin: 0;
}

.forecast-metrics {
    border-left: 1px solid var(--line-strong);
    display: grid;
    gap: 14px;
    padding-left: 22px;
}

.forecast-metric span,
.forecast-metric small {
    color: var(--muted);
    display: block;
    font-size: .78rem;
}

.forecast-metric strong {
    display: block;
    font-size: 1.55rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.04em;
    line-height: 1.2;
    margin: 2px 0;
}

.forecast-scenarios {
    margin-top: 36px;
}

.forecast-scenarios .section-heading {
    margin-bottom: 14px;
}

.forecast-scenarios .section-heading h2 {
    margin-bottom: 5px;
}

.forecast-scenarios .section-heading .muted {
    font-size: .9rem;
    margin: 0;
}

.forecast-scenario-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.forecast-scenario {
    border-top: 3px solid var(--line-strong);
    margin: 0;
    padding: 20px;
}

.forecast-scenario.is-expected {
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    border-top: 3px solid var(--accent);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
    padding: 20px;
}

.forecast-scenario-label {
    color: var(--muted);
    display: block;
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.forecast-scenario > strong {
    display: block;
    font-size: 1.8rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.04em;
    line-height: 1.2;
    margin-top: 10px;
}

.forecast-scenario > strong small {
    color: var(--muted);
    font-size: .8rem;
    font-weight: 650;
    letter-spacing: 0;
}

.forecast-scenario p {
    color: var(--muted);
    font-size: .86rem;
    line-height: 1.5;
    margin: 8px 0 0;
}

.forecast-detail-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    margin-top: 18px;
}

.forecast-detail-grid > .panel {
    min-width: 0;
}

.forecast-detail-grid .section-heading {
    margin-bottom: 20px;
}

.forecast-detail-grid .section-heading h2 {
    margin-bottom: 5px;
}

.forecast-detail-grid .section-heading .muted {
    font-size: .84rem;
    margin: 0;
}

.forecast-week-list {
    display: grid;
    gap: 18px;
}

.forecast-week-row {
    align-items: center;
    display: grid;
    font-size: .82rem;
    gap: 10px;
    grid-template-columns: 88px minmax(48px, 1fr) auto 38px;
}

.forecast-week-label,
.forecast-week-count {
    color: var(--muted);
    white-space: nowrap;
}

.forecast-week-count {
    font-size: .75rem;
    text-align: right;
}

.forecast-week-row > strong {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.forecast-progress {
    height: 8px;
}

.forecast-note,
.forecast-disclaimer {
    color: var(--muted);
    font-size: .8rem;
    line-height: 1.55;
}

.forecast-note {
    border-top: 1px solid var(--line);
    margin: 20px 0 0;
    padding-top: 14px;
}

.forecast-table-wrap {
    overflow-x: auto;
}

.forecast-table {
    border-collapse: collapse;
    min-width: 330px;
    width: 100%;
}

.forecast-table th {
    color: var(--muted-2);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .07em;
    padding: 0 8px 10px;
    text-align: left;
    text-transform: uppercase;
}

.forecast-table td {
    border-top: 1px solid var(--line);
    font-size: .82rem;
    padding: 12px 8px;
    vertical-align: middle;
}

.forecast-table th:first-child,
.forecast-table td:first-child {
    padding-left: 0;
}

.forecast-table th:last-child,
.forecast-table td:last-child {
    padding-right: 0;
    text-align: right;
}

.forecast-no-sessions {
    margin-top: 18px;
}

.forecast-no-sessions h2 {
    font-size: 1.15rem;
}

.forecast-no-sessions p {
    margin-bottom: 18px;
}

.forecast-disclaimer {
    margin: 22px auto 0;
    max-width: 90ch;
    text-align: center;
}

.forecast-empty {
    margin-top: 12px;
}

@media (max-width: 860px) {
    .forecast-summary {
        grid-template-columns: 1fr;
    }

    .forecast-metrics {
        border-left: 0;
        border-top: 1px solid var(--line-strong);
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 16px 0 0;
    }
}

@media (max-width: 760px) {
    .forecast-scenario-grid,
    .forecast-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .forecast-period {
        width: 100%;
        text-align: center;
    }

    .forecast-summary {
        gap: 20px;
        padding: 22px 18px;
    }

    .forecast-metrics {
        grid-template-columns: 1fr 1fr;
    }

    .forecast-week-row {
        gap: 7px;
        grid-template-columns: minmax(65px, .9fr) minmax(35px, 1fr) auto 32px;
    }

    .forecast-week-label,
    .forecast-week-count {
        font-size: .69rem;
    }

    .forecast-week-row > strong {
        font-size: .75rem;
    }
}

/* --------------------------------------------------------------------------
   Insights dashboard
   -------------------------------------------------------------------------- */

.insights-page {
    max-width: 1200px;
}

.insights-metrics {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 16px;
}

.insights-metric {
    min-width: 0;
    padding: 20px;
}

.insights-metric-top {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: .82rem;
    font-weight: 650;
    gap: 10px;
    justify-content: space-between;
}

.insights-metric-icon {
    align-items: center;
    background: var(--accent-soft);
    border-radius: var(--r-sm);
    color: var(--accent);
    display: inline-flex;
    flex: none;
    font-size: .95rem;
    height: 32px;
    justify-content: center;
    width: 32px;
}

.insights-metric-value {
    display: block;
    font-size: clamp(1.7rem, 3vw, 2rem);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.05em;
    line-height: 1.15;
    margin: 15px 0 7px;
    white-space: nowrap;
}

.insights-metric-value small {
    color: var(--muted-2);
    font-size: .85rem;
    font-weight: 650;
    letter-spacing: 0;
}

.insights-metric-foot {
    color: var(--muted);
    font-size: .75rem;
    line-height: 1.45;
    margin: 0;
    min-height: 2.2em;
}

.insights-metric-progress {
    height: 6px;
    margin-top: 12px;
}

.is-positive {
    color: var(--accent-strong) !important;
    font-weight: 750;
}

.is-negative {
    color: var(--danger) !important;
    font-weight: 750;
}

.is-neutral {
    color: var(--muted) !important;
}

.insights-primary-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr);
    margin-bottom: 16px;
}

.insights-primary-grid > .panel,
.insights-supplemental-grid > .panel,
.insights-lower-grid > .panel {
    min-width: 0;
}

.insights-panel-heading {
    align-items: flex-start;
    margin-bottom: 12px;
}

.insights-panel-heading h2,
.insights-panel-heading h3 {
    margin: 0 0 5px;
}

.insights-panel-heading .muted {
    font-size: .82rem;
    margin: 0;
}

.insights-legend {
    align-items: center;
    color: var(--muted);
    display: inline-flex;
    flex: none;
    font-size: .74rem;
    gap: 7px;
    white-space: nowrap;
}

.insights-legend i {
    background: var(--accent);
    border-radius: 50%;
    height: 8px;
    width: 8px;
}

.insights-chart-summary {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 11px;
    margin: 16px 0 0;
}

.insights-chart-summary strong {
    font-size: 1.8rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.04em;
}

.insights-chart-summary span {
    font-size: .75rem;
}

.insights-chart-wrap {
    height: 210px;
    margin-top: 4px;
}

.insights-chart-wrap svg {
    height: 100%;
    overflow: visible;
    width: 100%;
}

.insights-chart-grid {
    stroke: var(--surface-3);
    stroke-width: 1;
}

.insights-chart-area {
    fill: url(#insights-area-fill);
}

.insights-chart-line {
    fill: none;
    stroke: var(--accent);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 3;
}

.insights-chart-point {
    fill: var(--surface);
    stroke: var(--accent);
    stroke-width: 2.5;
}

.insights-chart-label {
    fill: var(--muted-2);
    font: 10px ui-sans-serif, system-ui, sans-serif;
}

.insights-chart-y {
    fill: var(--muted-2);
    font: 9px ui-sans-serif, system-ui, sans-serif;
}

.insights-empty-chart {
    align-items: center;
    background: var(--surface-2);
    border-radius: var(--r-md);
    color: var(--muted);
    display: flex;
    justify-content: center;
    margin: 14px 0 0;
    min-height: 180px;
    padding: 20px;
    text-align: center;
}

.insights-donut-area {
    align-items: center;
    display: flex;
    gap: 18px;
    justify-content: center;
    padding: 14px 0 18px;
}

.insights-donut {
    flex: none;
    height: 142px;
    width: 142px;
}

.insights-donut-track,
.insights-donut-segment {
    fill: none;
    stroke-width: 16;
}

.insights-donut-track {
    stroke: var(--surface-3);
}

.insights-donut-segment {
    stroke-linecap: butt;
}

.insights-donut-segment.is-completed {
    stroke: var(--accent);
}

.insights-donut-segment.is-incomplete {
    stroke: #d39b3d;
}

.insights-donut-segment.is-missed {
    stroke: #e2e8e3;
}

.insights-donut-total {
    fill: var(--ink);
    font: 800 24px ui-sans-serif, system-ui, sans-serif;
    text-anchor: middle;
}

.insights-donut-label {
    fill: var(--muted);
    font: 11px ui-sans-serif, system-ui, sans-serif;
    text-anchor: middle;
}

.insights-outcome-list {
    display: grid;
    gap: 10px;
    min-width: 112px;
}

.insights-outcome-row {
    align-items: center;
    color: var(--muted);
    display: grid;
    font-size: .76rem;
    gap: 7px;
    grid-template-columns: 9px 1fr auto;
}

.insights-outcome-row i {
    border-radius: 50%;
    height: 8px;
    width: 8px;
}

.insights-outcome-row i.is-completed {
    background: var(--accent);
}

.insights-outcome-row i.is-incomplete {
    background: #d39b3d;
}

.insights-outcome-row i.is-pending {
    background: var(--line-strong);
}

.insights-outcome-row i.is-missed {
    background: #e2e8e3;
    border: 1px solid var(--line-strong);
}

.insights-outcome-row strong {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.insights-callout,
.insights-pattern-summary {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.55;
    padding: 11px 13px;
}

.insights-callout strong,
.insights-pattern-summary strong {
    color: var(--accent-strong);
}

.insights-heat-panel {
    margin-bottom: 18px;
}

.insights-heat-panel .section-heading {
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.insights-heat-legend {
    align-items: center;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: .68rem;
    gap: 5px;
}

.insights-heat-legend .heat-cell {
    height: 12px;
    width: 12px;
}

.insights-heat-legend .heat-cell.miss {
    margin-left: 6px;
}

.insights-heat-wrap {
    margin-top: 16px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.insights-heat-grid {
    align-items: center;
    display: grid;
    gap: 7px;
    grid-template-columns: 78px repeat(7, 22px);
    width: max-content;
}

.insights-heat-label,
.insights-heat-day {
    color: var(--muted-2);
    font-size: .67rem;
}

.insights-heat-label {
    align-items: center;
    display: flex;
    padding-left: 1px;
    white-space: nowrap;
}

.insights-heat-day {
    text-align: center;
}

.heat-cell {
    background: var(--surface-3);
    border-radius: 4px;
    display: inline-block;
    height: 22px;
    width: 22px;
}

.heat-cell.empty {
    background: #edf1ed;
}

.heat-cell.low {
    background: #cfe7d7;
}

.heat-cell.mid {
    background: #81bd96;
}

.heat-cell.high {
    background: #258156;
}

.heat-cell.miss {
    background: #f4d2cb;
}

.heat-cell.outside {
    background: transparent;
}

.insights-heat-note {
    color: var(--muted);
    font-size: .77rem;
    line-height: 1.5;
    margin: 13px 0 0;
}

.insights-forecast-section {
    margin: 30px 0 20px;
}

.insights-forecast-heading {
    align-items: flex-start;
    margin-bottom: 16px;
}

.insights-forecast-heading .eyebrow {
    margin-bottom: 6px;
}

.insights-forecast-heading h2 {
    margin-bottom: 6px;
}

.insights-forecast-heading .muted {
    font-size: .87rem;
    margin: 0;
}

.insights-forecast-metrics {
    border: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 0;
}

.insights-forecast-metrics .forecast-metric {
    border-left: 1px solid var(--line);
    padding-left: 14px;
}

.insights-forecast-metrics .forecast-metric:first-child {
    border-left: 0;
    padding-left: 0;
}

.insights-scenario-grid {
    margin: 14px 0;
}

.insights-scenario-grid .forecast-scenario h3 {
    font-size: 1rem;
    margin: 7px 0 4px;
}

.insights-forecast-detail {
    margin-top: 0;
}

.insights-forecast-detail .section-heading {
    margin-bottom: 16px;
}

.insights-forecast-detail .forecast-table td:last-child {
    font-size: .76rem;
}

.insights-empty-forecast {
    margin-top: 14px;
}

.insights-empty-forecast h3 {
    margin-bottom: 7px;
}

.insights-empty-forecast p {
    color: var(--muted);
    margin-bottom: 14px;
}

.insights-supplemental-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
    margin-bottom: 18px;
}

.insights-weekday-list {
    display: grid;
    gap: 12px;
    margin-top: 17px;
}

.insights-weekday-row {
    align-items: center;
    display: grid;
    font-size: .74rem;
    gap: 9px;
    grid-template-columns: 34px minmax(50px, 1fr) 38px 92px;
}

.insights-weekday-name {
    color: var(--muted);
    font-weight: 700;
}

.insights-weekday-track {
    height: 7px;
}

.insights-weekday-track .progress-fill {
    background: #72ae86;
}

.insights-weekday-row.is-best .progress-fill {
    background: var(--accent);
}

.insights-weekday-row.is-low .progress-fill {
    background: #d39b3d;
}

.insights-weekday-rate {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.insights-weekday-tag {
    color: var(--muted-2);
    font-size: .67rem;
    text-align: right;
}

.insights-pattern-summary {
    margin-top: 17px;
}

.insights-score-highlight {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    display: flex;
    gap: 14px;
    margin-top: 16px;
    padding: 14px;
}

.insights-score-badge {
    align-items: center;
    background: var(--accent-soft);
    border-radius: 50%;
    color: var(--accent-strong);
    display: flex;
    flex: none;
    font-size: 1.2rem;
    font-weight: 850;
    height: 52px;
    justify-content: center;
    width: 52px;
}

.insights-score-highlight strong,
.insights-score-highlight div > span {
    display: block;
}

.insights-score-highlight strong {
    font-size: .86rem;
}

.insights-score-highlight div > span {
    color: var(--muted);
    font-size: .72rem;
    line-height: 1.5;
    margin-top: 3px;
}

.insights-milestone-list {
    display: grid;
    gap: 17px;
    margin-top: 18px;
}

.insights-milestone-head {
    align-items: baseline;
    display: flex;
    font-size: .75rem;
    gap: 10px;
    justify-content: space-between;
}

.insights-milestone-head strong {
    font-size: .8rem;
}

.insights-milestone-head span {
    color: var(--muted);
    white-space: nowrap;
}

.insights-milestone-bar {
    height: 7px;
    margin-top: 8px;
}

.insights-milestone-hint {
    color: var(--muted);
    font-size: .71rem;
    margin: 5px 0 0;
}

.insights-lower-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, .85fr);
    margin-bottom: 18px;
}

.insights-table-wrap {
    overflow-x: auto;
}

.insights-habit-table,
.insights-recent-table {
    border-collapse: collapse;
    width: 100%;
}

.insights-habit-table {
    margin-top: 14px;
    min-width: 520px;
}

.insights-habit-table th,
.insights-recent-table th {
    color: var(--muted-2);
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .07em;
    padding: 0 8px 10px;
    text-align: left;
    text-transform: uppercase;
}

.insights-habit-table td,
.insights-recent-table td {
    border-top: 1px solid var(--line);
    font-size: .77rem;
    padding: 11px 8px;
    vertical-align: middle;
}

.insights-habit-table th:first-child,
.insights-habit-table td:first-child,
.insights-recent-table th:first-child,
.insights-recent-table td:first-child {
    padding-left: 0;
}

.insights-habit-name {
    font-weight: 700;
    white-space: nowrap;
}

.insights-rate-cell {
    align-items: center;
    display: flex;
    gap: 8px;
}

.insights-habit-progress {
    height: 6px;
    min-width: 50px;
    width: 72px;
}

.insights-rate-cell strong {
    font-size: .72rem;
}

.insights-streak {
    color: var(--muted);
    white-space: nowrap;
}

.insights-status,
.insights-result {
    border-radius: var(--r-pill);
    display: inline-block;
    font-size: .67rem;
    font-weight: 750;
    padding: 4px 8px;
    white-space: nowrap;
}

.insights-status.is-good,
.insights-result.complete {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.insights-status.is-watch,
.insights-result.partial {
    background: var(--warn-soft);
    color: var(--warn);
}

.insights-result.missed {
    background: var(--danger-soft);
    color: var(--danger);
}

.insights-no-rate,
.insights-table-empty {
    color: var(--muted-2);
}

.insights-observation-list {
    display: grid;
    gap: 11px;
    margin-top: 16px;
}

.insights-observation {
    align-items: flex-start;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    display: flex;
    gap: 10px;
    padding: 12px;
}

.insights-observation-icon {
    align-items: center;
    background: var(--accent-soft);
    border-radius: var(--r-sm);
    color: var(--accent);
    display: flex;
    flex: none;
    font-size: .85rem;
    height: 30px;
    justify-content: center;
    width: 30px;
}

.insights-observation-icon.is-support {
    background: var(--warn-soft);
    color: var(--warn);
}

.insights-observation h3 {
    font-size: .81rem;
    margin: 1px 0 3px;
}

.insights-observation p {
    color: var(--muted);
    font-size: .73rem;
    line-height: 1.45;
    margin: 0;
}

.insights-recent-panel {
    margin-top: 16px;
}

.insights-recent-panel .section-heading {
    align-items: center;
    margin-bottom: 16px;
}

.insights-recent-caption {
    color: var(--muted);
    font-size: .76rem;
    white-space: nowrap;
}

.insights-recent-table {
    min-width: 610px;
}

.insights-recent-table td {
    font-size: .74rem;
    white-space: nowrap;
}

.insights-recent-note,
.insights-footer-note {
    color: var(--muted);
    font-size: .75rem;
    line-height: 1.5;
}

.insights-recent-note {
    margin: 12px 0 0;
}

.insights-footer-note {
    color: var(--muted-2);
    margin: 20px 0 0;
    text-align: center;
}

@media (max-width: 1050px) {
    .insights-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .insights-primary-grid {
        grid-template-columns: minmax(0, 1.3fr) minmax(260px, 1fr);
    }

    .insights-forecast-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .insights-primary-grid,
    .insights-supplemental-grid,
    .insights-lower-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .insights-forecast-metrics {
        grid-template-columns: 1fr 1fr;
    }

    .insights-forecast-metrics .forecast-metric:last-child {
        border-left: 0;
        grid-column: 1 / -1;
        padding-left: 0;
    }
}

@media (max-width: 520px) {
    .insights-metrics {
        gap: 9px;
    }

    .insights-metric {
        padding: 15px;
    }

    .insights-metric-top {
        align-items: flex-start;
        font-size: .7rem;
    }

    .insights-metric-icon {
        height: 27px;
        width: 27px;
    }

    .insights-metric-value {
        font-size: 1.55rem;
    }

    .insights-metric-foot {
        font-size: .68rem;
    }

    .insights-donut-area {
        flex-wrap: wrap;
        gap: 12px;
    }

    .insights-donut {
        height: 118px;
        width: 118px;
    }

    .insights-weekday-row {
        gap: 6px;
        grid-template-columns: 30px minmax(35px, 1fr) 34px 78px;
    }

    .insights-weekday-tag {
        font-size: .61rem;
    }

    .insights-score-highlight {
        align-items: flex-start;
        padding: 11px;
    }

    .insights-panel-heading {
        flex-wrap: wrap;
    }
}

/* --------------------------------------------------------------------------
   Habit creation
   -------------------------------------------------------------------------- */

.habit-create-page {
    max-width: 1120px;
    padding-top: 38px;
}

.habit-create-heading {
    align-items: flex-end;
    display: grid;
    gap: 28px;
    grid-template-columns: minmax(0, 1fr) minmax(230px, 300px);
    margin-bottom: 30px;
}

.habit-create-back {
    align-items: center;
    color: var(--muted);
    display: inline-flex;
    font-size: 0.87rem;
    gap: 8px;
    margin-bottom: 22px;
}

.habit-create-back:hover {
    color: var(--accent-strong);
    text-decoration: none;
}

.habit-create-back span {
    font-size: 1.15rem;
    line-height: 1;
}

.habit-create-title h1 {
    font-size: clamp(2rem, 4vw, 2.65rem);
    margin-bottom: 8px;
}

.habit-create-title > .muted {
    margin: 0;
    max-width: 560px;
}

.habit-create-callout {
    align-items: flex-start;
    background: linear-gradient(140deg, #edf5ef, #f8faf7);
    border: 1px solid var(--accent-line);
    border-radius: var(--r-lg);
    display: flex;
    gap: 13px;
    padding: 18px;
}

.habit-create-form-number,
.habit-create-tip-number {
    align-items: center;
    background: var(--accent-soft);
    border-radius: 10px;
    color: var(--accent-strong);
    display: inline-flex;
    flex: none;
    font-size: 0.75rem;
    font-weight: 800;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.habit-create-callout-mark {
    background: var(--accent);
    border-radius: 50%;
    flex: none;
    height: 9px;
    margin: 8px 4px 0 2px;
    width: 9px;
}

.habit-create-callout strong {
    display: block;
    font-size: 0.9rem;
    margin: 1px 0 3px;
}

.habit-create-callout p {
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
    margin: 0;
}

.habit-create-layout {
    align-items: start;
    display: grid;
    gap: 24px;
    grid-template-columns: minmax(0, 1fr) 285px;
}

.habit-create-form-heading {
    align-items: center;
    display: flex;
    gap: 13px;
    margin: 0 0 16px;
}

.habit-create-form-heading h2 {
    font-size: 1.16rem;
    margin: 0 0 3px;
}

.habit-create-form-heading p {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0;
}

.habit-create-form-column > .panel {
    border-color: var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-2);
    padding: 28px;
}

.habit-create-page .field {
    margin-bottom: 20px;
}

.habit-create-page .field label {
    color: var(--ink-soft);
    font-size: 0.84rem;
    margin-bottom: 8px;
}

.habit-create-page input:not([type="checkbox"]):not([type="radio"]),
.habit-create-page select,
.habit-create-page textarea {
    border-color: var(--line-strong);
    border-radius: 11px;
    padding: 12px 14px;
}

.habit-create-page textarea {
    min-height: 92px;
}

.habit-create-page .tracking-fieldset,
.habit-create-page .day-fieldset {
    background: var(--surface-2);
    border-color: var(--line);
    border-radius: var(--r-lg);
    margin-bottom: 16px;
    padding: 17px;
}

.habit-create-page .tracking-fieldset legend,
.habit-create-page .day-fieldset legend {
    color: var(--ink);
    font-size: 0.91rem;
    margin-bottom: 9px;
}

.habit-create-page .tracking-options {
    gap: 9px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.habit-create-page .tracking-option {
    background: var(--surface);
    border-color: var(--line);
    border-radius: 13px;
    gap: 9px;
    min-height: 94px;
    padding: 13px 11px;
}

.habit-create-page .tracking-option:hover {
    border-color: var(--accent-line);
}

.habit-create-page .tracking-option:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.habit-create-page .tracking-option:has(input:disabled) {
    cursor: not-allowed;
    opacity: 0.56;
}

.habit-create-page .tracking-option-title {
    font-size: 0.83rem;
    line-height: 1.35;
}

.habit-create-page .tracking-option-help {
    font-size: 0.73rem;
}

.habit-create-page .field-help {
    font-size: 0.79rem;
    line-height: 1.5;
}

.habit-create-page .day-picker {
    gap: 7px;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.habit-create-page .day-option {
    background: var(--surface);
    border-radius: 11px;
    font-size: 0.77rem;
    gap: 6px;
    padding: 10px 4px;
}

.habit-create-page .day-option input {
    height: 15px;
    margin: 0;
    width: 15px;
}

.habit-create-page .day-option:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-strong);
}

.habit-create-page .day-option:focus-within,
.habit-create-page .tracking-option:focus-within {
    box-shadow: 0 0 0 3px rgba(30, 122, 88, .14);
}

.habit-create-page .form-actions {
    border-top: 1px solid var(--line);
    margin-top: 22px;
    padding-top: 20px;
}

.habit-create-page .form-actions .button {
    min-height: 46px;
    padding-left: 22px;
    padding-right: 22px;
}

.habit-create-guide {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-1);
    padding: 24px 22px;
}

.habit-create-guide .eyebrow {
    font-size: 0.68rem;
    margin-bottom: 9px;
}

.habit-create-guide h2 {
    font-size: 1.18rem;
    line-height: 1.3;
    margin-bottom: 9px;
}

.habit-create-guide-intro {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.55;
    margin: 0;
}

.habit-create-tips {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 17px;
    list-style: none;
    margin: 20px 0;
    padding: 18px 0 0;
}

.habit-create-tips li {
    align-items: flex-start;
    display: flex;
    gap: 11px;
}

.habit-create-tip-number {
    border-radius: 8px;
    font-size: 0.68rem;
    height: 28px;
    width: 28px;
}

.habit-create-tips strong,
.habit-create-tips small {
    display: block;
}

.habit-create-tips strong {
    font-size: 0.82rem;
    line-height: 1.3;
    margin: 2px 0 3px;
}

.habit-create-tips small {
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.45;
}

.habit-create-example {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    display: grid;
    gap: 5px;
    padding: 13px 14px;
}

.habit-create-example span {
    color: var(--muted-2);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.habit-create-example strong {
    color: var(--accent-strong);
    font-size: 0.82rem;
    line-height: 1.45;
}

@media (max-width: 900px) {
    .habit-create-layout {
        grid-template-columns: minmax(0, 1fr) 250px;
        gap: 16px;
    }

    .habit-create-form-column > .panel {
        padding: 22px;
    }

    .habit-create-guide {
        padding: 21px 18px;
    }
}

@media (max-width: 760px) {
    .habit-create-heading,
    .habit-create-layout {
        grid-template-columns: 1fr;
    }

    .habit-create-heading {
        align-items: start;
        gap: 18px;
        margin-bottom: 24px;
    }

    .habit-create-back {
        margin-bottom: 17px;
    }

    .habit-create-callout {
        max-width: 420px;
    }

    .habit-create-guide {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 24px;
    }

    .habit-create-guide > .eyebrow,
    .habit-create-guide > h2,
    .habit-create-guide-intro {
        grid-column: 1 / -1;
    }

    .habit-create-tips {
        align-self: start;
        grid-row: span 2;
    }

    .habit-create-example {
        align-self: start;
        margin-top: 18px;
    }
}

@media (max-width: 520px) {
    .habit-create-page {
        padding-left: 16px;
        padding-right: 16px;
        padding-top: 28px;
    }

    .habit-create-form-column > .panel {
        border-radius: var(--r-lg);
        padding: 18px 15px;
    }

    .habit-create-page .tracking-fieldset,
    .habit-create-page .day-fieldset {
        padding: 15px 12px;
    }

    .habit-create-page .tracking-options {
        grid-template-columns: 1fr;
    }

    .habit-create-page .tracking-option {
        min-height: 0;
        padding: 12px;
    }

    .habit-create-page .day-picker {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .habit-create-guide {
        display: block;
    }

    .habit-create-page .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .habit-create-page .form-actions .button {
        justify-content: center;
        width: 100%;
    }
}

.insights-quantity-summary {
    display: grid;
    gap: 4px;
    margin-top: 9px;
    max-width: 190px;
}

.insights-quantity-summary > span {
    color: var(--muted-2);
    font-size: 0.67rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.insights-quantity-summary > strong {
    color: var(--ink-soft);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.insights-quantity-progress {
    height: 5px;
}
