:root {
    --bg: #e8f3f1;
    --bg-deep: #d3ebe6;
    --surface: #ffffff;
    --ink: #16332e;
    --muted: #5b736e;
    --teal: #0f766e;
    --teal-dark: #0b5a54;
    --amber: #d97706;
    --rose: #be123c;
    --line: rgba(15, 118, 110, 0.14);
    --shadow: 0 10px 30px rgba(15, 70, 60, 0.08);
    --radius: 18px;
    --font-display: "Nunito", system-ui, sans-serif;
    --font-body: "Source Sans 3", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 10%, rgba(217, 119, 6, 0.12), transparent 35%),
        radial-gradient(circle at 90% 0%, rgba(15, 118, 110, 0.16), transparent 40%),
        linear-gradient(160deg, var(--bg), var(--bg-deep));
}

a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    padding: 1.5rem 1.1rem;
    background: linear-gradient(180deg, #0f766e 0%, #0b4f4a 100%);
    color: #f3fffc;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.brand {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,0.16);
    font-family: var(--font-display);
    font-weight: 800;
}

.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    background: #fff;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 0.35rem;
}

.login-brand img {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: var(--shadow);
}

.login-brand h1 {
    margin: 0;
}

.board-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    margin-bottom: 1rem;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--teal-dark);
}

.board-brand img {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    object-fit: cover;
    box-shadow: var(--shadow);
}

.link-prefix {
    display: inline-flex;
    align-items: center;
    padding: 0 0.75rem;
    border-radius: 12px;
    background: #ecfdf5;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.92rem;
    white-space: nowrap;
}

.link-panel {
    grid-column: 1 / -1;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.06), rgba(217, 119, 6, 0.08)),
        #fff;
}

.link-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.link-panel-head h2 { margin: 0; }

.link-editor { display: grid; gap: 0.65rem; }
.link-label { margin: 0; font-weight: 700; }

.url-shell {
    display: flex;
    align-items: stretch;
    border: 1px solid #b7d4ce;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.url-host {
    display: flex;
    align-items: center;
    padding: 0 0.9rem;
    background: #e7f5f2;
    color: var(--teal-dark);
    font-weight: 700;
    font-size: 0.92rem;
    white-space: nowrap;
    border-right: 1px solid #b7d4ce;
}

.url-shell input {
    border: 0;
    border-radius: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.url-shell input:focus {
    outline: none;
    background: #f4fffc;
}

.hint-line {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.preview-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    background: #16332e;
    color: #e7fffa;
}

.preview-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.7;
    margin-bottom: 0.2rem;
}

.preview-box strong {
    display: block;
    word-break: break-all;
    font-size: 0.95rem;
    font-weight: 600;
}

.preview-box .btn-soft {
    flex-shrink: 0;
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-color: rgba(255,255,255,0.2);
}

.rotate-row { margin-top: 0.85rem; }

.dash-hero {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.25rem;
    padding: 1.25rem 1.4rem;
    border-radius: 22px;
    background:
        radial-gradient(circle at 90% 20%, rgba(217, 119, 6, 0.22), transparent 40%),
        linear-gradient(120deg, #0f766e, #0b5a54 55%, #134e4a);
    color: #f3fffc;
    box-shadow: var(--shadow);
    animation: rise 0.45s ease both;
}

.dash-kicker {
    margin: 0;
    opacity: 0.85;
    font-weight: 600;
}

.dash-title {
    margin: 0.2rem 0 0.35rem;
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 2.4vw, 1.9rem);
}

.dash-sub {
    margin: 0;
    opacity: 0.85;
    max-width: 36rem;
}

.dash-stats {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.dash-stat {
    min-width: 110px;
    padding: 0.75rem 0.9rem;
    border-radius: 16px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.16);
}

.dash-stat span {
    display: block;
    font-size: 0.8rem;
    opacity: 0.8;
}

.dash-stat strong {
    font-family: var(--font-display);
    font-size: 1.6rem;
    line-height: 1.1;
}

