:root {
    color-scheme: light;
    --ink: #22252a;
    --muted: #6d6e71;
    --line: #e3d8e8;
    --panel: #ffffff;
    --soft: #faf7fb;
    --purple: #711484;
    --purple-soft: #a450af;
    --green: #339933;
    --green-dark: #40803c;
    --gray: #6d6e71;
    --danger: #b42318;
    --success: #339933;
    --shadow: 0 26px 70px rgba(113, 20, 132, .13);
    --glow: 0 18px 45px rgba(164, 80, 175, .16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Cairo", Tahoma, Arial, sans-serif;
    background:
        linear-gradient(135deg, rgba(113, 20, 132, .075) 0%, rgba(164, 80, 175, .045) 34%, rgba(51, 153, 51, .065) 100%),
        linear-gradient(180deg, #ffffff 0%, #fbf8fc 42%, #f4faf4 100%);
    color: var(--ink);
}

a {
    color: inherit;
    text-decoration: none;
}

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

.auth-layout {
    min-height: calc(100vh - 88px);
    display: grid;
    place-items: center;
}

.auth-panel,
.upload-zone,
.table-shell {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(255, 255, 255, .93)),
        linear-gradient(135deg, rgba(164, 80, 175, .13), rgba(51, 153, 51, .1));
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: 8px;
}

.auth-panel {
    position: relative;
    width: min(520px, 100%);
    padding: 42px;
    overflow: hidden;
}

.auth-panel::before,
.upload-zone::before,
.table-shell::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: linear-gradient(90deg, var(--purple), var(--purple-soft), var(--green));
}

.upload-zone {
    position: relative;
    overflow: hidden;
}

.table-shell {
    position: relative;
}

.brand-logo {
    display: block;
    width: auto;
    object-fit: contain;
}

.auth-logo {
    max-width: 214px;
    height: auto;
    margin-bottom: 14px;
    filter: drop-shadow(0 12px 24px rgba(113, 20, 132, .12));
}

.header-brand {
    display: inline-flex;
    align-items: center;
    min-height: 56px;
    padding: 8px 12px;
    border: 1px solid rgba(164, 80, 175, .18);
    border-radius: 8px;
    background: rgba(255, 255, 255, .72);
    box-shadow: var(--glow);
}

.header-logo {
    max-width: 170px;
    max-height: 56px;
}

.eyebrow {
    margin: 18px 0 8px;
    color: var(--purple);
    font-weight: 700;
    font-size: 13px;
}

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

h1 {
    margin-bottom: 12px;
    /*font-size: clamp(30px, 5vw, 54px);*/
    line-height: 1.15;
    color: var(--purple);
}

h2 {
    margin-bottom: 10px;
    font-size: 28px;
    color: #303339;
}

h3 {
    margin: 10px 0 8px;
    font-size: 20px;
}

.lead {
    color: var(--muted);
    font-size: 17px;
    line-height: 1.8;
}

.form-card,
.upload-form {
    display: grid;
    gap: 16px;
}

label {
    font-weight: 700;
}

input[type="password"],
input[type="text"] {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 14px;
    font: inherit;
    color: var(--ink);
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(113, 20, 132, .035);
}

input[type="password"]:focus,
input[type="text"]:focus {
    border-color: rgba(164, 80, 175, .65);
    outline: 3px solid rgba(164, 80, 175, .13);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.table-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border-radius: 6px;
    border: 1px solid transparent;
    padding: 0 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled,
.danger-button:disabled,
.table-button:disabled {
    cursor: wait;
    opacity: .76;
}

.primary-button {
    color: #fff;
    background: linear-gradient(135deg, var(--purple), var(--purple-soft));
    box-shadow: 0 12px 26px rgba(113, 20, 132, .22);
}

.primary-button:hover {
    background: linear-gradient(135deg, #5f106f, #9443a0);
}

.secondary-button {
    color: var(--purple);
    border-color: rgba(164, 80, 175, .22);
    background: #fff;
}

.ghost-button {
    color: var(--muted);
    background: transparent;
    border-color: var(--line);
}

.danger-button {
    color: #fff;
    background: var(--danger);
}

.table-button {
    color: var(--purple);
    background: #fbf7fc;
    border-color: var(--line);
}

.wide {
    width: 100%;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 28px;
    padding-top: 10px;
}

.topbar.compact h1 {
    font-size: 38px;
}

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

.workspace {
    display: grid;
}

.upload-zone {
    padding: 30px;
}

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

.alert {
    margin: 16px 0;
    padding: 14px 16px;
    border-radius: 6px;
    line-height: 1.7;
    border: 1px solid var(--line);
}

.alert-info {
    background: linear-gradient(135deg, rgba(113, 20, 132, .065), rgba(51, 153, 51, .055));
    color: #38333b;
    border-color: rgba(164, 80, 175, .18);
}

.alert-success {
    background: #f0fbf0;
    border-color: #b7dfb7;
    color: var(--success);
}

.alert-warning {
    background: #fffaf0;
    border-color: #f2d99d;
    color: #7a4b10;
}

.alert-danger {
    background: #fef3f2;
    border-color: #fecdca;
    color: var(--danger);
}

.file-drop {
    position: relative;
    display: grid;
    gap: 8px;
    place-items: center;
    min-height: 180px;
    border: 2px dashed rgba(164, 80, 175, .32);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(164, 80, 175, .07), rgba(51, 153, 51, .055)),
        #fff;
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.file-drop span {
    font-size: 20px;
    color: var(--purple);
}

.file-drop.has-files {
    border-color: rgba(51, 153, 51, .55);
    box-shadow: inset 0 0 0 1px rgba(51, 153, 51, .18), 0 14px 30px rgba(51, 153, 51, .08);
}

.file-drop small,
.muted-note,
td small {
    color: var(--muted);
}

.file-drop input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.result-card {
    display: grid;
    gap: 18px;
    margin: 20px 0;
    padding: 20px;
    border: 1px solid rgba(51, 153, 51, .2);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(51, 153, 51, .06), rgba(164, 80, 175, .045));
}

.result-list {
    display: grid;
    gap: 14px;
    margin: 20px 0;
}

.copy-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.failure-list {
    display: grid;
    gap: 10px;
    margin: 20px 0;
    padding: 16px;
    border: 1px solid #fecdca;
    border-radius: 8px;
    background: #fff8f7;
}

.failure-list h3 {
    margin-bottom: 4px;
    color: var(--danger);
}

.failure-item {
    display: grid;
    gap: 4px;
    padding: 12px;
    border-radius: 6px;
    background: #fff;
}

.failure-item span {
    color: var(--muted);
}

.upload-status {
    display: grid;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid rgba(164, 80, 175, .22);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(113, 20, 132, .06), rgba(51, 153, 51, .05));
}

