/* Design tokens — tjanser-codebase.md §10.1, ported verbatim from the PoC's app.css :root */
:root {
    --color-primary: #4DA3FF;
    --color-secondary: #FFD93D;
    --color-success: #6BCB77;
    --color-danger: #FF6B6B;
    --color-info: #118AB2;
    --color-background: #FFF7E6;
    --color-card: #FFFFFF;
    --color-text: #1F2A44;
    --color-muted: #7A8BA8;
    --color-border: #D8C7FF;

    --radius-card: 14px;
    --radius-button: 50px;
    --radius-sheet: 24px;

    --shadow-sm: 0 2px 12px rgba(0, 0, 0, .08);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, .14);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    color: var(--color-text);
    background: var(--color-background);
}

a {
    color: var(--color-primary);
}

.content {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 16px 84px;
}

/* Auth screens — full-bleed gradient behind a floating white card (spec §10.1) */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(160deg, #4DA3FF, #FFD93D);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-card);
    border-radius: var(--radius-sheet);
    box-shadow: var(--shadow-lg);
    padding: 32px 28px;
}

.auth-card h1 {
    margin: 0 0 4px;
    font-size: 1.5rem;
    font-weight: 800;
}

.auth-card .subtitle {
    margin: 0 0 24px;
    color: var(--color-muted);
}

.auth-links {
    margin-top: 20px;
    text-align: center;
    color: var(--color-muted);
}

/* Cards */
.card {
    background: var(--color-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

.card + .card {
    margin-top: 16px;
}

.card > h1,
.card > h2 {
    margin-top: 0;
}

.section-label {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--color-muted);
    letter-spacing: .05em;
}

/* Forms */
.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 6px;
}

.field input,
.field select {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-background);
    color: var(--color-text);
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.field-error {
    color: var(--color-danger);
    font-size: 0.8125rem;
    margin-top: 4px;
    font-weight: 600;
}

.photo-preview {
    display: block;
    width: 100%;
    max-height: 260px;
    object-fit: cover;
    border-radius: var(--radius-card);
    margin-top: 10px;
}

.field-hint {
    color: var(--color-muted);
    font-size: 0.8125rem;
    margin: 4px 0 0;
}

.invite-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-align: center;
    background: var(--color-background);
    border-radius: var(--radius-card);
    padding: 12px 16px;
    margin: 8px 0 16px;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    cursor: pointer;
}

.checkbox-field.is-locked {
    cursor: default;
    opacity: .55;
}

.checkbox-field input {
    width: 20px;
    height: 20px;
    accent-color: var(--color-primary);
}

.radio-pills {
    display: flex;
    gap: 10px;
}

.role-tabs {
    margin-bottom: 20px;
}

.role-tabs .radio-pill {
    text-decoration: none;
    color: inherit;
}

.radio-pill {
    flex: 1;
    display: block;
    text-align: center;
    padding: 12px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-card);
    cursor: pointer;
    font-weight: 700;
}

.radio-pill input {
    display: none;
}

.radio-pill.is-active {
    border-color: var(--color-primary);
    background: #F8FBFF;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 28px;
    border: none;
    border-radius: var(--radius-button);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: transform .1s ease;
}

.btn:active {
    transform: scale(.96);
}

.btn-block {
    display: flex;
    width: 100%;
}

.card .btn-block {
    margin-top: 12px;
}

/* An action button following a stack of row-cards directly in .content
   (not nested inside a card itself) — e.g. "Opret opgave", "Tilføj barn". */
.content > .btn-block {
    margin-top: 16px;
}

.btn-small {
    min-height: 32px;
    padding: 0 16px;
    font-size: 0.8125rem;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-success {
    background: var(--color-success);
    color: #fff;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-outline {
    background: transparent;
    color: var(--color-text);
    border: 2px solid var(--color-border);
}

/* Flash / error messages */
.alert {
    border-radius: var(--radius-card);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-weight: 600;
}

.alert-danger {
    background: #FFE5E5;
    color: #8A1A1A;
}

.alert-success {
    background: #DFF5E3;
    color: #1A6B2A;
}

/* App shell (dashboard + inner pages) */
.app-header {
    height: 56px;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 16px;
    font-weight: 800;
}

.app-header a {
    color: #fff;
    text-decoration: none;
}

.app-header .brand {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.brand-icon {
    height: 32px;
    width: 32px;
}

.app-header .btn-outline {
    min-height: 32px;
    padding: 0 16px;
    color: #fff;
    border-color: rgba(255, 255, 255, .5);
}

.profile-menu {
    position: relative;
}

.profile-trigger {
    display: flex;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 50%;
}

.profile-trigger:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.profile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .25);
    font-size: 1.1rem;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: var(--color-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 20;
}

.profile-dropdown[hidden] {
    display: none;
}

/* .app-header a { color: #fff } would otherwise win on specificity and
   whiten out the "Ændre kodeord" link (an <a>, unlike the "Log ud" <button>
   beside it) against the dropdown's white background. */
.app-header .profile-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: none;
    color: var(--color-text);
    font-weight: 700;
    font-size: 0.875rem;
    text-align: left;
    text-decoration: none;
    border-radius: 10px;
    cursor: pointer;
}

