:root {
    --app-bg: #eac6c6;
    --app-surface: #ffffff;
    --app-surface-soft: #f9edec;
    --app-surface-alt: #fff7f7;
    --app-border: #e3b8b7;
    --app-ink: #1f1716;
    --app-muted: #6a514f;
    --app-primary: #be3a34;
    --app-primary-dark: #9f2f2b;
    --app-primary-soft: #f4d6d5;
    --app-success: #2f6f4f;
    --app-success-soft: #e7f4ed;
    --app-danger: #9f2f2b;
    --app-danger-soft: #fdeeee;
    --app-shadow: 0 24px 48px rgba(63, 20, 18, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--app-ink);
    font-family: Inter, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

a {
    color: var(--app-primary);
}

img {
    max-width: 100%;
}

.app-page {
    background:
        radial-gradient(circle at 12% 8%, rgba(190, 58, 52, 0.16), transparent 40%),
        radial-gradient(circle at 88% 2%, rgba(234, 198, 198, 0.66), transparent 45%),
        var(--app-bg);
}

.shell {
    max-width: 1460px;
    margin: 0 auto;
    padding: 28px 20px 56px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
    padding: 16px 18px;
    border: 1px solid var(--app-border);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--app-shadow);
    backdrop-filter: blur(10px);
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    color: inherit;
    text-decoration: none;
}

.brand-logo {
    width: 172px;
    max-width: 42vw;
    height: auto;
    display: block;
}

.brand-copy {
    display: grid;
    gap: 3px;
}

.brand-title {
    font-size: clamp(1.05rem, 1.5vw, 1.3rem);
    font-weight: 800;
    color: #351211;
}

.brand-subtitle {
    font-size: 0.9rem;
    color: var(--app-muted);
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

h1,
h2,
h3 {
    margin: 0 0 12px;
}

h1 {
    font-size: clamp(1.8rem, 2.6vw, 2.5rem);
}

h2 {
    font-size: clamp(1.2rem, 1.7vw, 1.55rem);
}

h3 {
    font-size: 1rem;
}

p {
    margin: 0 0 14px;
    line-height: 1.55;
}

.stack {
    display: grid;
    gap: 20px;
}

.grid {
    display: grid;
    gap: 20px;
}

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

.panel {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--app-border);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--app-shadow);
}

.panel.success {
    background: linear-gradient(180deg, var(--app-success-soft), #ffffff 85%);
}

.panel.danger {
    background: linear-gradient(180deg, var(--app-danger-soft), #ffffff 85%);
}

.field {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.field span,
.form-label {
    font-weight: 700;
}

input[type="file"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    padding: 12px 14px;
    background: #fff;
    color: var(--app-ink);
    font: inherit;
}

textarea {
    min-height: 220px;
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    background: linear-gradient(180deg, var(--app-primary) 0%, var(--app-primary-dark) 100%);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    box-shadow: 0 14px 28px rgba(190, 58, 52, 0.2);
}

.button:hover,
.button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 18px 30px rgba(190, 58, 52, 0.24);
}

.button:disabled {
    opacity: 0.72;
    cursor: default;
    transform: none;
}

.button.ghost {
    background: transparent;
    color: var(--app-primary);
    border: 1px solid var(--app-primary);
    box-shadow: none;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.hint {
    color: var(--app-muted);
    font-size: 0.92rem;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--app-primary-soft);
    color: var(--app-primary-dark);
    font-size: 0.88rem;
    font-weight: 700;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--app-border);
    border-radius: 16px;
    background: #fff;
}

.table-wrap.wide table {
    min-width: 1600px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid #f0d9d7;
    text-align: left;
    vertical-align: top;
    font-size: 0.9rem;
}

th {
    position: sticky;
    top: 0;
    background: #fdf4f3;
    z-index: 1;
}

.flat-list {
    margin: 0;
    padding-left: 18px;
}

.flat-list li {
    margin-bottom: 8px;
}

.mono {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.82rem;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.meta-grid > div {
    padding: 14px 16px;
    border: 1px solid var(--app-border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.86);
}

.app-home {
    min-height: 100vh;
}

.app-home-single {
    display: grid;
    gap: 24px;
    padding: 24px 20px 48px;
}

.app-home-stage {
    position: relative;
    overflow: hidden;
    height: clamp(180px, 22vw, 240px);
    border-radius: 32px;
    box-shadow: var(--app-shadow);
}

.app-home-stage-image {
    width: 100%;
    height: clamp(180px, 22vw, 240px);
    object-fit: cover;
    display: block;
}

.app-home-stage-overlay {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(23, 21, 20, 0.08), rgba(23, 21, 20, 0.18)),
        linear-gradient(90deg, rgba(255, 255, 255, 0.2), transparent 45%);
}

.app-home-stage-brand {
    position: absolute;
    top: clamp(16px, 2.2vw, 24px);
    right: clamp(16px, 2.6vw, 28px);
    z-index: 2;
    padding: 12px 14px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(8px);
}

.app-home-stage-logo {
    display: block;
    width: clamp(210px, 23vw, 320px);
    height: auto;
}

.app-home-stage-inner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: clamp(18px, 4vw, 34px);
}

