/* ==========================================================================
   Q.Suite Control Panel — design system
   Brand-aligned with Cyvy (indigo/violet). Light, data-dense admin theme.
   Class names are preserved 1:1 with the Razor markup; restyling only.
   ========================================================================== */

@font-face {
    font-family: "Lexend";
    src: url("/landing/fonts/Lexend-VariableFont_wght.ttf") format("truetype-variations");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    color-scheme: light;

    /* Surfaces & neutrals */
    --bg: #f5f6fc;
    --surface: #ffffff;
    --surface-2: #f3f5fd;
    --surface-3: #eef1fb;
    --line: #e6e8f4;
    --line-strong: #d6daec;
    --text: #171a33;
    --text-soft: #3a405f;
    --muted: #6c7390;

    /* Brand (Cyvy) */
    --brand: #5b68e8;
    --brand-dark: #4954d4;
    --brand-darker: #3a45b8;
    --brand-2: #8b85f4;
    --brand-3: #5ca8fb;
    --brand-deep: #161a3c;
    --brand-deep-2: #1f2350;
    --brand-soft: #eef0fe;
    --brand-soft-2: #e4e7fd;
    --brand-ring: rgba(91, 104, 232, .32);
    --brand-grad: linear-gradient(135deg, #6b73ec 0%, #5b68e8 55%, #5ca8fb 130%);

    /* Status */
    --green: #0f8a52;
    --green-soft: #e7f8ef;
    --green-line: #b6e6cb;
    --amber: #9a5b00;
    --amber-soft: #fff5e3;
    --amber-line: #f3d39a;
    --red: #c5392b;
    --red-soft: #fdeeec;
    --red-line: #f4c0ba;

    /* Radius scale */
    --r-xs: 7px;
    --r-sm: 9px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-pill: 999px;

    /* Elevation */
    --shadow-xs: 0 1px 2px rgba(20, 24, 54, .05);
    --shadow-sm: 0 2px 6px rgba(20, 24, 54, .06), 0 1px 2px rgba(20, 24, 54, .04);
    --shadow: 0 10px 26px rgba(28, 33, 74, .08), 0 2px 6px rgba(28, 33, 74, .05);
    --shadow-lg: 0 24px 60px rgba(24, 28, 64, .16), 0 6px 16px rgba(24, 28, 64, .08);

    font-family: "Lexend", "Segoe UI", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

/* Subtle ambient brand wash behind the whole app */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(820px 520px at 100% -10%, rgba(92, 168, 251, .10), transparent 60%),
        radial-gradient(720px 480px at -10% 0%, rgba(139, 133, 244, .10), transparent 55%);
}

a {
    color: inherit;
    text-decoration: none;
}

::selection {
    background: var(--brand-soft-2);
    color: var(--brand-darker);
}

button,
input,
select,
textarea {
    font: inherit;
}

/* ----------------------------------------------------------------- Buttons */

button:not([class*="mud-"]),
.primary-link {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: var(--r-sm);
    padding: 0 16px;
    background: var(--brand-grad);
    color: #fff;
    font-weight: 600;
    letter-spacing: .005em;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(91, 104, 232, .28), inset 0 1px 0 rgba(255, 255, 255, .18);
    transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
}

button:not([class*="mud-"]):hover,
.primary-link:hover {
    filter: brightness(1.04);
    box-shadow: 0 7px 18px rgba(91, 104, 232, .34), inset 0 1px 0 rgba(255, 255, 255, .2);
    transform: translateY(-1px);
}

button:not([class*="mud-"]):active,
.primary-link:active {
    transform: translateY(0);
    box-shadow: 0 3px 9px rgba(91, 104, 232, .26);
}

button:not([class*="mud-"]):disabled {
    cursor: not-allowed;
    opacity: .5;
    box-shadow: none;
    transform: none;
    filter: grayscale(.2);
}

button:not([class*="mud-"]):focus-visible,
.primary-link:focus-visible,
.ghost-button:focus-visible,
a:focus-visible,
input:not([class*="mud-"]):focus-visible,
select:not([class*="mud-"]):focus-visible,
textarea:not([class*="mud-"]):focus-visible,
.nav-link:focus-visible,
.table-row:focus-visible,
.dense-row:focus-visible,
summary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--brand-ring);
}

.ghost-button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    padding: 0 15px;
    background: var(--surface);
    color: var(--text-soft);
    font-weight: 600;
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .12s ease;
}

.ghost-button:hover {
    background: var(--brand-soft);
    border-color: var(--brand);
    color: var(--brand-darker);
    transform: translateY(-1px);
}

.danger-button {
    border: 1px solid var(--red-line);
    background: var(--red-soft);
    color: var(--red);
    box-shadow: none;
}

.danger-button:hover {
    background: #fbe1dd;
    border-color: var(--red);
    color: var(--red);
    filter: none;
}

