/* ==========================================================================
   Pin Studio – design system
   ========================================================================== */

:root {
    --bg: #f4f3f8;
    --bg-glow-1: rgba(230, 0, 35, .07);
    --bg-glow-2: rgba(106, 90, 249, .08);
    --surface: #ffffff;
    --surface-2: #f6f5fa;
    --surface-3: #eceaf3;
    --text: #17151f;
    --text-2: #4a4758;
    --muted: #8a8799;
    --border: #e7e5ef;
    --border-strong: #d8d5e3;

    --accent: #e60023;
    --accent-2: #ff4d6a;
    --accent-soft: #fff0f2;
    --accent-grad: linear-gradient(135deg, #ff4d6a 0%, #e60023 55%, #c4001d 100%);
    --violet: #6a5af9;
    --violet-soft: #efedff;
    --teal: #0ea5a0;
    --teal-soft: #e3f7f5;
    --amber: #f59e0b;
    --amber-soft: #fff4dc;
    --ok: #10a35a;
    --ok-soft: #e4f7ec;
    --info: #2f6fea;
    --info-soft: #e8f0ff;
    --error: #e5354f;
    --error-soft: #ffeef1;

    --radius-sm: 10px;
    --radius: 18px;
    --radius-lg: 26px;
    --shadow-sm: 0 1px 2px rgba(23, 21, 31, .05);
    --shadow: 0 1px 2px rgba(23, 21, 31, .04), 0 8px 24px -8px rgba(23, 21, 31, .08);
    --shadow-lg: 0 24px 48px -16px rgba(23, 21, 31, .18);
    --ring: 0 0 0 4px rgba(230, 0, 35, .14);
    --sidebar-w: 264px;
    --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d0d12;
        --bg-glow-1: rgba(230, 0, 35, .12);
        --bg-glow-2: rgba(106, 90, 249, .14);
        --surface: #16161d;
        --surface-2: #1d1d26;
        --surface-3: #262632;
        --text: #f1f0f6;
        --text-2: #c4c2d0;
        --muted: #8b899b;
        --border: #262631;
        --border-strong: #33333f;
        --accent-soft: #2a1218;
        --violet: #8b7dff;
        --violet-soft: #1f1c3a;
        --teal: #2dd4bf;
        --teal-soft: #0f2a29;
        --amber: #fbbf24;
        --amber-soft: #2c2311;
        --ok: #34d399;
        --ok-soft: #0f2a1f;
        --info: #6ea2ff;
        --info-soft: #14203a;
        --error: #ff6b81;
        --error-soft: #2c1219;
        --shadow-sm: none;
        --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px -12px rgba(0, 0, 0, .6);
        --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, .7);
        --ring: 0 0 0 4px rgba(255, 77, 106, .22);
        color-scheme: dark;
    }
}

/* --- Base ----------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font: 15px/1.55 var(--font);
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    background:
        radial-gradient(900px 500px at 100% -10%, var(--bg-glow-2), transparent 60%),
        radial-gradient(700px 400px at 20% -10%, var(--bg-glow-1), transparent 60%),
        var(--bg);
    background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
h1, h2, h3 { letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 1.75rem; font-weight: 750; margin: 0; }
h2 { font-size: 1.02rem; font-weight: 700; margin: 0 0 .9rem; }
p { margin: 0 0 .75rem; }
img { max-width: 100%; }
code {
    font: 12.5px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
    background: var(--surface-2); border: 1px solid var(--border);
    padding: 2px 7px; border-radius: 7px; word-break: break-all;
}
code.block { display: block; padding: 12px 14px; }

.icon {
    width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

::selection { background: rgba(230, 0, 35, .18); }

/* --- App shell -------------------------------------------------------------- */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 22px;
    padding: 22px 16px 18px;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(18px);
    border-right: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); padding: 4px 8px; }