.profile-dropdown-item:hover {
    background: var(--color-background);
}

.profile-dropdown-item-danger {
    color: var(--color-danger);
}

/* Bottom nav (spec §10.2): fixed, lavender top border, active item gets
   primary color text + a 3px indicator bar along its top edge. */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-card);
    border-top: 2px solid var(--color-border);
    z-index: 10;
}

.bottom-nav-inner {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    height: 64px;
}

.bottom-nav-item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--color-muted);
    text-decoration: none;
    font-size: 0.6875rem;
    font-weight: 700;
}

.bottom-nav-item .icon {
    font-size: 1.25rem;
    line-height: 1;
}

.bottom-nav-item.is-active {
    color: var(--color-primary);
}

.bottom-nav-item.is-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 3px;
    background: var(--color-primary);
    border-radius: 0 0 3px 3px;
}

.hero {
    background: linear-gradient(135deg, var(--color-primary), #7ec1ff);
    color: #fff;
    border-radius: var(--radius-card);
    padding: 24px;
    margin-bottom: 20px;
}

.hero .amount {
    font-size: 1.8rem;
    font-weight: 900;
}

.hero-eyebrow,
.hero-subtitle {
    font-size: 0.875rem;
    opacity: .85;
}

.hero-title {
    font-size: 1.8rem;
    font-weight: 900;
    margin: 2px 0;
}

.hero-with-badges {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.hero-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.hero-badge {
    background: rgba(255, 255, 255, .25);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
}

.hero-badge-pro {
    background: var(--color-secondary);
    color: #6A4800;
}

/* Avatar — background-color is per-instance data (a child's chosen color),
   passed in via the --avatar-color custom property so no inline style
   declarations are needed in templates. */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 800;
    background-color: var(--avatar-color, var(--color-primary));
}

.avatar-56 {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
}

.avatar-40 {
    width: 40px;
    height: 40px;
    font-size: 1.125rem;
}

/* Pro-tier character avatars — the SVG already includes its own background
   circle, so this is just a sizing wrapper (no --avatar-color). */
.avatar-icon {
    display: inline-flex;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
}

.avatar-icon img {
    width: 100%;
    height: 100%;
    display: block;
}

.avatar-icon-56 {
    width: 56px;
    height: 56px;
}

.avatar-icon-40 {
    width: 40px;
    height: 40px;
}

/* Avatar picker (child login) */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 16px;
    margin-bottom: 8px;
}

.avatar-pick {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-card);
}

.avatar-pick:hover {
    background: #F8FBFF;
}

.avatar-pick.is-selected {
    background: #F8FBFF;
    border-color: var(--color-primary);
}

.avatar-pick.is-locked {
    cursor: default;
    opacity: .55;
}

.avatar-pick.is-locked:hover {
    background: none;
}

.avatar-lock-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--color-border);
    color: var(--color-text);
    font-size: 0.5625rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 8px;
    border: 2px solid var(--color-card);
}

.pin-input {
    text-align: center;
    letter-spacing: 0.5em;
    font-size: 1.5rem;
    font-weight: 800;
}

.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--color-muted);
}

/* Tasks */
.reward-badge {
    display: inline-block;
    background: var(--color-secondary);
    color: #6A4800;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    white-space: nowrap;
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 700;
    background: var(--color-border);
    color: var(--color-text);
}

/* Each row is its own .card (design: stacked cards, not dividers within one
   shared card — spaced automatically via the .card + .card rule above). */
.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

a.list-row:hover {
    color: var(--color-primary);
}

.list-row .title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
}

.list-row .meta {
    color: var(--color-muted);
    font-size: 0.8125rem;
    margin-top: 2px;
}

.photo-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-border);
    color: var(--color-info);
    vertical-align: middle;
}

.photo-flag svg {
    width: 12px;
    height: 12px;
}

.photo-flag-button {
    border: none;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}

