/* --brand is set per deployment from SITE_PRIMARY_COLOR (see layouts/base.html) */
:root {
    --brand: #0f766e;
    --brand-ink: color-mix(in srgb, var(--brand) 82%, black);
    --brand-soft: color-mix(in srgb, var(--brand) 10%, white);
    --bg: #f7f8fa;
    --surface: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --ok-bg: #ecfdf5;
    --ok-text: #065f46;
    --err-bg: #fef2f2;
    --err-text: #991b1b;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .05);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --brand-ink: color-mix(in srgb, var(--brand) 70%, white);
        --brand-soft: color-mix(in srgb, var(--brand) 18%, #111827);
        --bg: #0b0f14;
        --surface: #121821;
        --text: #e5e7eb;
        --muted: #9ca3af;
        --border: #232b36;
        --ok-bg: #052e22;
        --ok-text: #a7f3d0;
        --err-bg: #3b0d0d;
        --err-text: #fecaca;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--brand-ink); }

h1 { font-size: 1.5rem; margin: 0 0 .5rem; letter-spacing: -.01em; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.c-err { color: var(--err-text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 650;
    font-size: 1.05rem;
    text-decoration: none;
}
.brand img { border-radius: 6px; }
.spacer { flex: 1; }

.langswitch { display: flex; gap: 4px; }
.langswitch a { padding: 2px 6px; border-radius: 6px; color: var(--muted); text-decoration: none; text-transform: uppercase; font-size: .8rem; }
.langswitch a.active { background: var(--brand-soft); color: var(--brand-ink); }

/* Account menu */
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.avatar {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
}
.usermenu .menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu form { margin: 0; }
.menu .linklike { width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; }
.menu .linklike:hover { background: var(--bg); }

/* Layout */
.container { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 32px 20px; }
.site-footer { padding: 20px; text-align: center; color: var(--muted); font-size: .85rem; }

.greeting { padding: 48px 0; text-align: center; }
.greeting h1 { font-size: 1.75rem; }

.empty-state { padding: 64px 0; text-align: center; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 550;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-small { padding: 6px 12px; font-size: .9rem; }
.btn-block { width: 100%; }

.linklike {
    padding: 0;
    border: 0;
    background: none;
    color: var(--brand-ink);
    font: inherit;
    cursor: pointer;
}
.linklike:disabled { color: var(--muted); cursor: default; }

/* Auth */
.auth-card {
    max-width: 400px;
    margin: 24px auto;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.auth-alt { margin: 16px 0 0; text-align: center; font-size: .9rem; color: var(--muted); }
.resend-msg { margin-bottom: 4px; }

.form { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.form label { font-weight: 550; font-size: .9rem; }
.form input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}
.form input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.form button { margin-top: 8px; }
.otp-input { font-family: ui-monospace, monospace; font-size: 1.5rem !important; letter-spacing: .4em; text-align: center; }

/* Alerts & toasts */
.alert { max-width: 400px; margin: 0 auto 16px; padding: 10px 14px; border-radius: 8px; font-size: .9rem; }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }
.alert-error { background: var(--err-bg); color: var(--err-text); }

.toast-area { position: fixed; right: 16px; bottom: 16px; z-index: 50; }
.toast { padding: 10px 14px; border-radius: 8px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); }
.toast-error { background: var(--err-text); color: #fff; }

@media (max-width: 520px) {
    .topbar { padding: 0 16px; }
    .container { padding: 24px 16px; }
    .auth-card { padding: 20px; }
}

/* ---- Clouds -------------------------------------------------------------- */
h2 { font-size: 1.05rem; margin: 28px 0 12px; }
.page-narrow { max-width: 760px; margin: 0 auto; }
.lead { font-size: 1.02rem; margin-top: 0; }
.eyebrow { margin: 0 0 6px; color: var(--brand-ink); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.crumbs { margin: 0 0 12px; }
.crumbs a { text-decoration: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }

.topnav { display: flex; gap: 4px; margin-left: 12px; }
.topnav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 550; }
.topnav a:hover { color: var(--text); }
.topnav a.active { background: var(--brand-soft); color: var(--brand-ink); }

/* provider monogram badges (neutral colors per provider, not brand logos) */
.prov {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    color: #fff;
    vertical-align: middle;
}
.prov-gcp { background: #2563eb; }
.prov-aws { background: #d97706; }
.prov-tencent { background: #0891b2; }
h1 .prov { width: 34px; height: 34px; margin-right: 6px; }

.provider-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.provider-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    flex-wrap: wrap;
}
.provider-card:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.provider-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-err { background: var(--err-bg); color: var(--err-text); }
.badge-wait { background: var(--brand-soft); color: var(--brand-ink); }

.cloud-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.cloud-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex-wrap: wrap; }
.cloud-row + .cloud-row { border-top: 1px solid var(--border); }
.cloud-main { display: flex; flex-direction: column; flex: 1; min-width: 180px; overflow-wrap: anywhere; }
.cloud-row form { margin: 0; }
.cloud-actions { display: flex; gap: 4px; }
.cloud-row .btn[disabled] { opacity: .5; cursor: default; }
.empty-note { padding: 16px; border: 1px dashed var(--border); border-radius: 12px; text-align: center; }

.btn-ghost { background: transparent; }

.wizard-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
.wizard-actions form { margin: 0; }

.connect-layout { display: grid; gap: 20px; grid-template-columns: 1fr 1.2fr; align-items: start; margin-top: 20px; }
.steps h2 { margin-top: 0; }
.steps ol { padding-left: 20px; margin: 0 0 16px; }
.steps li { margin-bottom: 10px; }
.connect-layout .form { margin-top: 0; }
.form textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    resize: vertical;
}
.form textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.field-help { margin: -2px 0 6px; }
.file-input { font-size: .85rem; }

@media (max-width: 720px) {
    .connect-layout { grid-template-columns: 1fr; }
    .topnav { margin-left: 0; }
}
.field-help { overflow-wrap: anywhere; }
.form input[type=file] { padding: 0; border: 0; background: none; }
.provider-text .badge { margin-top: 6px; }

/* a form field the last error was about */
.form [aria-invalid="true"] { border-color: var(--err-text); background: var(--err-bg); }

/* Organization switcher (reuses the account menu) */
.orgmenu { margin-left: 8px; }
.orgmenu-summary { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font-weight: 550; font-size: .9rem; max-width: 220px; }
.orgmenu-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orgmenu .menu-left { left: 0; right: auto; min-width: 240px; }
.menu-label { padding: 6px 10px 2px; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.menu .linklike { display: block; text-decoration: none; color: inherit; }
.menu-org { display: flex !important; justify-content: space-between; gap: 8px; }
.menu-org.current { background: var(--brand-soft); color: var(--brand-ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); display: inline-block; }

/* Organization page */
.member-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.member-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex-wrap: wrap; }
.member-row + .member-row { border-top: 1px solid var(--border); }
.member-main { display: flex; flex-direction: column; flex: 1; min-width: 180px; overflow-wrap: anywhere; }
.member-row form { margin: 0; display: flex; gap: 6px; align-items: center; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-top: 12px; }
.inline-form .field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 200px; }
.inline-form label { font-weight: 550; font-size: .9rem; }
.inline-form input, select { padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; font: inherit; }
.member-row select { padding: 5px 8px; font-size: .9rem; }
.section-card { padding: 16px; margin-top: 12px; }
.invite-card { padding: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.invite-card + .invite-card { margin-top: 8px; }
.btn-danger { color: var(--err-text); }

/* Cloud account details */
.details-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.details-head h1 { margin: 0; font-size: 1.4rem; }
.details-head form { margin: 0; }
.plain-link { color: inherit; text-decoration: none; }
.plain-link:hover { text-decoration: underline; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 16px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.runs { display: flex; flex-direction: column; gap: 8px; }
.run { padding: 10px 14px; }
.run summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; cursor: pointer; }
.run-meta { margin-left: auto; }
.run-error { margin: 10px 0 6px; }
.run-detail { margin: 0; padding: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    font-size: .8rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto; }
.alert-wide { max-width: none; margin: 0 0 12px; }

/* Sync in progress: a spinning gear in place of the status and "Sync now" */
.syncing { display: inline-flex; align-items: center; gap: 6px; color: var(--brand-ink); font-size: .85rem; font-weight: 600; white-space: nowrap; }
.syncing .gear { animation: gear-spin 1.6s linear infinite; }
@keyframes gear-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .syncing .gear { animation-duration: 6s; } }

/* Sync run log */
.run-label { margin: 12px 0 4px; font-weight: 600; }
.run-log { margin: 0; padding: 10px 12px; background: #0f172a; color: #e2e8f0; border-radius: 8px;
    font-size: .78rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; }
.run-log .log-warn { color: #fbbf24; }
.run-log .log-error { color: #f87171; }
.run-log .log-cursor { color: #94a3b8; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Date picker (static/js/datepicker.js) */
.dp { position: relative; display: inline-block; }
.dp-trigger { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--border);
    border-radius: 8px; background: var(--surface); color: var(--brand-ink); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }
.dp-trigger svg { color: var(--muted); flex: none; }
.dp-trigger:hover { border-color: var(--brand); }
.dp-pop { position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); }
.dp-menu { min-width: 240px; padding: 6px; }
.dp-item { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-radius: 6px; background: none;
    color: inherit; font: inherit; font-weight: 400; cursor: pointer; }
.dp-item:hover, .dp-item:focus-visible { background: var(--bg); color: var(--brand-ink); outline: none; }
.dp-item.current { color: var(--brand-ink); background: var(--brand-soft); }
.dp-sep { height: 1px; background: var(--border); margin: 6px 8px; }
.dp-custom { width: min(600px, calc(100vw - 32px)); }
.dp-head { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); padding: 0 8px; }
.dp-back, .dp-tab, .dp-nav { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.dp-back { font-size: 1.3rem; padding: 6px 10px; }
.dp-tab { padding: 10px 10px; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.dp-tab.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.dp-fields { display: flex; align-items: center; gap: 12px; padding: 14px 16px 4px; }
.dp-input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; font: inherit; }
.dp-cals { display: flex; gap: 24px; padding: 8px 16px 12px; }
.dp-month { flex: 1; }
.dp-month-title { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.dp-nav { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border-radius: 8px; color: var(--brand); }
.dp-nav:hover, .dp-nav:focus-visible { background: var(--brand-soft); color: var(--brand-ink); outline: 0; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { text-align: center; font-size: .75rem; color: var(--muted); padding: 4px 0; }
.dp-day { aspect-ratio: 1 / 1; border: 0; border-radius: 6px; background: none; color: inherit; font: inherit; font-size: .9rem; cursor: pointer; }
.dp-day:hover:not(:disabled) { background: var(--bg); }
.dp-day.today { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.dp-day.in-range { background: var(--brand-soft); color: var(--brand-ink); border-radius: 0; }
.dp-day.edge { background: var(--brand); color: #fff; border-radius: 6px; }
.dp-day:disabled { color: var(--border); cursor: default; }
.dp-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); }
.dp-msg { color: var(--muted); }
@media (max-width: 640px) { .dp-pop { position: fixed; left: 16px; right: 16px; top: 80px; width: auto; } }

/* Sync form on the account details page */
.sync-form { padding: 14px 16px; margin-bottom: 12px; }
.sync-form-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sync-form-label { font-weight: 600; font-size: .9rem; }
.sync-form .dp-pop { left: 0; right: auto; }
.sync-form p { margin: 8px 0 0; }

/* Stop button next to the spinning gear */
.btn-stop { color: var(--err-text); border-color: color-mix(in srgb, var(--err-text) 35%, transparent); background: var(--surface); }
.btn-stop:hover { background: var(--err-bg); }
.badge-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
form:has(> .btn-stop) { margin: 0; }

/* Cost dashboard */
.page-wide { max-width: 1100px; margin: 0 auto; }
.costs-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.costs-head h1 { margin-bottom: 0; }
.costs-head p { margin: 2px 0 0; }
.costs-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 16px 0; }
.costs-filters select, .chart-head select { padding: 7px 10px; font-size: .9rem; max-width: 220px; }
.costs-filters .dp-pop { left: 0; right: auto; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi-label { color: var(--muted); font-size: .85rem; }
.kpi-value { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .8rem; }
.kpi-sub.up { color: var(--err-text); }
.kpi-sub.down { color: var(--ok-text); }
.chart-card { padding: 14px 16px; margin-bottom: 12px; }
.chart-card h2 { font-size: 1rem; margin: 0 0 8px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chart-grid .chart-card { margin-bottom: 0; }
.chart-grid + .chart-card { margin-top: 12px; }
.chart-empty { padding: 40px 0; text-align: center; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th, .data-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table form { margin: 0; }
@media (max-width: 860px) { .kpis { grid-template-columns: 1fr 1fr; } .chart-grid { grid-template-columns: 1fr; } }

/* Cost rules */
.rules-section { padding: 16px 18px; margin-bottom: 14px; }
.rules-section h2 { margin-top: 0; font-size: 1.1rem; }
.rules-section h3 { font-size: .95rem; margin: 18px 0 6px; }
.rules-grid { display: grid; grid-template-columns: max-content 1fr; gap: 10px 14px; align-items: center; margin-top: 10px; }
.rules-grid label { font-weight: 550; font-size: .9rem; }
.rules-grid input, .rules-section textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; font: inherit; }
.rules-grid input.short { width: 140px; }
.rules-section textarea { width: 100%; font-size: .85rem; margin: 6px 0; }
.rules-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.rules-two label { font-weight: 550; font-size: .9rem; }
.manual-form .field { min-width: 140px; }
.gear-inline { vertical-align: -3px; animation: gear-spin 1.6s linear infinite; }
@media (max-width: 760px) { .rules-grid, .rules-two { grid-template-columns: 1fr; } }

/* Rename on the account details page */
.rename summary { cursor: pointer; color: var(--brand-ink); list-style: none; display: inline-block; margin-top: 2px; }
.rename summary::-webkit-details-marker { display: none; }
.rename[open] summary { color: var(--muted); }
.rename-form { display: flex; gap: 8px; margin: 6px 0 4px; flex-wrap: wrap; }
.rename-form input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; font: inherit; min-width: 220px; }
.rename-form input[aria-invalid="true"] { border-color: var(--err-text); background: var(--err-bg); }

.label-pair { display: flex; gap: 8px; flex-wrap: wrap; }
.label-pair input { flex: 1; min-width: 140px; }

.label-pair { display: flex; gap: 8px; flex-wrap: wrap; }
.label-pair input { flex: 1; min-width: 140px; }

/* Organization page: AI assistant and API tokens */
.ai-form { padding: 14px 16px; margin: 8px 0; }
.ai-form input { width: 100%; }
.ai-form input.short-wide { max-width: 260px; }
.ai-actions { display: flex; align-items: center; gap: 10px; }
.token-new { padding: 14px 16px; margin: 10px 0; border-color: var(--brand); }
.token-new pre { user-select: all; }

/* FinOps Assistant chat */
.chat-fab { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 16px; border: 0; border-radius: 999px; background: var(--brand); color: #fff; font: inherit; font-weight: 600;
    box-shadow: 0 6px 20px rgba(0,0,0,.18); cursor: pointer; }
.chat-is-open .chat-fab { display: none; }
.chat-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(520px, 100vw); display: flex; flex-direction: column;
    background: var(--surface); border-left: 1px solid var(--border); box-shadow: -8px 0 30px rgba(0,0,0,.08); }
.chat-panel[hidden] { display: none; }
@media (min-width: 1200px) { .chat-is-open .container { margin-right: 520px; } }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.chat-head-actions { display: flex; gap: 4px; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; flex-direction: column; gap: 8px; }
.chat-user { align-items: flex-end; }
.chat-bubble { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: .92rem; line-height: 1.5; overflow-wrap: anywhere; }
.chat-user .chat-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.chat-assistant .chat-bubble { background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-bubble p { margin: 0 0 6px; } .chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul, .chat-bubble ol { margin: 4px 0 6px; padding-left: 20px; }
.chat-bubble code { font-size: .85em; background: var(--surface); padding: 1px 4px; border-radius: 4px; }
.chat-bubble .table-wrap { margin: 6px 0; }
.chat-error { color: var(--err-text); background: var(--err-bg) !important; }
.chat-thinking { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.dots { display: inline-flex; gap: 3px; } .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
.chat-chart { margin: 0; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.chat-chart figcaption { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px; border-top: 1px solid var(--border); }
.chat-form textarea { flex: 1; resize: none; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: inherit; font: inherit; font-size: .92rem; max-height: 160px; }
.chat-empty, .chat-off { margin: auto 0; text-align: center; color: var(--muted); }
.chat-suggestions { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.chip { text-align: left; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand-ink); }

/* Modal dialog */
.modal { border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px));
    background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(15, 23, 42, .45); }
.modal-form { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.modal-form h3 { margin: 0; font-size: 1.1rem; }
.modal-form p { margin: 0; }
.modal-line { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; padding: 10px 12px; background: var(--bg); border-radius: 10px; overflow-wrap: anywhere; }
.modal-line strong { font-weight: 550; font-size: .9rem; }
.modal-fields { display: grid; grid-template-columns: max-content 1fr; gap: 8px 12px; align-items: center; }
.modal-fields[hidden] { display: none; }
.modal-fields label { font-weight: 550; font-size: .9rem; }
.modal-fields input, .modal-fields select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; font: inherit; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.table-search { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; font: inherit; font-size: .9rem; width: min(280px, 100%); }

/* Filters fill the row: the dropdowns share the width after the date picker */
.costs-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.costs-filters > .ss, .costs-filters > select, .costs-selects > .ss, .costs-selects > select { flex: 1 1 160px; max-width: none; min-width: 0; }

/* Searchable select (static/js/select.js) */
.ss { position: relative; }
.ss-native { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.ss-button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; font: inherit; font-size: .9rem;
    cursor: pointer; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-button::after { content: ""; flex: none; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px); opacity: .6; }
.ss-button:hover, .ss-button[aria-expanded="true"] { border-color: var(--brand); }
.ss-pop { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: min(420px, calc(100vw - 32px));
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; }
.ss-search { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; font: inherit; font-size: .9rem; margin-bottom: 4px; }
.ss-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.ss-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: .9rem; overflow-wrap: anywhere; }
.ss-list li:hover, .ss-list li.active { background: var(--bg); }
.ss-list li.selected { color: var(--brand-ink); font-weight: 600; }
.ss-list li.ss-none { color: var(--muted); cursor: default; }

/* Back link above a page title */
.back-link { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 14px; padding: 6px 12px 6px 8px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
    font-size: .92rem; font-weight: 550; text-decoration: none; }
.back-link svg { color: var(--brand); flex: none; }
.back-link:hover { border-color: var(--brand); color: var(--brand-ink); }

.model-pick { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.model-pick .ss { min-width: 240px; }

/* Chat: tidy bubbles and input */
.chat-assistant { align-items: flex-start; }
.chat-assistant .chat-chart { align-self: stretch; }
.chat-thinking { width: auto; }
.chat-form { align-items: center; }
.chat-form textarea { min-height: 42px; line-height: 1.4; }
.chat-form .btn { height: 42px; }
.chat-head .btn-ghost[data-chat-close] { width: 34px; padding: 0; }

/* Chat: the message list is its own scroll area; scrolling it never moves the page */
.chat-panel { overflow: hidden; }
.chat-head, .chat-form { flex: none; }
.chat-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }

/* Segmented control (currency switch) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); flex: none; }
.seg-item { position: relative; }
.seg-item input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg-item span { display: block; padding: 7px 12px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.seg-item + .seg-item span { border-left: 1px solid var(--border); }
.seg-item input:checked + span { background: var(--brand-soft); color: var(--brand-ink); }
.seg-item input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -2px; }

.prov-idcloudhost { background: #e11d48; }

.costs-head-actions { display: flex; align-items: center; gap: 8px; }

/* small hover tooltip (exchange rate on the USD | IDR toggle) */
.tip-wrap { position: relative; }
.tip { position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; width: max-content; max-width: 260px;
  display: flex; flex-direction: column; gap: 2px; padding: 7px 10px; border-radius: 6px;
  background: var(--text, #1f2937); color: var(--surface, #fff); font-size: .75rem; line-height: 1.35;
  box-shadow: 0 4px 14px rgba(0,0,0,.15); opacity: 0; visibility: hidden; transform: translateY(-2px);
  transition: opacity .12s, transform .12s, visibility .12s; pointer-events: none; }
.tip small { opacity: .75; font-size: .7rem; }
.tip-wrap:hover .tip, .tip-wrap:focus-within .tip { opacity: 1; visibility: visible; transform: none; transition-delay: .25s; }

/* ---- Actionables ---- */
.nav-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 2px; border-radius: 999px; background: var(--brand); color: #fff; font-size: .7rem; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.act-kpis { grid-template-columns: repeat(3, 1fr); margin-top: 16px; }
.act-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 8px 0 12px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.act-tabs a { padding: 8px 12px; color: var(--muted); text-decoration: none; font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.act-tabs a:hover { color: var(--text); }
.act-tabs a.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.act-count { display: inline-block; padding: 0 6px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); font-size: .72rem; color: var(--muted); }
.act-filters { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.act-cats { display: flex; gap: 6px; flex-wrap: wrap; }
.act-cat { position: relative; }
.act-cat input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.act-cat span { display: block; padding: 5px 11px; border: 1px solid var(--border); border-radius: 999px; font-size: .85rem; color: var(--muted); background: var(--surface); }
.act-cat input:checked + span { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--brand-soft); font-weight: 600; }
.act-cat input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }
.act-selects { display: flex; gap: 8px; flex-wrap: wrap; }
.act-list { display: flex; flex-direction: column; gap: 10px; }
.act-card { display: grid; grid-template-columns: 1fr 210px; gap: 18px; padding: 16px 18px; border-left: 4px solid var(--border); }
.act-card.sev-high { border-left-color: #dc2626; }
.act-card.sev-medium { border-left-color: #f59e0b; }
.act-card.sev-low { border-left-color: #94a3b8; }
.act-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sev-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; flex: none; }
.sev-high .sev-dot { background: #dc2626; }
.sev-medium .sev-dot { background: #f59e0b; }
.act-scope { overflow-wrap: anywhere; }
.act-title { margin: 8px 0 4px; font-size: 1.05rem; overflow-wrap: anywhere; }
.act-why { margin: 0 0 6px; }
.act-how summary { cursor: pointer; font-weight: 550; font-size: .9rem; color: var(--brand-ink); }
.act-how ol { margin: 6px 0 4px; padding-left: 20px; }
.act-how li { margin: 2px 0; }
.act-meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 6px 0 0; }
.act-links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.act-head > div:first-child { flex: 1 1 420px; }
.act-head .costs-head-actions { padding-bottom: 4px; }
.act-side { display: flex; flex-direction: column; align-items: stretch; gap: 6px; text-align: right; }
.act-impact { font-size: 1.25rem; font-weight: 700; color: var(--ok-text); font-variant-numeric: tabular-nums; }
.act-stake { font-size: 1rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.spark { width: 100%; height: 34px; display: block; color: var(--brand); }
.spark-line { fill: none; stroke: currentColor; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark-area { fill: currentColor; opacity: .12; }
.sev-high .spark { color: #dc2626; }
@media (max-width: 720px) {
  .act-kpis { grid-template-columns: 1fr; }
  .act-card { grid-template-columns: 1fr; }
  .act-side { text-align: left; }
}
.act-settings-modal input.wide { width: min(460px, 100%); }
.act-settings-modal input.invalid { border-color: var(--err-text); }

/* phones: the page links move to their own row under the brand and menus */
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; height: auto; min-height: 56px; padding: 8px 16px 0; row-gap: 6px; }
  .topnav { order: 10; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; padding-bottom: 6px; }
  .topnav a { white-space: nowrap; }
}
.act-settings-modal { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.act-settings-fields { display: grid; grid-template-columns: max-content 1fr; gap: 10px 14px; align-items: start; }
.act-settings-fields label { font-weight: 550; font-size: .9rem; padding-top: 8px; }
.act-settings-fields input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; font: inherit; }
.act-settings-fields input.short { width: 120px; }
.act-settings-fields .field-help { margin: 3px 0 0; }
.act-settings-modal .modal-actions { position: sticky; bottom: -18px; background: var(--surface); padding: 10px 0 2px; }
@media (max-width: 560px) {
  .act-settings-fields { grid-template-columns: 1fr; gap: 4px; }
  .act-settings-fields label { padding-top: 6px; }
}

/* filters beyond the dropdowns (from a link), each removable */
.scope-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -2px 0 12px; }
.scope-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); font-size: .85rem; font-weight: 550; text-decoration: none; overflow-wrap: anywhere; }
.scope-chip:hover { filter: brightness(.96); }
.scope-chip .muted { font-weight: 450; }

/* chat: what the user attached (above the box), and its tag on their bubbles */
.chat-context { margin: 8px 12px 0; padding: 10px 12px; border: 1px solid var(--border); border-left: 3px solid var(--brand); border-radius: 10px; background: var(--bg); display: flex; flex-direction: column; gap: 6px; }
.chat-context[hidden] { display: none; }
.chat-context-head { display: flex; justify-content: space-between; align-items: center; }
.chat-context-label { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.chat-context-remove { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: .85rem; padding: 2px 4px; border-radius: 6px; }
.chat-context-remove:hover { color: var(--text); background: var(--surface); }
.chat-context-body { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; font-size: .88rem; overflow-wrap: anywhere; }
.chat-context-asks { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-context-asks .chip { padding: 5px 9px; font-size: .8rem; }
.chat-context-tag { align-self: flex-end; max-width: 85%; margin-bottom: -4px; font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-context.asked .chat-context-asks { display: none; }

/* the Costs filters and search stay at the top while scrolling */
.costs-sticky { position: sticky; top: 56px; z-index: 9; margin: 0 -12px 12px; padding: 10px 12px; background: var(--bg); border-bottom: 1px solid transparent; transition: border-color .15s, box-shadow .15s; }
.costs-sticky.stuck { border-bottom-color: var(--border); box-shadow: 0 6px 12px -10px rgba(0,0,0,.25); }
.costs-sticky .costs-filters { margin: 0; }
.costs-search { flex: 1 1 100%; display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted); }
.costs-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.costs-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: .95rem; padding: 10px 0; }
@media (max-width: 560px) {
  .costs-sticky { position: static; }
}
.costs-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; } /* ours instead */
.costs-search-clear { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; margin-right: -6px; border: 0; border-radius: 50%; background: var(--bg); color: var(--muted); cursor: pointer; }
.costs-search-clear:hover { background: var(--border); color: var(--text); }
.costs-search-clear[hidden] { display: none; }
.label-pair-head span { flex: 1; min-width: 140px; }

/* Actionables: the card's Action menu and its dialogs */
.act-menu { position: relative; align-self: flex-end; margin-top: auto; } /* bottom right of the card */
.act-menu summary { list-style: none; cursor: pointer; }
.act-menu summary::-webkit-details-marker { display: none; }
.act-menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 150px; padding: 4px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow), 0 8px 24px rgba(0,0,0,.12); text-align: center; }
.act-menu-list form { margin: 0; }
.act-menu-list button { width: 100%; text-align: center; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; }
.act-menu-list button:hover, .act-menu-list button:focus-visible { background: var(--brand-soft); color: var(--brand-ink); outline: 0; }
.act-dialog-item { font-weight: 600; overflow-wrap: anywhere; }
.act-snooze-options { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.act-snooze-date, .act-dialog-text, .act-dialog-select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; font: inherit; }
.act-dialog-text { resize: vertical; }
@media (max-width: 720px) { .act-menu { align-self: flex-start; } .act-menu-list { left: 0; right: auto; } }

/* chart cards: an expand button opens the chart full width */
.chart-card .chart-head h2 { margin-bottom: 8px; }
.chart-expand { margin-left: auto; flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin-top: -8px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.chart-expand:hover, .chart-expand:focus-visible { border-color: var(--border); background: var(--bg); color: var(--text); }
.chart-head select + .chart-expand { margin-left: 4px; }
/* the whole window, with the same 24px margin on every side */
.chart-modal { position: fixed; inset: 24px; margin: 0; width: auto; height: auto; max-width: none; max-height: none; }
.chart-modal[open] { display: flex; flex-direction: column; }
.chart-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px 4px; }
.chart-modal-head h2 { margin: 0; font-size: 1.1rem; }
.chart-modal-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 4px 14px 14px; }
.chart-modal-scroll[hidden] { display: none; }
.chart-modal-body { height: 100%; }
@media (max-width: 560px) { .chart-modal { inset: 8px; } }
/* the question and "thinking" bubble shown while waiting are wrapped together:
   space them like the rest of the log */
.chat-pending { display: flex; flex-direction: column; gap: 12px; }
.costs-selects { display: contents; } /* its dropdowns lay out in the filter row */
/* while the chart popup is open the page doesn't scroll (nor show its scrollbar
   beside the popup, which would make the right margin look wider) */
html:has(dialog.chart-modal[open]) { overflow: hidden; }

/* searchable select with checkboxes (select multiple) */
.ss-multi .ss-list li { display: flex; align-items: center; gap: 8px; }
.ss-check { flex: none; width: 16px; height: 16px; border: 1.5px solid var(--border); border-radius: 4px; background: var(--surface); position: relative; }
.ss-list li.checked .ss-check { background: var(--brand); border-color: var(--brand); }
.ss-list li.checked .ss-check::after { content: ""; position: absolute; left: 4.5px; top: 1.5px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.ss-list li.ss-all { border-bottom: 1px solid var(--border); border-radius: 6px 6px 0 0; margin-bottom: 2px; }
.ss-multi .ss-button { justify-content: flex-start; }
.ss-multi .ss-button::after { margin-left: auto; }
.ss-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ss-more { flex: none; padding: 0 6px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); font-size: .75rem; font-weight: 650; line-height: 18px; }
.ss-button.ss-has { color: var(--brand-ink); font-weight: 600; }
.ss-list li[hidden] { display: none; } /* rows hidden by the search (they are flex in multi mode) */
.ss-apply { display: block; width: 100%; margin-top: 6px; padding: 8px 10px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }
.ss-apply:hover { background: var(--brand-ink); }
.ss-apply[hidden] { display: none; }
.chart-modal-table { flex: 1; min-height: 0; overflow: auto; margin: 4px 18px 18px; }
.chart-modal-table[hidden], .chart-modal-body[hidden] { display: none; }
.chart-modal-table .table-wrap { overflow: visible; }
.chart-modal-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.chart-hint { margin-left: 8px; font-size: .78rem; font-weight: 450; color: var(--muted); }
@media (max-width: 560px) { .chart-hint { display: none; } }
/* a searchable select not enhanced yet (first paint, or just swapped in by HTMX)
   takes a dropdown's size and stays invisible, so the filter row doesn't jump while
   select.js turns it into its button (a select multiple would show as a tall list) */
select[data-searchable]:not(.ss-native) { height: 36px; min-height: 36px; max-height: 36px; overflow: hidden; visibility: hidden; flex: 1 1 160px; min-width: 0; }
/* a multi-select with choices: the chevron gives way to a clear button */
.ss-multi .ss-button.ss-has::after { display: none; }
.ss-multi .ss-button.ss-has { padding-right: 34px; }
.ss-clear { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: transparent; color: var(--brand-ink); cursor: pointer; }
.ss-clear:hover, .ss-clear:focus-visible { background: var(--brand-soft); outline: 0; }
.ss-clear[hidden] { display: none; }

/* ---- Home: the organization at a glance ---- */
.home { padding-top: 4px; }
.home-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 8px 0 18px; padding: 22px 24px; border-radius: 16px;
  background: linear-gradient(135deg, var(--brand-soft), var(--surface) 70%); border: 1px solid var(--border); }
.home-hero h1 { margin: 2px 0 4px; font-size: 1.6rem; }
.home-hero p { margin: 0; }
.home-org { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--brand-ink); }
.home-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.home-kpis .home-kpi { text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.home-kpis .home-kpi:hover { border-color: var(--brand); transform: translateY(-1px); }
.home-kpi-save .kpi-value { color: var(--ok-text); }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
.home-card { padding: 16px 18px; margin-bottom: 12px; }
.home-grid .home-card { margin-bottom: 0; }
.home-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.home-card-head h2 { margin: 0; font-size: 1rem; display: flex; align-items: center; gap: 6px; }
.home-more { font-size: .85rem; font-weight: 600; color: var(--brand-ink); text-decoration: none; white-space: nowrap; }
.home-more:hover { text-decoration: underline; }
.home-spark .spark { height: 90px; }
.home-sub { margin: 14px 0 6px; font-size: .8rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.home-bars, .home-acts, .home-clouds { list-style: none; margin: 0; padding: 0; }
.home-bars a { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; align-items: center; gap: 10px; padding: 5px 4px; border-radius: 6px; color: inherit; text-decoration: none; font-size: .9rem; }
.home-bars a:hover { background: var(--bg); }
.home-bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-bar-track { height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.home-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.home-bar-value { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.home-acts li + li, .home-clouds li + li { border-top: 1px solid var(--border); }
.home-act a, .home-clouds a { display: flex; align-items: center; gap: 10px; padding: 9px 4px; color: inherit; text-decoration: none; border-radius: 6px; }
.home-act a:hover, .home-clouds a:hover { background: var(--bg); }
.home-act-text, .home-cloud-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.home-act-text strong, .home-cloud-name strong { font-size: .92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-act-value { flex: none; text-align: right; }
.home-save { font-weight: 700; color: var(--ok-text); font-variant-numeric: tabular-nums; }
.home-mine { border-left: 4px solid var(--brand); }
.home-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px 0; }
.home-empty-icon { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--ok-bg); color: var(--ok-text); font-weight: 700; }
@media (max-width: 760px) { .home-grid { grid-template-columns: 1fr; } .home-hero { padding: 18px; } }
/* the row under the pointer is slightly highlighted, so a wide row is easy to follow */
.data-table tbody tr { transition: background-color .1s; }
.data-table tbody tr:hover { background: var(--bg); }
/* the Costs filters inside an expanded chart or table */
.chart-modal .costs-sticky { position: static; margin: 0 18px 4px; padding: 0; background: transparent; border: 0; box-shadow: none; }
.chart-modal .costs-sticky .costs-filters { margin: 0; }
/* chart cards: the download menu, before the expand button */
.chart-download { position: relative; margin-left: auto; margin-top: -8px; }
.chart-download + .chart-expand { margin-left: 2px; }
.chart-download .chart-expand { margin: 0; }
.chart-head select + .chart-download { margin-left: 4px; }
.chart-download-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 25; min-width: 96px; padding: 4px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow), 0 8px 24px rgba(0,0,0,.12); }
.chart-download-menu[hidden] { display: none; }
.chart-download-menu button { padding: 7px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font: inherit; font-size: .85rem; font-weight: 600; text-align: center; cursor: pointer; }
.chart-download-menu button:hover, .chart-download-menu button:focus-visible { background: var(--brand-soft); color: var(--brand-ink); outline: 0; }

/* ---- an actionable's own page ---- */
.act-detail { border-left: 4px solid var(--border); padding: 20px 22px; margin-bottom: 12px; }
.act-detail.sev-high { border-left-color: #dc2626; }
.act-detail.sev-medium { border-left-color: #f59e0b; }
.act-detail.sev-low { border-left-color: #94a3b8; }
.act-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.act-detail-title { flex: 1 1 420px; min-width: 0; }
.act-detail-title h1 { margin: 10px 0 0; font-size: 1.45rem; overflow-wrap: anywhere; }
.act-detail-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.act-detail-actions .act-menu { margin-top: 0; align-self: center; }
.act-detail-kpis { margin: 18px 0 6px; }
.act-detail-kpis .kpi { border: 1px solid var(--border); border-radius: 12px; }
.act-kpi-text { font-size: 1.1rem; overflow-wrap: anywhere; }
.act-section { margin-top: 16px; }
.act-section h2, .act-detail-scope h2, .act-history h2 { font-size: 1rem; margin: 0 0 6px; }
.act-why-lg { margin: 0; font-size: 1rem; line-height: 1.55; }
.act-note { margin: 8px 0 0; padding: 8px 12px; border-radius: 8px; background: var(--bg); }
.act-steps { margin: 0; padding-left: 22px; line-height: 1.7; }
.act-detail-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; margin-bottom: 12px; }
.act-detail-grid .card { margin-bottom: 0; }
.act-detail-scope { padding: 16px 18px; }
.act-scope-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 8px 0 0; font-size: .9rem; }
.act-scope-list dt { color: var(--muted); }
.act-scope-list dd { margin: 0; overflow-wrap: anywhere; font-weight: 550; }
.act-history { padding: 16px 18px; }
.act-timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.act-timeline li { display: flex; gap: 12px; padding: 8px 0; position: relative; }
.act-timeline li + li::before { content: ""; position: absolute; left: 5px; top: -8px; height: 16px; border-left: 2px solid var(--border); }
.act-timeline p { margin: 2px 0 0; }
.act-tl-dot { flex: none; width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; background: var(--border); }
.act-tl-detected, .act-tl-reappeared { background: #f59e0b; }
.act-tl-done, .act-tl-resolved { background: var(--ok-text); }
.act-tl-assigned, .act-tl-reopened { background: var(--brand); }
.act-title a { color: inherit; text-decoration: none; }
.act-title a:hover { color: var(--brand-ink); text-decoration: underline; }
@media (max-width: 760px) { .act-detail-grid { grid-template-columns: 1fr; } }
/* card heads: the title on the left; any select, download and expand together on the right */
.chart-head { justify-content: flex-start; }
.chart-head > select { margin-left: auto; }
.chart-head > .chart-download { margin-left: auto; }
.chart-head > select + .chart-download { margin-left: 6px; }

/* close buttons (✕): a green circle everywhere */
.btn-close { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 50%; background: var(--brand); color: #fff; cursor: pointer; transition: background-color .15s, transform .1s; }
.btn-close:hover { background: var(--brand-ink); }
.btn-close:active { transform: scale(.94); }
.btn-close:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn-close-sm { width: 22px; height: 22px; }
.chat-context-remove.btn-close { padding: 0; color: #fff; }
.chat-context-remove.btn-close:hover { background: var(--brand-ink); color: #fff; }
/* a popup's title row: the title, and its close button on the right */
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h3 { margin: 0; }
.act-checking { display: inline-flex; align-items: center; gap: 6px; color: var(--brand-ink); font-weight: 600; }
/* counts next to titles and tabs: a green circle, like the nav badge */
.act-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border: 0; border-radius: 999px; background: var(--brand); color: #fff; font-size: .72rem; font-weight: 700; font-variant-numeric: tabular-nums; }
