*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #F7F8FA;
    --surface: #FFFFFF;
    --border: #E2E6EA;
    --text: #2D3748;
    --text-muted: #718096;
    --accent: #3B82F6;
    --accent-hover: #2563EB;
    --success: #10B981;
    --error: #EF4444;
    --info: #3B82F6;
    --shadow: 0 1px 4px rgba(0,0,0,.07);
    --radius: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container { max-width: 960px; margin: 0 auto; padding: 0 24px; }

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
}
.header .container { display: flex; align-items: center; gap: 16px; }
.logo {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.3px;
}
.logo:hover { color: var(--accent); }
.header-sub { color: var(--text-muted); font-size: 13px; }

/* Main */
.main { flex: 1; padding: 36px 0 48px; }

/* Footer */
.footer {
    border-top: 1px solid var(--border);
    padding: 16px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    background: var(--surface);
}

/* Page header */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; }
.page-sub { color: var(--text-muted); margin-top: 4px; }

/* Breadcrumb */
.breadcrumb {
    display: flex; align-items: center; gap: 8px;
    color: var(--text-muted); font-size: 13px; margin-bottom: 20px;
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* Tools grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color .15s, box-shadow .15s;
    position: relative;
}
.tool-card:hover:not(.tool-card--disabled) {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.08);
}
.tool-card--disabled { opacity: .6; cursor: default; }
.tool-card__icon { width: 36px; height: 36px; color: var(--accent); }
.tool-card__icon svg { width: 100%; height: 100%; }
.tool-card__name { font-size: 15px; font-weight: 600; }
.tool-card__desc { color: var(--text-muted); font-size: 13px; }
.tool-card__badge {
    position: absolute; top: 12px; right: 12px;
    background: #F1F5F9; color: var(--text-muted);
    font-size: 11px; padding: 2px 8px; border-radius: 20px;
}

/* Upload section */
.upload-section { max-width: 560px; display: flex; flex-direction: column; gap: 16px; }

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone--active {
    border-color: var(--accent);
    background: rgba(59,130,246,.04);
}
.drop-zone__icon { width: 36px; height: 36px; color: var(--text-muted); margin: 0 auto 12px; }
.drop-zone__text { color: var(--text); margin-bottom: 4px; }
.drop-zone__hint { color: var(--text-muted); font-size: 12px; }
.drop-zone__link { color: var(--accent); cursor: pointer; text-decoration: underline; }
.drop-zone__input { display: none; }