/* ------------------------------------------------------------ Form controls */

input:not([class*="mud-"]),
select:not([class*="mud-"]),
textarea:not([class*="mud-"]) {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    padding: 8px 12px;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

input:not([class*="mud-"])::placeholder,
textarea:not([class*="mud-"])::placeholder {
    color: #9aa1bd;
}

input:not([class*="mud-"]):hover,
select:not([class*="mud-"]):hover,
textarea:not([class*="mud-"]):hover {
    border-color: #c2c8e0;
}

input:not([class*="mud-"]):focus,
select:not([class*="mud-"]):focus,
textarea:not([class*="mud-"]):focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-ring);
}

input[type="checkbox"]:not([class*="mud-"]) {
    width: 18px;
    min-height: 18px;
    accent-color: var(--brand);
}

label:not([class*="mud-"]) {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.checkbox-label {
    min-height: 40px;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    align-content: center;
    color: var(--text);
}

/* -------------------------------------------------------------- Typography */

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.15;
}

h2 {
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -.01em;
}

small {
    color: var(--muted);
}

.eyebrow {
    display: inline-block;
    margin-bottom: 4px;
    color: var(--brand);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}

/* ------------------------------------------------------------- App shell */

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
}

.app-shell.app-shell-login {
    grid-template-columns: minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 22px 16px;
    border-right: 1px solid rgba(255, 255, 255, .07);
    background: linear-gradient(180deg, var(--brand-deep-2) 0%, var(--brand-deep) 60%, #11142f 100%);
    color: #fff;
    overflow: hidden;
}

.sidebar::after {
    content: "";
    position: absolute;
    width: 320px;
    height: 320px;
    top: -120px;
    right: -140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 133, 244, .35), transparent 70%);
    filter: blur(20px);
    pointer-events: none;
}

.brand-block {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-block strong {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.brand-block span,
.sidebar-meta span {
    display: block;
    color: rgba(214, 219, 255, .58);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 11px;
    object-fit: contain;
    background: rgba(255, 255, 255, .06);
    padding: 5px;
    box-shadow: 0 6px 14px rgba(2, 8, 30, .35), inset 0 0 0 1px rgba(255, 255, 255, .08);
}

.nav-section-label {
    position: relative;
    z-index: 1;
    padding: 0 10px;
    color: rgba(214, 219, 255, .42);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.nav-stack {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 4px;
}

.nav-link {
    position: relative;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: var(--r-sm);
    padding: 0 12px;
    color: rgba(225, 228, 255, .74);
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: .85;
}

.nav-link:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(124, 122, 248, .26), rgba(124, 122, 248, .08));
    color: #fff;
}

.nav-link.active::before {
    content: "";
    position: absolute;
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 22px;
    border-radius: 0 4px 4px 0;
    background: linear-gradient(180deg, var(--brand-2), var(--brand-3));
}

.nav-link.active svg {
    opacity: 1;
}

.sidebar-meta {
    position: relative;
    z-index: 1;
    margin-top: auto;
    display: grid;
    gap: 3px;
    padding: 12px;
    border-radius: var(--r-md);
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .08);
    overflow-wrap: anywhere;
}

.sidebar-meta strong {
    font-size: 13px;
    font-weight: 600;
}

/* --------------------------------------------------------------- Main area */

.main-surface {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-width: 0;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 26px;
    border-bottom: 1px solid var(--line);
    background: rgba(250, 251, 254, .82);
    backdrop-filter: saturate(160%) blur(14px);
}

.topbar .eyebrow {
    margin-bottom: 2px;
}

.topbar strong {
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -.01em;
}

.identity-block {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
    font-size: 14px;
}

.identity-block > span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 8px;
    border-radius: var(--r-pill);
    background: var(--brand-soft);
    color: var(--brand-darker);
    font-weight: 600;
    font-size: 13px;
}

.identity-block > span::before {
    content: "";
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-grad);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55);
}

.page-content {
    min-width: 0;
    padding: 26px;
    max-width: 1480px;
    width: 100%;
}

