/* ============================================================
   Refined design system — calm, delicate, professional (RTL)
   ============================================================ */
:root {
    /* accent — a single refined indigo, used sparingly */
    --accent:      #4c53c6;
    --accent-2:    #6b73e0;
    --accent-weak: #eef0fb;
    --accent-ring: rgba(76, 83, 198, 0.16);

    /* neutrals */
    --bg:        #f5f6f8;
    --surface:   #ffffff;
    --surface-2: #fafbfc;
    --border:    #e7e9ee;
    --border-2:  #eef0f3;

    --text:      #1f2430;
    --text-soft: #5b6472;
    --text-mute: #9aa1ac;

    /* semantic (muted) */
    --ok:      #2f9e5f;
    --ok-weak: #e9f6ee;
    --warn:      #b7791f;
    --warn-weak: #fbf1e0;
    --danger:      #d0494f;
    --danger-weak: #fbe9ea;
    --info:      #2a72b5;
    --info-weak: #e8f1fb;

    /* form */
    --radius:    14px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
    --shadow:    0 1px 3px rgba(16,24,40,.05), 0 10px 28px rgba(16,24,40,.05);
}

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

body {
    font-family: 'Segoe UI', 'Assistant', Tahoma, system-ui, sans-serif;
    direction: rtl;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 1280px; margin: 0 auto; }

/* ==================== App shell + sidebar ==================== */
.app-shell { display: flex; align-items: stretch; min-height: 100vh; }
.app-shell.no-nav { display: block; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    width: 232px; flex: 0 0 232px;
    background: var(--surface);
    border-inline-start: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 18px 14px;
    z-index: 40;
}
.brand {
    display: flex; flex-direction: column; align-items: center; gap: 9px;
    padding: 4px 8px 18px; text-align: center;
}
/* The logo file is the brand's own asset, served byte-identical to biaivision.com/logo.svg.
   Its viewBox is 200x240: the rounded square occupies the top ~185, and the "to B AI or not
   to B" tagline sits below it. At sidebar size the tagline would render ~7px tall, so it's
   cropped here presentationally (cover + top) rather than by editing the file — the full
   lockup, tagline included, still shows on the login screen where there's room for it. */
.brand-logo {
    width: 96px; aspect-ratio: 200 / 185;
    object-fit: cover; object-position: top center;
}
.brand-name {
    font-size: 13px; font-weight: 600; letter-spacing: .02em;
    color: var(--text-mute);
}
/* Legacy mark, kept so any template still rendering it doesn't lose its styling. */
.brand-mark {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--accent); color: #fff;
    display: grid; place-items: center; font-size: 19px; font-weight: 700;
}

/* min-height:0 lets this flex child shrink below its content height so overflow-y can
   take effect — without it the nav grows past the viewport and the bottom items (הגדרות
   among them) are clipped off-screen with no way to reach them. The scrollbar is thin and
   only appears when the item count actually exceeds the height. */
