/* nalog.t-ov.ru — Dark minimal theme, single-page layout */

:root {
    --bg: #0d1117;
    --bg-card: #161b22;
    --bg-hover: #1c2128;
    --border: #30363d;
    --text: #c9d1d9;
    --text-dim: #8b949e;
    --accent: #58a6ff;
    --accent-glow: rgba(88, 166, 255, 0.15);
    --green: #3fb950;
    --red: #f85149;
    --yellow: #d29922;
    --radius: 8px;
    --font: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', monospace;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navigation — fixed top */
.nav {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.nav-brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 2px;
}

.nav-links { display: flex; gap: 16px; margin-left: auto; }
.nav-links a {
    color: var(--text-dim);
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    cursor: pointer;
}
.nav-links a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }

/* === MAIN LAYOUT: fixed 2-column grid === */
.main-layout {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 3fr;
    gap: 0;
    height: calc(100vh - 49px);
    overflow: hidden;
}

/* LEFT COLUMN: button + log (independent scroll) */
.left-col {
    border-right: 1px solid var(--border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

/* Button area — fixed at top of left column */
.btn-area { flex-shrink: 0; position: relative; }

/* Trigger Button — rectangle with rounded corners */
.trigger-btn {
    width: 100%;
    padding: 20px;
    border-radius: 12px;
    border: 2px solid var(--accent);
    background: var(--bg-card);
    color: var(--accent);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
    text-align: center;
    line-height: 1.4;
}

.trigger-btn:hover:not(:disabled) {
    background: var(--accent-glow);
    box-shadow: 0 0 30px rgba(88, 166, 255, 0.15);
}

.trigger-btn:disabled {
    cursor: not-allowed;
    border-color: var(--border);
    color: var(--text-dim);
}

.trigger-btn .btn-label {
    display: block;
    font-size: 15px;
    font-weight: 700;
}

.trigger-btn .btn-timer {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-dim);
    margin-top: 6px;
}

.trigger-btn:not(:disabled) .btn-timer { display: none; }

.trigger-btn .btn-countdown {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    margin-top: 4px;
    opacity: 0.7;
}

.trigger-btn:not(:disabled) .btn-countdown { display: none; }

/* Test button — small, in corner of button area */
.test-btn {
    display: none;
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font);
    background: var(--bg-hover);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    z-index: 2;
}
.test-btn:hover { color: var(--accent); border-color: var(--accent); }
.test-btn.visible { display: block; }

/* Progress bar */
.progress-bar {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    display: none;
    flex-shrink: 0;
}

.progress-bar.active { display: block; }

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.5s ease;
    width: 0%;
}

/* Log section — scrollable independently */
.log-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.log-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.progress-log {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    flex: 1;
    overflow-y: auto;
    font-size: 11px;
    min-height: 0;
}

.progress-log .entry {
    padding: 3px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 6px;
    align-items: flex-start;
}

.progress-log .entry:last-child { border-bottom: none; }