.app-home-hero {
    z-index: 1;
    width: min(620px, 100%);
    padding: 24px 26px 22px;
    border-radius: 32px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.78);
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(10px);
}

.app-home-content {
    display: flex;
    justify-content: center;
}

.app-home-panel {
    width: min(920px, 100%);
    padding: clamp(20px, 3vw, 30px);
    border: 1px solid var(--app-border);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--app-shadow);
}

.app-home-panel-header {
    max-width: 720px;
    margin-bottom: 20px;
}

.app-home-source-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.app-home-source-card {
    padding: 20px;
    border: 1px solid #efd4d2;
    border-radius: 24px;
    background: linear-gradient(180deg, #fffaf9 0%, #ffffff 100%);
}

.app-home-section {
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid #efd4d2;
}

.app-home-section:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.app-home-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.app-home-kicker {
    margin: 0 0 10px;
    color: var(--app-primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.76rem;
    font-weight: 800;
}

.app-home-hero-title {
    margin-bottom: 10px;
    color: #0f2345;
    font-size: clamp(1.4rem, 2.2vw, 2.1rem);
    line-height: 1.1;
}

.app-home-hero-copy {
    margin: 0;
    color: #374151;
    font-size: 1rem;
}

.app-home-title {
    color: #351211;
}

.app-home-alert {
    padding: 16px 18px;
    border: 1px solid #efb7b5;
    background: #fff6f6;
}

.app-upload-form {
    gap: 1.25rem;
}

.upload-dropzone {
    display: grid;
    gap: 8px;
    justify-items: start;
    padding: 20px;
    border: 2px dashed #d8b6b4;
    border-radius: 18px;
    background: linear-gradient(180deg, #fff6f5 0%, #ffffff 100%);
    color: inherit;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.upload-dropzone:hover,
.upload-dropzone:focus-within {
    border-color: var(--app-primary);
    transform: translateY(-1px);
    box-shadow: 0 18px 32px rgba(190, 58, 52, 0.12);
}

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

.upload-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--app-primary-soft);
    color: var(--app-primary-dark);
    font-size: 1.6rem;
    line-height: 1;
    font-weight: 600;
}

.upload-title {
    font-size: 1rem;
    font-weight: 800;
    color: #351211;
}

.upload-subtitle {
    color: var(--app-muted);
    font-size: 0.94rem;
}

.app-home-actions {
    display: flex;
    justify-content: flex-start;
    padding-top: 4px;
}

.app-home-submit {
    min-width: 220px;
}

.app-home-db-entry {
    background: linear-gradient(180deg, #fff8f8 0%, #ffffff 100%);
    border-radius: 22px;
    padding-inline: 20px;
    padding-bottom: 20px;
}

.app-home-db-button {
    min-width: 220px;
}

@media (max-width: 1100px) {
    .brand-logo {
        width: 150px;
    }
}

@media (max-width: 900px) {
    .grid.two {
        grid-template-columns: 1fr;
    }

    .app-home-source-grid {
        grid-template-columns: 1fr;
    }

    .shell {
        padding-inline: 16px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
    }

    .app-home-single {
        padding-inline: 16px;
        padding-top: 16px;
        padding-bottom: 28px;
    }

    .app-home-stage {
        height: 210px;
        border-radius: 24px;
    }

    .app-home-stage-image {
        height: 210px;
    }

    .app-home-stage-brand {
        top: 14px;
        right: 14px;
        padding: 10px 12px;
    }

    .app-home-stage-logo {
        width: clamp(170px, 34vw, 250px);
    }

    .app-home-hero {
        width: 100%;
        max-width: 540px;
        padding: 20px 18px;
    }
}

@media (max-width: 560px) {
    .shell {
        padding-top: 16px;
        padding-bottom: 32px;
    }

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

    .brand-link {
        align-items: flex-start;
    }

    .brand-logo {
        width: 132px;
    }

    .brand-subtitle {
        font-size: 0.82rem;
    }

    .app-home-stage {
        height: 180px;
    }

    .app-home-stage-image {
        height: 180px;
    }

    .app-home-stage-brand {
        position: static;
        margin: 14px 14px 0 auto;
        width: fit-content;
    }

    .app-home-stage-inner {
        position: static;
        padding: 14px;
        margin-top: -6px;
    }

    .app-home-section-head {
        display: block;
    }

    .app-home-submit,
    .button {
        width: 100%;
    }

    .topbar-actions {
        width: 100%;
    }
}
