:root {
    --bg: #f3f7fc;
    --panel: #ffffff;
    --panel-border: #d8e3ef;
    --text: #16324a;
    --muted: #5f758d;
    --primary: #0f7ae5;
    --primary-soft: #eaf4ff;
    --success-bg: #edf9f4;
    --success-text: #18794e;
    --error-bg: #fff1ef;
    --error-text: #b42318;
    --shadow: 0 18px 45px rgba(24, 50, 77, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background:
        radial-gradient(circle at top left, #ffffff 0, #eef5ff 36%, rgba(238, 245, 255, 0) 60%),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
    color: var(--text);
}

.page {
    width: min(1320px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.06;
}

.subtitle,
.hint {
    color: var(--muted);
}

.subtitle {
    margin: 14px 0 0;
    max-width: 860px;
    line-height: 1.6;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.report-form {
    position: relative;
}

.settings-grid,
.summary-grid,
.tables-grid {
    display: grid;
    gap: 16px;
}

.settings-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    align-items: end;
}

.settings-grid .bonus-rate {
    grid-column: 1;
}

.settings-grid .bonus-threshold {
    grid-column: 2;
}

.summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin: 20px 0;
}

.tables-grid {
    grid-template-columns: minmax(0, 1fr);
    margin-bottom: 20px;
}

.summary-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.summary-label {
    color: var(--muted);
    font-size: 14px;
}

.summary-card strong {
    font-size: 30px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.field input,
.field select {
    width: 100%;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    min-height: 52px;
    padding: 13px 14px;
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.3;
    color: var(--text);
    background: #fcfdff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field select {
    background-image:
        linear-gradient(45deg, transparent 50%, var(--primary) 50%),
        linear-gradient(135deg, var(--primary) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% - 2px),
        calc(100% - 12px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 40px;
}

.field select::-ms-expand {
    display: none;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: #89bfff;
    box-shadow: 0 0 0 4px rgba(15, 122, 229, 0.12);
    background: #ffffff;
}

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

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 220px;
    border: 0;
    background: linear-gradient(135deg, var(--primary) 0%, #34a2ff 100%);
    color: #fff;
    padding: 14px 20px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(15, 122, 229, 0.24);
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.primary-button:hover {
    transform: translateY(-1px);
}

.primary-button:disabled {
    cursor: wait;
    opacity: 0.95;
}

.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 220px;
    border: 1px solid #bdd9fb;
    background: #f4f9ff;
    color: var(--primary);
    padding: 14px 20px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.secondary-button:hover {
    transform: translateY(-1px);
    background: #edf6ff;
}

.button-loader {
    display: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    animation: spin 0.8s linear infinite;
}

.primary-button.is-loading .button-loader {
    display: inline-block;
}

.loading-bar {
    display: none;
    width: 100%;
    height: 12px;
    margin-top: 14px;
    border-radius: 999px;
    background: var(--primary-soft);
    overflow: hidden;
    border: 1px solid #cfe3ff;
}

.loading-bar.is-visible {
    display: block;
}

.loading-bar-fill {
    display: block;
    width: 36%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary) 0%, #53b1ff 100%);
    box-shadow: 0 0 14px rgba(15, 122, 229, 0.3);
    animation: progress 1s ease-in-out infinite;
}

.status-box {
    margin-top: 20px;
    font-weight: 600;
}

.status-box.success {
    color: var(--success-text);
    background: var(--success-bg);
    border-color: #bee7d3;
}

.status-box.error {
    color: var(--error-text);
    background: var(--error-bg);
    border-color: #f4c7c2;
}

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

.deal-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.deal-link:hover {
    text-decoration: underline;
}

.deal-actions-cell {
    min-width: 230px;
}

.inline-engineer-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inline-engineer-form select {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: #fcfdff;
    color: var(--text);
}

.mini-button {
    border: 0;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

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

th,
td {
    padding: 13px 10px;
    border-bottom: 1px solid #e7edf5;
    text-align: left;
    font-size: 14px;
}

th {
    color: var(--muted);
    font-weight: 700;
}

tbody tr:hover {
    background: #f8fbff;
}

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

@keyframes progress {
    0% {
        transform: translateX(-120%);
    }
    100% {
        transform: translateX(320%);
    }
}

@media (max-width: 860px) {
    .page {
        width: min(100% - 20px, 1320px);
        padding-top: 16px;
    }

    .hero,
    .actions {
        flex-direction: column;
    }

    .primary-button {
        width: 100%;
    }

    .settings-grid .bonus-rate,
    .settings-grid .bonus-threshold {
        grid-column: auto;
    }
}
