:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-hover: #22262f;
    --border: #2a2e3a;
    --text: #e1e4ea;
    --text-muted: #8b8fa3;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --green: #22c55e;
    --red: #ef4444;
    --amber: #f59e0b;
    --blue: #3b82f6;
    --gray: #6b7280;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.logo span { color: var(--accent); }

nav { display: flex; gap: 8px; }

nav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.15s;
}

nav a:hover, nav a.active {
    color: var(--text);
    background: var(--surface-hover);
}

main { padding: 24px 0; }

/* Status bar */
.status-bar {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--surface);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.status-item .label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-item .value {
    font-size: 22px;
    font-weight: 700;
}

/* Client cards */
.client-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
}

.client-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.client-name {
    font-size: 18px;
    font-weight: 600;
}

.platform-badge {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--surface-hover);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* Task rows */
.task-list { padding: 0; }

.task-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--surface-hover); }

/* Status dot */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.running { background: var(--blue); animation: pulse 1.5s infinite; }
.status-dot.completed { background: var(--green); }
.status-dot.failed { background: var(--red); }
.status-dot.stopped { background: var(--amber); }
.status-dot.never { background: var(--gray); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.task-info { min-width: 0; }

.task-name {
    font-size: 14px;
    font-weight: 500;
}

.task-desc {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-meta {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
}

.task-schedule {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--surface-hover);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.btn-run { border-color: var(--green); color: var(--green); }
.btn.btn-run:hover { background: rgba(34, 197, 94, 0.1); }

.btn.btn-dry { border-color: var(--amber); color: var(--amber); }
.btn.btn-dry:hover { background: rgba(245, 158, 11, 0.1); }

.btn.btn-adv {
    padding: 6px 10px;
    border-color: var(--border);
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 1px;
}
.btn.btn-adv:hover { color: var(--accent); border-color: var(--accent); background: rgba(99, 102, 241, 0.08); }

.btn.btn-stop { border-color: var(--red); color: var(--red); }
.btn.btn-stop:hover { background: rgba(239, 68, 68, 0.1); }

.btn.btn-logs { border-color: var(--accent); color: var(--accent); }
.btn.btn-logs:hover { background: rgba(99, 102, 241, 0.1); }

.task-actions { display: flex; gap: 6px; }

/* Log viewer */
.log-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.log-controls select, .log-controls input {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font);
}

.log-viewer {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.log-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.log-content {
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.7;
    padding: 16px 20px;
    max-height: 600px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-line { padding: 1px 0; }
.log-line.ERROR { color: var(--red); }
.log-line.WARNING { color: var(--amber); }
.log-line.DEBUG { color: var(--text-muted); }
.log-line.INFO { color: var(--text); }

.log-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .task-row { grid-template-columns: auto 1fr auto; gap: 10px; }
    .task-meta, .task-schedule { display: none; }
    .status-bar { flex-wrap: wrap; gap: 16px; }
}

/* Loading indicator */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }

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

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

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    animation: slideIn 0.2s ease;
}

.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Run options modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px 28px;
    width: 440px;
    max-width: 92vw;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.modal h3 {
    font-size: 16px;
    margin-bottom: 6px;
    font-family: var(--mono);
    color: var(--text);
}

.modal-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.modal-field {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text);
}

.modal-field > span {
    display: block;
}

.modal-field > span small {
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 6px;
}

.modal-field input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    accent-color: var(--accent);
}

.modal-field:has(input[type="checkbox"]) {
    flex-direction: row;
    align-items: center;
}

.modal-field input[type="date"],
.modal-field input[type="text"] {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 13px;
    color-scheme: dark;
}

.modal-field input[type="date"]:focus,
.modal-field input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-hint {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
