:root {
    --pink-50: #fff4f9;
    --pink-100: #ffe1ef;
    --pink-200: #ffc2dc;
    --pink-400: #f35b9f;
    --pink-500: #dc3f89;
    --pink-700: #9d1f61;
    --gold: #d8a642;
    --gold-soft: #fff1c9;
    --white: #ffffff;
    --ink: #46233a;
    --muted: #8a5b76;
    --line: rgba(220, 63, 137, 0.16);
    --shadow: 0 18px 55px rgba(157, 31, 97, 0.14);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255, 194, 220, 0.85), transparent 36rem),
        radial-gradient(circle at bottom right, rgba(255, 241, 201, 0.9), transparent 34rem),
        linear-gradient(135deg, #fff8fb 0%, #ffe6f1 48%, #fff 100%);
    overflow-x: hidden;
}

button,
input,
select {
    font: inherit;
}

button,
a,
input,
select {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

.animated-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.animated-bg span {
    position: absolute;
    display: block;
    width: 8rem;
    aspect-ratio: 1;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(255, 194, 220, 0.36));
    box-shadow: inset 0 0 28px rgba(255, 255, 255, 0.72), 0 0 35px rgba(243, 91, 159, 0.16);
    animation: bubbleFloat 14s infinite ease-in-out;
}

.animated-bg span:nth-child(1) { left: 6%; top: 12%; animation-delay: 0s; }
.animated-bg span:nth-child(2) { right: 12%; top: 8%; width: 5rem; animation-delay: -4s; }
.animated-bg span:nth-child(3) { left: 18%; bottom: 9%; width: 6rem; animation-delay: -8s; }
.animated-bg span:nth-child(4) { right: 5%; bottom: 18%; width: 10rem; animation-delay: -2s; }
.animated-bg span:nth-child(5) { left: 48%; top: 38%; width: 4rem; animation-delay: -6s; }
.animated-bg span:nth-child(6) { left: 73%; top: 62%; width: 3rem; animation-delay: -10s; }

@keyframes bubbleFloat {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); opacity: 0.75; }
    45% { transform: translate3d(18px, -34px, 0) scale(1.08); opacity: 0.45; }
    70% { transform: translate3d(-16px, 20px, 0) scale(0.96); opacity: 0.62; }
}

.app-shell {
    position: relative;
    z-index: 1;
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 48px;
}

.hero-panel,
.gate-card,
.topbar,
.metric-card,
.form-card,
.table-card {
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.74);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 220px;
    padding: clamp(26px, 4vw, 52px);
    border-radius: 30px;
    overflow: hidden;
    position: relative;
}

.hero-panel::after {
    content: "✧";
    position: absolute;
    right: 18%;
    top: 26px;
    color: var(--gold);
    font-size: 4rem;
    opacity: 0.3;
    animation: twinkle 2.4s infinite ease-in-out;
}

@keyframes twinkle {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.28; }
    50% { transform: scale(1.14) rotate(12deg); opacity: 0.52; }
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--pink-700);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    line-height: 1.05;
}

h1 {
    max-width: 700px;
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(2.25rem, 5vw, 5rem);
    color: var(--pink-700);
}

h2 {
    color: var(--ink);
    font-size: clamp(1.35rem, 2vw, 2rem);
}

.hero-copy {
    max-width: 620px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.7;
}

.admin-link,
.primary-button,
.ghost-button,
.operator-form button {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 800;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.admin-link,
.primary-button,
.operator-form button {
    color: var(--white);
    background: linear-gradient(135deg, var(--pink-400), var(--pink-700));
    box-shadow: 0 14px 32px rgba(220, 63, 137, 0.26);
}

.admin-link {
    padding: 14px 20px;
}

.primary-button,
.operator-form button {
    padding: 15px 22px;
}

.ghost-button {
    padding: 12px 18px;
    color: var(--pink-700);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
}

.admin-link:hover,
.primary-button:hover,
.operator-form button:hover,
.ghost-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px rgba(220, 63, 137, 0.24);
}

.gate-card {
    position: relative;
    width: min(760px, 100%);
    margin: 26px auto 0;
    padding: clamp(24px, 4vw, 42px);
    border-radius: var(--radius);
    animation: popIn 0.45s ease both;
}