/* Photo viewer popup (history page) */
.photo-dialog {
    border: none;
    border-radius: var(--radius-card);
    padding: 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.photo-dialog::backdrop {
    background: rgba(31, 42, 68, .6);
}

.photo-dialog-body {
    max-height: 65vh;
    overflow: auto;
    background: var(--color-background);
}

.photo-dialog-body img {
    display: block;
    width: 100%;
    height: auto;
}

.photo-dialog-actions {
    display: flex;
    gap: 10px;
    padding: 16px;
}

.photo-dialog-actions form {
    flex: 1;
    display: flex;
}

.photo-dialog-actions .btn {
    flex: 1;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.empty-state .emoji {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 8px;
}

.is-hidden {
    display: none !important;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0 0 16px;
}

/* Completion review cards (spec §10.3 "Review card") */
.review-card {
    padding: 0;
    overflow: hidden;
}

.review-photo {
    display: block;
    width: 100%;
    max-height: 260px;
    object-fit: cover;
}

.review-photo-removed {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
    background: var(--color-background);
    color: var(--color-muted);
    font-weight: 600;
    font-size: 0.875rem;
}

.review-body {
    padding: 16px 20px 20px;
}

.review-title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 800;
}

.review-pills {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.review-note {
    background: var(--color-background);
    border-radius: var(--radius-card);
    padding: 10px 14px;
    font-style: italic;
    margin: 12px 0 0;
}

.btn-link-danger {
    display: inline-block;
    background: none;
    border: none;
    color: var(--color-danger);
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    padding: 12px 0 0;
}

.review-child {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.review-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* Reject bottom sheet (spec §10.3: "24px top radius" bottom sheet) */
.reject-dialog {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 600px;
    border: none;
    border-radius: 24px 24px 0 0;
    padding: 24px 20px;
    box-shadow: var(--shadow-lg);
}

.reject-dialog::backdrop {
    background: rgba(31, 42, 68, .5);
}

.reject-dialog-title {
    margin: 0 0 16px;
    font-size: 1.25rem;
    font-weight: 800;
}

.reject-dialog label {
    display: block;
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 6px;
}

.reject-dialog textarea {
    width: 100%;
    padding: 12px 14px;
    font: inherit;
    resize: vertical;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-background);
    color: var(--color-text);
}

.reject-dialog textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.reject-dialog-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.reject-dialog-actions .btn {
    flex: 1;
}

/* History / payouts list rows */
.list-row-end {
    text-align: right;
}

.list-row-end .reward-badge {
    margin-top: 4px;
}

.list-row-end form,
.list-row-end a.btn {
    margin-top: 6px;
}

/* Status pills (spec §10.3) */
.status-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.status-claimed {
    background: #E0EEFF;
    color: #1A5BB5;
}

.status-pending {
    background: #FFF8DC;
    color: #8A5A00;
}

.status-approved,
.status-paid {
    background: #DFF5E3;
    color: #1A6B2A;
}

.status-rejected {
    background: #FFE5E5;
    color: #8A1A1A;
}

/* Payouts */
.payout-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.payout-header .title {
    font-weight: 700;
    flex: 1;
}

.select-all-row {
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

.payout-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    opacity: .5;
    transition: opacity .1s ease;
}

.payout-row.is-selected {
    opacity: 1;
}

.payout-row:last-of-type {
    border-bottom: none;
}

.payout-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    flex-shrink: 0;
}

.payout-row-title {
    flex: 1;
}

.payout-row .meta {
    color: var(--color-muted);
    font-size: 0.8125rem;
}

/* Sibling leaderboard (child dashboard) */
.leaderboard-row.is-self {
    border: 2px solid var(--color-primary);
}

.leaderboard-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-border);
    color: var(--color-text);
    font-size: 0.75rem;
    font-weight: 800;
    flex-shrink: 0;
}

.leaderboard-row .meta {
    color: var(--color-muted);
    font-size: 0.8125rem;
}

/* Parent dashboard: pending-approval alert card */
.card-danger-accent {
    border-left: 4px solid var(--color-danger);
}

.card-title {
    font-weight: 800;
    font-size: 1rem;
    margin: 0 0 4px;
}

.card-subtitle {
    color: var(--color-muted);
    font-size: 0.875rem;
    margin: 0 0 16px;
}

/* Parent dashboard: children's weekly savings */
.section-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 20px 0 8px;
}

.section-label-suffix {
    color: var(--color-muted);
    font-size: 0.75rem;
}

.savings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: inherit;
    text-decoration: none;
}

.savings-child {
    display: flex;
    align-items: center;
    gap: 10px;
}

.savings-name {
    font-weight: 700;
}

.amount-primary {
    color: var(--color-primary);
    font-weight: 800;
    font-size: 1rem;
    white-space: nowrap;
}

/* Child progress/account view (spec §10.3 "Progress screen") */
.stats-total {
    text-align: center;
    padding: 16px 0 4px;
}

.stats-total-amount {
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--color-primary);
    line-height: 1.1;
}

.stats-total-label {
    color: var(--color-muted);
    font-weight: 700;
    margin-top: 4px;
}

.stats-split {
    display: flex;
    align-items: center;
}

.stats-split-item {
    flex: 1;
    text-align: center;
}

.stats-split-value {
    font-size: 1.5rem;
    font-weight: 800;
}

.stats-value-success {
    color: var(--color-success);
}

.stats-value-primary {
    color: var(--color-primary);
}

.stats-split-label {
    color: var(--color-muted);
    font-size: 0.8125rem;
    margin-top: 2px;
}

.stats-split-divider {
    width: 1px;
    align-self: stretch;
    background: var(--color-border);
}

.stats-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 140px;
}

.stats-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    gap: 6px;
}

.stats-bar {
    width: 100%;
    max-width: 28px;
    height: var(--bar-height, 0%);
    min-height: 4px;
    background: var(--color-primary);
    border-radius: 6px 6px 0 0;
}

.stats-bar-label {
    font-size: 0.6875rem;
    color: var(--color-muted);
    font-weight: 700;
}

.payout-amount {
    color: var(--color-success);
    font-weight: 800;
    font-size: 1rem;
    white-space: nowrap;
}
