:root {
    --bg: #eef2f7;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #172033;
    --muted: #667085;
    --line: #d9e2ef;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #0f766e;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --shadow: 0 24px 70px rgba(23, 32, 51, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 34rem),
        linear-gradient(135deg, #eef2f7 0%, #f9fbfd 45%, #e8f4f1 100%);
    color: var(--text);
}

button,
input,
textarea {
    font: inherit;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding: 34px;
    color: #fff;
    background: linear-gradient(135deg, #172033 0%, #24567a 52%, #0f766e 100%);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 8px;
    color: inherit;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.72;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: clamp(2.2rem, 4vw, 4rem);
    line-height: 1;
}

h2 {
    margin-bottom: 4px;
    font-size: 1.35rem;
}

.hero-copy {
    max-width: 560px;
    margin-bottom: 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 1.04rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 10px;
    min-width: 280px;
}

.stats div {
    padding: 18px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
}

.stats span {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
}

.stats small {
    color: rgba(255, 255, 255, 0.74);
}

.upload-panel,
.files-section {
    margin-top: 22px;
    padding: 24px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(217, 226, 239, 0.86);
    border-radius: 8px;
    box-shadow: 0 16px 38px rgba(23, 32, 51, 0.08);
    backdrop-filter: blur(12px);
}

.flash-message {
    margin-top: 18px;
    padding: 14px 16px;
    color: #047857;
    background: #dff7ef;
    border: 1px solid #bdebdc;
    border-radius: 8px;
    font-weight: 800;
}

.panel-header,
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-header p {
    margin-bottom: 0;
    color: var(--muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 7px 11px;
    color: #075e54;
    background: #dff7ef;
    border: 1px solid #bdebdc;
    border-radius: 999px;
    font-size: 0.86rem;
    font-weight: 700;
    white-space: nowrap;
}

.upload-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: stretch;
}

.file-drop {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 78px;
    padding: 18px;
    background: var(--surface-soft);
    border: 1px dashed #9fb0c8;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.file-drop:hover {
    background: #f1f6fd;
    border-color: var(--primary);
}

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

.file-drop small,
.muted {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.file-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: var(--primary);
    background: #dbeafe;
    border-radius: 8px;
    font-size: 1.65rem;
    font-weight: 500;
}

.primary-button,
.upload-result button,
.icon-button {
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.primary-button {
    min-width: 160px;
    padding: 0 22px;
    color: #fff;
    background: var(--primary);
    box-shadow: 0 12px 22px rgba(37, 99, 235, 0.24);
}

.primary-button:hover,
.upload-result button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.progress-wrap {
    display: grid;
    grid-template-columns: 1fr 48px;
    gap: 12px;
    align-items: center;
    margin-top: 16px;
}

.progress-wrap[hidden] {
    display: none;
}

progress {
    width: 100%;
    height: 14px;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
}

progress::-webkit-progress-bar {
    background: #e5eaf2;
}

progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

progress::-moz-progress-bar {
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

#progressText {
    color: var(--muted);
    font-weight: 800;
    text-align: right;
}

.upload-result {
    margin-top: 16px;
}

.upload-result:empty {
    display: none;
}

.upload-result p {
    margin-bottom: 10px;
}

.upload-result code {
    display: inline-block;
    padding: 5px 10px;
    color: #12326f;
    background: #dbeafe;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 900;
}

.upload-result form {
    display: grid;
    gap: 8px;
    max-width: 560px;
    padding: 16px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.upload-result textarea {
    width: 100%;
    min-height: 105px;
    padding: 12px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.upload-result button {
    justify-self: start;
    padding: 10px 14px;
    color: #fff;
    background: var(--primary);
}

.upload-result a {
    color: var(--primary-dark);
    font-weight: 800;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    color: var(--muted);
    background: #f4f7fb;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
}

th,
td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

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

.file-name {
    display: block;
    max-width: 280px;
    overflow-wrap: anywhere;
}

.description {
    max-width: 330px;
    color: #344054;
}

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

.pin-form {
    display: flex;
    gap: 6px;
    margin: 0;
}

.pin-form input[type="password"] {
    width: 82px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    color: #fff;
    background: var(--accent);
    font-size: 1.25rem;
    line-height: 1;
}

.icon-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(15, 118, 110, 0.18);
}

.icon-button.danger {
    background: var(--danger);
}

.icon-button.danger:hover {
    box-shadow: 0 10px 18px rgba(220, 38, 38, 0.18);
}

.empty-state {
    padding: 36px;
    color: var(--muted);
    background: var(--surface-soft);
    border: 1px dashed #aab8cc;
    border-radius: 8px;
    text-align: center;
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    margin-bottom: 0;
}

.message.error {
    color: #991b1b;
    font-weight: 800;
}

.message.success {
    color: #047857;
    font-weight: 800;
}

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

    .hero,
    .panel-header,
    .section-title,
    .upload-form {
        display: grid;
        grid-template-columns: 1fr;
    }

    .hero,
    .upload-panel,
    .files-section {
        padding: 20px;
    }

    .stats {
        min-width: 0;
        grid-template-columns: 1fr 1fr;
    }

    .primary-button {
        min-height: 48px;
    }

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

    thead {
        display: none;
    }

    tr {
        padding: 14px 0;
        border-bottom: 1px solid var(--line);
    }

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

    td {
        display: grid;
        grid-template-columns: 110px 1fr;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 800;
        text-transform: uppercase;
    }

    .actions {
        align-items: flex-start;
    }
}

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

    td {
        grid-template-columns: 1fr;
    }

    .pin-form {
        width: 100%;
    }

    .pin-form input[type="password"] {
        flex: 1;
    }
}