.page-heading,
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.command-group {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.command-group.wrap {
    flex-wrap: wrap;
}

/* ---------------------------------------------------------------- Tenant hero */

.tenant-hero {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 22px;
    background:
        radial-gradient(120% 140% at 0% 0%, var(--brand-soft) 0%, transparent 45%),
        linear-gradient(180deg, #ffffff 0%, var(--surface-2) 100%);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.tenant-hero::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--brand-grad);
}

.tenant-hero p {
    margin-top: 8px;
    color: var(--muted);
}

.tenant-actions {
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    gap: 9px;
    flex-wrap: wrap;
}

.tenant-action {
    min-width: 136px;
    min-height: 58px;
    display: grid;
    align-content: center;
    gap: 3px;
    border: 1px solid var(--brand-soft-2);
    border-radius: var(--r-md);
    padding: 10px 14px;
    background: var(--surface);
    color: var(--brand-dark);
    box-shadow: var(--shadow-xs);
    transition: border-color .15s ease, background .15s ease, transform .12s ease, box-shadow .15s ease;
}

.tenant-action:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.tenant-action span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.tenant-action strong {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

.tenant-action-secondary {
    border-color: transparent;
    background: var(--brand-grad);
    box-shadow: 0 6px 16px rgba(91, 104, 232, .26);
}

.tenant-action-secondary:hover {
    border-color: transparent;
    background: var(--brand-grad);
    filter: brightness(1.05);
}

.tenant-action-secondary span,
.tenant-action-secondary strong {
    color: #fff;
}

.tenant-action-secondary span {
    color: rgba(255, 255, 255, .82);
}

/* ------------------------------------------------------------------ Login */

.login-shell {
    min-height: calc(100vh - 4px);
    display: grid;
    place-items: center;
    padding: 32px 20px;
    background:
        radial-gradient(900px 600px at 50% -10%, rgba(139, 133, 244, .16), transparent 60%),
        radial-gradient(700px 500px at 100% 100%, rgba(92, 168, 251, .14), transparent 55%);
}

.login-panel {
    position: relative;
    width: min(440px, 100%);
    display: grid;
    gap: 22px;
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: var(--brand-grad);
}

.login-brand {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 16px;
}

.login-brand img {
    width: 60px;
    height: 60px;
    border-radius: var(--r-md);
    object-fit: contain;
    background: var(--brand-soft);
    padding: 8px;
    box-shadow: var(--shadow-sm);
}

.login-brand h1 {
    font-size: 24px;
}

.login-panel .form-stack button {
    margin-top: 4px;
    min-height: 44px;
}

/* ------------------------------------------------------------ Form layouts */

.form-stack,
.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 16px;
}

/* ----------------------------------------------------------- Metric tiles */

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric-tile,
.panel {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.metric-tile {
    position: relative;
    display: grid;
    gap: 7px;
    padding: 18px;
    overflow: hidden;
    transition: transform .14s ease, box-shadow .16s ease, border-color .16s ease;
}

.metric-tile::before {
    content: "";
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand-grad);
    opacity: .85;
}

.metric-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--brand-soft-2);
}

.metric-tile span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.metric-tile strong {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--text);
}

.tenant-metrics .metric-tile {
    min-height: 96px;
}

.tenant-metrics .metric-tile strong {
    font-size: 25px;
}

/* --------------------------------------------------------------- Grids */

.split-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    gap: 16px;
}

.tenant-detail-grid {
    display: grid;
    grid-template-columns: minmax(360px, .9fr) minmax(520px, 1.35fr);
    gap: 16px;
    align-items: start;
}

.panel {
    padding: 18px;
}

/* ------------------------------------------------------------ Lists/tables */

.dense-list,
.data-table {
    display: grid;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--surface);
}

.dense-row,
.table-row {
    display: grid;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    text-align: left;
    transition: background .13s ease;
}

.dense-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.table-row {
    grid-template-columns: minmax(220px, 1.4fr) minmax(130px, .8fr) minmax(130px, .8fr) auto;
    width: 100%;
}

.table-row:last-child,
.dense-row:last-child {
    border-bottom: 0;
}

.table-row:hover,
.dense-row:hover {
    background: var(--brand-soft);
}

.table-row span:first-child,
.dense-row span:first-child {
    display: grid;
    gap: 2px;
}

.table-row strong,
.dense-row strong {
    font-weight: 600;
}

/* ------------------------------------------------------------------ Chips */

.status-chip {
    width: fit-content;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--r-pill);
    padding: 0 11px;
    background: var(--surface-3);
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .01em;
}

.warning-chip {
    background: var(--amber-soft);
    color: var(--amber);
}

.danger-chip {
    background: var(--red-soft);
    color: var(--red);
}

.live-chip {
    background: var(--green-soft);
    color: var(--green);
}

.live-chip::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 3px rgba(15, 138, 82, .16);
}

/* ----------------------------------------------------------- Permissions */