.dash-stat .neg { color: #fecdd3; }
.dash-stat .pos { color: #bbf7d0; }

.fun-card {
    animation: rise 0.5s ease both;
    animation-delay: var(--delay, 0s);
    padding: 1.2rem;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, white), white 45%);
}

.fun-card-top {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.85rem;
    align-items: center;
    margin-bottom: 1rem;
}

.fun-identity {
    min-width: 0;
    display: grid;
    gap: 0.35rem;
    align-content: center;
}

.fun-name {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.age-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent, var(--teal)) 14%, white);
    border: 1px solid color-mix(in srgb, var(--accent, var(--teal)) 28%, white);
    color: var(--teal-dark);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.fun-avatar {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.45rem;
    box-shadow: 0 8px 18px rgba(0,0,0,0.12);
    flex-shrink: 0;
}

.score-chip {
    min-width: 70px;
    text-align: center;
    padding: 0.45rem 0.6rem;
    border-radius: 14px;
    background: #ecfdf5;
    border: 1px solid var(--line);
}

.score-chip small {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.score-chip strong {
    font-family: var(--font-display);
    font-size: 1.55rem;
    line-height: 1;
}

.score-chip.neg {
    background: #fff1f2;
    border-color: #fecdd3;
}
.score-chip.neg strong { color: var(--rose); }
.score-chip.pos strong { color: var(--teal-dark); }

.btn-score {
    transition: transform 0.15s ease, filter 0.15s ease;
}
.btn-score:hover { transform: translateY(-1px) scale(1.02); }
.btn-score:active { transform: scale(0.98); }

.redeem-fun { margin-top: 0.85rem; }
.redeem-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.redeem-grid {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 0.5rem;
}

.empty-fun { text-align: center; padding: 2rem 1.25rem; }

.activity-list { display: grid; gap: 0.55rem; }
.activity-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem;
    align-items: start;
    padding: 0.85rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfefe;
}
.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 0.45rem;
}
.activity-dot.good { background: #14b8a6; box-shadow: 0 0 0 4px rgba(20,184,166,0.15); }
.activity-dot.bad { background: #f43f5e; box-shadow: 0 0 0 4px rgba(244,63,94,0.12); }
.activity-main {
    min-width: 0;
    display: grid;
    gap: 0.35rem;
}
.activity-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}
.activity-name {
    font-family: var(--font-display);
    font-size: 1.05rem;
    line-height: 1.2;
}
.activity-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.7rem;
    align-items: center;
}
.activity-time::before {
    content: "·";
    margin-right: 0.7rem;
    opacity: 0.55;
}
.activity-pts {
    font-family: var(--font-display);
    font-size: 1.2rem;
    line-height: 1;
    flex-shrink: 0;
}
.activity-action { margin: 0; }
.activity-action .btn { margin-top: 0.15rem; }

.brand strong {
    display: block;
    font-family: var(--font-display);
    font-size: 1.05rem;
}

.brand small {
    opacity: 0.8;
}

.nav {
    display: grid;
    gap: 0.35rem;
}

.nav a {
    color: #e7fffa;
    text-decoration: none;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    font-weight: 600;
}

.nav a:hover,
.nav a.active {
    background: rgba(255,255,255,0.14);
    text-decoration: none;
}

.sidebar-foot { margin-top: auto; }

.main {
    padding: 1.5rem 1.75rem 2.5rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.topbar h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 2vw, 2rem);
}

.topbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.flash {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-weight: 600;
}

