/* ---------------------------------------------------------------------
   Admin backend design system — tokens + components.
   Scoped to .admin-shell / .auth-shell so the guest-facing page (/g/{token}),
   which still runs on Pico's own theme, is completely unaffected. Custom
   property names below (--primary-*, --neutral-*, --surface-*, --fg-*, ...)
   are deliberately namespaced away from Pico's --pico-* variables.
   --------------------------------------------------------------------- */

@import url("https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,600&display=swap");

/* Pico used to reset the UA default body margin/box-sizing; now that it's
   gone, restore that baseline globally so no page gets a stray margin. */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

:root {
    --primary-50: hsl(206 100% 96%);
    --primary-100: hsl(206 100% 92%);
    --primary-200: hsl(206 100% 84%);
    --primary-300: hsl(206 100% 74%);
    --primary-400: hsl(206 100% 64%);
    --primary-500: hsl(206 100% 50%);
    --primary-600: hsl(206 100% 44%);
    --primary-700: hsl(206 100% 38%);
    --primary-800: hsl(206 90% 32%);
    --primary-900: hsl(206 85% 26%);
    --primary-950: hsl(206 80% 16%);
    --neutral-0: #ffffff;
    --neutral-50: hsl(210 20% 98%);
    --neutral-100: hsl(210 16% 96%);
    --neutral-200: hsl(210 14% 91%);
    --neutral-300: hsl(210 12% 83%);
    --neutral-400: hsl(210 10% 65%);
    --neutral-500: hsl(210 10% 50%);
    --neutral-600: hsl(210 12% 38%);
    --neutral-700: hsl(210 14% 28%);
    --neutral-800: hsl(210 16% 18%);
    --neutral-900: hsl(210 20% 11%);
    --neutral-950: hsl(210 24% 7%);
    --success-50: hsl(152 60% 94%);
    --success-500: hsl(152 60% 40%);
    --success-600: hsl(152 62% 34%);
    --warning-50: hsl(38 95% 94%);
    --warning-500: hsl(38 95% 50%);
    --warning-600: hsl(32 90% 44%);
    --error-50: hsl(4 80% 95%);
    --error-500: hsl(4 80% 58%);
    --error-600: hsl(4 75% 50%);
    --fg-primary: var(--neutral-900);
    --fg-secondary: var(--neutral-600);
    --fg-tertiary: var(--neutral-400);
    --surface-page: #ffffff;
    --surface-subtle: var(--neutral-50);
    --surface-card: #ffffff;
    --border-subtle: var(--neutral-200);
    --border-default: var(--neutral-300);
    --border-strong: var(--neutral-400);
    --focus-ring: var(--primary-400);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 999px;

    --shadow-sm: 0 1px 2px hsl(210 30% 20% / 0.06);
    --shadow-md: 0 4px 12px hsl(210 30% 20% / 0.08), 0 1px 2px hsl(210 30% 20% / 0.04);
    --shadow-lg: 0 12px 32px hsl(210 30% 20% / 0.12), 0 2px 6px hsl(210 30% 20% / 0.06);
    --shadow-brand: 0 8px 24px hsl(206 100% 50% / 0.28);
    --shadow-focus: 0 0 0 4px hsl(206 100% 64% / 0.35);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-md: 18px;
    --text-lg: 20px;
    --text-xl: 24px;
    --text-2xl: 30px;
    --text-3xl: 36px;
    --leading-normal: 1.5;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --tracking-tight: -0.02em;
}

/* ---------------------------------------------------------------------
   Shell layout
   --------------------------------------------------------------------- */

.admin-shell {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    background: var(--surface-subtle);
    color: var(--fg-primary);
}

.admin-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--neutral-900);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    gap: 4px;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px 20px;
}

.admin-brand-icon {
    height: 28px;
    width: 28px;
    border-radius: 8px;
    object-fit: cover;
}

.admin-brand-name {
    font-weight: 800;
    font-size: var(--text-md);
    color: #fff;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    width: 100%;
    background: transparent;
    color: #fff;
    text-decoration: none;
    box-sizing: border-box;
}

.admin-nav-item:hover {
    background: var(--neutral-800);
}

.admin-nav-item.is-active,
.admin-nav-item.is-active:hover {
    background: var(--primary-500);
}

.admin-nav-item-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.admin-nav-item-disabled:hover {
    background: transparent;
}

.admin-sidebar-spacer {
    flex: 1;
}

.admin-sidebar-footer {
    padding: 0 8px;
}

.admin-logout-form {
    margin: 0;
}

.admin-logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    padding: 10px 4px;
    cursor: pointer;
    text-align: left;
}

.admin-logout-btn:hover {
    color: #fff;
}

