:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #131825;
    --bg-tertiary: #1a1f33;
    --accent-primary: #6366f1;
    --accent-secondary: #a855f7;
    --accent-success: #10b981;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-radius: 14px;
    --border-radius-lg: 22px;
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 24px rgba(99, 102, 241, 0.25);
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font-family);
    background:
        radial-gradient(circle at top right, rgba(99, 102, 241, 0.14), transparent 28%),
        radial-gradient(circle at bottom left, rgba(168, 85, 247, 0.08), transparent 24%),
        var(--bg-primary);
    color: var(--text-primary);
}

body.login-page {
    background:
        radial-gradient(circle at top center, rgba(109, 99, 242, 0.12), transparent 30%),
        linear-gradient(180deg, #0b1020 0%, #0a0e1a 100%);
}

.app-shell {
    width: min(100%, 760px);
    margin: 0 auto;
    min-height: 100vh;
    padding: 24px 16px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
}

.logout-form {
    display: flex;
    justify-content: flex-end;
}

.logout-button {
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 999px;
    width: 46px;
    height: 46px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.logout-button:hover {
    transform: translateY(-1px);
    color: var(--text-primary);
    border-color: rgba(99, 102, 241, 0.45);
}

.logout-icon {
    width: 22px;
    height: 22px;
}

.app-shell.panel-open {
    justify-content: flex-start;
    padding-top: 40px;
}

.login-shell {
    width: min(100%, 920px);
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.login-card {
    width: 100%;
    max-width: 830px;
    background:
        radial-gradient(circle at top center, rgba(255, 255, 255, 0.03), transparent 28%),
        linear-gradient(180deg, rgba(28, 33, 52, 0.98), rgba(33, 37, 58, 0.99));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 32px;
    padding: 64px 44px 42px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.login-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(99, 102, 241, 0.03));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.login-brand {
    display: grid;
    justify-items: center;
    text-align: center;
    margin-bottom: 36px;
}

.login-logo {
    width: 124px;
    height: auto;
    margin-bottom: 26px;
    filter: drop-shadow(0 0 20px rgba(255, 212, 79, 0.18));
}

.login-title {
    margin: 0 0 18px;
    font-size: clamp(3rem, 8vw, 4.5rem);
    line-height: 0.95;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 700;
    background: linear-gradient(135deg, #6d63f2 0%, #9a52ea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-copy {
    margin: 0;
    color: #8f9ab5;
    font-size: clamp(1.05rem, 3vw, 1.45rem);
    font-weight: 500;
}

.login-card .alert {
    margin-bottom: 18px;
}

.alert {
    border-radius: var(--border-radius);
    padding: 14px 16px;
    border: 1px solid transparent;
    box-shadow: var(--shadow-md);
}

.alert-success {
    background: rgba(255, 255, 255, 0.03);
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, 0.06);
}

.alert-error {
    background: rgba(239, 68, 68, 0.14);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.25);
}

.home-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.home-actions-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-button,
.submit-button {
    width: 100%;
    min-height: 76px;
    border: none;
    border-radius: var(--border-radius-lg);
    font: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.home-button:hover,
.submit-button:hover,
.camera-button:hover {
    transform: translateY(-2px);
}

.home-button-primary,
.home-button-active,
.submit-button {
    color: #fff;
    background: var(--gradient-primary);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.home-button-secondary {
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.home-button.home-button-active {
    color: #fff;
    background: var(--gradient-primary);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: transparent;
}

.panel-wrap {
    display: grid;
    gap: 18px;
}

.panel-card {
    background: rgba(19, 24, 37, 0.96);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 20px;
    box-shadow: var(--shadow-lg);
}

.viewer-empty {
    margin-top: 18px;
    padding: 26px 18px;
    border-radius: 20px;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    text-align: center;
}

.ticket-groups {
    display: grid;
    gap: 24px;
    margin-top: 22px;
}

.ticket-group {
    display: grid;
    gap: 14px;
}

.ticket-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ticket-group-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.ticket-group-count {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.ticket-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

.ticket-card {
    display: grid;
    gap: 10px;
    padding: 10px;
    border-radius: 18px;
    background: rgba(26, 31, 51, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.ticket-photo-button {
    position: relative;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

.ticket-photo-thumb,
.ticket-photo-missing {
    width: 100%;
    aspect-ratio: 0.82 / 1;
    border-radius: 14px;
}

.ticket-photo-thumb {
    display: block;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #060b17;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.ticket-photo-button:hover .ticket-photo-thumb {
    transform: translateY(-1px);
    border-color: rgba(99, 102, 241, 0.45);
}

.ticket-photo-count {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 14, 26, 0.88);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.ticket-photo-missing {
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    background: rgba(6, 11, 23, 0.9);
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

.ticket-meta {
    display: grid;
    gap: 8px;
}

.ticket-meta-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.ticket-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.16);
    color: #dbe3ff;
    font-size: 0.8rem;
    font-weight: 700;
}

.ticket-badge-amount {
    background: rgba(16, 185, 129, 0.16);
    color: #bbf7d0;
}

.ticket-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
}

.ticket-date {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.ticket-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.ticket-delete-form {
    margin: 0;
}

.ticket-action-button {
    width: 100%;
    min-height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(19, 24, 37, 0.96);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.ticket-action-danger {
    border-color: rgba(239, 68, 68, 0.24);
    color: #fda4af;
}

.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
}

.image-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 8, 18, 0.88);
    backdrop-filter: blur(8px);
}

.image-viewer-dialog {
    position: relative;
    z-index: 1;
    width: min(100vw - 24px, 920px);
    max-height: calc(100vh - 24px);
    padding: 0;
}

.image-viewer-photo {
    display: block;
    width: 100%;
    max-height: calc(100vh - 24px);
    object-fit: contain;
    border-radius: 24px;
    background: #050914;
    box-shadow: var(--shadow-lg);
}

.image-viewer-close {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2;
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 999px;
    background: rgba(19, 24, 37, 0.92);
    color: #fff;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}

body.modal-open {
    overflow: hidden;
}

.edit-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: grid;
    align-items: start;
    justify-items: center;
    padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.edit-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 8, 18, 0.82);
    backdrop-filter: blur(8px);
}

.edit-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 520px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: auto 0;
    padding: 20px;
    border-radius: 24px;
    background: rgba(19, 24, 37, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-lg);
}

.edit-photo-block {
    display: grid;
    gap: 12px;
}

.edit-photo-frame {
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 22px;
    background: rgba(10, 14, 26, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.edit-photo-preview {
    width: 100%;
    height: min(30dvh, 260px);
    object-fit: contain;
    border-radius: 18px;
    background: #050914;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-md);
}

.edit-photo-caption {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

.edit-photo-label {
    display: grid;
    grid-template-columns: 48px 1fr;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    padding: 12px 14px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(168, 85, 247, 0.14));
    border: 1px solid rgba(99, 102, 241, 0.34);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.edit-photo-label:hover {
    transform: translateY(-1px);
    border-color: rgba(129, 140, 248, 0.55);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.edit-photo-label-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: rgba(8, 12, 24, 0.58);
    color: #fff;
    font-size: 1.6rem;
    font-weight: 700;
}

.edit-photo-label-copy {
    display: grid;
    gap: 2px;
}

.edit-photo-label-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
}

.edit-photo-label-sub {
    color: #d6dbff;
    font-size: 0.88rem;
    line-height: 1.35;
}

.edit-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.form-stack {
    display: grid;
    gap: 16px;
}

.login-form {
    width: 100%;
    max-width: 610px;
    margin: 0 auto;
}

.camera-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.camera-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 180px;
    padding: 24px;
    border-radius: 24px;
    border: 2px dashed rgba(99, 102, 241, 0.45);
    background:
        linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(168, 85, 247, 0.12)),
        var(--bg-tertiary);
    color: var(--text-primary);
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.camera-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.camera-preview {
    width: 100%;
    height: 100%;
    min-height: 180px;
    object-fit: cover;
    border-radius: 16px;
}

.camera-button-main {
    font-size: 1.45rem;
    font-weight: 700;
}

.camera-button-sub {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.selected-file {
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.95rem;
}

.optional-fields {
    display: grid;
    gap: 14px;
    padding-top: 4px;
}

.form-group {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.form-label {
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 600;
}

.login-form .form-label {
    color: #d9e0ef;
    font-size: 1rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: block;
    padding: 0.9rem 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}

.login-input {
    min-height: 78px;
    border-radius: 18px;
    background: #060b17;
    border: 1px solid rgba(99, 102, 241, 0.18);
    padding: 0 28px;
    font-size: 1.1rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.login-input:focus {
    border-color: #645cf0;
    box-shadow: 0 0 0 4px rgba(100, 92, 240, 0.16);
}

.remember-row {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.45;
    cursor: pointer;
    margin-top: 6px;
}

.remember-checkbox {
    width: 24px;
    height: 24px;
    accent-color: #7a5bf2;
    cursor: pointer;
    flex: 0 0 auto;
    margin-top: 2px;
}

.login-submit {
    margin-top: 12px;
    min-height: 80px;
    font-size: 1.2rem;
    border-radius: 20px;
}

textarea.form-control {
    resize: vertical;
}

input[type="date"].form-control {
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border: 2px solid var(--accent-primary);
}

.range-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    min-width: 0;
}

.is-hidden {
    display: none;
}

@media (max-width: 640px) {
    .app-shell {
        padding-top: 18px;
        padding-bottom: 24px;
    }

    .login-card {
        padding: 36px 18px 24px;
        border-radius: 24px;
    }

    .login-logo {
        width: 98px;
        margin-bottom: 20px;
    }

    .login-title {
        font-size: 3.1rem;
    }

    .login-copy {
        font-size: 1rem;
    }

    .login-form {
        max-width: none;
    }

    .app-shell.panel-open {
        padding-top: 22px;
    }

    .panel-card {
        padding: 16px;
        border-radius: 20px;
    }

    .home-button,
    .submit-button {
        min-height: 68px;
        font-size: 0.98rem;
        padding: 10px 8px;
    }

    .login-input {
        min-height: 72px;
        padding: 0 20px;
    }

    .login-submit {
        min-height: 72px;
    }

    .camera-button {
        min-height: 160px;
    }

    .camera-preview {
        min-height: 160px;
    }

    .range-fields {
        grid-template-columns: 1fr;
    }

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

    .ticket-group-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .image-viewer-dialog {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
    }

    .image-viewer-photo {
        max-height: calc(100vh - 16px);
        border-radius: 18px;
    }

    .edit-modal {
        padding: max(10px, env(safe-area-inset-top, 0px)) 10px max(10px, env(safe-area-inset-bottom, 0px));
    }

    .edit-modal-dialog {
        width: 100%;
        max-height: calc(100dvh - 20px);
        padding: 16px;
        border-radius: 20px;
    }

    .edit-photo-frame {
        padding: 10px;
        gap: 8px;
    }

    .edit-photo-preview {
        height: min(24dvh, 180px);
        border-radius: 14px;
    }

    .edit-photo-label {
        min-height: 64px;
        grid-template-columns: 42px 1fr;
        gap: 10px;
        padding: 10px 12px;
    }

    .edit-photo-label-icon {
        width: 42px;
        height: 42px;
        border-radius: 14px;
        font-size: 1.35rem;
    }
}