.flash-ok { background: #d1fae5; color: #065f46; }
.flash-err { background: #ffe4e6; color: #9f1239; }

.grid {
    display: grid;
    gap: 1rem;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem;
}

.panel h2,
.panel h3 {
    margin: 0 0 0.85rem;
    font-family: var(--font-display);
}

.child-card {
    position: relative;
    overflow: hidden;
}

.child-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 6px;
    background: var(--accent, var(--teal));
}

.points {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1;
    margin: 0.35rem 0;
}

.points.neg { color: var(--rose); }
.points.pos { color: var(--teal-dark); }

.muted { color: var(--muted); }
.small { font-size: 0.92rem; }

.btn {
    appearance: none;
    border: 0;
    border-radius: 12px;
    padding: 0.65rem 1rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-decoration: none;
}

.btn:hover { text-decoration: none; filter: brightness(1.03); }
.btn-primary { background: var(--teal); color: white; }
.btn-amber { background: var(--amber); color: white; }
.btn-danger { background: var(--rose); color: white; }
.btn-ghost {
    background: rgba(255,255,255,0.12);
    color: inherit;
    border: 1px solid rgba(255,255,255,0.2);
}
.btn-soft {
    background: #ecfdf5;
    color: var(--teal-dark);
    border: 1px solid var(--line);
}
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.9rem; border-radius: 10px; }

.stack { display: grid; gap: 0.65rem; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

label {
    display: grid;
    gap: 0.35rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border-radius: 12px;
    border: 1px solid #c5d8d3;
    font: inherit;
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 0.7rem 0.4rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-good { background: #d1fae5; color: #065f46; }
.badge-bad { background: #ffe4e6; color: #9f1239; }

.progress {
    height: 10px;
    background: #e5efec;
    border-radius: 999px;
    overflow: hidden;
}

.progress > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--teal), #14b8a6);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-card {
    width: min(420px, 100%);
    background: rgba(255,255,255,0.92);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0 0 0.35rem;
    font-family: var(--font-display);
}

.color-swatches {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.color-swatches label {
    margin: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
}

.color-swatches input { display: none; }
.color-swatches input:checked + span,
.color-swatches label:has(input:checked) {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
}

.quick-form {
    display: grid;
    gap: 0.55rem;
    padding: 0.75rem;
    border: 1px dashed var(--line);
    border-radius: 14px;
    background: #f7fbfa;
}

.score-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.score-actions form { margin: 0; }

.btn-score {
    width: 100%;
    min-height: 3.4rem;
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
    border-radius: 14px;
}

.board-body {
    background:
        radial-gradient(circle at 20% 0%, rgba(217, 119, 6, 0.18), transparent 40%),
        radial-gradient(circle at 80% 20%, rgba(15, 118, 110, 0.22), transparent 45%),
        linear-gradient(180deg, #dff3ef, #f7faf8 55%, #fff7ed);
}

.board-wrap {
    width: min(1100px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.5rem 0 3rem;
}

.board-hero {
    text-align: center;
    margin-bottom: 1.5rem;
    animation: rise 0.6s ease both;
}

.board-hero h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3rem);
}

.board-hero p {
    margin: 0.4rem 0 0;
    color: var(--muted);
    font-size: 1.1rem;
}

.board-child {
    text-align: center;
    animation: rise 0.7s ease both;
    display: grid;
    justify-items: center;
}

.board-child:nth-child(2) { animation-delay: 0.08s; }
.board-child:nth-child(3) { animation-delay: 0.16s; }

.avatar-dot {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    margin: 0 auto 0.5rem;
    display: grid;
    place-items: center;
    color: white;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.3rem;
}

.reward-ready {
    border-color: rgba(217, 119, 6, 0.35);
    background: linear-gradient(180deg, #fffbeb, #fff);
}

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

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 1rem;
    }
    .nav {
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        overflow-x: auto;
    }
    .sidebar-foot { display: none; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .main { padding: 1rem; }
    .dash-hero { flex-direction: column; align-items: stretch; }
    .url-shell { flex-direction: column; }
    .url-host {
        border-right: 0;
        border-bottom: 1px solid #b7d4ce;
        padding: 0.55rem 0.9rem;
    }
    .redeem-grid { grid-template-columns: 1fr; }
    .activity-item {
        padding: 0.8rem;
        gap: 0.65rem;
    }
    .activity-head {
        align-items: flex-start;
    }
    .activity-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
    }
    .activity-time::before { content: none; margin: 0; }
    .activity-action .btn {
        width: 100%;
        margin-top: 0.35rem;
    }
    .preview-box { flex-direction: column; align-items: stretch; }
}
