/* ============================================================
   PKPP Flipbook — Corporate Design System
   Palette derived from the PKPP logo:
   green #58B542 · purple #5B3E92 · orange #F58220 · ink #14181D
   ============================================================ */

:root {
    --c-green: #2e9a3f;
    --c-green-deep: #1c6f2b;
    --c-green-bright: #58b542;
    --c-green-soft: #e8f5e4;
    --c-purple: #5b3e92;
    --c-purple-deep: #462f73;
    --c-purple-soft: #efeaf8;
    --c-orange: #f58220;
    --c-orange-deep: #d96a0e;
    --c-orange-soft: #fdeedd;
    --c-ink: #14181d;

    --bg: #f4f6f2;
    --paper: #ffffff;
    --line: #e2e7df;
    --ink: #1b222a;
    --muted: #5f6d64;
    --danger: #c0392b;
    --danger-soft: #fbe7e4;
    --ok: #1c6f2b;
    --ok-soft: #e4f4e2;

    --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-head: "Sora", "Segoe UI", system-ui, sans-serif;

    --radius: 14px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 3px rgba(20, 24, 29, .06), 0 4px 14px rgba(20, 24, 29, .04);
    --shadow-md: 0 6px 24px rgba(20, 24, 29, .08);
    --shadow-lg: 0 18px 50px rgba(20, 24, 29, .14);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

h1, h2, h3, h4 {
    font-family: var(--font-head);
    letter-spacing: -.01em;
    line-height: 1.25;
}

/* ---- Brand stripe (echoes the three logo leaves) ---- */
.brand-stripe {
    height: 4px;
    background: linear-gradient(90deg,
        var(--c-purple) 0%, var(--c-purple) 26%,
        var(--c-green-bright) 26%, var(--c-green-bright) 62%,
        var(--c-orange) 62%, var(--c-orange) 84%,
        var(--c-ink) 84%, var(--c-ink) 100%);
}

/* ---- App shell ---- */
.app-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 24px 48px;
}

/* ---- Top bar ---- */
.topbar-wrap {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.topbar {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    flex: none;
}

.brand .brand-name {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 17px;
    color: var(--c-ink);
    white-space: nowrap;
}

.brand .brand-sub {
    font-size: 10.5px;
    color: var(--muted);
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.nav-area {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.nav-links { display: flex; gap: 6px; align-items: center; }

.nav-link {
    padding: 9px 16px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    color: var(--muted);
    white-space: nowrap;
    transition: color .15s ease, background .15s ease;
}

.nav-link:hover { color: var(--c-green-deep); background: var(--c-green-soft); }

.nav-link.active {
    background: var(--c-ink);
    color: #fff;
}

.nav-toggle {
    display: none;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    width: 42px;
    height: 42px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex: none;
}

.nav-toggle svg { width: 20px; height: 20px; stroke: var(--ink); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 18px;
    font: 600 14px/1.2 var(--font-body);
    cursor: pointer;
    background: linear-gradient(135deg, var(--c-green) 0%, var(--c-green-deep) 100%);
    color: #fff;
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
    touch-action: manipulation;
}

.btn:hover { filter: brightness(1.06); box-shadow: 0 6px 16px rgba(28, 111, 43, .25); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.btn.secondary {
    background: #fff;
    color: var(--c-green-deep);
    border-color: #c4dcc0;
}
.btn.secondary:hover { background: var(--c-green-soft); box-shadow: none; }

.btn.ghost {
    background: transparent;
    color: var(--muted);
    border-color: var(--line);
}
.btn.ghost:hover { color: var(--ink); background: #fff; box-shadow: none; }

.btn.warn {
    background: linear-gradient(135deg, var(--c-orange) 0%, var(--c-orange-deep) 100%);
    color: #fff;
}
.btn.warn:hover { box-shadow: 0 6px 16px rgba(217, 106, 14, .3); }

.btn.purple {
    background: linear-gradient(135deg, var(--c-purple) 0%, var(--c-purple-deep) 100%);
    color: #fff;
}
.btn.purple:hover { box-shadow: 0 6px 16px rgba(70, 47, 115, .3); }

.btn.err, .btn.danger {
    background: #fff;
    color: var(--danger);
    border-color: #ecc4bd;
}
.btn.err:hover, .btn.danger:hover { background: var(--danger-soft); box-shadow: none; }

.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }

/* ---- Cards ---- */
.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}

.card h2, .card h3 { margin-top: 0; }
.card h2 { font-size: 19px; }
.card h3 { font-size: 16px; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---- Page heading ---- */
.page-head { margin: 6px 0 20px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; }
.page-head p { margin: 0; color: var(--muted); font-size: 14.5px; }

/* ---- KPI cards ---- */
.grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.kpi {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kpi::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--kpi-accent, var(--c-green));
}

.kpi.accent-green { --kpi-accent: var(--c-green-bright); }
.kpi.accent-purple { --kpi-accent: var(--c-purple); }
.kpi.accent-orange { --kpi-accent: var(--c-orange); }
.kpi.accent-ink { --kpi-accent: var(--c-ink); }

.kpi .label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.kpi .value {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 34px;
    line-height: 1.1;
    color: var(--c-ink);
}

/* ---- Status chips ---- */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
}

.status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
}

.status.ready { color: var(--ok); background: var(--ok-soft); }
.status.processing, .status.pending { color: var(--c-orange-deep); background: var(--c-orange-soft); }
.status.failed { color: var(--danger); background: var(--danger-soft); }
.status.role { color: var(--c-purple-deep); background: var(--c-purple-soft); }

/* ---- Alerts ---- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-weight: 500;
    font-size: 14.5px;
}

.alert.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #c4e5c0; }
.alert.err { background: var(--danger-soft); color: var(--danger); border: 1px solid #ecc4bd; }

/* ---- Tables ---- */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -6px;
    padding: 0 6px;
}