.admin-main {
    flex: 1;
    padding: 32px 40px;
    overflow: auto;
}

/* ---------------------------------------------------------------------
   Auth (login) shell
   --------------------------------------------------------------------- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-subtle);
    font-family: var(--font-sans);
    padding: 24px;
    box-sizing: border-box;
}

.auth-card {
    width: 360px;
    max-width: 100%;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}

.auth-brand .admin-brand-name {
    color: var(--fg-primary);
}

.auth-title {
    font-size: var(--text-xl);
    font-weight: 800;
    text-align: center;
    margin: 0 0 20px;
    color: var(--fg-primary);
}

.auth-shell .flash {
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: var(--text-sm);
    margin-bottom: 16px;
}

.auth-shell .flash-success {
    background: var(--success-50);
    color: var(--success-600);
}

.auth-shell .flash-error {
    background: var(--error-50);
    color: var(--error-600);
}

/* ---------------------------------------------------------------------
   Page header
   --------------------------------------------------------------------- */

.admin-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.admin-page-title {
    font-size: var(--text-2xl);
    font-weight: 800;
    letter-spacing: var(--tracking-tight);
    color: var(--fg-primary);
    margin: 0;
}

.admin-page-subtitle {
    color: var(--fg-secondary);
    font-size: var(--text-sm);
    margin-top: 4px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: none;
    color: var(--fg-secondary);
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    cursor: pointer;
    text-decoration: none;
    padding: 0;
    margin-bottom: 16px;
}

.back-link:hover {
    color: var(--fg-primary);
}

.event-detail-meta {
    display: flex;
    gap: 16px;
    margin-top: 6px;
    color: var(--fg-secondary);
    font-size: var(--text-sm);
    flex-wrap: wrap;
}

.event-detail-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ---------------------------------------------------------------------
   Card
   --------------------------------------------------------------------- */

.card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-6);
    box-sizing: border-box;
}

.card-flush {
    padding: 0;
    overflow: hidden;
}

.card-heading {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--fg-primary);
    margin: 0 0 8px;
}

.about-text {
    color: var(--fg-secondary);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    margin: 0;
}

/* ---------------------------------------------------------------------
   Event grid + cards
   --------------------------------------------------------------------- */

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

.event-card {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: box-shadow 150ms ease-out, transform 100ms ease-out;
}

.event-card:hover {
    box-shadow: var(--shadow-md);
}

.event-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 8px;
}

.event-card-name {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--fg-primary);
}

.event-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--fg-secondary);
    font-size: var(--text-sm);
    margin-bottom: 4px;
}

.event-card-meta .icon {
    flex-shrink: 0;
}

.event-card-stats {
    display: flex;
    gap: 20px;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

.event-card-stat-label {
    font-size: var(--text-xs);
    color: var(--fg-tertiary);
}

.event-card-stat-value {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--fg-primary);
}

.admin-empty {
    padding: 60px 0;
    text-align: center;
    color: var(--fg-tertiary);
    font-size: var(--text-sm);
}

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 20px;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    background: var(--primary-500);
    color: #fff;
    box-sizing: border-box;
    transition: background 150ms ease-out, transform 100ms ease-out, box-shadow 150ms ease-out;
}

.btn:hover {
    background: var(--primary-600);
    box-shadow: var(--shadow-brand);
    color: #fff;
}

.btn:active {
    background: var(--primary-700);
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--neutral-0);
    color: var(--fg-primary);
    border-color: var(--border-default);
}

.btn-secondary:hover {
    background: var(--surface-subtle);
    box-shadow: none;
    color: var(--fg-primary);
}

.btn-secondary:active {
    background: var(--neutral-200);
}

.btn-destructive {
    background: var(--error-500);
    color: #fff;
}

.btn-destructive:hover {
    background: var(--error-600);
    box-shadow: none;
    color: #fff;
}

.btn-sm {
    height: 32px;
    padding: 0 14px;
}

.btn:disabled {
    background: var(--neutral-200);
    color: var(--fg-tertiary);
    cursor: not-allowed;
    box-shadow: none;
}

.icon-btn, button.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--fg-primary);
    cursor: pointer;
    transition: background 150ms ease-out, transform 100ms ease-out;
    padding: 0;
}

.icon-btn:hover {
    background: var(--surface-subtle);
}

.icon-btn:active {
    transform: scale(0.94);
    background: var(--neutral-200);
}

.icon-btn-sm {
    width: 36px;
    height: 36px;
}

.inline-form {
    margin: 0;
    display: contents;
}