.upload-status.is-error {
    border-color: #fecdca;
    background: #fff8f7;
}

.upload-status.is-error .upload-percent,
.upload-status.is-error strong {
    color: var(--danger);
}

.upload-status.is-error .upload-progress span {
    background: linear-gradient(90deg, #b42318, #d92d20);
}

.upload-status.is-complete .upload-progress span {
    background: linear-gradient(90deg, var(--purple), var(--green));
}

.upload-status[hidden] {
    display: none;
}

.upload-status-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
}

.upload-status strong,
.upload-status small {
    display: block;
}

.upload-status small {
    color: var(--muted);
}

.upload-percent {
    min-width: 54px;
    color: var(--purple);
    text-align: left;
}

.upload-progress {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(109, 110, 113, .14);
    box-shadow: inset 0 1px 2px rgba(34, 37, 42, .08);
}

.upload-progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--purple), var(--purple-soft), var(--green));
    transition: width .18s ease;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(164, 80, 175, .2);
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: spin .85s linear infinite;
    flex: 0 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    color: var(--green-dark);
    background: #edf8ed;
    font-size: 12px;
    font-weight: 700;
}

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

.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .86);
    box-shadow: 0 16px 40px rgba(113, 20, 132, .08);
}

.admin-toolbar strong,
.admin-toolbar span {
    display: block;
}

.admin-toolbar span {
    margin-top: 4px;
    color: var(--muted);
}

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

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .86);
}

.pagination-bar > span {
    color: var(--muted);
    font-weight: 700;
}

.pagination-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.page-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--purple);
    font-weight: 800;
}

.page-number.is-current {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--purple), var(--purple-soft));
}

.secondary-button.is-disabled {
    opacity: .45;
    cursor: not-allowed;
}

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

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

th {
    color: var(--muted);
    background: linear-gradient(180deg, #fcf9fd, #f7f1f8);
    font-size: 13px;
}

td strong,
td small {
    display: block;
}

.file-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.file-actions form {
    margin: 0;
}

.file-actions .table-button,
.file-actions .danger-button {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
}

.muted-inline {
    color: var(--muted);
    white-space: nowrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.status-pill.is-active {
    color: var(--green-dark);
    background: #edf8ed;
}

.status-pill.is-expired {
    color: #7a4b10;
    background: #fff3d6;
}

.download-log summary {
    color: var(--purple);
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

.download-log-list {
    display: grid;
    gap: 8px;
    width: min(360px, 70vw);
    margin-top: 10px;
}

.download-log-item {
    display: grid;
    gap: 3px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.download-log-item span,
.download-log-item small {
    color: var(--muted);
}

.download-log-item small {
    max-width: 320px;
    overflow-wrap: anywhere;
}

.empty-state,
.message-page {
    text-align: center;
}

.message-page {
    padding-top: 20vh;
}

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

    .auth-panel,
    .upload-zone {
        padding: 22px;
    }

    .topbar,
    .copy-row {
        grid-template-columns: 1fr;
        display: grid;
    }

    .upload-status-head {
        grid-template-columns: auto 1fr;
    }

    .upload-percent {
        grid-column: 1 / -1;
        text-align: right;
    }

    h1 {
        font-size: 34px;
    }

    .actions a {
        flex: 1;
    }

    .admin-toolbar {
        align-items: stretch;
        display: grid;
    }

    .pagination-bar {
        align-items: stretch;
        display: grid;
    }
}
