:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-hover: #222533;
    --border: #2a2d3a;
    --text: #e1e4ed;
    --text-muted: #6b7084;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --error: #ef4444;
    --info: #3b82f6;
    --radius: 8px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}

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

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

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

code, pre {
    font-family: var(--mono);
    font-size: 0.875rem;
}

pre {
    background: var(--bg);
    padding: 0.75rem;
    border-radius: var(--radius);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Navbar */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text) !important;
    letter-spacing: -0.02em;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.nav-link {
    font-size: 1.0625rem;
    color: var(--text-muted) !important;
    font-weight: 600;
}

.nav-link:hover {
    color: var(--text) !important;
}

.nav-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
    text-decoration: none;
    white-space: nowrap;
}

.btn-sm { padding: 0.25rem 0.625rem; font-size: 0.8125rem; }
.btn-block { width: 100%; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; color: #fff; }

.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { opacity: 0.9; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9375rem;
    font-family: var(--font);
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

textarea { resize: vertical; font-family: var(--mono); }
select { cursor: pointer; }

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.form-hint code {
    background: var(--bg);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 1rem;
}

.form-fieldset {
    border: none;
    padding: 0;
    margin: 0 0 1rem;
}

.form-fieldset legend {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Auth card */
.auth-card {
    max-width: 400px;
    margin: 4rem auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

.auth-card h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Form card */
.form-card {
    max-width: 700px;
    margin: 2rem auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

.form-card h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 2rem 0 1.5rem;
}

.dashboard-header h1 {
    font-size: 1.75rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.empty-state h2 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    vertical-align: middle;
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

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

/* Job cards */
.job-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.job-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.job-card:hover {
    border-color: var(--text-muted);
}

.job-card-row1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.75rem;
}

.job-card-left {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
}

.job-card-name {
    font-size: 1.0625rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-card-actions {
    display: flex;
    gap: 0.375rem;
    flex-shrink: 0;
}

.job-card-row2 {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.job-card-url {
    font-family: var(--mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 400px;
}

.job-card-meta {
    white-space: nowrap;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-error { background: rgba(239, 68, 68, 0.15); color: var(--error); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge-muted { background: rgba(107, 112, 132, 0.15); color: var(--text-muted); }

/* Job Detail */
.job-detail {
    margin: 2rem 0;
}

.job-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.job-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.job-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.job-actions .btn {
    height: 36px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.detail-card h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

dt {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
}

dd {
    font-size: 0.875rem;
    word-break: break-all;
}

/* Logs */
.logs-section {
    margin-top: 2rem;
}

.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.logs-header h2 {
    font-size: 1.25rem;
}

.table-logs {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.log-success { border-left: 3px solid var(--success); }
.log-failure { border-left: 3px solid var(--error); }

.log-body {
    max-width: 400px;
    font-family: var(--mono);
    font-size: 0.8125rem;
}

.log-body details summary {
    cursor: pointer;
    color: var(--text-muted);
}

.log-body pre {
    margin-top: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.text-muted { color: var(--text-muted); }
.text-error { color: var(--error); }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
}

.pagination-info {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Tag filter bar */
.tag-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 1.25rem;
}

.tag-filter-active {
    font-weight: 700;
}

.tag-filter-inactive {
    opacity: 0.55;
}

.tag-filter-inactive:hover {
    opacity: 0.85;
}

.tag-tiny {
    font-size: 0.6875rem;
    padding: 0.0625rem 0.375rem;
}

.job-card-tags {
    display: inline-flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

/* Header key-value rows */
.header-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.header-key {
    flex: 0 0 35%;
}

.header-value {
    flex: 1;
}

.header-remove {
    flex-shrink: 0;
    width: 32px;
    padding: 0.25rem;
}

/* Tags */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.tag-active {
    cursor: pointer;
}

.tag-active:hover {
    opacity: 0.75;
}

.tag-inactive {
    background: transparent;
    cursor: pointer;
    opacity: 0.5;
}

.tag-inactive:hover {
    opacity: 0.85;
}

.tag-toggle-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.tag-remove {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0 0.125rem;
    opacity: 0.7;
    line-height: 1;
}

.tag-remove:hover { opacity: 1; }

.tags-section {
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.tag-add-form {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.tag-select {
    padding: 0.2rem 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.8125rem;
}

.tag-create-form .form-row {
    align-items: end;
}

.color-input {
    width: 100%;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    cursor: pointer;
}

.color-preview {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 0.375rem;
}

/* Icon buttons */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    text-decoration: none;
    transition: all 0.15s;
    font-family: var(--font);
}

.btn-icon:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-icon-danger:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.actions-icon-cell {
    display: flex;
    gap: 0.375rem;
    align-items: center;
}

/* Responsive */
@media (max-width: 768px) {
    .detail-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .job-header { flex-direction: column; }
    .dashboard-header { flex-direction: column; gap: 1rem; align-items: flex-start; }
}