/* ---------------------------------------------------------------------
   Badge / Tag
   --------------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
}

.badge-neutral {
    background: var(--neutral-100);
    color: var(--fg-primary);
}

.badge-primary {
    background: var(--primary-50);
    color: var(--primary-700);
}

.badge-success {
    background: var(--success-50);
    color: var(--success-600);
}

.badge-warning {
    background: var(--warning-50);
    color: var(--warning-600);
}

.badge-error {
    background: var(--error-50);
    color: var(--error-600);
}

.tag {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 12px;
    border-radius: var(--radius-full);
    background: var(--surface-subtle);
    border: 1px solid var(--border-subtle);
    color: var(--fg-primary);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
}

.tag-muted {
    color: var(--fg-tertiary);
    border-style: dashed;
}

/* ---------------------------------------------------------------------
   Tabs
   --------------------------------------------------------------------- */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-subtle);
    margin: 20px 0;
}

button.tab-btn {
    padding: 10px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--fg-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 120ms ease-out, border-color 120ms ease-out;
}

.tab-btn:hover {
    color: var(--fg-primary);
}

.tab-btn.is-active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-500);
}

/* ---------------------------------------------------------------------
   Stats
   --------------------------------------------------------------------- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card .stat-label {
    color: var(--fg-secondary);
    font-size: var(--text-sm);
}

.stat-card .stat-value {
    font-size: var(--text-3xl);
    font-weight: 800;
    color: var(--fg-primary);
    margin-top: 4px;
}

@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ---------------------------------------------------------------------
   Data tables (guests / goods)
   --------------------------------------------------------------------- */

.panel-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 12px;
}

.data-table-head,
.data-row {
    display: grid;
    align-items: center;
}

.data-table-head {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    color: var(--fg-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-row {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.data-row:last-child {
    border-bottom: none;
}

.data-row-name {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--fg-primary);
}

.data-row-sub {
    font-size: var(--text-xs);
    color: var(--fg-tertiary);
    margin-top: 2px;
}

.data-row-sub-cell {
    font-size: var(--text-sm);
    color: var(--fg-secondary);
}

.data-row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
}

.guests-table .data-table-head,
.guests-table .data-row {
    grid-template-columns: 1.4fr 1fr 1fr 92px;
}

.goods-table .data-table-head,
.goods-table .data-row {
    grid-template-columns: 1.6fr 0.6fr 1fr 60px;
}

.table-empty {
    padding: 20px;
    color: var(--fg-tertiary);
    font-size: var(--text-sm);
}

.invite-links-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow: auto;
}

.invite-link-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface-subtle);
    border-radius: var(--radius-md);
}

.invite-link-info {
    min-width: 0;
}

.invite-link-info .data-row-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: var(--font-sans);
    width: 100%;
    margin-bottom: 14px;
}

.field:last-child {
    margin-bottom: 0;
}

.field label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--fg-primary);
}

.input,
.select,
textarea.input {
    height: 44px;
    padding: 0 14px;
    background: #fff;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    color: var(--fg-primary);
    font-family: var(--font-sans);
    width: 100%;
    box-sizing: border-box;
    transition: box-shadow 150ms ease-out, border-color 150ms ease-out;
}

.input:focus,
.select:focus,
textarea.input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: var(--shadow-focus);
}

textarea.input {
    height: auto;
    min-height: 88px;
    padding: 10px 14px;
    resize: vertical;
}

.select {
    appearance: none;
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M1 3l4 4 4-4' stroke='%236b7785' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ---------------------------------------------------------------------
   Dialog / modal (native <dialog>)
   --------------------------------------------------------------------- */

dialog.modal {
    border: none;
    padding: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 420px;
    max-width: 90vw;
    font-family: var(--font-sans);
    color: var(--fg-primary);
}

dialog.modal::backdrop {
    background: rgba(15, 23, 32, 0.4);
}

.modal-inner {
    padding: var(--space-8);
    box-sizing: border-box;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-title {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    color: var(--fg-primary);
}

.modal-close {
    border: none;
    background: var(--surface-subtle);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--fg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-close:hover {
    background: var(--neutral-200);
}

.modal-body {
    color: var(--fg-secondary);
    font-size: var(--text-sm);
}

.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ---------------------------------------------------------------------
   Toast (server-rendered flash inside the admin shell, and JS-created
   copy-to-clipboard confirmations)
   --------------------------------------------------------------------- */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--neutral-900);
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    max-width: 360px;
    animation: toast-in 200ms ease-out;
}

.toast-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-500);
    flex-shrink: 0;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.admin-main > .flash {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--neutral-900);
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    max-width: 360px;
    margin: 0;
    animation: toast-in 200ms ease-out;
}

.admin-main > .flash::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-500);
    flex-shrink: 0;
}

.admin-main > .flash.flash-error::before {
    background: var(--error-500);
}