.permission-workbench {
    margin-top: 16px;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.permission-item {
    grid-template-columns: minmax(0, 1fr) 150px;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.permission-item span {
    display: grid;
    gap: 2px;
}

/* ------------------------------------------------------------------ Audit */

.audit-toolbar {
    display: grid;
    grid-template-columns: auto minmax(260px, 1fr) 150px auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 14px;
}

.audit-toolbar > div:first-child {
    display: grid;
    gap: 2px;
    min-width: 110px;
}

.audit-toolbar > div:first-child strong {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -.02em;
}

.audit-toolbar > div:first-child span {
    color: var(--muted);
    font-size: 13px;
}

.audit-policy {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    border: 1px solid var(--brand-soft-2);
    border-radius: var(--r-md);
    padding: 12px 14px;
    background: var(--brand-soft);
    color: var(--brand-darker);
}

.audit-policy span {
    color: var(--brand-dark);
}

.audit-table .audit-row {
    grid-template-columns: minmax(320px, 1.8fr) minmax(190px, .8fr) minmax(190px, .8fr) minmax(220px, 1fr);
}

.audit-narrative strong,
.audit-narrative small {
    overflow-wrap: anywhere;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    color: var(--muted);
}

/* ------------------------------------------------------------ Module cards */

.module-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
    margin-bottom: 12px;
}

.module-search small {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    padding-bottom: 11px;
}

.module-card-list {
    display: grid;
    gap: 9px;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

.module-card-list::-webkit-scrollbar {
    width: 8px;
}

.module-card-list::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: var(--r-pill);
}

.module-card {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(160px, .9fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 74px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    transition: border-color .14s ease, box-shadow .14s ease;
}

.module-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-sm);
}

.module-card.enabled {
    border-color: var(--green-line);
    background: linear-gradient(180deg, #fbfffc, #f3fbf6);
}

.module-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.module-main-openable {
    cursor: pointer;
}

.module-main-openable:hover strong {
    color: var(--brand);
}

.module-main span:last-child,
.module-meta,
.tenant-user-row span:first-child {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.module-main strong,
.module-main small,
.tenant-user-row strong,
.tenant-user-row small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.module-meta {
    justify-items: start;
}

.module-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--r-pill);
    background: #c4cadb;
}

.status-dot.on {
    background: var(--green);
    box-shadow: 0 0 0 4px rgba(15, 138, 82, .14);
}

/* -------------------------------------------------------------- Tenant users */

.tenant-user-workbench {
    display: grid;
    grid-template-columns: minmax(260px, .78fr) minmax(360px, 1fr);
    gap: 16px;
    align-items: start;
}

.tenant-user-form {
    display: grid;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px;
    background: var(--surface-2);
}

.two-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.tenant-user-list {
    display: grid;
    gap: 9px;
}

.tenant-user-row {
    width: 100%;
    min-height: 74px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 14px;
    background: var(--surface);
    color: var(--text);
    text-align: left;
    box-shadow: var(--shadow-xs);
    transition: border-color .14s ease, background .14s ease, box-shadow .14s ease;
}

.tenant-user-row:hover,
.tenant-user-row.selected {
    border-color: var(--brand);
    background: var(--brand-soft);
    box-shadow: var(--shadow-sm);
}

.user-row-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

/* --------------------------------------------------------- Status blocks */

.loading-block,
.success-text,
.warning-text,
.error-text {
    padding: 14px 16px;
    border-radius: var(--r-md);
    font-size: 14px;
}

.loading-block {
    position: relative;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    box-shadow: var(--shadow-xs);
    padding-left: 42px;
}

.loading-block::before {
    content: "";
    position: absolute;
    left: 16px;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border-radius: 50%;
    border: 2px solid var(--brand-soft-2);
    border-top-color: var(--brand);
    animation: spin .7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.success-text {
    border: 1px solid var(--green-line);
    background: var(--green-soft);
    color: var(--green);
    margin-bottom: 14px;
}

.warning-text {
    border: 1px solid var(--amber-line);
    background: var(--amber-soft);
    color: var(--amber);
    margin-bottom: 14px;
}

.error-text {
    border: 1px solid var(--red-line);
    background: var(--red-soft);
    color: var(--red);
    margin-bottom: 14px;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 160px;
    padding: 20px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-md);
    background: var(--surface-2);
}

.empty-state p,
.empty-inline {
    color: var(--muted);
}

.empty-inline {
    padding: 14px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface-2);
}

/* ----------------------------------------------------------- Communications */

.communications-workbench {
    display: grid;
    grid-template-columns: minmax(260px, .85fr) minmax(420px, 1.45fr) minmax(300px, .95fr);
    gap: 16px;
    align-items: start;
}

