/* CMP admin — plain CSS, no build step */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #e1e4e9;
    --text: #1d2330;
    --muted: #677184;
    --accent: #2457d6;
    --accent-hover: #1b46b3;
    --accent-soft: #e8eefc;
    --ok: #18794e;
    --ok-soft: #e3f4ea;
    --warn: #9a5b00;
    --warn-soft: #fdf1dc;
    --err: #c0352b;
    --err-soft: #fde8e6;
    --info-soft: #eef0f4;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151b;
        --surface: #1a1e26;
        --surface-2: #222733;
        --border: #2d3340;
        --text: #e6e9ef;
        --muted: #98a1b3;
        --accent: #7aa2ff;
        --accent-hover: #9bb9ff;
        --accent-soft: #1f2a44;
        --ok: #4cc38a;
        --ok-soft: #173326;
        --warn: #f0b04f;
        --warn-soft: #3a2c13;
        --err: #ff7b72;
        --err-soft: #3d1d1b;
        --info-soft: #232835;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .75rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code, .mono { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* layout */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
    max-width: 1240px; margin: 0 auto; padding: 0 20px;
    display: flex; align-items: center; gap: 24px; min-height: 58px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark {
    height: 28px; padding: 0 7px; border-radius: 8px; background: var(--accent); color: #fff;
    display: inline-grid; place-items: center; font-size: .75rem; font-weight: 700; letter-spacing: .04em;
}
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
    padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .9rem; }
.container { max-width: 1240px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* cards & grid */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card > h2:first-child { margin-top: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > h2 { padding: 16px 20px 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); margin-bottom: 20px; }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); }
.grid.clients { grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); }
.grid-2 { display: grid; gap: 20px; grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.6rem; font-weight: 650; margin-top: 2px; }
.client-card { display: flex; flex-direction: column; gap: 12px; }
.client-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.client-card h3 { margin: 0; font-size: 1.05rem; }
.counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.counts div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.counts b { display: block; font-size: 1.05rem; }
.counts span { color: var(--muted); font-size: .78rem; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-link { color: inherit; }

/* badges */
.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
    font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--info-soft); color: var(--muted);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.success, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warning { background: var(--warn-soft); color: var(--warn); }
.badge.failed, .badge.error { background: var(--err-soft); color: var(--err); }
.badge.running { background: var(--accent-soft); color: var(--accent); }
.badge.running::before { animation: pulse 1.2s infinite; }
.badge.plain::before { display: none; }
@keyframes pulse { 50% { opacity: .3; } }
.count-pill { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 999px; font-size: .78rem; font-weight: 600; text-align: center; }
.count-pill.warning { background: var(--warn-soft); color: var(--warn); }
.count-pill.error { background: var(--err-soft); color: var(--err); }
.count-pill.zero { color: var(--muted); }

/* buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 550; font-size: .9rem;
    cursor: pointer; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { color: var(--err); }
.btn-danger:hover { background: var(--err-soft); color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
form.inline { display: inline; }

/* forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
label { font-weight: 600; font-size: .88rem; }
.hint { color: var(--muted); font-size: .8rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select, textarea {
    width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; }
.error-text { color: var(--err); font-size: .82rem; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

/* alerts */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; border: 1px solid transparent; }
.alert-success { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--err-soft); color: var(--err); }
.alert-info { background: var(--accent-soft); color: var(--accent); }

/* filters & tabs */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters select { width: auto; min-width: 160px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 16px; flex-wrap: wrap; }
.tabs a { padding: 10px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* log */
.log { font-size: .88rem; }
.log td { padding: 8px 14px; }
.log .lvl { width: 92px; }
.log .when { width: 98px; color: var(--muted); font-family: var(--mono); font-size: .8rem; }
.log .step { width: 104px; color: var(--muted); }
.log .item { width: 130px; font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.log tr.error td { background: color-mix(in srgb, var(--err-soft) 45%, transparent); }
.log tr.warning td { background: color-mix(in srgb, var(--warn-soft) 40%, transparent); }
.log details { margin-top: 6px; }
.log summary { cursor: pointer; color: var(--muted); font-size: .8rem; }
.log pre {
    margin: 6px 0 0; padding: 10px 12px; background: var(--surface-2); border-radius: 8px;
    overflow-x: auto; font-size: .78rem; max-height: 340px;
}
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.token { font-family: var(--mono); font-size: .85rem; word-break: break-all; }

/* pagination (Laravel simple markup) */
.pagination-wrap { padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pager { display: flex; gap: 6px; }

/* small screens */
@media (max-width: 700px) {
    .topbar-inner { gap: 6px 12px; padding: 10px 16px; }
    .nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; }
    .user { margin-left: auto; }
    .user span { display: none; }
    .container { padding: 20px 16px 48px; }
    .grid.stats { grid-template-columns: 1fr 1fr; }
    .stat .value { font-size: 1.3rem; }
    .kv { grid-template-columns: 1fr; gap: 0; }
    .kv dd { margin-bottom: 8px; }
}

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }
.auth h1 { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth form { display: grid; gap: 14px; margin-top: 18px; }

/* clickable rows */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }

/* live progress */
.alert-warning { background: var(--warn-soft); color: var(--warn); }
.live { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.live-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.live-label { margin: 10px 0 0; }
.live .alert { margin: 14px 0 0; }
.step-track { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; counter-reset: step; }
.step-track li {
    counter-increment: step; display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px 4px 6px; border-radius: 999px; font-size: .82rem; font-weight: 600;
    background: var(--surface-2); color: var(--muted);
}
.step-track li::before {
    content: counter(step); width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center;
    font-size: .72rem; background: var(--border); color: var(--muted);
}
.step-track li.done { background: var(--ok-soft); color: var(--ok); }
.step-track li.done::before { content: "✓"; background: var(--ok); color: var(--surface); }
.step-track li.failed { background: var(--err-soft); color: var(--err); }
.step-track li.failed::before { content: "!"; background: var(--err); color: var(--surface); }
.step-track li.running { background: var(--accent-soft); color: var(--accent); }
.step-track li.running::before { background: var(--accent); color: var(--surface); animation: pulse 1.2s infinite; }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s ease; }
.bar-sm { height: 6px; }
.bar.indeterminate > span {
    width: 100% !important;
    background: linear-gradient(90deg, transparent 0, var(--accent) 40%, transparent 80%) 0 0 / 50% 100% no-repeat;
    animation: slide 1.4s linear infinite;
}
@keyframes slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }
@media (prefers-reduced-motion: reduce) {
    .bar > span { transition: none; }
    .bar.indeterminate > span { animation: none; background: var(--accent); opacity: .35; }
    .step-track li.running::before, .badge.running::before { animation: none; }
}
.mini-progress { display: grid; gap: 6px; min-width: 220px; }
tr.current td { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
a.count-pill:hover { text-decoration: none; filter: brightness(.95); outline: 1px solid currentColor; }
.filter-chip {
    align-self: center; margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .82rem; font-weight: 600;
}
.filter-chip a { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; padding: 0; margin: 0; border: 0; color: inherit; }
.filter-chip a:hover { background: var(--surface); text-decoration: none; }