.file-info {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 16px;
}
.file-info svg { width: 20px; height: 20px; color: var(--accent); flex-shrink: 0; }
.file-info span { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 20px; border-radius: 8px; font-size: 14px; font-weight: 500;
    cursor: pointer; border: 1px solid transparent; text-decoration: none;
    transition: background .15s, border-color .15s;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--primary:disabled { opacity: .5; cursor: not-allowed; }
.btn--success { background: var(--success); color: #fff; }
.btn--success:hover { background: #059669; }
.btn--lg { padding: 12px 28px; font-size: 15px; }
.btn--sm { padding: 5px 12px; font-size: 12px; background: var(--bg); border-color: var(--border); color: var(--text); }
.btn--sm:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; padding: 2px 4px; }
.btn-icon:hover { color: var(--error); }

/* Alerts */
.alert {
    padding: 12px 16px; border-radius: 8px; font-size: 13px; border: 1px solid transparent;
}
.alert--error { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }
.alert--info { background: #EFF6FF; color: #1D4ED8; border-color: #BFDBFE; }

/* Success block */
.success-block {
    display: flex; align-items: flex-start; gap: 14px;
    background: #F0FDF4; border: 1px solid #A7F3D0;
    border-radius: var(--radius); padding: 16px;
}
.success-block svg { width: 22px; height: 22px; color: var(--success); flex-shrink: 0; margin-top: 2px; }
.success-block p { font-size: 13px; color: #065F46; margin-bottom: 10px; }

/* Spinner */
.spinner {
    width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* History */
.history-section { margin-top: 40px; }
.section-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; }

.history-table {
    width: 100%; border-collapse: collapse;
    background: var(--surface); border-radius: var(--radius);
    overflow: hidden; border: 1px solid var(--border);
}
.history-table th {
    background: #F8FAFC; text-align: left; padding: 10px 14px;
    font-size: 12px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .5px; color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.history-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.history-table tr:last-child td { border-bottom: none; }
.history-table__name { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Multi-file slots */
.file-slots { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }

.file-slot {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.file-slot__label {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.file-slot__optional {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    background: #F1F5F9;
    border-radius: 20px;
    padding: 1px 8px;
    margin-left: 8px;
    vertical-align: middle;
}

.file-slot__hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.file-slot .drop-zone { margin-bottom: 0; }
.file-slot .file-info { margin-top: 8px; margin-bottom: 0; }

/* Config section */
.config-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.config-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.config-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.config-label {
    font-size: 13px;
    color: var(--text);
    min-width: 180px;
    flex-shrink: 0;
}
.config-input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    min-width: 200px;
}
.config-input:focus { outline: none; border-color: var(--accent); }
.config-hint {
    font-size: 11px;
    color: var(--text-muted);
}

/* Preview */
.preview-block { margin-top: 24px; }
.preview-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.preview-wrap { overflow-x: auto; max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.preview-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.preview-table th {
    background: #F8FAFC; text-align: left; padding: 7px 10px;
    font-weight: 600; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; white-space: nowrap;
}
.preview-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.preview-table tr:last-child td { border-bottom: none; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    padding: 24px;
}
.modal-window {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    width: 100%; max-width: 800px;
    max-height: 90vh;
    display: flex; flex-direction: column;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 18px; padding: 2px 6px;
    border-radius: 4px; line-height: 1;
}
.modal-close:hover { color: var(--error); background: #FEF2F2; }
.modal-body {
    flex: 1; overflow-y: auto;
    padding: 20px;
    display: flex; flex-direction: column; gap: 20px;
}
.modal-preview-wrap {
    overflow-x: auto; max-height: 280px; overflow-y: auto;
    border: 1px solid var(--border); border-radius: var(--radius);
}
.modal-config { display: flex; flex-direction: column; gap: 12px; }
.modal-config-title {
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .4px; margin-bottom: 2px;
}
.modal-footer {
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* Progress bar */
.progress-block { margin-top: 4px; }
.progress-bar-wrap {
    height: 8px; background: var(--border);
    border-radius: 4px; overflow: hidden;
}
.progress-bar-fill {
    height: 100%; width: 0%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.6s ease;
}
.progress-msg { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* Inline config (год и т.п. прямо на странице) */
.inline-config-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Forex: inline account selection */
.forex-accounts-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}
.forex-accounts-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 6px;
}
.forex-accounts-ctrl {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 10px;
}
.forex-table-wrap {
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.forex-tbl { min-width: 620px; }
.forex-tbl th { font-size: 12px; white-space: nowrap; }
.forex-tbl td { font-size: 12px; padding: 5px 10px; }
.fa-row { cursor: pointer; transition: background .1s; }
.fa-row:hover { background: #F8FAFC; }
.fa-row--on { background: #EFF6FF; }
.fa-row--on:hover { background: #DBEAFE; }
.fa-v { font-family: monospace; color: var(--accent); width: 36px; text-align: center; }
.fa-v-h { width: 36px; }
.fa-name { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fa-num { text-align: right; }

/* Tool layout: upload left, examples right */
.tool-layout { display: block; }
.tool-layout--with-examples {
    display: flex;
    gap: 28px;
    align-items: flex-start;
}
.tool-layout--with-examples .upload-section {
    flex: 1;
    min-width: 0;
    max-width: 560px;
}
.tool-layout--with-examples .examples-section {
    flex-shrink: 0;
    width: 200px;
    padding-top: 4px;
}

/* Examples sidebar */
.examples-title { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .05em; }
.examples-grid { display: flex; flex-direction: column; gap: 8px; }
.example-card {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    cursor: zoom-in;
    background: #f8f9fa;
    transition: box-shadow .15s;
}
.example-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.example-img { width: 100%; display: block; height: 50px; object-fit: cover; }
.example-caption { font-size: 10px; color: var(--text-muted); padding: 4px 7px; border-top: 1px solid var(--border); margin: 0; line-height: 1.4; }
.example-card--zoomed {
    position: fixed !important; inset: 0; z-index: 9999;
    width: auto !important; border-radius: 0; cursor: zoom-out;
    display: flex !important; flex-direction: column;
    background: rgba(0,0,0,.88);
    align-items: center; justify-content: center;
}
.example-card--zoomed .example-img { height: auto !important; max-height: 90vh; max-width: 92vw; width: auto; object-fit: contain; }
.example-card--zoomed .example-caption { color: #ccc; background: transparent; border: none; font-size: 13px; }
.examples-notice {
    margin-top: 10px;
    font-size: 11px;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 5px;
    padding: 6px 8px;
    line-height: 1.5;
}

/* Utils */
.hidden { display: none !important; }
