* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f5f7fa;
    color: #1f2937;
}

/* ----------------------------------------------------------
           Header
        ---------------------------------------------------------- */
.header {
    background: #111827;
    color: white;
    padding: 20px 28px;
}

.header h1 {
    margin: 0;
    font-size: 24px;
}

.header .subtitle {
    margin-top: 5px;
    color: #9ca3af;
    font-size: 13px;
}

/* ----------------------------------------------------------
           Main
        ---------------------------------------------------------- */
.container {
    padding: 24px;
}

/* ----------------------------------------------------------
           Toolbar
        ---------------------------------------------------------- */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search {
    flex: 1;
    min-width: 250px;
    padding: 10px 13px;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    font-size: 14px;
    background: white;
}

.refresh-button {
    padding: 10px 15px;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    background: white;
    cursor: pointer;
    font-size: 14px;
}

.refresh-button:hover {
    background: #f3f4f6;
}

.job-count {
    padding: 10px 14px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 7px;
    font-size: 14px;
}

/* ----------------------------------------------------------
           Table
        ---------------------------------------------------------- */
.table-container {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 9px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

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

th {
    background: #f9fafb;
    text-align: left;
    padding: 12px 14px;
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #e5e7eb;
}

td {
    padding: 13px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

tbody tr:hover {
    background: #f3f4f6;
}

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

.id {
    font-family: monospace;
    font-weight: 600;
}

.tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e0e7ff;
    color: #3730a3;
    font-size: 12px;
}

.no-tag {
    color: #9ca3af;
}

/* ----------------------------------------------------------
           Loading / errors
        ---------------------------------------------------------- */
.loading {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

.error {
    margin-bottom: 16px;
    padding: 12px 15px;
    border-radius: 7px;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ----------------------------------------------------------
           Modal
        ---------------------------------------------------------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1000;
    padding: 30px;
}

.modal.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    width: min(1400px, 96vw);
    height: min(900px, 94vh);
    background: white;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.modal-title {
    font-size: 19px;
    font-weight: 600;
}

.modal-subtitle {
    color: #6b7280;
    font-size: 13px;
    margin-top: 3px;
}

.close-button {
    border: none;
    background: #f3f4f6;
    width: 34px;
    height: 34px;
    border-radius: 7px;
    font-size: 20px;
    cursor: pointer;
}

.close-button:hover {
    background: #e5e7eb;
}

/* ----------------------------------------------------------
           Job details
        ---------------------------------------------------------- */
.job-details {
    padding: 14px 20px;
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.detail {
    font-size: 13px;
}

.detail-label {
    color: #6b7280;
    margin-right: 5px;
}

.detail-value {
    font-weight: 600;
}

/* ----------------------------------------------------------
           DAG toolbar
        ---------------------------------------------------------- */
.dag-toolbar {
    padding: 10px 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.dag-button {
    padding: 6px 11px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 6px;
    cursor: pointer;
}

.dag-button:hover {
    background: #f3f4f6;
}

.dag-help {
    margin-left: auto;
    color: #6b7280;
    font-size: 12px;
}

/* ----------------------------------------------------------
           DAG
        ---------------------------------------------------------- */
#dag {
    flex: 1;
    min-height: 0;
    position: relative;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.025) 1px, transparent 1px), linear-gradient(rgba(0, 0, 0, 0.025) 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: hidden;
}

#dag svg {
    width: 100%;
    height: 100%;
}

.node rect {
    stroke-width: 1.5;
    rx: 8;
    ry: 8;
}

.node text {
    pointer-events: none;
    user-select: none;
}

.node-id {
    font-size: 12px;
    font-weight: 700;
    fill: #111827;
}

.node-description {
    font-size: 12px;
    fill: #374151;
}

.node-command {
    font-size: 10px;
    fill: #6b7280;
}

.link {
    fill: none;
    stroke: #6b7280;
    stroke-width: 1.8;
    marker-end: url(#arrow);
}

.optional-badge {
    font-size: 9px;
    fill: #92400e;
}

.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    font-size: 15px;
}

/* ----------------------------------------------------------
           Tooltip
        ---------------------------------------------------------- */
.tooltip {
    position: fixed;
    display: none;
    pointer-events: none;
    background: #111827;
    color: white;
    padding: 10px 12px;
    border-radius: 7px;
    font-size: 12px;
    max-width: 400px;
    z-index: 3000;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25);
}

.tooltip strong {
    color: #d1d5db;
}

/* ----------------------------------------------------------
           Responsive
        ---------------------------------------------------------- */
@media (max-width: 700px) {
    .container {
        padding: 12px;
    }

    .modal {
        padding: 8px;
    }

    .modal-content {
        width: 100%;
        height: 100%;
    }

    .dag-help {
        display: none;
    }
}

.action-button {
    border: 1px solid #d1d5db;
    background: white;
    color: #374151;
    padding: 5px 9px;
    border-radius: 5px;
    cursor: pointer;
    margin-right: 5px;
    font-size: 12px;
}

.action-button:hover {
    background: #f3f4f6;
}

.action-button.danger {
    color: #b91c1c;
    border-color: #fecaca;
}

.action-button.danger:hover {
    background: #fef2f2;
}

.form-field {
    width: 100%;
    padding: 9px;
    margin-top: 5px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}