@keyframes popIn {
    from { transform: translateY(14px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.sparkle {
    position: absolute;
    right: 28px;
    top: 24px;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    color: var(--gold);
    background: var(--gold-soft);
    border-radius: 999px;
}

.operator-form {
    margin-top: 24px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--pink-700);
    font-size: 0.88rem;
    font-weight: 800;
}

.inline-field {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
}

input,
select {
    width: 100%;
    min-height: 50px;
    border: 1px solid rgba(220, 63, 137, 0.2);
    border-radius: 16px;
    padding: 0 16px;
    color: var(--ink);
    font-size: 16px;
    background: rgba(255, 255, 255, 0.86);
    outline: 0;
    transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

input:focus,
select:focus {
    border-color: var(--pink-400);
    box-shadow: 0 0 0 4px rgba(243, 91, 159, 0.14);
}

input[readonly] {
    color: var(--muted);
    background: rgba(255, 244, 249, 0.78);
}

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

.system-area {
    margin-top: 24px;
    animation: popIn 0.45s ease both;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 20px;
    padding: 22px;
    border-radius: var(--radius);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.metric-card {
    min-height: 138px;
    padding: 22px;
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: "";
    position: absolute;
    right: -28px;
    bottom: -28px;
    width: 90px;
    height: 90px;
    border-radius: 999px;
    background: rgba(255, 194, 220, 0.44);
}

.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.metric-card strong {
    display: block;
    margin-top: 12px;
    color: var(--pink-700);
    font-size: clamp(1.7rem, 3vw, 2.5rem);
}

.latest-card ul {
    position: relative;
    z-index: 1;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    color: var(--ink);
    font-size: 0.86rem;
}

.latest-card li + li {
    margin-top: 6px;
}

.content-grid,
.admin-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.78fr) minmax(0, 1.22fr);
    gap: 18px;
    align-items: start;
}

.content-grid {
    grid-template-columns: 1fr;
}

.content-grid .form-card {
    max-width: 760px;
}

.admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide {
    grid-column: 1 / -1;
}

.form-card,
.table-card {
    border-radius: var(--radius);
    padding: clamp(20px, 3vw, 30px);
}

.section-heading {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

small {
    display: block;
    min-height: 18px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.78rem;
}

small.error {
    color: #c32256;
}

small.success {
    color: #138a58;
}

.filters {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr 0.75fr;
    gap: 12px;
    margin-bottom: 16px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.52);
}

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

.actions-heading {
    text-align: right;
}

.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    white-space: nowrap;
}

.action-button {
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--pink-700);
    font-weight: 800;
    background: #fff;
    cursor: pointer;
}

.action-button:hover { background: var(--pink-50); }
.action-button.delete { color: #a51d45; background: #fff3f6; }
.action-button:disabled { opacity: .55; cursor: wait; }
.edit-form { margin-top: 24px; }

th,
td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(220, 63, 137, 0.12);
}

th {
    color: var(--pink-700);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
    background: rgba(255, 225, 239, 0.66);
}

td {
    color: var(--ink);
    font-size: 0.92rem;
}

tbody tr {
    transition: background 0.18s ease, transform 0.18s ease;
}

tbody tr:hover {
    background: rgba(255, 244, 249, 0.85);
}

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

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(70, 35, 58, 0.34);
    backdrop-filter: blur(8px);
}

.modal-backdrop.is-visible {
    display: flex;
}

.modal-card {
    width: min(560px, 100%);
    position: relative;
    padding: 30px;
    border-radius: 28px;
    color: var(--ink);
    background: linear-gradient(145deg, #fff, #fff1f7);
    box-shadow: 0 28px 80px rgba(70, 35, 58, 0.26);
    animation: modalPop 0.28s ease both;
}

@keyframes modalPop {
    from { transform: translateY(18px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 999px;
    color: var(--pink-700);
    background: var(--pink-100);
    cursor: pointer;
    font-size: 1.5rem;
}

.modal-icon {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    margin-bottom: 14px;
    color: var(--white);
    font-size: 2rem;
    font-weight: 900;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--pink-400), var(--gold));
    animation: pulse 1.35s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

.modal-card p {
    color: var(--muted);
    line-height: 1.6;
}

.duplicate-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0 22px;
}

.detail-item {
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 225, 239, 0.64);
}

.detail-item span {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.detail-item strong {
    display: block;
    margin-top: 4px;
    word-break: break-word;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 12;
    max-width: min(360px, calc(100% - 44px));
    padding: 15px 18px;
    border-radius: 18px;
    color: var(--white);
    font-weight: 800;
    background: linear-gradient(135deg, var(--pink-400), var(--pink-700));
    box-shadow: 0 18px 42px rgba(157, 31, 97, 0.32);
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background: linear-gradient(135deg, #d62f62, #8f1f4a);
}

.ranking-list {
    display: grid;
    gap: 12px;
}

.ranking-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.58);
}

