:root {
    --bg: #eef2f7;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --success: #16a34a;
    --success-soft: #ecfdf3;
    --warning-soft: #fff7ed;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    font-family: Inter, Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37,99,235,0.10), transparent 34%),
        radial-gradient(circle at top right, rgba(16,185,129,0.08), transparent 28%),
        var(--bg);
    margin: 0;
    color: var(--text);
    font-size: 14px;
}

.container {
    max-width: 1220px;
    margin: 22px auto;
    background: rgba(255,255,255,0.96);
    padding: 20px 24px 26px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255,255,255,0.7);
}

.top-menu {
    display: flex;
    align-items: center;
    margin-bottom: 22px;
    padding: 9px;
    background: #0f172a;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(15,23,42,0.16);
}

.menu-left,
.menu-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-right {
    margin-left: auto;
}

.top-menu a {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: #dbeafe;
    font-weight: 700;
    font-size: 13px;
    transition: 0.15s ease;
}

.top-menu a:hover {
    background: rgba(255,255,255,0.12);
    color: #ffffff;
}

.top-menu .logout-link {
    color: #fecaca;
}

.top-menu .logout-link:hover {
    background: rgba(220,38,38,0.22);
    color: #ffffff;
}

h1 {
    font-size: 30px;
    letter-spacing: -0.03em;
    margin: 8px 0 16px;
}

h2 {
    font-size: 20px;
    letter-spacing: -0.02em;
    margin: 22px 0 12px;
}

h3 {
    font-size: 14px;
}

p {
    line-height: 1.5;
}

.small-muted {
    color: var(--muted);
    font-size: 13px;
}

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

.card {
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    padding: 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(15,23,42,0.04);
}

.card h3 {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.card .value {
    font-size: 25px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
    font-size: 13px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

th, td {
    border-bottom: 1px solid var(--border);
    padding: 9px 10px;
    text-align: left;
    vertical-align: middle;
}

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

th {
    background: #f8fafc;
    color: #475569;
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

tr:hover td {
    background: #f8fafc;
}

input,
select,
textarea {
    padding: 9px 10px;
    margin: 4px 0;
    font-size: 13px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #ffffff;
    color: var(--text);
    outline: none;
    transition: 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

textarea {
    line-height: 1.45;
}

button {
    padding: 9px 13px;
    cursor: pointer;
    border: 0;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    font-weight: 800;
    font-size: 13px;
    transition: 0.15s ease;
    box-shadow: 0 4px 12px rgba(37,99,235,0.20);
}

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

button.danger {
    background: var(--danger);
    box-shadow: 0 4px 12px rgba(220,38,38,0.18);
}

button.danger:hover {
    background: #b91c1c;
}

form {
    margin: 0;
}

.login-box {
    max-width: 390px;
    margin: 80px auto;
    background: rgba(255,255,255,0.96);
    padding: 28px;
    border-radius: 18px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255,255,255,0.7);
}

.login-box h2 {
    font-size: 28px;
    margin-top: 0;
}

.login-box input {
    width: 100%;
}

.upload-panel {
    margin-top: 20px;
}

.dropzone {
    border: 2px dashed #93c5fd;
    background:
        linear-gradient(180deg, rgba(239,246,255,0.9), rgba(248,250,252,0.95));
    border-radius: 18px;
    padding: 46px 26px;
    text-align: center;
    transition: 0.18s ease;
    cursor: pointer;
}

.dropzone:hover,
.dropzone.dragover {
    background: #eff6ff;
    border-color: var(--primary);
    box-shadow: inset 0 0 0 4px rgba(37,99,235,0.08);
}

.dropzone-icon {
    font-size: 46px;
    margin-bottom: 10px;
}

.dropzone-title {
    font-size: 21px;
    font-weight: 850;
    margin-bottom: 7px;
    letter-spacing: -0.02em;
}

.dropzone-subtitle {
    color: var(--muted);
    font-size: 13px;
}

.selected-file {
    margin-top: 13px;
    font-weight: 800;
    color: var(--primary);
}

.upload-actions {
    margin-top: 16px;
    display: flex;
    justify-content: center;
}

.upload-actions button {
    min-width: 165px;
}

/* Brokers page */
.broker-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
}

.broker-list {
    max-height: 650px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    background: #f8fafc;
}

.broker-item {
    display: block;
    padding: 10px 12px;
    margin-bottom: 7px;
    border-radius: 10px;
    text-decoration: none;
    color: #111827;
    border: 1px solid rgba(15,23,42,0.06);
    transition: 0.15s ease;
}

.broker-item:hover {
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(15,23,42,0.08);
}

.wide-input {
    width: 100%;
}

.status-box {
    padding: 14px;
    margin-bottom: 14px;
    border-left: 5px solid #888;
    border-radius: 12px;
}

.status-green {
    background: var(--success-soft);
    border-left-color: var(--success);
}

.status-yellow {
    background: var(--warning-soft);
    border-left-color: #d97706;
}

.status-red {
    background: var(--danger-soft);
    border-left-color: var(--danger);
}

.copied {
    color: var(--success);
    font-weight: 800;
    margin-left: 10px;
}

@media (max-width: 760px) {
    .container {
        margin: 10px;
        padding: 14px;
    }

    .top-menu {
        flex-wrap: wrap;
    }

    .menu-right {
        margin-left: 0;
        width: 100%;
        flex-wrap: wrap;
    }

    .broker-layout {
        grid-template-columns: 1fr;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    margin-top: 10px;
}

.result-grid input {
    width: 100%;
}

.log-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.compact-log-table {
    font-size: 11px;
    min-width: 1450px;
}

.compact-log-table th,
.compact-log-table td {
    padding: 6px 7px;
    white-space: nowrap;
}

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

/* Final compact result page */
.result-card-final {
    width: 100%;
    background: #ffffff;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    padding: 14px 18px;
    margin-bottom: 14px;
}

.result-card-title {
    margin: 0 0 10px 0;
    font-size: 15px;
}

.result-form-final {
    display: grid;
    grid-template-columns: 110px minmax(0, 1.6fr) 110px minmax(0, 1.25fr);
    gap: 8px 14px;
    align-items: center;
}

.result-label-final {
    font-weight: 800;
    white-space: nowrap;
    font-size: 13px;
}

.result-input-final {
    width: 100% !important;
    min-width: 0;
    box-sizing: border-box;
    margin: 0 !important;
    padding: 6px 9px !important;
    font-size: 13px !important;
}

.copy-block-final {
    margin-top: 10px;
}

.copy-title-final {
    margin: 6px 0 8px 0;
    font-size: 15px;
}

.result-actions-final {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 8px;
}

@media (max-width: 900px) {
    .result-form-final {
        grid-template-columns: 100px minmax(0, 1fr);
    }
}

/* History page */
.history-search {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 14px 0;
}

.history-search input {
    width: 280px;
}

.history-table tr.history-row {
    cursor: pointer;
}

.history-table tr.history-row:hover td {
    background: #eff6ff;
}

.load-link {
    color: #2563eb;
    font-weight: 800;
    text-decoration: underline;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-box {
    position: relative;
    width: min(760px, 95vw);
    max-height: 88vh;
    overflow-y: auto;
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.modal-close {
    position: absolute;
    right: 16px;
    top: 14px;
    background: #dc2626;
    padding: 6px 10px;
    border-radius: 8px;
}

.modal-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px 14px;
    margin-top: 14px;
}

.modal-grid b {
    color: #374151;
}

.modal-grid span {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    padding: 8px 10px;
    border-radius: 8px;
    min-height: 34px;
}