table { width: 100%; border-collapse: collapse; min-width: 480px; }

th, td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
}

tbody tr:hover { background: #f8faf7; }
tbody tr:last-child td { border-bottom: 0; }

td a strong { color: var(--c-green-deep); }
td a:hover strong { text-decoration: underline; }

/* ---- Forms ---- */
label { display: block; margin-bottom: 7px; font-weight: 600; font-size: 13.5px; }

input, select, textarea {
    width: 100%;
    border: 1px solid #ccd6cc;
    border-radius: 10px;
    padding: 11px 13px;
    font: inherit;
    font-size: 14.5px;
    background: #fff;
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--c-green);
    box-shadow: 0 0 0 3px rgba(46, 154, 63, .14);
}

input[type="file"] { padding: 9px; background: #fafcf9; border-style: dashed; cursor: pointer; }

input[type="file"]::file-selector-button {
    border: 0;
    border-radius: 8px;
    padding: 8px 14px;
    margin-right: 12px;
    font: 600 13px var(--font-body);
    background: var(--c-green-soft);
    color: var(--c-green-deep);
    cursor: pointer;
}

.field { margin-bottom: 16px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

/* ---- Layout helpers ---- */
.split {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr 1fr;
    align-items: start;
}

.stack > * + * { margin-top: 16px; }

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.pagination .page-btn {
    min-width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--muted);
}

.pagination .page-btn:hover { border-color: #c4dcc0; color: var(--c-green-deep); }
.pagination .page-btn.current { background: var(--c-ink); color: #fff; border-color: var(--c-ink); }
.pagination .page-btn.disabled { opacity: .4; pointer-events: none; }

/* ---- Footer ---- */
.app-footer {
    margin-top: 40px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12.5px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============================================================
   Auth pages
   ============================================================ */
.auth-body {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 22px 16px;
    background:
        radial-gradient(720px 420px at 8% -4%, rgba(91, 62, 146, .10), transparent 62%),
        radial-gradient(760px 460px at 96% 0%, rgba(88, 181, 66, .13), transparent 60%),
        radial-gradient(640px 420px at 88% 100%, rgba(245, 130, 32, .09), transparent 60%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 430px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.auth-card .brand-stripe { border-radius: 0; }

.auth-inner { padding: 36px 34px 30px; text-align: center; }

.auth-inner .logo { width: 84px; margin-bottom: 12px; }

.auth-title {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 21px;
    margin: 0;
    color: var(--c-ink);
}

.auth-sub {
    font-size: 12.5px;
    color: var(--muted);
    margin: 4px 0 26px;
}

.auth-inner form { text-align: left; }

.auth-heading {
    font-family: var(--font-head);
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 18px;
    text-align: left;
}

.password-wrapper { position: relative; }

.password-wrapper input { padding-right: 64px; }

.toggle-password {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    color: var(--c-green-deep);
    user-select: none;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    font-size: 13px;
}

.auth-links a { color: var(--c-green-deep); font-weight: 600; }
.auth-links a:hover { text-decoration: underline; }

.auth-footer {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    font-size: 11.5px;
    color: var(--muted);
    text-align: center;
}

/* ============================================================
   Public gallery
   ============================================================ */
.g-shell { max-width: 1200px; margin: 0 auto; padding: 26px 24px 56px; }

.g-hero {
    position: relative;
    overflow: hidden;
    border-radius: 22px;
    padding: 40px 36px;
    margin-bottom: 24px;
    color: #fff;
    background:
        radial-gradient(560px 300px at 88% -20%, rgba(245, 130, 32, .35), transparent 60%),
        radial-gradient(520px 320px at -6% 110%, rgba(91, 62, 146, .5), transparent 62%),
        linear-gradient(120deg, #17251b 0%, #1d3a24 55%, #234a2b 100%);
    box-shadow: var(--shadow-md);
}

.g-hero .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #bfe3b4;
    margin-bottom: 10px;
}

.g-hero h1 { margin: 0 0 8px; font-size: clamp(24px, 4vw, 36px); color: #fff; }
.g-hero p { margin: 0; color: rgba(255, 255, 255, .78); max-width: 560px; font-size: 15px; }

.g-cat-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 22px;
}

.g-cat-chip {
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--muted);
    transition: all .15s ease;
}

.g-cat-chip:hover { border-color: #c4dcc0; color: var(--c-green-deep); }
.g-cat-chip.active { background: var(--c-ink); border-color: var(--c-ink); color: #fff; }

.g-section { margin-bottom: 30px; }

.g-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.g-section-head h2 {
    margin: 0;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.g-section-head h2::before {
    content: "";
    width: 5px;
    height: 22px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--c-green-bright), var(--c-green-deep));
}

.g-section-head .count { color: var(--muted); font-size: 13px; font-weight: 500; }

.g-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.g-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 12px 12px 14px;
    box-shadow: var(--shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.g-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: #c4dcc0;
}

.g-card h3 {
    margin: 0;
    font-size: 14.5px;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.g-card .meta { color: var(--muted); font-size: 12.5px; }

.thumb {
    position: relative;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #eef1ec;
    aspect-ratio: 1 / 1.35;
    width: 100%;
    overflow: hidden;
    display: grid;
    place-items: center;
}

.thumb canvas, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumb .thumb-text { color: var(--muted); font-size: 12px; z-index: 1; }

.thumb.loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .65) 50%, transparent 70%);
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

.g-empty {
    text-align: center;
    color: var(--muted);
    padding: 60px 20px;
    background: var(--paper);
    border: 1px dashed var(--line);
    border-radius: var(--radius-lg);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .split { grid-template-columns: 1fr; }
}

@media (max-width: 920px) {
    .brand .brand-sub { display: none; }

    .nav-toggle { display: inline-flex; }

    .nav-area {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        background: #fff;
        border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow-md);
        padding: 14px 20px 18px;
    }

    .nav-area.open { display: flex; }

    .nav-links { flex-direction: column; gap: 4px; align-items: stretch; }

    .nav-link { border-radius: 10px; padding: 12px 14px; text-align: left; }

    .topbar { position: relative; padding: 10px 16px; }
}

@media (max-width: 640px) {
    .app-shell { padding: 16px 14px 40px; }
    .card { padding: 16px; border-radius: var(--radius); }
    .page-head h1 { font-size: 22px; }
    .kpi .value { font-size: 28px; }
    .g-shell { padding: 16px 14px 44px; }
    .g-hero { padding: 26px 20px; border-radius: 18px; }
    .g-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .auth-inner { padding: 28px 22px 24px; }
    .btn { min-height: 42px; }
}

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