:root {
    --bg: #f8f9fb;
    --surface: #ffffff;
    --surface-hover: #f3f4f8;
    --border: #e5e7eb;
    --border-light: #f0f1f4;
    --text: #1e293b;
    --text-muted: #94a3b8;
    --text-secondary: #64748b;
    --blue: #3e7ed8;
    --blue-light: rgba(62,126,216,0.08);
    --green: #16a34a;
    --green-light: rgba(22,163,74,0.07);
    --red: #dc2626;
    --red-light: rgba(220,38,38,0.06);
    --orange: #ea580c;
    --orange-light: rgba(234,88,12,0.07);
    --purple: #7c3aed;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ── Header ────────────────────────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.app-logo {
    height: 32px;
    width: auto;
    opacity: 0.9;
}

h1 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

.env-badge {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--blue);
    background: var(--blue-light);
    border: 1px solid rgba(62,126,216,0.15);
    padding: 0.18rem 0.5rem;
    border-radius: 4px;
}

/* ── Service pills ─────────────────────────────────────────────── */
.services-status {
    display: flex;
    gap: 0.45rem;
}

.service-pill {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.6rem;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: all 0.3s;
    cursor: default;
    box-shadow: var(--shadow-sm);
}

.pill-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
    flex-shrink: 0;
}

.service-pill.ok .pill-dot   { background: var(--green); box-shadow: 0 0 5px rgba(22,163,74,0.35); }
.service-pill.err .pill-dot  { background: var(--red); }
.service-pill.warn .pill-dot { background: var(--orange); }
.service-pill.live .pill-dot {
    background: var(--green);
    box-shadow: 0 0 5px rgba(22,163,74,0.35);
    animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.35; }
}

.service-pill.ok   { color: var(--text-secondary); border-color: rgba(22,163,74,0.15); }
.service-pill.err  { border-color: rgba(220,38,38,0.15); }
.service-pill.live { color: var(--text-secondary); border-color: rgba(22,163,74,0.15); }

/* ── Feed header ───────────────────────────────────────────────── */
.feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.feed-header h2 {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.btn-refresh {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 1rem;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}
.btn-refresh:hover {
    color: var(--text);
    border-color: var(--border);
    background: var(--surface-hover);
}
.btn-refresh.spinning {
    animation: spin 0.6s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Feed ──────────────────────────────────────────────────────── */
.workflow-feed {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.feed-empty {
    text-align: center;
    padding: 5rem 2rem;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.feed-empty p {
    font-size: 0.92rem;
    margin-bottom: 0.45rem;
    color: var(--text-secondary);
}
.feed-empty small {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ── Workflow card ──────────────────────────────────────────────── */
.wf-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.35rem 1.5rem 1.15rem;
    animation: slide-in 0.35s ease;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-shadow: var(--shadow-sm);
}
.wf-card:hover {
    border-color: #d1d5db;
    box-shadow: var(--shadow-md);
}
.wf-card.has-error {
    border-left: 3px solid var(--red);
}
.wf-card.is-success {
    border-left: 3px solid var(--green);
}
.wf-card.is-running {
    border-left: 3px solid var(--blue);
}

@keyframes slide-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

.wf-meta { flex: 1; min-width: 0; }

.wf-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wf-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 0.1rem;
}

.wf-email-subject {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wf-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
    flex-shrink: 0;
}

.wf-amount {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.wf-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Workflow step rows ────────────────────────────────────────── */
.wf-rows {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.wf-group-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
}

/* ── Stepper ───────────────────────────────────────────────────── */
.stepper {
    display: flex;
    align-items: flex-start;
}

.step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Connector line */
.step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 11px;
    left: calc(50% + 12px);
    right: calc(-50% + 12px);
    height: 1.5px;
    background: var(--border);
    transition: background 0.4s;
}
.step.done:not(:last-child)::after   { background: var(--green); opacity: 0.45; }
.step.error:not(:last-child)::after  { background: var(--red); opacity: 0.35; }

.step-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    z-index: 1;
    transition: all 0.3s;
    color: var(--text-muted);
}

.step.pending .step-dot  { border-color: var(--border); color: transparent; }
.step.running .step-dot  {
    border-color: var(--blue);
    color: var(--blue);
    box-shadow: 0 0 0 3px rgba(62,126,216,0.1);
    animation: pulse-step 1.2s infinite;
}
.step.done .step-dot     { border-color: var(--green); background: var(--green); color: #fff; }
.step.error .step-dot    { border-color: var(--red); background: var(--red); color: #fff; }
.step.skipped .step-dot  { border-color: var(--border-light); color: var(--text-muted); background: var(--bg); }

@keyframes pulse-step {
    0%, 100% { box-shadow: 0 0 0 3px rgba(62,126,216,0.1); }
    50%       { box-shadow: 0 0 0 6px rgba(62,126,216,0.04); }
}

.step-label {
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    text-align: center;
    line-height: 1.25;
    max-width: 74px;
}
.step.done .step-label    { color: var(--text-secondary); }
.step.error .step-label   { color: var(--red); }
.step.running .step-label { color: var(--blue); }

.step-detail {
    font-size: 0.58rem;
    color: var(--text-muted);
    margin-top: 0.12rem;
    text-align: center;
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.7;
}
.step.error .step-detail { color: var(--red); opacity: 0.6; }

/* ── Step not-configured ───────────────────────────────────────── */
.step.not-configured .step-dot {
    border: 1.5px dashed var(--border);
    color: var(--border);
    background: var(--bg);
}
.step.not-configured .step-label {
    color: #c8ccd3;
}
.step.not-configured:not(:last-child)::after {
    background: var(--border-light);
    opacity: 0.5;
}

/* ── Footer ────────────────────────────────────────────────────── */
.app-footer {
    margin-top: 3rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    opacity: 0.5;
    transition: opacity 0.3s;
}
.app-footer:hover {
    opacity: 1;
}
.app-footer code {
    font-size: 0.68rem;
    color: var(--text-secondary);
    background: rgba(0,0,0,0.03);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}