.progress-log .entry .icon {
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

.progress-log .entry .msg { color: var(--text-dim); }
.progress-log .entry.done .msg { color: var(--green); }
.progress-log .entry.error .msg { color: var(--red); }
.progress-log .entry.active .msg { color: var(--accent); }
.progress-log .entry.info .msg { color: var(--text-dim); font-style: italic; }

.progress-log .empty-log {
    color: var(--text-dim);
    font-style: italic;
    text-align: center;
    padding: 16px 0;
}

.spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* RIGHT COLUMN: news feed (independent scroll) */
.right-col {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.news-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

/* Run date tabs */
.run-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.run-tab {
    padding: 4px 10px;
    font-size: 11px;
    font-family: var(--font);
    background: var(--bg-card);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}
.run-tab:hover { border-color: var(--accent); color: var(--text); }
.run-tab.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

.news-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.news-item {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.news-item:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.news-item .title {
    font-size: 13px;
    color: var(--text);
    line-height: 1.4;
}

.news-item .meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-dim);
}

.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-tg { background: #2a4a7f; color: #79b8ff; }
.badge-rss { background: #4a3a20; color: #d29922; }
.badge-llm { background: #2a4a3a; color: #3fb950; }

/* === MODALS === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 700px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
}

.modal-wide { max-width: 900px; }
.modal-small { max-width: 400px; text-align: center; }

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    font-family: var(--font);
}

.modal-close:hover { color: var(--text); }

.modal h2 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--text);
    line-height: 1.4;
    padding-right: 32px;
}

.modal .article-text {
    color: var(--text-dim);
    margin-bottom: 24px;
    line-height: 1.8;
}

.modal .sources-list {
    list-style: none;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.modal .sources-list li {
    padding: 6px 0;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    word-break: break-all;
}

.source-ok { color: var(--green); }
.source-broken { color: var(--red); }
.source-unknown { color: var(--text-dim); }

.modal .article-meta {
    margin-top: 16px;
    font-size: 11px;
    color: var(--text-dim);
    display: flex;
    gap: 12px;
}

/* Auth modal */
.modal-small input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    width: 100%;
    margin-bottom: 12px;
    outline: none;
}
.modal-small input:focus { border-color: var(--accent); }

/* Sources modal */
.sources-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.sources-table th,
.sources-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 13px;
}

.sources-table th {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.add-source-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.add-source-form select,
.add-source-form input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    outline: none;
}

.add-source-form select:focus,
.add-source-form input:focus { border-color: var(--accent); }

.admin-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Buttons */
.btn {
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: var(--radius);
    padding: 10px 20px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.85; }
.btn-danger { background: var(--red); color: #fff; }
.btn-small { padding: 4px 10px; font-size: 11px; }
.btn-outline {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
}
.btn-outline:hover { color: var(--text); border-color: var(--text-dim); }

.empty {
    text-align: center;
    padding: 40px 0;
    color: var(--text-dim);
    font-size: 13px;
}

/* Gear icon in nav */
.nav-gear {
    font-size: 18px;
    cursor: pointer;
    text-decoration: none !important;
}
.nav-gear:hover { color: var(--text); }

/* Settings tabs */
.settings-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.settings-tab {
    padding: 8px 20px;
    font-size: 13px;
    font-family: var(--font);
    font-weight: 600;
    background: none;
    color: var(--text-dim);
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Filters tab */
.filter-group {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.filter-group:last-child { border-bottom: none; }

.filter-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.filter-group select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    outline: none;
    width: 100%;
}
.filter-group select:focus { border-color: var(--accent); }

.prompt-editor {
    position: relative;
    margin-bottom: 8px;
}

.prompt-editor textarea {
    width: 100%;
    min-height: 120px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}
.prompt-editor textarea:focus { border-color: var(--accent); }

.prompt-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Cost banner */
.cost-banner {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cost-banner .cost-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}

/* Delete modal */
.delete-stages {
    text-align: left;
    margin: 16px 0;
}
.delete-stages label {
    display: block;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}
.delete-stages input[type="radio"] {
    margin-right: 8px;
    accent-color: var(--accent);
}

.modal-small textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    width: 100%;
    resize: vertical;
    outline: none;
}
.modal-small textarea:focus { border-color: var(--accent); }

/* News delete button in modal */
.news-delete-btn {
    margin-top: 12px;
}

/* Negative examples list */
.neg-examples {
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
}
.neg-examples .neg-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-dim);
}
.neg-examples .neg-item:last-child { border-bottom: none; }
.neg-examples .neg-stage {
    font-size: 10px;
    color: var(--yellow);
    text-transform: uppercase;
    margin-left: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    body { overflow: auto; height: auto; }
    .main-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: auto;
    }
    .left-col {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 50vh;
    }
    .right-col { max-height: none; overflow-y: visible; }
    .nav { gap: 12px; padding: 10px 12px; }
    .nav-brand { font-size: 13px; letter-spacing: 1px; white-space: nowrap; }
    .nav-links { gap: 8px; flex-shrink: 1; min-width: 0; }
    .nav-links a { font-size: 11px; padding: 3px 6px; white-space: nowrap; }
    .test-btn { padding: 8px 16px; font-size: 13px; }
}