.side-nav {
    display: flex; flex-direction: column; gap: 2px;
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin;
}
.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: 9px;
    color: var(--text-soft); text-decoration: none;
    font-size: 14.5px; font-weight: 500;
    transition: background .13s, color .13s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.nav-link .ic {
    width: 22px; text-align: center; font-size: 15px; opacity: .9;
    flex: 0 0 22px;
}
.sidebar-foot {
    border-top: 1px solid var(--border-2); padding-top: 14px; margin-top: 8px;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sidebar-foot .who { font-size: 13.5px; font-weight: 600; color: var(--text-soft);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-version {
    font-size: 11px; color: var(--text-mute); text-align: center;
    padding-top: 8px; letter-spacing: .02em;
}

.main { flex: 1 1 auto; min-width: 0; padding: 26px 30px 48px; }
.no-nav .main { padding: 0; }
.flash-wrap { max-width: 1280px; margin: 0 auto 18px; }

.sidebar-toggle {
    display: none; position: fixed; top: 14px; inset-inline-start: 14px; z-index: 60;
    width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font-size: 18px; cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.nav-scrim { display: none; }

/* Inner admin pages: drop the legacy card wrapper + duplicate header nav
   (the sidebar now provides navigation, so per-page nav/logout is redundant). */
.app-shell:not(.no-nav) .dashboard {
    background: transparent; border: none; box-shadow: none; padding: 0;
}
.app-shell:not(.no-nav) .container { max-width: none; }
.app-shell:not(.no-nav) .header {
    border-bottom: none; padding-bottom: 0; margin-bottom: 20px; align-items: flex-start;
}
.app-shell:not(.no-nav) .header .user-info { display: none; }
.app-shell:not(.no-nav) .header h1 {
    font-size: 23px; letter-spacing: -0.015em;
}

/* ==================== Page header (in-content) ==================== */
.page-head {
    display: flex; justify-content: space-between; align-items: flex-end;
    flex-wrap: wrap; gap: 14px; margin-bottom: 22px;
}
.page-head .titles h1 {
    font-size: 23px; font-weight: 700; letter-spacing: -0.015em; color: var(--text);
}
.page-head .titles p { color: var(--text-mute); font-size: 14px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ==================== KPI cards ==================== */
.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.kpi {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.kpi .kpi-label { font-size: 13px; color: var(--text-soft); font-weight: 600;
    display: flex; align-items: center; gap: 8px; }
.kpi .kpi-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--accent); }
.kpi .kpi-val { font-size: 27px; font-weight: 700; letter-spacing: -0.02em;
    margin-top: 8px; color: var(--text); }
.kpi .kpi-sub { font-size: 12.5px; color: var(--text-mute); margin-top: 4px; }
.kpi.ok  .kpi-dot { background: var(--ok); }
.kpi.warn .kpi-dot { background: var(--warn); }
.kpi.info .kpi-dot { background: var(--info); }

/* ==================== Panels & charts ==================== */
.panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 20px 22px; margin-bottom: 22px;
}
.panel > h2, .panel-title {
    font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 16px;
    letter-spacing: -0.01em;
}
.panel-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 22px;
}

/* horizontal bar chart (pure CSS) */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 12px; }
.bar-row .bar-label { font-size: 13.5px; color: var(--text-soft); font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-2); border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent);
    background-image: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bar-row .bar-val { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.bar-fill.ok { background: var(--ok); background-image: none; }
.bar-fill.warn { background: var(--warn); background-image: none; }

/* legend + donut */
.legend { display: flex; flex-direction: column; gap: 9px; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-soft); }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 11px; }
.legend-item .val { margin-inline-start: auto; font-weight: 600; color: var(--text); }
.chart-flex { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }

/* ---------- Login ---------- */
.login-container {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; padding: 20px;
}
.login-box {
    background: var(--surface);
    padding: 44px 40px;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    max-width: 400px; width: 100%;
}
.login-logo { display: block; width: 132px; margin: 0 auto 18px; }
.login-box h1 {
    text-align: center; color: var(--text);
    margin-bottom: 32px; font-size: 20px; font-weight: 700;
    letter-spacing: -0.01em;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; margin-bottom: 7px;
    color: var(--text-soft); font-weight: 600; font-size: 14px;
}
.form-group input,
textarea, select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 96px; }
select { cursor: pointer; }
.form-group input:focus,
textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}
.form-group input::placeholder, textarea::placeholder { color: var(--text-mute); }
small { font-size: 12.5px; }

