:root {
    --background: #f4f6f8;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-solid: #ffffff;
    --text: #18202a;
    --muted: #6e7781;
    --border: #e3e7eb;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;
    --success: #15803d;
    --success-soft: #f0fdf4;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.07);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, #e8f0ff 0, transparent 28rem),
        radial-gradient(circle at top right, #eef2ff 0, transparent 24rem),
        var(--background);
    font-family:
        Inter,
        "PingFang SC",
        "Microsoft YaHei",
        "Hiragino Sans GB",
        "Noto Sans CJK SC",
        sans-serif;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

.page-shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    padding: 0 5vw;
    border-bottom: 1px solid rgba(227, 231, 235, 0.8);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(16px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-icon,
.large-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.26);
}

.brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 13px;
}

.large-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 22px;
    border-radius: 20px;
    font-size: 22px;
    font-weight: 800;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 18px;
    color: var(--muted);
    font-size: 14px;
}

.topbar-actions form {
    margin: 0;
}

.username {
    padding: 7px 11px;
    border-radius: 999px;
    background: #f1f4f7;
    color: #3b4652;
}

.nav-link:hover,
.text-button:hover {
    color: var(--primary);
}

.main-container {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 56px 0 80px;
}

.hero-section {
    max-width: 820px;
    margin-bottom: 34px;
}

.hero-section h1,
.page-heading h1 {
    margin: 10px 0 14px;
    font-size: clamp(32px, 4.5vw, 54px);
    line-height: 1.12;
    letter-spacing: -0.045em;
}

.hero-section p,
.page-heading p {
    max-width: 740px;
    margin: 0;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.8;
}

.eyebrow {
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.16em;
}

.panel {
    border: 1px solid rgba(227, 231, 235, 0.9);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(15px);
}

.upload-panel {
    padding: 28px;
}

.drop-zone {
    padding: 58px 24px;
    text-align: center;
    border: 1.5px dashed #b9c2cf;
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.84), #fff);
    cursor: pointer;
    transition:
        border-color 0.2s ease,
        background-color 0.2s ease,
        transform 0.2s ease;
}

.drop-zone:hover,
.drop-zone:focus,
.drop-zone.dragging {
    border-color: var(--primary);
    background: var(--primary-soft);
    outline: none;
    transform: translateY(-1px);
}

.upload-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin-bottom: 14px;
    border-radius: 15px;
    color: var(--primary);
    background: #e7efff;
    font-size: 26px;
    font-weight: 300;
}

.drop-zone h2 {
    margin: 0 0 8px;
    font-size: 21px;
}

.drop-zone p {
    margin: 0 0 12px;
    color: var(--muted);
}

.file-limit {
    color: #98a1ab;
    font-size: 13px;
}

.selected-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
    padding: 15px 17px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: #fafbfc;
}

.selected-file div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.selected-file span {
    color: var(--muted);
    font-size: 13px;
}

.options-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-top: 26px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.field > span {
    color: #4b5563;
    font-size: 13px;
    font-weight: 650;
}

.field input[type="text"],
.field input[type="password"] {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    color: var(--text);
    border: 1px solid #d7dde4;
    border-radius: 11px;
    background: white;
    outline: none;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.language-field {
    min-width: 260px;
}

.segmented-control {
    display: flex;
    padding: 4px;
    border-radius: 12px;
    background: #eef1f5;
}

.segmented-control label {
    flex: 1;
    cursor: pointer;
}

.segmented-control input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented-control span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 39px;
    border-radius: 9px;
    color: var(--muted);
    font-size: 14px;
    transition: all 0.2s ease;
}

.segmented-control input:checked + span {
    color: var(--text);
    background: white;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
    font-weight: 700;
}

.primary-button,
.secondary-button,
.danger-button,
.copy-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 19px;
    border: none;
    border-radius: 11px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        transform 0.15s ease;
}

.primary-button {
    color: white;
    background: var(--primary);
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.2);
}

.primary-button:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.primary-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    box-shadow: none;
}

.secondary-button,
.copy-button {
    color: #334155;
    border: 1px solid var(--border);
    background: white;
}

.secondary-button:hover,
.copy-button:hover {
    border-color: #b9c2cf;
    background: #f8fafc;
}

.danger-button {
    color: var(--danger);
    background: var(--danger-soft);
}

.danger-button:hover {
    background: #fee2e2;
}

.text-button {
    padding: 0;
    color: var(--muted);
    border: none;
    background: none;
    cursor: pointer;
}

.danger-text {
    color: var(--danger);
}

.full-button {
    width: 100%;
}

.progress-panel {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 24px;
    padding: 24px;
}

.progress-panel h3 {
    margin: 0 0 5px;
    font-size: 16px;
}

