:root {
    --bg: #0F1417;
    --panel: #161D22;
    --panel-alt: #1C242A;
    --border: #232B31;
    --text: #E6EDF0;
    --text-dim: #8B98A1;
    --accent: #4FD1C5;

    --zone-green: #34D399;
    --zone-yellow: #FBBF24;
    --zone-orange: #FB923C;
    --zone-red: #F87171;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
    line-height: 1.4;
}

.mono {
    font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
}

/* ---------- Топбар ---------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
}

.tabs button {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.tabs button:hover {
    background: var(--panel-alt);
    color: var(--text);
}

.tabs button.active {
    background: var(--panel-alt);
    color: var(--accent);
    font-weight: 600;
}

.tabs button .badge-new {
    display: inline-block;
    margin-left: 6px;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--accent);
    color: var(--bg);
    font-weight: 700;
    vertical-align: middle;
}

.tabs button .badge-paused {
    display: inline-block;
    margin-left: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-dim);
    vertical-align: middle;
}

/* ---------- Layout ---------- */

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ---------- Лимиты ---------- */

.limits-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 16px;
    align-items: stretch;
}

.limit-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.limit-label {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.limit-sub {
    font-size: 11px;
    opacity: 0.7;
}

.limit-bar-track {
    height: 8px;
    border-radius: 4px;
    background: var(--panel-alt);
    overflow: hidden;
    margin-bottom: 8px;
}

.limit-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--zone-green);
    transition: width .4s ease, background .4s ease;
}

.limit-bar-fill.zone-green { background: var(--zone-green); }
.limit-bar-fill.zone-yellow { background: var(--zone-yellow); }
.limit-bar-fill.zone-orange { background: var(--zone-orange); }
.limit-bar-fill.zone-red { background: var(--zone-red); }

.limit-value {
    font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
    font-size: 20px;
    font-weight: 600;
}

.account-controls {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: flex-start;
    min-width: 240px;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--text-dim);
}

.control-row.disabled {
    opacity: 0.4;
}

/* Переключатель (toggle) */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: background .2s;
}

.switch-slider::before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 2px;
    top: 2px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: transform .2s, background .2s;
}

.switch input:checked + .switch-slider {
    background: rgba(79, 209, 197, 0.25);
    border-color: var(--accent);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(16px);
    background: var(--accent);
}

.btn-pause {
    background: var(--panel-alt);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.btn-pause:hover { border-color: var(--accent); }

.btn-pause.is-paused {
    color: var(--zone-red);
    border-color: var(--zone-red);
}

.control-row.prompt-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}

.prompt-label {
    font-size: 13px;
    color: var(--text-dim);
}

.prompt-textarea {
    width: 100%;
    min-height: 70px;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    padding: 8px;
    resize: vertical;
}

.prompt-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* ---------- График ---------- */

.chart-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.chart-header h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.period-selector {
    display: flex;
    gap: 4px;
    background: var(--panel-alt);
    border-radius: 6px;
    padding: 3px;
}

.period-selector button {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.period-selector button.active {
    background: var(--bg);
    color: var(--accent);
}

.chart-wrap {
    height: 220px;
}

/* ---------- Лог ---------- */

.log-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
}

.log-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.log-header h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    flex-shrink: 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-dim);
    cursor: pointer;
}

.log-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-dim);
    font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
}

.log-table-wrap {
    max-height: 480px;
    overflow-y: auto;
}

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.log-table th {
    text-align: left;
    color: var(--text-dim);
    font-weight: 500;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--panel);
}

.log-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.log-table td.time,
.log-table td.comment {
    font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
    color: var(--text-dim);
    white-space: nowrap;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.status-dot.success { background: var(--zone-green); }
.status-dot.queued { background: var(--zone-yellow); }
.status-dot.failed { background: var(--zone-red); }
.status-dot.expired,
.status-dot.duplicate { background: var(--text-dim); }

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

@media (max-width: 720px) {
    .limits-row { grid-template-columns: 1fr; }
    main { padding: 16px; }
}
