:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --text: #1d2533;
    --muted: #667085;
    --border: #d8dee9;
    --primary: #1d4ed8;
    --primary-dark: #1e40af;
    --secondary: #eef2ff;
    --success: #0f9d58;
    --warning: #b45309;
    --danger: #c62828;
    --shadow: 0 16px 40px rgba(16, 24, 40, 0.08);
    --radius: 18px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, Arial, Helvetica, sans-serif;
    background: linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
    color: var(--text);
}

button,
input,
dialog,
table {
    font: inherit;
}

.page-shell {
    width: min(1200px, calc(100vw - 32px));
    margin: 32px auto;
}

.page-header,
.panel,
.operation-card,
.notice,
.modal-content,
.toast {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 28px;
    margin-bottom: 22px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
    color: var(--primary);
    margin: 0 0 8px;
    font-weight: 700;
}

h1, h2, h3, p { margin-top: 0; }

.subtitle,
.muted {
    color: var(--muted);
}

.grid-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.panel {
    padding: 24px;
    margin-bottom: 22px;
}

.panel-wide {
    padding-bottom: 8px;
    scroll-margin-top: 24px;
}

.panel-header,
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.panel-header {
    margin-bottom: 18px;
}

.stack {
    display: flex;
    flex-direction: column;
}

.gap-md { gap: 16px; }

label span {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff;
}

input:focus {
    outline: 2px solid rgba(29, 78, 216, 0.18);
    border-color: var(--primary);
}

.button-row,
.search-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-row input { flex: 1; }

.btn,
.link-btn {
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:hover,
.link-btn:hover { transform: translateY(-1px); }
.btn:disabled,
.link-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

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

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: var(--secondary);
    color: var(--primary-dark);
}

.link-btn {
    background: transparent;
    color: var(--primary);
    padding: 0;
}

.job-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.summary-item {
    background: #f8fafc;
    border-radius: 14px;
    padding: 14px;
    border: 1px solid var(--border);
}

.summary-item .label {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.summary-item .value {
    font-weight: 700;
    word-break: break-word;
}

.operations-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    padding-bottom: 18px;
}

.operation-card {
    padding: 18px;
}

.operation-card h3 {
    margin-bottom: 8px;
}

.operation-meta {
    display: grid;
    gap: 8px;
    margin: 14px 0 18px;
    color: var(--muted);
    font-size: 0.95rem;
}

.badge,
.session-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 700;
}

.badge.running,
.session-badge {
    background: rgba(15, 157, 88, 0.12);
    color: var(--success);
}

.badge.idle {
    background: rgba(29, 78, 216, 0.1);
    color: var(--primary);
}

.timer-value {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 14px 0;
}

.notice {
    padding: 14px 16px;
    margin-bottom: 18px;
    color: var(--warning);
    background: #fffbeb;
}

.modal {
    border: 0;
    padding: 0;
    border-radius: 22px;
    max-width: 560px;
    width: calc(100vw - 32px);
}

.modal-wide {
    max-width: 980px;
}

.modal::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.modal-content {
    padding: 24px;
}

.modal-actions {
    padding: 0;
    margin: 0;
}

.history-table-wrap {
    overflow-x: auto;
}

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

.history-table th,
.history-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.history-table th {
    color: var(--muted);
    font-size: 0.9rem;
}

.text-success {
    color: var(--success);
    font-weight: 700;
}

.toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: grid;
    gap: 10px;
    z-index: 999;
}

.toast {
    padding: 14px 16px;
    min-width: 260px;
}

.toast.success { border-left: 5px solid var(--success); }
.toast.error { border-left: 5px solid var(--danger); }
.toast.info { border-left: 5px solid var(--primary); }

.hidden { display: none !important; }

@media (max-width: 900px) {
    .grid-layout,
    .job-summary {
        grid-template-columns: 1fr;
    }

    .page-header,
    .button-row,
    .search-row,
    .panel-header,
    .card-head {
        flex-direction: column;
        align-items: stretch;
    }
}


.small-text {
    font-size: 0.9rem;
    margin-bottom: 0;
}

.summary-item .value a {
    color: var(--primary);
    text-decoration: none;
}

.summary-item .value a:hover {
    text-decoration: underline;
}

.processing-note {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-dark);
    font-weight: 600;
}

.processing-note::before,
.btn.is-processing::before {
    content: '';
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: spin 0.8s linear infinite;
}

.btn.is-processing {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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