.progress-panel p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.spinner {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 3px solid #dce7ff;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.alert {
    margin: 22px 0;
    padding: 14px 17px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
}

.alert-error {
    color: #991b1b;
    border: 1px solid #fecaca;
    background: var(--danger-soft);
}

.alert-success {
    color: #166534;
    border: 1px solid #bbf7d0;
    background: var(--success-soft);
}

.results-grid {
    display: grid;
    gap: 24px;
    margin-top: 28px;
}

.result-card {
    overflow: hidden;
}

.result-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 25px 27px;
    border-bottom: 1px solid var(--border);
}

.result-header h2 {
    margin: 5px 0 7px;
    font-size: 21px;
}

.result-header p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.result-number {
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.result-content {
    min-height: 240px;
    max-height: 720px;
    margin: 0;
    padding: 27px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #27313d;
    background: rgba(250, 251, 252, 0.7);
    font-family:
        "SFMono-Regular",
        Consolas,
        "Noto Sans Mono CJK SC",
        monospace;
    font-size: 14px;
    line-height: 1.85;
}

.login-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 190px);
}

.login-card {
    width: min(430px, 100%);
    padding: 38px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.91);
    box-shadow: var(--shadow);
}

.login-heading {
    margin-bottom: 27px;
    text-align: center;
}

.login-heading h1 {
    margin: 0 0 10px;
    font-size: 28px;
}

.login-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 19px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 32px;
}

.page-heading h1 {
    font-size: 40px;
}

.admin-panel {
    margin-bottom: 24px;
    padding: 27px;
}

.section-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 23px;
}

.section-heading h2 {
    margin: 0;
    font-size: 20px;
}

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 25px;
    height: 25px;
    padding: 0 8px;
    border-radius: 999px;
    color: var(--primary);
    background: var(--primary-soft);
    font-size: 12px;
    font-weight: 800;
}

.admin-create-form {
    display: grid;
    grid-template-columns: 1.1fr 1.1fr 0.8fr auto auto;
    align-items: end;
    gap: 16px;
}

.checkbox-field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    color: #4b5563;
    font-size: 14px;
    cursor: pointer;
}

.checkbox-field input {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
}

.user-list {
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.user-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fafbfc;
}

.user-edit-form {
    display: grid;
    grid-template-columns:
        minmax(130px, 1fr)
        minmax(150px, 1fr)
        110px
        auto
        auto
        auto;
    align-items: end;
    gap: 12px;
    flex: 1;
}

.compact-field {
    min-width: 0;
}

.hidden {
    display: none !important;
}

.quota-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px 17px;
    border: 1px solid #dbe4f0;
    border-radius: 13px;
    background: linear-gradient(
        135deg,
        #f8fbff,
        #f4f7fb
    );
}

.quota-bar > div {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.quota-label {
    color: var(--muted);
    font-size: 12px;
}

.quota-bar strong {
    color: #334155;
    font-size: 15px;
}

.quota-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    color: #1d4ed8;
    background: #dbeafe;
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}

.quota-badge.unlimited {
    color: #047857;
    background: #d1fae5;
}

.quota-badge.exhausted {
    color: #b91c1c;
    background: #fee2e2;
}

.usage-status {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    min-height: 44px;
    white-space: nowrap;
}

.usage-status span {
    color: var(--muted);
    font-size: 12px;
}

.usage-status strong {
    color: #334155;
    font-size: 13px;
}

.form-help {
    grid-column: 1 / -1;
    margin: -4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 820px) {
    .topbar {
        padding: 0 20px;
    }

    .username {
        display: none;
    }

    .main-container {
        width: min(100% - 28px, 1180px);
        padding-top: 36px;
    }

    .options-row,
    .page-heading,
    .result-header {
        align-items: stretch;
        flex-direction: column;
    }

    .language-field {
        min-width: 0;
    }

    .primary-button {
        width: 100%;
    }

    .admin-create-form,
    .user-edit-form {
        grid-template-columns: 1fr;
    }

    .user-row {
        align-items: stretch;
        flex-direction: column;
    }

    .user-row > form:last-child,
    .user-row > form:last-child button {
        width: 100%;
    }
    
    .quota-bar {
        align-items: flex-start;
    }

    .usage-status {
        min-height: auto;
        padding: 5px 0;
    }
}

@media (max-width: 520px) {
    .brand span:last-child {
        display: none;
    }

    .topbar-actions {
        gap: 12px;
    }

    .upload-panel,
    .admin-panel,
    .login-card {
        padding: 20px;
    }

    .drop-zone {
        padding: 42px 16px;
    }

    .hero-section h1 {
        font-size: 35px;
    }

    .result-header,
    .result-content {
        padding: 21px;
    }
}