.ranking-number {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: var(--pink-700);
    font-weight: 900;
    background: var(--gold-soft);
}

.ranking-item strong {
    display: block;
}

.ranking-item span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.85rem;
}

.ranking-total {
    color: var(--pink-700);
    font-weight: 900;
}

@media (max-width: 980px) {
    .hero-panel,
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .cards-grid,
    .content-grid,
    .admin-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .content-grid .form-card,
    .content-grid .table-card {
        grid-column: 1 / -1;
    }

    .filters {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .app-shell {
        width: min(100% - 24px, 1200px);
        padding: 12px 0 32px;
    }

    .hero-panel {
        min-height: auto;
        padding: 26px 20px;
    }

    .hero-panel::after {
        right: 18px;
        top: 12px;
        font-size: 2.6rem;
    }

    h1 {
        font-size: clamp(2rem, 12vw, 3.1rem);
    }

    .hero-copy {
        font-size: 0.96rem;
        line-height: 1.55;
    }

    .admin-link,
    .ghost-button {
        width: 100%;
        text-align: center;
    }

    .gate-card,
    .form-card,
    .table-card,
    .topbar,
    .metric-card {
        border-radius: 18px;
    }

    .gate-card,
    .form-card,
    .table-card {
        padding: 20px;
    }

    .topbar {
        padding: 18px;
    }

    .cards-grid,
    .content-grid,
    .admin-grid,
    .form-row,
    .inline-field,
    .duplicate-details {
        grid-template-columns: 1fr;
    }

    .metric-card {
        min-height: 112px;
        padding: 18px;
    }

    .metric-card strong {
        font-size: 2rem;
    }

    .table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    table {
        min-width: 0;
    }

    thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    tbody {
        display: grid;
        gap: 12px;
    }

    tbody tr {
        border: 1px solid var(--line);
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.68);
        box-shadow: 0 12px 28px rgba(157, 31, 97, 0.09);
        overflow: hidden;
    }

    td {
        display: grid;
        grid-template-columns: minmax(92px, 38%) 1fr;
        gap: 10px;
        align-items: start;
        padding: 12px 14px;
        border-bottom: 1px solid rgba(220, 63, 137, 0.1);
        word-break: break-word;
    }

    td:last-child {
        border-bottom: 0;
    }

    td.row-actions {
        display: grid;
        grid-template-columns: minmax(92px, 38%) 1fr 1fr;
        white-space: normal;
    }

    td::before {
        content: attr(data-label);
        color: var(--pink-700);
        font-size: 0.72rem;
        font-weight: 900;
        text-transform: uppercase;
    }

    td.empty-state {
        display: block;
        border: 1px dashed var(--line);
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.7);
    }

    td.empty-state::before {
        content: "";
    }
}

@media (max-width: 640px) {
    .app-shell {
        width: min(100% - 20px, 1200px);
        padding-top: 10px;
    }

    .hero-panel {
        border-radius: 22px;
    }

    .cards-grid,
    .content-grid,
    .admin-grid,
    .form-row,
    .inline-field,
    .duplicate-details {
        grid-template-columns: 1fr;
    }

    .inline-field button,
    .primary-button {
        width: 100%;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions button {
        width: 100%;
    }

    .ranking-item {
        grid-template-columns: auto 1fr;
    }

    .ranking-total {
        grid-column: 2;
    }
}

@media (max-width: 420px) {
    .app-shell {
        width: min(100% - 14px, 1200px);
    }

    .hero-panel,
    .gate-card,
    .form-card,
    .table-card,
    .topbar,
    .metric-card {
        border-radius: 16px;
    }

    .hero-panel,
    .gate-card,
    .form-card,
    .table-card {
        padding: 16px;
    }

    .eyebrow {
        font-size: 0.68rem;
        letter-spacing: 0.08em;
    }

    h2 {
        font-size: 1.25rem;
    }

    input,
    select,
    .primary-button,
    .operator-form button,
    .ghost-button,
    .admin-link {
        min-height: 48px;
    }

    .sparkle {
        right: 16px;
        top: 16px;
        width: 36px;
        height: 36px;
    }

    .modal-backdrop {
        align-items: flex-end;
        padding: 10px;
    }

    .modal-card {
        max-height: calc(100vh - 20px);
        overflow-y: auto;
        padding: 22px 16px 16px;
        border-radius: 22px;
    }

    .toast {
        right: 10px;
        bottom: 10px;
        max-width: calc(100% - 20px);
    }
}