.brand:hover { color: var(--text); }
.brand-logo { width: 38px; height: 38px; filter: drop-shadow(0 6px 14px rgba(230, 0, 35, .35)); }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 1.05rem; font-weight: 750; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: .76rem; font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-label {
    font-size: .7rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
    color: var(--muted); padding: 14px 12px 6px;
}
.nav-label:first-child { padding-top: 0; }
.nav-link {
    position: relative; display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 12px;
    color: var(--text-2); font-weight: 550; font-size: .94rem;
    transition: background .15s, color .15s;
}
.nav-link .icon { color: var(--muted); transition: color .15s; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link:hover .icon { color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link.active .icon { color: var(--accent); }
.nav-link.active::before {
    content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 4px;
    border-radius: 0 4px 4px 0; background: var(--accent-grad);
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.status-card {
    padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 7px; font-size: .8rem; color: var(--text-2);
}
.status-line { display: flex; align-items: center; gap: 9px; }
.logout-btn { width: 100%; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--muted); position: relative; }
.dot.ok { background: var(--ok); }
.dot.ok::after {
    content: ""; position: absolute; inset: -4px; border-radius: 50%;
    background: var(--ok); opacity: .35; animation: pulse 2s ease-out infinite;
}
.dot.warn { background: var(--amber); }
.dot.off { background: var(--error); }
.dot.idle { background: var(--muted); }
@keyframes pulse { 0% { transform: scale(.6); opacity: .5; } 100% { transform: scale(1.8); opacity: 0; } }

.main { padding: 28px clamp(16px, 3.4vw, 44px) 48px; max-width: 1320px; width: 100%; }

.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.eyebrow { display: block; color: var(--muted); font-size: .84rem; font-weight: 550; margin-bottom: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
    display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}
.mobile-only { display: none !important; }

.toasts:empty { display: none; }
.toasts { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.toasts .alert { animation: slide-in .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } }

.tabbar { display: none; }

/* --- Responsive shell ---------------------------------------------------------- */

@media (max-width: 900px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .sidebar { display: none; }
    .main { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
    .topbar { align-items: center; margin-bottom: 20px; }
    h1 { font-size: 1.45rem; }
    .mobile-only { display: inline-grid !important; }
    .desktop-only { display: none !important; }

    .tabbar {
        position: fixed; z-index: 50; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
        display: flex; justify-content: space-around; align-items: center;
        height: 64px; padding: 0 8px; border-radius: 22px;
        background: color-mix(in srgb, var(--surface) 86%, transparent);
        backdrop-filter: blur(18px); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
    }
    .tabbar a {
        display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: var(--muted);
    }
    .tabbar a .icon { width: 22px; height: 22px; }
    .tabbar a.active { color: var(--accent); background: var(--accent-soft); }
    .tabbar a.fab {
        width: 54px; height: 54px; border-radius: 18px; color: #fff; background: var(--accent-grad);
        box-shadow: 0 10px 22px -6px rgba(230, 0, 35, .55); transform: translateY(-10px);
    }
}

/* --- Cards & layout helpers ---------------------------------------------------- */

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.card.highlight { border-color: var(--accent); box-shadow: var(--ring); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-head p { margin: 4px 0 0; }
.more { display: inline-flex; align-items: center; gap: 4px; font-size: .86rem; font-weight: 600; white-space: nowrap; }
.more .icon { width: 15px; height: 15px; transition: transform .15s; }
.more:hover .icon { transform: translateX(3px); }
details.card > summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 10px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before {
    content: "+"; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
    background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
details.card[open] > summary::before { content: "–"; }
details.card[open] > summary { margin-bottom: 16px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 20px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 20px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > h2 { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.error-text { color: var(--error); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Dashboard: hero ------------------------------------------------------------- */

.hero {
    position: relative; overflow: hidden; isolation: isolate;
    display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: center; gap: 12px;
    padding: 30px 34px; margin-bottom: 20px; border-radius: var(--radius-lg);
    color: #fff; background: var(--accent-grad); box-shadow: 0 24px 50px -24px rgba(230, 0, 35, .6);
}
.hero::before, .hero::after {
    content: ""; position: absolute; z-index: -1; border-radius: 50%; filter: blur(2px);
}
.hero::before { width: 420px; height: 420px; right: -120px; top: -200px; background: radial-gradient(circle, rgba(255, 255, 255, .25), transparent 65%); }
.hero::after { width: 360px; height: 360px; left: 30%; bottom: -260px; background: radial-gradient(circle, rgba(106, 90, 249, .55), transparent 65%); }
.hero-kicker {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
    background: rgba(255, 255, 255, .18); font-size: .78rem; font-weight: 650; letter-spacing: .02em; backdrop-filter: blur(6px);
}
.hero-kicker .icon { width: 14px; height: 14px; }
.hero h2 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); font-weight: 780; margin: 14px 0 8px; }
.hero p { color: rgba(255, 255, 255, .88); max-width: 46ch; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.hero-art { width: 100%; max-height: 220px; }

.float-a { animation: float 6s ease-in-out infinite; }
.float-b { animation: float 7s ease-in-out -2s infinite; }
.float-c { animation: float 8s ease-in-out -4s infinite; }
@keyframes float { 50% { transform: translateY(-7px); } }

@media (max-width: 760px) {
    .hero { grid-template-columns: 1fr; padding: 24px; }
    .hero-art { display: none; }
}

/* --- Dashboard: KPIs ---------------------------------------------------------------- */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi {
    display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi > div { display: flex; flex-direction: column; min-width: 0; }
.kpi-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0; }
.kpi-icon .icon { width: 22px; height: 22px; }
.kpi-icon.accent { background: var(--accent-soft); color: var(--accent); }
.kpi-icon.violet { background: var(--violet-soft); color: var(--violet); }
.kpi-icon.teal { background: var(--teal-soft); color: var(--teal); }
.kpi-icon.amber { background: var(--amber-soft); color: var(--amber); }
.kpi-label { color: var(--muted); font-size: .82rem; font-weight: 550; }
.kpi-value { font-size: 1.6rem; font-weight: 780; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.2; }

/* --- Dashboard: grid ------------------------------------------------------------------ */

.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.dash-grid > .card { margin: 0; }
.dash-grid .span-2 { grid-row: span 2; }
@media (max-width: 1100px) {
    .dash-grid { grid-template-columns: minmax(0, 1fr); }
    .dash-grid .span-2 { grid-row: auto; }
}

/* Bar chart */
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.published { background: var(--accent-grad); }
.sw.scheduled { background: repeating-linear-gradient(45deg, var(--violet) 0 2px, var(--violet-soft) 2px 4px); }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 5; }
.chart .axis { fill: var(--muted); font: 600 10.5px var(--font); }
.chart .axis.faint { opacity: .6; font-weight: 500; }
.chart .axis.today { fill: var(--accent); font-weight: 750; }
.chart .today-band { fill: var(--accent); fill-opacity: .07; stroke: var(--accent); stroke-opacity: .35; stroke-dasharray: 4 4; }
.chart .empty-bar { fill: var(--surface-3); }
.chart .bar { cursor: default; }
.chart .bar:hover rect.grow { filter: brightness(1.12); }
.chart .grow {
    transform-box: fill-box; transform-origin: bottom;
    animation: grow .7s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i) * 25ms);
}
@keyframes grow { from { transform: scaleY(0); } }

/* Donut */
.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.donut { width: 170px; height: 170px; animation: donut .9s cubic-bezier(.2, .8, .2, 1) both; }
.donut-track { fill: none; stroke: var(--surface-3); stroke-width: 14; }
.donut-seg { fill: none; stroke-width: 14; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 70px 70px; }
@keyframes donut { from { opacity: 0; transform: rotate(-60deg) scale(.85); } }
.donut-value { fill: var(--text); font: 800 28px var(--font); letter-spacing: -.03em; }
.donut-label { fill: var(--muted); font: 600 11px var(--font); }
.donut-legend { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.donut-legend li { display: grid; grid-template-columns: 10px 1fr auto 40px; align-items: center; gap: 10px; font-size: .88rem; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend small { color: var(--muted); text-align: right; }

/* Upcoming */
.upcoming { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.upcoming li {
    display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 14px;
    background: var(--surface-2); border: 1px solid var(--border);
}
.date-chip {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 48px; height: 52px; border-radius: 12px; flex-shrink: 0;
    background: var(--surface); border: 1px solid var(--border); line-height: 1;
}
.date-chip strong { font-size: 1.2rem; font-weight: 800; }
.date-chip small { font-size: .68rem; font-weight: 700; color: var(--accent); text-transform: uppercase; margin-top: 3px; }
.upcoming-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.upcoming-text strong { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upcoming-text small { color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.upcoming-text small .icon { width: 13px; height: 13px; }

/* Health */
.health { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.health a {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; color: var(--text);
    border: 1px solid var(--border); transition: background .15s, border-color .15s;
}
.health a:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.health-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; }
.health-icon.ok { background: var(--ok-soft); color: var(--ok); }
.health-icon.warn { background: var(--amber-soft); color: var(--amber); }
.health-icon.off { background: var(--error-soft); color: var(--error); }
.health-icon.idle { background: var(--surface-3); color: var(--muted); }
.health-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.health-text strong { font-size: .9rem; }
.health-text small { color: var(--muted); font-size: .8rem; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 17px; top: 18px; bottom: 18px; width: 2px; background: var(--border); }
.timeline li { position: relative; display: flex; gap: 14px; padding: 8px 0; }
.tl-icon {
    position: relative; z-index: 1; display: grid; place-items: center;
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    background: var(--surface-2); color: var(--muted); border: 3px solid var(--surface);
}
.tl-icon .icon { width: 16px; height: 16px; }
.tl-icon.ok { background: var(--ok-soft); color: var(--ok); }
.tl-icon.error { background: var(--error-soft); color: var(--error); }
.tl-icon.info { background: var(--info-soft); color: var(--info); }
.tl-icon.violet { background: var(--violet-soft); color: var(--violet); }
.tl-icon.amber { background: var(--amber-soft); color: var(--amber); }
.tl-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding-top: 6px; }
.tl-text { font-size: .9rem; overflow-wrap: anywhere; }
.tl-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .78rem; }

/* Recent uploads */
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumbs a { position: relative; display: block; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.thumbs a span {
    position: absolute; inset: 0; display: grid; place-items: center; color: #fff;
    background: rgba(230, 0, 35, .55); opacity: 0; transition: opacity .2s;
}
.thumbs a:hover img { transform: scale(1.06); }
.thumbs a:hover span { opacity: 1; }
.upload-teaser {
    display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px;
    border: 2px dashed var(--border-strong); border-radius: 14px; color: var(--muted); font-weight: 600;
}
.upload-teaser .icon { width: 28px; height: 28px; color: var(--accent); }

/* Empty states */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 12px 0 4px; color: var(--muted); }
.empty svg { width: 120px; height: 90px; margin-bottom: 8px; }
.empty p { margin: 0 0 4px; }
.empty .e1 { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1.5; }
.empty .e2 { fill: var(--accent-soft); }
.empty .e3 { fill: var(--surface-3); }
.empty .e4 { fill: var(--accent); opacity: .6; }

/* --- Forms ----------------------------------------------------------------------- */

label { display: flex; flex-direction: column; gap: 7px; font-weight: 600; font-size: .88rem; color: var(--text-2); }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; color: var(--text); }
input, select, textarea {
    font: inherit; font-weight: 450; color: var(--text); background: var(--surface-2); width: 100%;
    border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); background: var(--surface); }
select {
    appearance: none; padding-right: 40px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8799' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; padding: 0; accent-color: var(--accent); cursor: pointer; }
textarea { resize: vertical; min-height: 44px; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.form-row > * { flex: 1 1 200px; }
.form-row > .btn { flex: 0 0 auto; }
.form-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
label:has(.counter) { flex-direction: row; flex-wrap: wrap; align-items: center; }
label:has(.counter) > input, label:has(.counter) > textarea { flex-basis: 100%; }
.counter { margin-left: auto; font-weight: 600; color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--error); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 650; font-size: .92rem; padding: 11px 18px; border-radius: 12px; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .15s, background .15s, filter .15s;
    white-space: nowrap;
}
.btn:hover { color: var(--text); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 17px; height: 17px; }
.btn.primary {
    background: var(--accent-grad); border-color: transparent; color: #fff;
    box-shadow: 0 8px 20px -8px rgba(230, 0, 35, .65), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.btn.primary:hover { color: #fff; filter: brightness(1.06); box-shadow: 0 12px 26px -8px rgba(230, 0, 35, .7); }
.btn.light { background: #fff; color: #c4001d; border-color: transparent; box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .35); }
.btn.light:hover { background: #fff; color: #e60023; }
.btn.ghost-light { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .3); box-shadow: none; }
.btn.ghost-light:hover { background: rgba(255, 255, 255, .22); color: #fff; }
.btn.small { padding: 7px 12px; font-size: .84rem; border-radius: 10px; }
.btn[disabled] { opacity: .65; cursor: wait; }
button.link {
    display: inline-flex; align-items: center; gap: 5px;
    background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer;
}
button.link:hover { color: var(--accent-2); }
.danger { color: var(--error) !important; }

/* Segmented tabs */
.tabs {
    display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 18px; flex-wrap: wrap;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
}
.tabs label {
    flex-direction: row; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 10px;
    cursor: pointer; font-weight: 600; color: var(--muted); transition: all .15s;
}
.tabs label:hover { color: var(--text); }
.tabs label:has(input:checked) { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.tabs input { display: none; }

/* Alerts, chips, badges */
.alert {
    display: flex; align-items: flex-start; gap: 10px; padding: 13px 16px; border-radius: 14px; margin-bottom: 16px;
    background: var(--info-soft); color: var(--info); font-weight: 550; border: 1px solid transparent;
}
.alert .icon { margin-top: 2px; }
.alert.success { background: var(--ok-soft); color: var(--ok); }
.alert.error { background: var(--error-soft); color: var(--error); }
a.alert:hover { filter: brightness(.98); }
.toasts .alert { margin: 0; }

.chip, .badge {
    display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 700;
    padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); letter-spacing: .01em; white-space: nowrap;
}
.chip .icon { width: 13px; height: 13px; }
.chip.warn, .badge.warn, .badge.cron, .chip.cron { background: var(--amber-soft); color: var(--amber); }
.chip.ok, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.chip.info, .badge.info { background: var(--info-soft); color: var(--info); }
.chip.mcp, .badge.mcp { background: var(--violet-soft); color: var(--violet); }
.chip.dashboard, .badge.dashboard { background: var(--accent-soft); color: var(--accent); }
.badge.error { background: var(--error-soft); color: var(--error); }

/* Tables */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
    text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.table td { padding: 13px 12px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: .92rem; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.row-error td { background: var(--error-soft); }
.pager { display: flex; justify-content: space-between; margin-top: 14px; font-weight: 600; }
@media (max-width: 640px) {
    .table thead { display: none; }
    .table tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--border); }
    .table td { display: block; border: 0; padding: 2px 0; }
}

/* --- Boards & pins ---------------------------------------------------------------- */

.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 18px; }
.board-card {
    display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; color: var(--text); box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
}
.board-card:hover { color: var(--text); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.board-cover {
    aspect-ratio: 4 / 3; position: relative;
    background:
        radial-gradient(circle at 30% 30%, var(--accent-soft), transparent 60%),
        radial-gradient(circle at 80% 70%, var(--violet-soft), transparent 55%),
        var(--surface-2);
}
.board-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.board-card:hover .board-cover img { transform: scale(1.04); }
.board-meta { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.board-meta strong { font-size: .98rem; }
.board-meta .muted { font-size: .82rem; }

.pin-grid { columns: 240px; column-gap: 18px; }
.pin-card {
    break-inside: avoid; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
}
.pin-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.pin-thumb { display: block; position: relative; background: var(--surface-2); min-height: 90px; }
.pin-thumb img { width: 100%; display: block; }
.pin-thumb .badge { position: absolute; top: 10px; left: 10px; background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(6px); }
.pin-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.pin-actions { display: flex; gap: 16px; margin-top: 8px; font-size: .86rem; font-weight: 600; }
.preview { width: 100%; border-radius: 14px; }

/* --- Media library ---------------------------------------------------------------- */

.dropzone {
    position: relative; overflow: hidden; text-align: center; margin-bottom: 24px;
    padding: 44px 20px; border-radius: var(--radius-lg);
    border: 2px dashed var(--border-strong); background: var(--surface);
    transition: border-color .2s, background .2s, transform .2s;
}
.dropzone::before {
    content: ""; display: block; width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px;
    background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e60023' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpath d='m17 8-5-5-5 5M12 3v12'/%3E%3C/svg%3E") center / 28px no-repeat;
    transition: transform .25s;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.01); }
.dropzone.over::before { transform: translateY(-4px) scale(1.06); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone-text { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.dropzone-text strong { font-size: 1.05rem; }
.dropzone-text label { display: inline; font-weight: 700; color: var(--accent); cursor: pointer; font-size: inherit; }
.progress { height: 6px; max-width: 420px; margin: 18px auto 0; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent-grad); transition: width .2s; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(170px, 42vw), 1fr)); gap: 16px; }
.media-card {
    margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
}
.media-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.media-card img, .media-card video { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--surface-2); }
.media-card figcaption { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
.media-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: .84rem; font-weight: 600; }

.media-picker {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px;
    max-height: 440px; overflow-y: auto; padding: 4px;
}
.media-item {
    position: relative; display: block; border-radius: 14px; overflow: hidden; cursor: pointer;
    box-shadow: 0 0 0 2px transparent; transition: box-shadow .15s, transform .15s;
}
.media-item:hover { transform: translateY(-2px); }
.media-item img, .media-item video { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--surface-2); }
.media-item input { position: absolute; top: 8px; right: 8px; z-index: 1; }
.media-item .badge { position: absolute; bottom: 8px; left: 8px; background: rgba(0, 0, 0, .55); color: #fff; }
.media-item:has(input:checked) { box-shadow: 0 0 0 3px var(--accent), 0 10px 22px -10px rgba(230, 0, 35, .6); }
.media-item .order {
    position: absolute; top: 7px; left: 7px; display: grid; place-items: center;
    min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px;
    background: var(--accent-grad); color: #fff; font-size: .75rem; font-weight: 800;
}
.video-only { margin-top: 16px; max-width: 340px; }

/* Create form steps */
.create-form { counter-reset: step; }
.create-form > .card > h2 { display: flex; align-items: center; gap: 10px; }

/* --- Settings ---------------------------------------------------------------- */

.steps { padding-left: 0; margin: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: baseline; color: var(--text-2); }
.steps li::before {
    content: counter(s); display: inline-grid; place-items: center; flex-shrink: 0;
    width: 24px; height: 24px; border-radius: 8px; background: var(--accent-soft); color: var(--accent);
    font-size: .78rem; font-weight: 800;
}
.secret { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.secret code { flex: 1 1 300px; padding: 11px 14px; }
.blurred { filter: blur(5px); user-select: none; }
.copy { cursor: copy; }
.help { padding: 6px 0 0; color: var(--text-2); }
.help p { margin: 10px 0; }
details > summary { cursor: pointer; font-weight: 600; color: var(--accent); }

/* --- Auth pages -------------------------------------------------------------- */

body.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-wrap {
    width: 100%; max-width: 940px; display: grid; grid-template-columns: 1.1fr 1fr;
    background: var(--surface); border: 1px solid var(--border); border-radius: 30px; overflow: hidden; box-shadow: var(--shadow-lg);
}
.auth-art {
    position: relative; overflow: hidden; isolation: isolate; color: #fff; padding: 34px;
    display: flex; flex-direction: column; justify-content: center; min-height: 540px;
    background: linear-gradient(160deg, #2a1a5e 0%, #6a1b4d 55%, #e60023 120%);
}
.auth-art::after {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background: radial-gradient(500px 300px at 80% 10%, rgba(255, 77, 106, .45), transparent 60%);
}
.auth-illustration { display: block; width: 100%; max-width: 320px; max-height: 300px; margin: 0 auto 24px; }
.auth-tagline h2 { font-size: 1.9rem; font-weight: 800; margin: 0 0 10px; line-height: 1.12; }
.auth-tagline p { color: rgba(255, 255, 255, .8); margin: 0; max-width: 34ch; }
.auth-card { padding: 44px 40px; display: flex; flex-direction: column; justify-content: center; }
.auth-card .brand { margin-bottom: 34px; padding: 0; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: 6px; }
.auth-card form { margin-top: 22px; }
.auth-card .btn { width: 100%; padding: 13px; }
@media (max-width: 760px) {
    .auth-wrap { grid-template-columns: 1fr; border-radius: 24px; }
    .auth-art { min-height: 200px; padding: 24px; }
    .auth-illustration { display: none; }
    .auth-tagline h2 { font-size: 1.4rem; }
    .auth-card { padding: 30px 24px; }
}

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

/* --- Page extras ------------------------------------------------------------- */

.step-no {
    display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px;
    background: var(--accent-grad); color: #fff; font-size: .82rem; font-weight: 800;
    box-shadow: 0 6px 14px -6px rgba(230, 0, 35, .6);
}
.section-title { display: flex; align-items: center; gap: 12px; }
.section-title .kpi-icon { width: 38px; height: 38px; border-radius: 11px; }
.section-title .kpi-icon .icon { width: 19px; height: 19px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.pin-actions a, .pin-actions button, .media-actions a { display: inline-flex; align-items: center; gap: 5px; }
.pin-actions .icon, .media-actions .icon { width: 15px; height: 15px; }
.empty-icon { width: 40px; height: 40px; color: var(--accent); margin-bottom: 8px; }

/* --- Public pages (privacy policy) ------------------------------------------- */

body.public { padding: 0 16px 64px; }
.public-head {
    position: sticky; top: 0; z-index: 10; max-width: 880px; margin: 0 auto; padding: 18px 0;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px);
}
.lang-switch { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.lang-switch a { padding: 6px 12px; border-radius: 9px; font-size: .85rem; font-weight: 650; color: var(--muted); }
.lang-switch a.active { background: var(--accent-soft); color: var(--accent); }
.public-main { max-width: 880px; margin: 0 auto; }

.legal {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: clamp(24px, 5vw, 56px); box-shadow: var(--shadow); line-height: 1.7; color: var(--text-2);
}
.legal h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); color: var(--text); margin: 6px 0 6px; }
.legal h2 { font-size: 1.15rem; color: var(--text); margin: 0 0 10px; scroll-margin-top: 90px; }
.legal section { padding-top: 26px; margin-top: 26px; border-top: 1px solid var(--border); }
.legal strong { color: var(--text); }
.legal ul { padding-left: 20px; margin: 0 0 12px; }
.legal li { margin-bottom: 6px; }
.legal-kicker {
    display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 5px 12px; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent); font-size: .8rem; font-weight: 700;
}
.legal-kicker .icon { width: 14px; height: 14px; }
.legal-toc {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 16px;
    margin-top: 24px; padding: 16px 18px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border);
}
.legal-toc a { font-size: .88rem; font-weight: 550; padding: 3px 0; }
.legal .scopes { display: flex; flex-wrap: wrap; gap: 6px; }
.operator {
    font-style: normal; padding: 16px 18px; border-radius: var(--radius); line-height: 1.6;
    background: var(--surface-2); border-left: 4px solid var(--accent);
}
.auth-foot { margin: 18px 0 0; text-align: center; font-size: .85rem; }
.auth-foot a { color: var(--muted); }
@media print {
    body.public { background: #fff; color: #000; }
    .public-head .lang-switch, .legal-toc { display: none; }
    .legal { box-shadow: none; border: 0; padding: 0; }
}