.communications-metrics {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.compact-head {
    margin-bottom: 12px;
}

.conversation-list-panel,
.conversation-thread-panel,
.operations-panel {
    min-height: 640px;
}

.conversation-list {
    display: grid;
    gap: 9px;
    margin-top: 12px;
}

.conversation-row {
    width: 100%;
    min-height: 86px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 12px;
    background: var(--surface);
    color: var(--text);
    text-align: left;
    box-shadow: var(--shadow-xs);
    transition: border-color .14s ease, background .14s ease, box-shadow .14s ease;
}

.conversation-row:hover,
.conversation-row.selected {
    border-color: var(--brand);
    background: var(--brand-soft);
    box-shadow: var(--shadow-sm);
}

.conversation-main,
.conversation-meta,
.webhook-item span,
.diagnostic-item summary span {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.conversation-main span,
.conversation-main small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-meta {
    justify-items: end;
}

.thread-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.inline-number {
    width: 118px;
}

.message-list {
    height: 480px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 14px;
    background:
        radial-gradient(140% 100% at 50% 0%, var(--surface-3), transparent 60%),
        var(--surface-2);
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

.message-row {
    display: flex;
}

.message-row.outbound {
    justify-content: flex-end;
}

.message-bubble {
    width: min(78%, 560px);
    display: grid;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 14px 14px 14px 4px;
    padding: 11px 13px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.message-row.outbound .message-bubble {
    border-color: transparent;
    border-radius: 14px 14px 4px 14px;
    background: var(--brand-grad);
    color: #fff;
    box-shadow: 0 4px 12px rgba(91, 104, 232, .24);
}

.message-row.outbound .message-bubble .message-meta,
.message-row.outbound .message-bubble small {
    color: rgba(255, 255, 255, .82);
}

.message-media-preview,
.message-media-player {
    width: 100%;
    max-height: 280px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    object-fit: contain;
}

.media-link {
    color: var(--brand);
    font-size: 13px;
    font-weight: 600;
}

.message-row.outbound .media-link {
    color: #fff;
    text-decoration: underline;
}

.message-meta,
.reaction-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
}

.reaction-row {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px auto;
    gap: 10px;
    align-items: end;
    margin-top: 12px;
}

.composer textarea,
.stacked-form textarea {
    width: 100%;
    min-height: 84px;
    resize: vertical;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    font: inherit;
}

.stacked-form {
    display: grid;
    gap: 10px;
}

.stacked-form textarea {
    min-height: 78px;
}

.diagnostic-list,
.webhook-list {
    display: grid;
    gap: 9px;
    max-height: 275px;
    overflow-y: auto;
}

.compact-list {
    max-height: 180px;
    gap: 0.65rem;
}

.diagnostic-item,
.webhook-item {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.diagnostic-item summary {
    cursor: pointer;
    font-weight: 600;
}

.diagnostic-item p {
    margin-top: 8px;
    color: var(--muted);
}

.diagnostic-item pre {
    max-height: 180px;
    overflow: auto;
    border: 1px solid var(--brand-deep-2);
    border-radius: var(--r-sm);
    padding: 10px;
    background: var(--brand-deep);
    color: #e8ecff;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.webhook-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.panel-divider {
    height: 1px;
    margin: 16px 0;
    background: var(--line);
}

.instance-form,
.add-instance-form {
    margin-bottom: 0;
}

.phone-hint {
    min-height: 36px;
    display: flex;
    align-items: center;
    border: 1px solid var(--amber-line);
    border-radius: var(--r-sm);
    padding: 8px 12px;
    background: var(--amber-soft);
    color: var(--amber);
    font-size: 13px;
}

.phone-hint.valid {
    border-color: var(--green-line);
    background: var(--green-soft);
    color: var(--green);
}

.fixed-settings-panel,
.connection-summary,
.danger-zone,
.polling-status,
.provider-details {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 14px;
    background: var(--surface-2);
}

.fixed-settings-panel strong,
.connection-summary strong,
.danger-zone strong {
    display: block;
}

.fixed-settings-panel small,
.connection-summary span,
.danger-zone small {
    color: var(--muted);
    font-size: 13px;
}

.evolution-default-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 9px;
}

.evolution-default-badge {
    min-height: 56px;
    display: grid;
    align-content: center;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 9px 12px;
    background: var(--surface);
}

.evolution-default-badge strong {
    overflow-wrap: anywhere;
    font-size: 13px;
    line-height: 1.2;
}

.evolution-default-badge small {
    font-size: 12px;
}

.evolution-default-badge.default-enabled {
    border-color: var(--green-line);
    background: var(--green-soft);
}

.evolution-default-badge.default-enabled small {
    color: var(--green);
}

.evolution-default-badge.default-disabled {
    border-color: var(--line);
    background: var(--surface-2);
}

.evolution-default-badge.default-disabled small {
    color: var(--muted);
}

.evolution-default-badge.default-neutral {
    border-color: var(--brand-soft-2);
    background: var(--brand-soft);
}

.evolution-default-badge.default-neutral small {
    color: var(--brand-dark);
}

.webhook-address-card {
    display: grid;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 12px;
    background: var(--surface);
}

.webhook-address-card code {
    display: block;
    overflow-wrap: anywhere;
    border: 1px solid var(--brand-deep-2);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    background: var(--brand-deep);
    color: #e8ecff;
    font-size: 12px;
    line-height: 1.55;
}

/* --------------------------------------------------------------- Groups */

.groups-panel {
    align-content: start;
}

.group-list {
    display: grid;
    gap: 9px;
}

.group-row {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.group-name-cell {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.group-icon {
    display: inline-grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid var(--brand-soft-2);
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
}

.group-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.group-row strong,
.group-row span,
.group-row small {
    display: block;
    overflow-wrap: anywhere;
}

.group-row span {
    color: var(--text);
    font-size: 13px;
}

/* ----------------------------------------------------------- Prompt editor */

.prompt-settings-panel {
    margin-bottom: 16px;
}

.prompt-editor-layout {
    display: grid;
    grid-template-columns: minmax(260px, .55fr) minmax(0, 1.7fr);
    gap: 18px;
    align-items: start;
}

.prompt-settings-sidebar,
.prompt-editor-main,
.prompt-editor-section {
    display: grid;
    gap: 12px;
}

.runtime-status-grid {
    display: grid;
    gap: 9px;
}

.runtime-status-grid div,
.prompt-help-box,
.prompt-editor-section {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 14px;
    background: var(--surface-2);
}

.runtime-status-grid span,
.prompt-settings-sidebar small,
.prompt-help-box small,
.prompt-editor-section small {
    color: var(--muted);
    font-size: 12px;
}

.runtime-status-grid strong,
.prompt-help-box code {
    display: block;
    margin-top: 3px;
    overflow-wrap: anywhere;
}

.runtime-flow {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.runtime-flow div {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 3px 8px;
    align-items: start;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 12px;
    background: var(--surface-2);
}

.runtime-flow strong,
.runtime-flow small {
    min-width: 0;
    overflow-wrap: anywhere;
}

.runtime-flow small {
    grid-column: 2;
    color: var(--muted);
    font-size: 12px;
}

.prompt-editor-section {
    background: var(--surface);
}

.prompt-editor-section-head,
.template-preview-head {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.prompt-editor-section h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
}

.template-editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
    gap: 12px;
    align-items: stretch;
}

.prompt-settings-sidebar label,
.prompt-editor-section label {
    display: grid;
    gap: 6px;
}

.editor-textarea,
.prompt-textarea {
    width: 100%;
    resize: vertical;
    line-height: 1.5;
    tab-size: 2;
    font-family: "Lexend", ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
}

.editor-textarea {
    min-height: 220px;
}

.classifier-textarea {
    min-height: 260px;
}

.prompt-textarea {
    min-height: 110px;
}

.prompt-textarea.tall {
    min-height: 430px;
}

.tool-settings-stack {
    display: grid;
    gap: 16px;
}

.tool-settings-section {
    display: grid;
    gap: 12px;
    padding: 16px 0;
    border-top: 1px solid var(--line);
}

.tool-settings-section:first-child {
    border-top: 0;
    padding-top: 0;
}

.module-inline-head {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.module-inline-head div {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.module-inline-head small {
    color: var(--muted);
}

.template-preview {
    display: grid;
    gap: 8px;
    min-width: 0;
    align-content: start;
    border-left: 3px solid var(--brand);
    padding-left: 14px;
}

.template-preview pre {
    margin: 0;
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 14px;
    background: var(--surface-2);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
}

.danger-zone {
    border-color: var(--red-line);
    background: var(--red-soft);
}

.polling-status {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    border-color: var(--brand-soft-2);
    background: var(--brand-soft);
    color: var(--brand-darker);
    font-size: 13px;
}

.spinner-dot {
    width: 10px;
    height: 10px;
    display: inline-block;
    border-radius: 50%;
    background: var(--brand);
    animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%,
    100% {
        opacity: .35;
        transform: scale(.8);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.provider-details summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.command-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.provider-result,
.qr-panel {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 14px;
    background: var(--surface-2);
}

.provider-result code,
.qr-panel code {
    display: block;
    overflow-wrap: anywhere;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 10px;
    background: var(--surface);
    color: var(--text);
}

.qr-panel {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
}

.connection-qr-panel {
    background: var(--surface);
}

.qr-panel img {
    width: 220px;
    max-width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: #fff;
    object-fit: contain;
    box-shadow: var(--shadow-sm);
}

.json-block {
    max-height: 460px;
    overflow: auto;
    border: 1px solid var(--brand-deep-2);
    border-radius: var(--r-md);
    padding: 14px;
    background: var(--brand-deep);
    color: #e8ecff;
    font-size: 12px;
    line-height: 1.55;
    white-space: pre-wrap;
}

/* --------------------------------------------------------------- Catalog */

.catalog-product-grid {
    display: grid;
    gap: 0.75rem;
}

.catalog-product-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) minmax(120px, auto);
    gap: 0.9rem;
    align-items: center;
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    transition: border-color .14s ease, box-shadow .14s ease;
}

.catalog-product-row:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-sm);
}

.catalog-product-row img {
    width: 72px;
    height: 72px;
    border-radius: var(--r-sm);
    object-fit: cover;
    background: var(--surface-2);
}

.catalog-product-row strong,
.catalog-product-row small,
.catalog-product-row p {
    display: block;
}

.catalog-product-row p {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.83rem;
    line-height: 1.35;
    max-height: 2.8em;
    overflow: hidden;
}

.catalog-product-side {
    display: grid;
    justify-items: end;
    gap: 0.35rem;
    text-align: right;
}

/* --------------------------------------------------------------- iFood */

.ifood-workbench-heading h1 {
    letter-spacing: 0;
}

.ifood-metrics {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.ifood-metrics .metric-tile {
    min-width: 0;
}

.ifood-metrics .metric-tile strong {
    min-width: 0;
    font-size: 18px;
    line-height: 1.15;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.ifood-tabbar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    gap: 8px;
    margin: 14px 0 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
}

button.ifood-tab {
    min-width: 140px;
    min-height: 56px;
    display: grid;
    grid-template-rows: auto auto;
    align-content: center;
    justify-content: start;
    gap: 3px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 9px 12px;
    background: var(--surface);
    color: var(--text);
    text-align: left;
    letter-spacing: 0;
    box-shadow: var(--shadow-xs);
}

button.ifood-tab:hover {
    border-color: var(--line-strong);
    background: var(--surface-2);
    box-shadow: var(--shadow-sm);
    filter: none;
}

button.ifood-tab.active {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand-darker);
    box-shadow: inset 3px 0 0 var(--brand), var(--shadow-xs);
}

.ifood-tab span {
    font-weight: 650;
    line-height: 1.1;
    white-space: nowrap;
}

.ifood-tab small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
}

.ifood-tab.active small {
    color: var(--brand-darker);
}

.ifood-workbench-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, .82fr);
    gap: 16px;
    align-items: start;
}

.ifood-checklist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
}

.ifood-check-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.ifood-check-item span:nth-child(2) {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.ifood-check-item strong,
.ifood-check-item small {
    overflow-wrap: anywhere;
}

.ifood-homologation-grid {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.ifood-homologation-row {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(210px, .7fr) 120px 110px;
    gap: 14px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    background: var(--surface);
}

.ifood-homologation-row.heading {
    border: 0;
    padding: 0 12px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.ifood-homologation-capability {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.ifood-homologation-capability small {
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ifood-homologation-row code {
    overflow-wrap: anywhere;
    color: var(--brand-darker);
}

.ifood-endpoint-list {
    display: grid;
    gap: 9px;
    margin-top: 14px;
}

.ifood-endpoint-row {
    display: grid;
    grid-template-columns: 72px minmax(260px, .75fr) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 12px;
    background: var(--surface-2);
}

.ifood-endpoint-row code {
    overflow-wrap: anywhere;
    color: var(--brand-darker);
}

.ifood-inline-panel {
    display: grid;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 14px;
    background: var(--surface-2);
}

.ifood-inline-panel h3 {
    margin: 0;
    font-size: 16px;
}

.ifood-mini-list {
    display: grid;
    gap: 8px;
}

.ifood-mini-list article {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    background: var(--surface);
}

.ifood-mini-list article > span:first-child {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.ifood-mini-list strong,
.ifood-mini-list small {
    overflow-wrap: anywhere;
}

/* --------------------------------------------------------------- Error UI */

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    padding: 14px 24px;
    background: var(--brand-deep);
    color: #fff;
    box-shadow: 0 -8px 24px rgba(16, 20, 48, .3);
}

#blazor-error-ui .reload {
    color: var(--brand-3);
    font-weight: 600;
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
    opacity: .7;
}

/* --------------------------------------------------------------- Responsive */

@media (max-width: 1040px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 12px;
        padding: 14px 16px;
    }

    .sidebar::after {
        display: none;
    }

    .brand-block {
        padding: 0;
        border-bottom: 0;
        flex: 1 1 auto;
    }

    .nav-section-label,
    .sidebar-meta {
        display: none;
    }

    .nav-stack {
        flex: 1 1 100%;
        grid-auto-flow: column;
        justify-content: start;
        gap: 6px;
        overflow-x: auto;
    }

    .nav-link.active::before {
        display: none;
    }

    .split-grid,
    .tenant-detail-grid,
    .tenant-user-workbench,
    .module-card,
    .prompt-editor-layout,
    .template-editor-grid,
    .runtime-flow,
    .audit-toolbar,
    .communications-workbench,
    .metric-grid,
    .permission-grid,
    .form-grid,
    .form-grid.compact,
    .two-field-grid,
    .table-row,
    .composer,
    .conversation-row,
    .group-row,
    .webhook-item,
    .audit-table .audit-row,
    .qr-panel {
        grid-template-columns: 1fr;
    }

    .catalog-product-row {
        grid-template-columns: 56px minmax(0, 1fr);
    }

    .catalog-product-row img {
        width: 56px;
        height: 56px;
    }

    .catalog-product-side {
        grid-column: 1 / -1;
        justify-items: start;
        text-align: left;
    }

    .ifood-workbench-grid,
    .ifood-check-item,
    .ifood-endpoint-row,
    .ifood-homologation-row,
    .ifood-mini-list article {
        grid-template-columns: 1fr;
    }

    .ifood-homologation-row.heading {
        display: none;
    }

    .audit-policy,
    .pagination-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .tenant-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .tenant-actions {
        justify-content: stretch;
    }

    .tenant-action {
        flex: 1 1 150px;
    }

    .module-search {
        grid-template-columns: 1fr;
    }

    .module-search small {
        padding-bottom: 0;
    }

    .tenant-user-row {
        grid-template-columns: 1fr;
    }

    .user-row-meta {
        justify-content: flex-start;
    }

    .module-actions {
        justify-content: flex-start;
        justify-items: start;
    }

    .conversation-list-panel,
    .conversation-thread-panel,
    .operations-panel {
        min-height: auto;
    }

    .message-list {
        height: 420px;
    }

    .message-bubble {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .page-content {
        padding: 18px 16px;
    }

    .topbar {
        padding: 12px 16px;
    }

    h1 {
        font-size: 24px;
    }
}

/* ---------------------------------------------------------- MudBlazor bridge
   Helpers that make MudBlazor components (data grids, etc.) sit inside the
   Cyvy design system without clashing with the custom panels above. */

.qs-grid.mud-table {
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.qs-grid .mud-table-toolbar {
    min-height: 68px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #ffffff, var(--surface-2));
}

.qs-grid .mud-table-toolbar .mud-typography {
    font-weight: 650;
    letter-spacing: -.01em;
}

.qs-grid .mud-table-head th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.qs-grid-row {
    cursor: pointer;
    transition: background .13s ease;
}

.qs-grid .mud-table-cell {
    border-bottom: 1px solid var(--line);
}

.qs-cell-stacked {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.qs-cell-stacked strong {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.tenant-grid-link {
    color: inherit;
    text-decoration: none;
}

.tenant-grid-link:hover {
    color: var(--brand);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.qs-cell-stacked small {
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.tenant-grid-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    color: var(--muted);
    text-decoration: none;
    transition: background .13s ease, color .13s ease;
}

.tenant-grid-action:hover {
    background: var(--surface-2);
    color: var(--brand);
}

.qs-grid-search {
    width: min(320px, 42vw);
}

.connector-filter {
    width: 150px;
}

.connector-cell,
.connector-detail-head {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.connector-grid-logo {
    width: 38px;
    height: 38px;
    object-fit: contain;
    flex: 0 0 38px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: #fff;
}

.connector-row-selected .mud-table-cell {
    background: var(--brand-soft);
}

.connector-detail {
    display: grid;
    gap: 14px;
}

.connector-detail-logo {
    width: 52px;
    height: 52px;
    object-fit: contain;
    flex: 0 0 52px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: #fff;
}

.connector-logo-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--brand);
    background: var(--brand-soft);
}

.connector-detail-meta {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 13px;
}

/* Dashboard stat cards */
.qs-stat {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 100%;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--r-md) !important;
    background: var(--surface);
    box-shadow: var(--shadow-sm) !important;
    transition: transform .14s ease, box-shadow .16s ease, border-color .16s ease;
}

.qs-stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow) !important;
    border-color: var(--brand-soft-2);
}

.qs-stat-icon {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 12px;
    background: var(--brand-soft);
    color: var(--brand);
}

.qs-stat-icon .mud-icon-root {
    font-size: 24px;
}

.qs-stat-body {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.qs-stat-body span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.qs-stat-body strong {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.1;
}

/* Dashboard panels */
.qs-panel {
    height: 100%;
    padding: 18px !important;
    border: 1px solid var(--line);
    border-radius: var(--r-lg) !important;
    background: var(--surface);
    box-shadow: var(--shadow-sm) !important;
}

.qs-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.qs-list .mud-list-item {
    border-radius: var(--r-sm);
}

.qs-list-row {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

/* Dialog forms */
.qs-dialog-form {
    display: grid;
    gap: 16px;
    min-width: min(420px, 78vw);
}

.qs-dialog-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.qs-permission-list {
    display: grid;
    gap: 10px;
    min-width: min(560px, 80vw);
    max-height: min(60vh, 540px);
    overflow-y: auto;
    padding-right: 4px;
}

.qs-permission-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
}

.qs-permission-select {
    width: 150px;
}

.qs-simple-table.mud-table {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
}

.qs-simple-table th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

@media (max-width: 560px) {
    .qs-dialog-two,
    .qs-permission-row {
        grid-template-columns: 1fr;
    }

    .qs-permission-select {
        width: 100%;
    }
}

@media (max-width: 1040px) {
    .qs-grid .mud-table-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .qs-grid-search {
        width: 100%;
    }
}
