/* SysCoERP Admin — Syscomatic brand (same palette and Satoshi type as the ERP theme,
   custom_addons/syscoerp_dashboard/static/src/scss/syscoerp_theme.scss) */
@font-face { font-family: "Satoshi"; src: url("fonts/Satoshi-Variable.woff2") format("woff2");
    font-weight: 300 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Satoshi"; src: url("fonts/Satoshi-VariableItalic.woff2") format("woff2");
    font-weight: 300 900; font-style: italic; font-display: swap; }

:root {
    --bg: #F6F4FB;
    --card: #FFFFFF;
    --text: #130D26;          /* sx-charcoal */
    --muted: #5E5670;         /* sx-ink-soft, 4.5:1+ on white */
    --line: #ECE6F7;          /* sx-line */
    --tint: #F4F0FC;          /* sx-tint */
    --primary: #5509D9;       /* sx-electric */
    --primary-dark: #371A74;  /* sx-deep */
    --accent: #A336FF;        /* sx-neon */
    --accent-2: #7134F1;      /* sx-light */
    --ring: rgba(85, 9, 217, .18);
    --success: #1E9E5A;
    --warning: #E39A2D;
    --danger: #D64545;
    --grey: #857D96;
    --radius: 16px;
    --shadow: 0 1px 2px rgba(19, 13, 38, .04), 0 10px 28px -18px rgba(55, 26, 116, .28);
    --gradient: linear-gradient(135deg, #5509D9 0%, #7134F1 55%, #A336FF 100%);
    --font: "Satoshi", "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; margin-bottom: 14px; }
code { font-size: 12.5px; background: var(--tint); padding: 2px 6px; border-radius: 6px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
    height: 64px; padding: 0 24px; background: rgba(255, 255, 255, .96); backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid #EEEAF5; box-shadow: 0 1px 2px rgba(19, 13, 38, .03), 0 10px 28px -18px rgba(55, 26, 116, .28); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text);
    letter-spacing: -.02em; }
.brand img { flex: none; width: 34px; height: 34px; border-radius: 10px; object-fit: contain; }
.brand span { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand:hover { text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right form { margin: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--gradient); color: #fff; font-weight: 600; }
.admin-email { color: var(--muted); }

/* Layout */
.page { max-width: 1280px; margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: 20px; }
.page > .alert { margin: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.page-head > div { min-width: 0; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.muted { color: var(--muted); }
.empty { margin: 0; padding: 24px 0; text-align: center; color: var(--muted); }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 16px; }
.stat { display: flex; align-items: center; gap: 14px; }
.stat-icon { position: relative; width: 44px; height: 44px; border-radius: 10px; flex: none;
    display: flex; align-items: center; justify-content: center; }
.stat-icon::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: currentColor; opacity: .12; }
.stat-total { color: var(--primary); }
.stat-pending { color: var(--warning); }
.stat-active { color: var(--success); }
.stat-suspended { color: var(--grey); }
.stat-renewals { color: var(--accent-2); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-label { color: var(--muted); font-weight: 500; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 6px 16px;
    text-align: center; line-height: 1.25;
    border: 1px solid transparent; border-radius: 12px; font: 600 14px var(--font); cursor: pointer;
    transition: background-color .15s, box-shadow .15s, color .15s; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -8px rgba(85, 9, 217, .6); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--primary); background: var(--tint); }
.btn-success { background: var(--success); color: #fff; }
.btn-warn { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-icon { width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted);
    font-size: 16px; cursor: pointer; }
.btn-icon:hover { background: var(--tint); color: var(--text); }
.btn-icon:focus { outline: none; }
.btn-icon:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.when-busy { display: none; }
.htmx-request .when-idle, .htmx-request.when-idle { display: none; }
.htmx-request .when-busy { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-sm { min-height: 30px; padding: 4px 12px; font-size: 13px; white-space: nowrap; }
.btn-block { width: 100%; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 900px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-active { background: #E3F4EA; color: #1F7A44; }
.badge-pending { background: #FDF1DE; color: #9A6312; }
.badge-suspended { background: #ECEAF2; color: #5E5670; }
.badge-provisioning_failed { background: #FBE6E5; color: #A93A36; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-weight: 500; }
.field textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: 14px/1.5 var(--font);
    color: var(--text); resize: vertical; }
.field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.field input, .field select { height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
    font: 14px var(--font); color: var(--text); background: #fff; }
.field em { color: var(--danger); font-style: normal; }
.field .error, .hint.error { color: var(--danger); font-weight: 500; font-size: 12.5px; }
.hint { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.hint.ok { color: var(--success); font-weight: 500; }
.has-error input, .has-error select { border-color: var(--danger); }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { flex: 1; min-width: 0; border-radius: 10px 0 0 10px; }
.input-suffix span { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line); border-left: 0;
    border-radius: 0 10px 10px 0; background: var(--tint); color: var(--muted); font-weight: 400; white-space: nowrap; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.alert { padding: 12px 14px; border-radius: 10px; }
.alert-danger { background: #FBE6E5; color: #A93A36; }
.alert-warning { background: #FDF1DE; color: #8A570C; }
.alert-success { background: #E3F4EA; color: #1F7A44; }
.alert-info { background: var(--tint); color: var(--primary-dark); }
.alert-detail { margin-top: 4px; font-size: 13px; opacity: .85; }
.alert-secret { margin-top: 8px; font-size: 13px; }
.alert-secret code { font-size: 14px; user-select: all; background: #fff; }
.login-card .alert { margin-bottom: 14px; }

/* Dialogs */
.dialog { width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0;
    border-radius: var(--radius); box-shadow: 0 24px 64px rgba(19, 13, 38, .28); color: var(--text); }
.dialog-sm { width: min(460px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(19, 13, 38, .5); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.dialog-head h2 { margin: 0; }
.dialog > div:not(.dialog-head), .dialog > form, .dialog #dialog-body { padding: 18px 20px 20px; }
.dialog[open] { display: flex; flex-direction: column; }
.dialog #dialog-body { overflow-y: auto; }
.dialog form p { margin-top: 0; }

/* Detail page */
.back { display: inline-block; color: var(--muted); font-weight: 500; }
.subtitle { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 0 0; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 20px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.text-danger { color: var(--danger); }
.text-warn { color: #B26A00; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 170px 1fr auto; gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.timeline .what strong { text-transform: capitalize; }
.timeline .who { color: var(--muted); font-size: 13px; }
.timeline li.is-error .what { color: var(--danger); }

/* Login */
.login-page { background: radial-gradient(1200px 600px at 10% -10%, #7134F1 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #A336FF 0%, transparent 55%), #371A74; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; padding: 32px; box-shadow: 0 30px 80px -20px rgba(19, 13, 38, .6); }
.login-card .brand { font-size: 22px; margin-bottom: 6px; }
.login-card .brand img { width: 40px; height: 40px; }
.login-card .muted { margin: 0 0 20px; }

@media (max-width: 860px) {
    /* Client tables become one card per client */
    .table-responsive { min-width: 0; }
    .table-responsive thead { display: none; }
    .table-responsive, .table-responsive tbody, .table-responsive tr, .table-responsive td { display: block; width: 100%; }
    .table-responsive tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
    .table-responsive tr:last-child { border-bottom: 0; }
    .table-responsive td { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 4px 0; border: 0;
        overflow-wrap: anywhere; }
    .table-responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 500; }
    .table-responsive td[data-label="Company"] { font-size: 15px; font-weight: 600; }
    .table-responsive td[data-label="Action"]:empty { display: none; }
    .table-responsive td.actions { display: grid; }
    .table-responsive td > * { justify-self: start; }
}

@media (max-width: 640px) {
    .topbar { height: 56px; padding: 0 16px; }
    .brand { font-size: 16px; gap: 8px; }
    .brand img { width: 30px; height: 30px; }
    .admin-email, .topbar .avatar { display: none; }
    .page { padding: 16px 16px 40px; gap: 16px; }
    h1 { font-size: 20px; }
    .card { padding: 16px; border-radius: 14px; }
    .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat { gap: 10px; }
    .stat-icon { width: 38px; height: 38px; }
    .stat-value { font-size: 22px; }
    .form-grid { grid-template-columns: 1fr; }
    .page-head .btn-primary { flex: 1 1 auto; }
    .actions { width: 100%; }
    .actions .btn { flex: 1 1 calc(50% - 8px); }
    .kv { grid-template-columns: 110px 1fr; }
    .timeline li { grid-template-columns: 1fr; gap: 2px; }
    .dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
    .dialog-sm { height: auto; max-height: 100dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
    .dialog #dialog-body { flex: 1; }
    .form-actions .btn { flex: 1 1 auto; }
    .login-card { padding: 24px; }
}

/* Apps: searchable picker (New Client, Manage Apps) and per-app status */
.app-fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.app-fieldset legend, .manage-apps h3 { font-weight: 600; font-size: 14px; margin-bottom: 8px; padding: 0; }
.manage-apps { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.app-picker-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.app-search { flex: 1; min-width: 0; height: 40px; padding: 0 12px 0 36px; border: 1px solid var(--line); border-radius: 10px;
    font: 14px var(--font); color: var(--text);
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235E5670' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center; }
.app-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.app-count { color: var(--primary); font-weight: 600; font-size: 13px; white-space: nowrap; }
.app-count:empty { display: none; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px;
    max-height: 340px; overflow-y: auto; padding: 2px 4px 2px 2px; margin-bottom: 6px; overscroll-behavior: contain; }
.app-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 14px 6px 10px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--card);
    cursor: pointer; text-align: center; transition: border-color .15s, background .15s, box-shadow .15s; }
.app-tile[hidden] { display: none; }
.app-tile:hover { border-color: #CDB8F5; box-shadow: 0 6px 18px -12px rgba(85, 9, 217, .5); }
.app-tile input { position: absolute; top: 8px; right: 8px; width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.app-tile img { border-radius: 10px; margin-bottom: 2px; }
.app-name { font-size: 13px; font-weight: 600; line-height: 1.25; }
.app-tile small { color: var(--muted); font-size: 11px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; max-width: 100%; }
.app-tile:has(input:checked) { border-color: var(--primary); background: var(--tint); }

.app-tile.is-included small { color: var(--primary); font-weight: 600; }
.app-tile:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.app-none { grid-column: 1 / -1; margin: 0; padding: 24px 0; text-align: center; color: var(--muted); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-head h2 { margin-bottom: 14px; }
.app-status-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 8px; }
.app-status { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 12px; background: #FAF8FE; }
.app-status img { flex: none; border-radius: 7px; }
.app-status-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; }
.app-status.app-failed { background: #FDF3F2; }
.app-error { overflow-wrap: anywhere; font-size: 12.5px; }
.spinner { display: inline-block; width: 11px; height: 11px; border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; vertical-align: -1px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Small screens: denser app tiles (after the base app rules so it wins) */
@media (max-width: 640px) {
    .sub-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .sub-item { padding: 10px 12px; }
    .app-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; max-height: 320px; }
    .app-tile { padding: 12px 4px 8px; border-radius: 12px; }
    .app-tile img { width: 32px; height: 32px; }
    .app-tile input { top: 6px; right: 6px; }
    .app-name { font-size: 12.5px; }
}

/* Subscription / activity summaries */
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }
.sub-item { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 12px; background: #FAF8FE;
    border: 1px solid var(--line); min-width: 0; }
.sub-item > span { color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: .02em; }
.sub-item strong { font-weight: 600; overflow-wrap: anywhere; }
.sub-item small { display: block; font-weight: 500; font-size: 12px; margin-top: 2px; }
.sub-notes { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--tint); color: var(--primary-dark);
    white-space: pre-line; }
.pay-trial { background: var(--tint); color: var(--primary); }
.pay-paid { background: #E3F4EA; color: #1F7A44; }
.pay-free { background: #ECEAF2; color: #5E5670; }
.pay-due { background: #FDF1DE; color: #9A6312; }
.pay-overdue { background: #FBE6E5; color: #A93A36; }
.table td .badge { margin-left: 4px; }
.table-activity { min-width: 980px; }
.table-activity td { font-size: 13.5px; vertical-align: top; }
.table-activity tr.is-revoked td { opacity: .6; }
.attribution { margin: 12px 0 0; }
.attribution a { color: var(--muted); text-decoration: underline; }

/* Password dialog */
.input-reveal { display: flex; gap: 8px; }
.input-reveal input { flex: 1; min-width: 0; }
.input-prefix .currency { flex: 0 0 72px; border-radius: 10px 0 0 10px; text-transform: uppercase; background: var(--tint);
    text-align: center; font-weight: 600; }
.input-prefix input:last-child { border-radius: 0 10px 10px 0; border-left: 0; }

/* Automation + edit details */
.toggle-state { display: inline-block; margin: 2px 6px 0 0; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.toggle-state.on { background: #E3F4EA; color: #1F7A44; }
.toggle-state.off { background: #ECEAF2; color: #5E5670; }
.automation-hint { margin: -6px 0 12px; }
.notices { margin-top: 12px; }
.notices summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.notices ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.kv dd.pre { white-space: pre-line; }
.card-head .actions { width: auto; flex-wrap: nowrap; }
.card-head .actions .btn { flex: none; }
.check + .check { margin-top: 10px; }

/* Top navigation + backups */
.topbar { gap: 16px; }
.topnav { display: flex; gap: 4px; margin-right: auto; margin-left: 12px; }
.topnav a { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.topnav a:hover { background: var(--tint); color: var(--text); text-decoration: none; }
.topnav a[aria-current="page"] { background: var(--tint); color: var(--primary); }
.backup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.backup-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 12px; background: #FAF8FE; }
.backup-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.backup-text code { overflow-wrap: anywhere; background: transparent; padding: 0; }
.howto { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
@media (max-width: 640px) {
    .topnav { margin-left: 0; }
    .topbar .brand { font-size: 0; gap: 0; }
    .topnav a { padding: 6px 8px; }
}

/* Branding & access card */
.branding { display: grid; grid-template-columns: minmax(200px, 260px) 1fr; gap: 20px; align-items: start; }
.logo-box { display: flex; flex-direction: column; gap: 10px; }
.logo-preview { height: 112px; border: 1px solid var(--line); border-radius: 12px; background: #FAF8FE;
    display: flex; align-items: center; justify-content: center; padding: 14px; }
.logo-preview img { max-width: 100%; max-height: 84px; object-fit: contain; }
.logo-preview.is-empty { border-style: dashed; color: var(--muted); font-size: 13px; }
.logo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.access-grid { margin-bottom: 0; }
@media (max-width: 720px) { .branding { grid-template-columns: 1fr; } }

/* Overview: KPIs, charts, attention list, usage table */
.small { font-size: 12.5px; }
.block { display: block; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere; }
.kpi-sub { color: var(--muted); font-size: 12.5px; }
.kpi-alert { box-shadow: inset 3px 0 0 var(--danger), var(--shadow); }
.kpi-alert .kpi-value { color: var(--danger); }
.overview-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.count-pill { padding: 2px 10px; border-radius: 999px; background: var(--tint); color: var(--primary); font-weight: 600; font-size: 12.5px; }

.bar-chart { position: relative; display: grid; grid-template-columns: 32px 1fr; grid-template-rows: 180px auto; column-gap: 8px; }
.bar-grid { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; justify-content: space-between; }
.bar-grid span { position: relative; height: 0; border-top: 1px solid var(--line); }
.bar-grid span:last-child { border-top-color: #D9D1EA; }
.bar-grid em { position: absolute; left: -40px; top: -8px; width: 32px; text-align: right; font: 500 11px var(--font);
    color: var(--muted); font-style: normal; font-variant-numeric: tabular-nums; }
.bar-plot { grid-column: 2; grid-row: 1; display: flex; align-items: flex-end; gap: 2px; height: 100%; z-index: 1; }
.bar-col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center;
    outline: none; cursor: default; }
.bar { width: min(100%, 22px); min-height: 0; border-radius: 4px 4px 0 0; background: var(--primary); transition: opacity .15s; }
.bar-plot:hover .bar-col:not(:hover) .bar { opacity: .45; }
.bar-col:hover::after, .bar-col:focus-visible::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px);
    left: 50%; transform: translateX(-50%); white-space: nowrap; padding: 6px 10px; border-radius: 8px;
    background: var(--text); color: #fff; font-size: 12px; font-weight: 600; pointer-events: none; z-index: 2; }
.bar-col:hover::before, .bar-col:focus-visible::before { content: ""; position: absolute; inset: 0 0 0 0;
    background: rgba(85, 9, 217, .06); border-radius: 6px; }
.bar-col:first-child:hover::after, .bar-col:first-child:focus-visible::after { left: 0; transform: none; }
.bar-col:last-child:hover::after, .bar-col:last-child:focus-visible::after { left: auto; right: 0; transform: none; }
.bar-axis { grid-column: 2; grid-row: 2; display: flex; gap: 2px; margin-top: 8px; }
.bar-axis span { flex: 1; min-width: 0; text-align: center; font-size: 11px; color: var(--muted); white-space: nowrap;
    overflow: visible; }

.meter-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.meter-text { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 13.5px; }
.meter-text strong { font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: 999px; background: var(--tint); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.meter-sm { height: 5px; margin-top: 6px; max-width: 120px; }
.meter.is-full span { background: var(--danger); }

.attention { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.attention li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #FAF8FE;
    border: 1px solid var(--line); }
.attention a { color: var(--text); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.attention a:hover { text-decoration: none; }
.attention a:hover strong { color: var(--primary); }
.attention strong { font-weight: 600; font-size: 13.5px; }
.attention small { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.att-dot { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--primary); }
.att-danger .att-dot { background: var(--danger); }
.att-warning .att-dot { background: var(--warning); }
.usage-table td.num, .usage-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.usage-table td small.block { margin-top: 2px; }

@media (max-width: 960px) { .overview-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .usage-table td.num { text-align: left; } }
@media (max-width: 640px) {
    .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
    .kpi-value { font-size: 21px; }
    .bar-chart { grid-template-rows: 150px auto; }
}
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 22px 0 0; padding-top: 16px;
    border-top: 1px solid var(--line); }
.mini-stats dt { color: var(--muted); font-size: 12px; font-weight: 500; }
.mini-stats dd { margin: 2px 0 0; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