/* ---------- Buttons ---------- */
.btn {
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14.5px; font-weight: 600;
    cursor: pointer; text-decoration: none;
    display: inline-block; line-height: 1.2;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:active { transform: translateY(.5px); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #3f46b0; }
/* The login button is the full-width one — that's a property of that form, not of
   .btn-primary itself. Scoped here so primary buttons in toolbars stay inline. */
.login-box .btn-primary { width: 100%; padding: 12px 18px; font-size: 15px; }

.btn-success { background: var(--ok); color: #fff; }
.btn-success:hover { background: #278a51; }

.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-weak); border-color: #f0c9cb; }

.btn-secondary { background: var(--surface); color: var(--text-soft); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: #d9dce2; color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- Dashboard shell ---------- */
.dashboard {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
}
.header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 14px;
    margin-bottom: 26px; padding-bottom: 18px;
    border-bottom: 1px solid var(--border-2);
}
.header h1 {
    color: var(--text); font-size: 22px; font-weight: 700;
    letter-spacing: -0.01em;
}
.user-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-info span { color: var(--text-soft); font-weight: 600; font-size: 14px; }

/* ---------- Nav tabs ---------- */
.nav-tabs {
    display: flex; gap: 6px; flex-wrap: wrap;
    margin-bottom: 26px;
    border-bottom: 1px solid var(--border-2);
    padding-bottom: 12px;
}
.nav-tab {
    padding: 8px 16px;
    background: transparent; border: none;
    color: var(--text-soft); cursor: pointer;
    font-size: 14.5px; font-weight: 600;
    border-radius: 8px; text-decoration: none;
    transition: background .15s, color .15s;
}
.nav-tab:hover { background: var(--surface-2); color: var(--text); }
.nav-tab.active { background: var(--accent-weak); color: var(--accent); }

/* ---------- Stat cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px; margin-bottom: 28px;
}
/* unified with .kpi — clean white card + a small colored dot on the label */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.stat-card h3 {
    font-size: 13px; font-weight: 600; color: var(--text-soft);
    margin-bottom: 8px; display: flex; align-items: center; gap: 8px;
}
.stat-card h3::before {
    content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--accent); flex: 0 0 auto;
}
.stat-card .number {
    font-size: 27px; font-weight: 700; color: var(--text);
    letter-spacing: -0.02em; line-height: 1.1;
}
.stat-card.green  h3::before { background: var(--ok); }
.stat-card.orange h3::before { background: var(--warn); }
.stat-card.blue   h3::before { background: var(--info); }

/* ---------- Tables ---------- */
.table-container {
    overflow-x: auto; margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
table { width: 100%; border-collapse: collapse; background: var(--surface); }
table thead { background: var(--surface-2); }
table th {
    padding: 12px 14px; text-align: right;
    font-weight: 600; font-size: 12.5px;
    color: var(--text-soft); letter-spacing: .01em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table td {
    padding: 12px 14px; text-align: right; font-size: 14.5px;
    border-bottom: 1px solid var(--border-2);
    color: var(--text);
}
table tbody tr:last-child td { border-bottom: none; }
table tbody tr { transition: background .12s; }
table tbody tr:hover { background: var(--surface-2); }

/* ---------- Badges ---------- */
.badge {
    padding: 4px 11px; border-radius: 999px;
    font-size: 12px; font-weight: 600; display: inline-block;
    border: 1px solid transparent;
}
.badge-success { background: var(--ok-weak);     color: #217a48; border-color: #d6ecdf; }
.badge-warning { background: var(--warn-weak);   color: #8a5e14; border-color: #f0e2c6; }
.badge-danger  { background: var(--danger-weak); color: #b23a40; border-color: #f0cdcf; }
.badge-info    { background: var(--info-weak);   color: #22608f; border-color: #d5e5f5; }

/* ---------- Alerts ---------- */
.alert {
    padding: 13px 16px; border-radius: var(--radius-sm);
    margin-bottom: 18px; font-weight: 500; font-size: 14.5px;
    border: 1px solid transparent;
}
.alert-success { background: var(--ok-weak);     color: #216c42; border-color: #cfe8d8; }
.alert-danger  { background: var(--danger-weak); color: #a9373d; border-color: #f0cdcf; }
.alert-info    { background: var(--info-weak);   color: #215d88; border-color: #d1e2f2; }
.alert-warning { background: var(--warn-weak);   color: #7d5512; border-color: #ecdcbe; }

/* ---------- Form container ---------- */
.form-container {
    background: var(--surface);
    padding: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    max-width: 760px; margin: 0 auto;
}
.form-container h2 {
    color: var(--text); margin-bottom: 24px;
    font-size: 21px; font-weight: 700; letter-spacing: -0.01em;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px; margin-bottom: 18px;
}
fieldset legend { font-weight: 600; }

/* ---------- Actions ---------- */
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.action-buttons { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* ---------- Invoice ---------- */
.invoice-container {
    background: var(--surface);
    padding: 48px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    max-width: 860px; margin: 0 auto;
}
.invoice-header {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px;
    margin-bottom: 32px; padding-bottom: 20px;
    border-bottom: 2px solid var(--accent-weak);
}
.invoice-header h1 { color: var(--text); font-size: 28px; font-weight: 700; }
.invoice-details {
    display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-bottom: 32px;
}
.invoice-section h3 { color: var(--accent); margin-bottom: 8px; font-size: 15px; }
.invoice-items { margin-bottom: 26px; }
.invoice-total { text-align: left; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.invoice-total .total-row {
    display: flex; justify-content: space-between;
    font-size: 21px; font-weight: 700; color: var(--accent); margin-top: 8px;
}

/* ---------- Dynamic invoice item rows ---------- */
.invoice-items-container { margin-top: 18px; }
.invoice-item-row {
    display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 10px; margin-bottom: 14px; align-items: end;
}
.btn-add-item { margin-top: 14px; }

/* ============================================================
   Automations
   ------------------------------------------------------------
   A workflow reads top-to-bottom as one sentence: WHEN something happens,
   THEN these stages run in order. The spine (--wf-spine) is what carries that
   reading — a single vertical line threading the trigger through every stage,
   with numbered nodes sitting on it. Everything else stays quiet so the spine
   and the content do the talking.

   Tokens only — no literal hex. This screen drifted to a foreign slate/blue
   palette once already; keep it on the app's own accent.
   ============================================================ */
:root {
    --wf-rail:  248px;
    --wf-spine: 2px;
}

.wf-layout {
    display: grid; grid-template-columns: var(--wf-rail) minmax(0, 1fr);
    gap: 20px; align-items: start;
}

/* ---------- workflow rail ---------- */
.wf-rail { display: flex; flex-direction: column; gap: 6px; position: sticky; top: 26px; }
.wf-rail-head {
    font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
    color: var(--text-mute); padding: 0 4px 6px;
}
.wf-item {
    display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px;
    align-items: start; padding: 11px 13px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); text-decoration: none; color: var(--text);
    position: relative; transition: border-color .13s, background .13s, box-shadow .13s;
}
.wf-item:hover { border-color: #d9dce2; background: var(--surface-2); }
.wf-item.active {
    border-color: var(--accent); background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-ring);
}
/* the active marker rides the inline-start edge — RTL-safe via logical props */
.wf-item.active::before {
    content: ""; position: absolute; inset-block: 10px; inset-inline-start: -1px;
    width: 3px; border-radius: 3px; background: var(--accent);
}
.wf-dot {
    width: 7px; height: 7px; border-radius: 50%; margin-top: 6px;
    background: var(--text-mute); flex: 0 0 7px;
}
.wf-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-weak); }
.wf-item-name {
    font-size: 14px; font-weight: 600; line-height: 1.35;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wf-item-meta {
    font-size: 12px; color: var(--text-mute); margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- editor toolbar ---------- */
.wf-toolbar {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
    position: sticky; top: 26px; z-index: 20;
}
.wf-name-input {
    flex: 1 1 200px; min-width: 160px; width: auto;
    font-size: 16.5px; font-weight: 700; letter-spacing: -0.01em;
    border: 1px solid transparent; background: transparent;
    padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text);
}
.wf-name-input:hover { background: var(--surface-2); }
.wf-name-input:focus {
    background: var(--surface); border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring); outline: none;
}
.wf-toolbar-sep { flex: 1 1 auto; }

/* enabled switch — a real toggle, not a button that says "on" */
.wf-switch {
    display: inline-flex; align-items: center; gap: 9px;
    padding: 6px 11px 6px 8px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface);
    font-size: 13px; font-weight: 600; color: var(--text-soft);
    transition: background .15s, border-color .15s, color .15s;
}
.wf-switch:hover { border-color: #d9dce2; background: var(--surface-2); }
.wf-switch .track {
    width: 32px; height: 18px; border-radius: 999px; background: #d9dce2;
    position: relative; transition: background .18s; flex: 0 0 32px;
}
.wf-switch .track::after {
    content: ""; position: absolute; top: 2px; inset-inline-start: 2px;
    width: 14px; height: 14px; border-radius: 50%; background: var(--surface);
    box-shadow: var(--shadow-sm); transition: transform .18s ease;
}
.wf-switch.on { color: var(--ok); border-color: #cfe8d8; background: var(--ok-weak); }
.wf-switch.on .track { background: var(--ok); }
/* RTL: the knob travels toward the inline-end, i.e. visually leftward */
.wf-switch.on .track::after { transform: translateX(-14px); }
[dir="ltr"] .wf-switch.on .track::after { transform: translateX(14px); }

.save-hint {
    font-size: 12.5px; color: var(--text-mute); min-height: 16px;
    display: flex; align-items: center; gap: 6px;
}
.save-hint.dirty { color: var(--warn); }
.save-hint.ok { color: var(--ok); }
.save-hint.err { color: var(--danger); }

/* ---------- the flow: trigger + stages on one spine ---------- */
.wf-flow { position: relative; padding-inline-start: 30px; }
.wf-flow::before {
    content: ""; position: absolute; inset-inline-start: 10px; top: 14px; bottom: 44px;
    width: var(--wf-spine); background: var(--border);
    border-radius: 2px;
}
.wf-node { position: relative; margin-bottom: 14px; }
/* the node marker sits ON the spine */
.wf-node::before {
    content: ""; position: absolute; inset-inline-start: -24px; top: 16px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--border);
    box-shadow: 0 0 0 4px var(--bg);
}
.wf-node.is-trigger::before { border-color: var(--accent); background: var(--accent); }
.wf-node.is-stage::before {
    /* numbered nodes: the counter is set per-stage in the template */
    content: counter(wf-stage); counter-increment: wf-stage;
    width: 20px; height: 20px; inset-inline-start: -29px; top: 14px;
    border-radius: 50%; border: 2px solid var(--border); background: var(--surface);
    color: var(--text-soft); font-size: 11px; font-weight: 700;
    display: grid; place-items: center; line-height: 1;
}
.wf-stages { counter-reset: wf-stage; }

.wf-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 16px 18px;
}
.wf-card-head {
    display: flex; align-items: center; gap: 10px; margin-bottom: 4px;
}
.wf-eyebrow {
    font-size: 11px; font-weight: 700; letter-spacing: .06em;
    color: var(--accent); text-transform: uppercase;
}
.wf-card-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.wf-card-sub { font-size: 13px; color: var(--text-mute); margin-bottom: 14px; }

/* stage card */
.stage .wf-card-head { margin-bottom: 12px; gap: 8px; }
.stage-name {
    flex: 1 1 auto; width: auto; font-weight: 700; font-size: 14.5px;
    border: 1px solid transparent; background: transparent; padding: 5px 8px;
    border-radius: var(--radius-sm); color: var(--text);
}
.stage-name:hover { background: var(--surface-2); }
.stage-name:focus {
    background: var(--surface); border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring); outline: none;
}
.stage-count { font-size: 12px; color: var(--text-mute); white-space: nowrap; }

/* ---------- action rows ---------- */
.action-row {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px; align-items: start;
    background: var(--surface-2); border: 1px solid var(--border-2);
    border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 8px;
    transition: border-color .13s, background .13s;
}
.action-row:hover { border-color: var(--border); background: var(--surface); }
.action-glyph {
    width: 28px; height: 28px; border-radius: 8px; flex: 0 0 28px;
    display: grid; place-items: center; font-size: 13px;
    background: var(--accent-weak); color: var(--accent);
}
.action-glyph.comm { background: var(--info-weak); color: var(--info); }
.action-glyph.ai   { background: var(--warn-weak); color: var(--warn); }
.action-glyph.flow { background: var(--surface); color: var(--text-soft); border: 1px solid var(--border); }
.action-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.action-type { width: auto; max-width: 260px; font-size: 13.5px; padding: 7px 10px; }
.action-cfg { display: flex; flex-direction: column; gap: 7px; }
.action-cfg input, .action-cfg textarea { font-size: 13.5px; padding: 8px 10px; }
.action-cfg textarea { min-height: 52px; }
.action-desc { font-size: 11.5px; color: var(--text-mute); }

/* ---------- conditions ---------- */
.cond-box {
    background: var(--surface-2); border: 1px solid var(--border-2);
    border-radius: var(--radius-sm); padding: 12px; margin-top: 14px;
}
.cond-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: 10px; margin-bottom: 10px;
}
.cond-head strong { font-size: 13px; font-weight: 700; }
.cond-match { width: auto; font-size: 12px; padding: 5px 9px; }
.cond-row {
    display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1.2fr) auto;
    gap: 7px; align-items: center; margin-bottom: 7px;
}
.cond-row select, .cond-row input { font-size: 13px; padding: 7px 9px; width: 100%; }
.cond-row.no-value { grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; }
.cond-empty { font-size: 12.5px; color: var(--text-mute); margin-bottom: 10px; }

/* ---------- schedule ---------- */
.sched-box {
    background: var(--accent-weak); border: 1px solid #dfe2f7;
    border-radius: var(--radius-sm); padding: 12px; margin-top: 12px;
}
.sched-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px; margin-bottom: 8px;
}
.sched-grid .form-group { margin-bottom: 0; }
.sched-grid label { font-size: 12px; margin-bottom: 4px; }
.sched-grid select, .sched-grid input { font-size: 13px; padding: 7px 9px; }

/* ---------- misc ---------- */
.icon-btn {
    border: 1px solid transparent; background: transparent; color: var(--text-mute);
    cursor: pointer; font-size: 15px; line-height: 1; padding: 5px 8px;
    border-radius: var(--radius-sm); transition: background .13s, color .13s;
}
.icon-btn:hover { background: var(--danger-weak); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips code {
    background: var(--surface-2); border: 1px solid var(--border-2);
    padding: 3px 7px; border-radius: 5px; font-size: 11px; color: var(--text-soft);
}
.wf-vars { margin-top: 14px; }
.wf-vars summary {
    cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600;
    list-style: none; padding: 4px 0;
}
.wf-vars summary::-webkit-details-marker { display: none; }
.wf-vars summary::before { content: "▸ "; font-size: 10px; }
.wf-vars[open] summary::before { content: "▾ "; }

.wf-add {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent; border: 1px dashed var(--border);
    color: var(--text-soft); border-radius: var(--radius-sm);
    padding: 9px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer;
    transition: border-color .13s, color .13s, background .13s;
}
.wf-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
.wf-add.block { display: flex; width: 100%; justify-content: center; }

/* ---------- empty state ---------- */
.wf-empty { text-align: center; padding: 48px 24px; }
.wf-empty .mark {
    width: 46px; height: 46px; border-radius: 13px; margin: 0 auto 14px;
    background: var(--accent-weak); color: var(--accent);
    display: grid; place-items: center; font-size: 22px;
}
.wf-empty h2 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.wf-empty p { color: var(--text-mute); font-size: 14px; max-width: 380px; margin: 0 auto 18px; }

/* ---------- run log ---------- */
.run-log { display: flex; flex-direction: column; gap: 3px; }
.run-log-line { display: flex; align-items: baseline; gap: 6px; font-size: 12px; }
.run-log-line .t { color: var(--text-soft); font-weight: 600; white-space: nowrap; }
.run-log-line .o { color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; }
.run-log-line .s { flex: 0 0 auto; font-size: 9px; line-height: 1; }
.run-log-line .s.ok { color: var(--ok); }
.run-log-line .s.err { color: var(--danger); }
.run-log-line .s.skip { color: var(--text-mute); }

/* ---------- wizard ---------- */
.wiz-backdrop {
    display: none; position: fixed; inset: 0; z-index: 60;
    background: rgba(16, 24, 40, .38); backdrop-filter: blur(3px);
    align-items: center; justify-content: center; padding: 20px;
}
.wiz-backdrop.open { display: flex; animation: wiz-fade .16s ease; }
@keyframes wiz-fade { from { opacity: 0 } to { opacity: 1 } }
.wiz-box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px; padding: 26px; width: min(620px, 100%);
    max-height: 90vh; overflow: auto;
    box-shadow: 0 24px 60px rgba(16, 24, 40, .22);
    animation: wiz-rise .2s cubic-bezier(.2, .8, .3, 1);
}
@keyframes wiz-rise { from { opacity: 0; transform: translateY(8px) scale(.99) } to { opacity: 1 } }
.wiz-box h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.015em; }
.wiz-box .wiz-sub { color: var(--text-mute); font-size: 13.5px; margin: 5px 0 16px; }
.wiz-box textarea { width: 100%; font-size: 14px; min-height: 92px; }
.wiz-examples { margin: 14px 0; }
.wiz-examples-head { font-size: 12px; color: var(--text-mute); margin-bottom: 7px; }
.wiz-example {
    text-align: start; font-weight: 500; font-size: 12.5px;
    padding: 7px 11px; border-radius: 999px;
}
.wiz-status { font-size: 13px; color: var(--text-soft); min-height: 18px; }

@media (max-width: 980px) {
    .wf-layout { grid-template-columns: 1fr; }
    .wf-rail { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
    .wf-rail .wf-rail-head { display: none; }
    .wf-rail .wf-item { flex: 0 0 220px; }
    .wf-toolbar { position: static; }
}
@media (max-width: 640px) {
    .wf-flow { padding-inline-start: 22px; }
    .action-row { grid-template-columns: auto minmax(0, 1fr); }
    .action-row .icon-btn { grid-column: 2; justify-self: start; }
    .cond-row, .cond-row.no-value { grid-template-columns: 1fr; }
}

/* ============================================================
   Dashboard
   ============================================================ */
.dash-filters {
    display: flex; gap: 10px; align-items: end; flex-wrap: wrap;
}
.dash-filters .form-group { margin: 0; }
.dash-filters label {
    font-size: 11.5px; font-weight: 600; color: var(--text-mute);
    margin-bottom: 4px; letter-spacing: .02em;
}
.dash-filters select {
    font-size: 13.5px; padding: 8px 10px; min-width: 120px; width: auto;
}

/* KPI sub-line: the count next to the money */
.kpi-count { color: var(--text); font-weight: 700; }

/* quantity counters — one row of plain numbers, deliberately flat so they read as
   supporting detail and don't compete with the KPI tiles above */
.counter-strip {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1px; background: var(--border);
    border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; margin-bottom: 22px;
}
.counter {
    background: var(--surface); padding: 14px 16px;
    display: flex; flex-direction: column; gap: 2px;
}
.counter .c-val {
    font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--text);
}
.counter .c-lbl { font-size: 12px; color: var(--text-mute); }

/* stacked bar chart */
.chart-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 16px; flex-wrap: wrap; margin-bottom: 14px;
}
.chart-sub {
    font-size: 12px; font-weight: 600; color: var(--text-mute);
    margin-inline-start: 8px;
}
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: flex-end; }
.chart-legend .legend-item { font-size: 12.5px; gap: 6px; }
.chart-legend .l-name {
    max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chart-legend .l-val { font-weight: 700; color: var(--text); }

.bar-chart { width: 100%; height: 240px; display: block; overflow: visible; }
.bar-chart .axis-val { font-size: 10px; fill: var(--text-mute); }
.bar-chart .axis-lbl { font-size: 10.5px; fill: var(--text-mute); }
.bar-chart .bar-seg { transition: opacity .12s; }
.bar-chart:hover .bar-seg { opacity: .45; }
.bar-chart .bar-seg:hover { opacity: 1; }

@media (max-width: 768px) {
    .dash-filters { width: 100%; }
    .dash-filters .form-group { flex: 1 1 130px; }
    .dash-filters select { min-width: 0; width: 100%; }
    .counter-strip { grid-template-columns: repeat(2, 1fr); }
    .bar-chart { height: 200px; }
    .chart-legend { justify-content: flex-start; }
}

/* ============================================================
   Dev board — one card per project
   ============================================================ */
.board {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 18px; align-items: start;
}
.dev-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column;
    transition: box-shadow .15s, border-color .15s;
}
.dev-card:hover { box-shadow: var(--shadow); border-color: #d9dce2; }
.dev-card-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
    padding: 16px 18px 12px; border-bottom: 1px solid var(--border-2);
}
.dev-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.dev-client { font-size: 12.5px; color: var(--text-mute); margin-top: 2px; }

.dev-sec { padding: 12px 18px; border-bottom: 1px solid var(--border-2); }
.dev-sec-t {
    font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
    color: var(--text-mute); margin-bottom: 7px;
}
.dev-empty { font-size: 13px; color: var(--text-mute); font-style: italic; }
.dev-mute { font-size: 11.5px; color: var(--text-mute); }
.dev-path {
    font-family: monospace; font-size: 12px; color: var(--text-soft);
    background: var(--surface-2); border: 1px solid var(--border-2);
    padding: 6px 8px; border-radius: 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dev-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.chip {
    font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
    background: var(--accent-weak); color: var(--accent);
}
.chip-soft {
    background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border-2);
    font-weight: 500;
}
.dev-git { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.git-branch { font-size: 12px; font-weight: 700; color: var(--ok); }
.dev-git code {
    font-size: 11px; background: var(--surface-2); border: 1px solid var(--border-2);
    padding: 1px 6px; border-radius: 4px; color: var(--text-soft);
}

.dev-facts { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; }
.dev-facts dt { font-size: 12px; color: var(--text-mute); }
.dev-facts dd {
    font-size: 12.5px; font-weight: 600; color: var(--text); margin: 0;
    overflow: hidden; text-overflow: ellipsis;
}
/* marks a value read off the disk rather than typed in */
.sniffed {
    font-size: 9.5px; font-weight: 700; color: var(--info);
    background: var(--info-weak); border-radius: 4px; padding: 1px 5px;
    margin-inline-start: 6px; vertical-align: 1px;
}

.dev-links { display: flex; flex-wrap: wrap; gap: 6px; }
.dev-link {
    font-size: 12px; font-weight: 600; text-decoration: none;
    padding: 5px 11px; border-radius: 999px;
    border: 1px solid var(--border); color: var(--accent); background: var(--surface);
    transition: background .13s, border-color .13s;
}
.dev-link:hover { background: var(--accent-weak); border-color: var(--accent); }
.dev-link.off { color: var(--text-mute); border-style: dashed; cursor: default; }

.doc-hit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc-badge {
    font-family: monospace; font-size: 11px; font-weight: 700;
    background: var(--ok-weak); color: #217a48; border: 1px solid #d6ecdf;
    padding: 2px 7px; border-radius: 5px; text-decoration: none;
    display: inline-block;
}
a.doc-badge:hover { background: #d6ecdf; }
.doc-title {
    font-size: 12px; color: var(--text-soft); margin-top: 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dev-notes {
    font-size: 12.5px; color: var(--text-soft); line-height: 1.5;
    white-space: pre-wrap; max-height: 84px; overflow: auto;
}

.dev-card-foot {
    display: flex; align-items: center; gap: 18px;
    padding: 12px 18px; margin-top: auto;
}
.foot-stat { display: flex; flex-direction: column; }
.foot-stat .fs-val { font-size: 14.5px; font-weight: 700; color: var(--text); }
.foot-stat .fs-lbl { font-size: 11px; color: var(--text-mute); }
.dev-card-foot .btn { margin-inline-start: auto; }

/* run command */
.run-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.run-cmd {
    flex: 1 1 140px; min-width: 0;
    font-family: monospace; font-size: 11.5px; color: var(--text-soft);
    background: var(--surface-2); border: 1px solid var(--border-2);
    padding: 5px 8px; border-radius: 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* warnings */
.warn-list { list-style: none; display: flex; flex-direction: column; gap: 7px; margin: 0; }
.warn { display: flex; align-items: flex-start; gap: 8px; }
.warn-dot {
    width: 6px; height: 6px; border-radius: 50%; margin-top: 6px; flex: 0 0 6px;
    background: var(--text-mute);
}
.warn-danger .warn-dot { background: var(--danger); }
.warn-warn .warn-dot { background: var(--warn); }
.warn-info .warn-dot { background: var(--info); }
.warn-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.warn-text { font-size: 12.5px; font-weight: 600; color: var(--text); }
.warn-danger .warn-text { color: var(--danger); }
.warn-fix { font-size: 11.5px; color: var(--text-mute); }
.warn-act {
    font-size: 11.5px; font-weight: 700; color: var(--accent);
    text-decoration: none; white-space: nowrap; padding-top: 1px;
}
.warn-act:hover { text-decoration: underline; }
.warn-btn {
    border: 1px solid var(--border); background: var(--surface);
    border-radius: 999px; padding: 3px 10px; cursor: pointer; font-family: inherit;
}
.warn-btn:hover { background: var(--accent-weak); border-color: var(--accent); text-decoration: none; }
.warn-btn:disabled { opacity: .5; cursor: default; }
.warn-fix { overflow-wrap: anywhere; }

/* run feedback */
.run-toast {
    position: fixed; inset-block-end: 22px; inset-inline-start: 22px; z-index: 70;
    padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px;
    font-weight: 600; box-shadow: var(--shadow); max-width: 420px;
    opacity: 0; transform: translateY(8px); pointer-events: none;
    transition: opacity .18s, transform .18s;
}
.run-toast.show { opacity: 1; transform: none; }
.run-toast.ok { background: var(--ok-weak); color: #217a48; border: 1px solid #cfe8d8; }
.run-toast.err { background: var(--danger-weak); color: #a9373d; border: 1px solid #f0cdcf; }

@media (max-width: 640px) { .board { grid-template-columns: 1fr; } }

/* ---------- AI settings ---------- */
.ai-test-result {
    font-size: 13.5px; font-weight: 600; color: var(--text-soft);
    min-height: 20px; margin-top: 10px;
}
.ai-test-result.ok  { color: var(--ok); }
.ai-test-result.err { color: var(--danger); }

/* ---------- Utilities ---------- */
.mb-3 { margin-bottom: 15px; }
.mt-3 { margin-top: 15px; }
.text-center { text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar-toggle { display: block; }
    .sidebar {
        position: fixed; inset-inline-end: 0; top: 0;
        transform: translateX(100%); transition: transform .2s ease;
        box-shadow: -8px 0 30px rgba(16,24,40,.12);
    }
    [dir="rtl"] .sidebar { transform: translateX(-100%); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .nav-scrim {
        display: block; position: fixed; inset: 0; z-index: 30;
        background: rgba(16,24,40,.28);
    }
    .main { padding: 64px 16px 40px; }
}
@media (max-width: 768px) {
    .header { flex-direction: column; align-items: flex-start; }
    .page-head { align-items: flex-start; }
    .stats-grid, .kpi-grid { grid-template-columns: 1fr 1fr; }
    .panel-grid { grid-template-columns: 1fr; }
    .nav-tabs { flex-wrap: wrap; }
    table { font-size: 13.5px; }
    table th, table td { padding: 10px; }
    .invoice-container { padding: 28px 20px; }
    .invoice-header { flex-direction: column; }
    .invoice-details { grid-template-columns: 1fr; }
    .form-container { padding: 22px; }
    .invoice-item-row { grid-template-columns: 1fr; }
    .bar-row { grid-template-columns: 96px 1fr auto; }
}
@media (max-width: 480px) {
    .stats-grid, .kpi-grid { grid-template-columns: 1fr; }
}
