/* =============================================================
   Robeeta SSO — canonical theme
   Mirrors D:\svn\robeeta\robeeta-sso\markdown\theme.html verbatim.
   Identical copies live in:
     Robeeta.SSO.AdminConsole/wwwroot/css/site.css
     Robeeta.SSO.LoginConsole/wwwroot/css/site.css
     Robeeta.SSO.DemoConsole/wwwroot/css/site.css
   Keep the three in sync — never tweak one without the others.
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    color: #1a2332;
    background: #f0f2f5;
}

a { color: #206bc4; }

code, kbd, samp, pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── App shell ─────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Brand (in topbar) ─────────────────── */
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}
.brand-icon {
    width: 30px;
    height: 30px;
    background: #206bc4;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}
.brand-icon i { font-size: 16px; line-height: 1; }
.brand-icon svg { width: 17px; height: 17px; }
.brand-name {
    font-size: 15px;
    font-weight: 700;
    color: #1a2332;
    letter-spacing: -0.01em;
}

/* ── Main area ─────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ── Topbar ────────────────────────────── */
.topbar {
    min-height: 52px;
    background: #ffffff;
    border-bottom: 1px solid #e6e9ef;
    display: flex;
    align-items: center;
    gap: 0.5rem 1.5rem;
    flex-wrap: wrap;
    padding: 0.4rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

/* ── Top navigation (horizontal menu) ──── */
.topnav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.topnav-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #5a6b80;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}
.topnav-item:hover { background: #f1f4f9; color: #1a2332; }
.topnav-item.active { background: #206bc4; color: #ffffff; }
.topnav-item i { flex-shrink: 0; font-size: 16px; opacity: 0.8; line-height: 1; }
.topnav-item.active i { opacity: 1; }

.topbar-right { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #206bc4;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: #3d4a5c; }
/* Email + role stacked in the profile trigger. */
.user-identity { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.user-identity .user-name {
    max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: 11px; font-weight: 600; color: #6b7a90; letter-spacing: 0.02em; }
/* Role badge in the dropdown header. */
.user-menu-header .role-badge {
    display: inline-block; margin-top: 5px;
    font-size: 11px; font-weight: 600; color: #206bc4;
    background: #eaf1fb; border-radius: 999px; padding: 1px 8px;
}

/* ── User menu (dropdown) ─────────────── */
.user-menu-wrap { position: relative; }
.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0.45rem 0.2rem 0.2rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    color: #1a2332;
    transition: background 0.12s, border-color 0.12s;
}
.user-menu-trigger:hover { background: #f0f2f5; border-color: #e6e9ef; }
.user-menu-trigger:focus-visible { outline: 2px solid #206bc4; outline-offset: 1px; }
.user-menu-trigger .chevron {
    width: 14px; height: 14px; color: #6b7a90;
    transition: transform 0.12s ease;
}
.user-menu-wrap.open .user-menu-trigger .chevron { transform: rotate(180deg); }
.user-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: #ffffff;
    border: 1px solid #e6e9ef;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(26,35,50,0.12);
    padding: 0.3rem;
    display: none;
    z-index: 20;
}
.user-menu-wrap.open .user-menu { display: block; }
.user-menu-header {
    padding: 0.5rem 0.65rem 0.55rem;
    border-bottom: 1px solid #f0f2f5;
    margin-bottom: 0.3rem;
}
.user-menu-header .name {
    font-size: 13px; font-weight: 700; color: #1a2332;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-menu-header .email {
    display: block; margin-top: 2px;
    font-size: 12px; color: #6b7a90;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.45rem 0.65rem;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    color: #3d4a5c;
    background: transparent;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    text-align: left;
}
.user-menu-item:hover { background: #f0f2f5; color: #1a2332; }
.user-menu-item i, .user-menu-item .icon {
    width: 15px; height: 15px;
    flex-shrink: 0;
    color: #6b7a90;
    font-size: 15px;
    line-height: 1;
}
.user-menu-item.danger { color: #b91c1c; }
.user-menu-item.danger:hover { background: #fff0f0; color: #991b1b; }
.user-menu-item.danger i, .user-menu-item.danger .icon { color: #d63939; }
.user-menu form { margin: 0; }

/* ── Page-header actions dropdown ─────── */
/* Reuses .user-menu-item for the rows; toggled by the generic handler in _Layout. */
.actions-menu { position: relative; display: inline-block; }
.actions-menu-trigger .chevron { width: 14px; height: 14px; transition: transform 0.12s ease; }
.actions-menu.open .actions-menu-trigger .chevron { transform: rotate(180deg); }
.actions-menu-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid #e6e9ef;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(26,35,50,0.12);
    padding: 0.3rem;
    display: none;
    z-index: 20;
}
.actions-menu.open .actions-menu-panel { display: block; }
.actions-menu-panel form { margin: 0; }
.actions-menu-sep { height: 1px; background: #f0f2f5; margin: 0.3rem 0; }

/* ── Platform nav dropdown (topnav) — reuses .actions-menu toggle JS + panel ── */
.topnav-dropdown .actions-menu-trigger.topnav-item {
    border: none;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
}
.topnav-dropdown .actions-menu-trigger.topnav-item:hover { background: #f1f4f9; color: #1a2332; }
.topnav-dropdown .actions-menu-trigger.topnav-item.active { background: #206bc4; color: #fff; }
.topnav-dropdown .actions-menu-trigger.topnav-item.active i { opacity: 1; color: #fff; }
.topnav-dropdown .actions-menu-trigger .chevron { font-size: 14px; opacity: 0.7; }
.topnav-dropdown .actions-menu-panel { left: 0; right: auto; min-width: 200px; }

/* ── Toggle switch ─────────────────────── */
.switch { display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; font-size: 13px; color: #3d4a5c; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
    flex: 0 0 auto; position: relative;
    width: 38px; height: 22px; border-radius: 999px;
    background: #ccd3dd; transition: background 0.15s;
}
.switch .track::after {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform 0.15s;
}
.switch input:checked + .track { background: #206bc4; }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid #206bc4; outline-offset: 2px; }

/* ── Impersonation banner ───────────────── */
.impersonation-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 1.25rem;
    background: #fef3c7;
    border-bottom: 1px solid #fcd34d;
    color: #78350f;
    font-size: 13px;
    font-weight: 500;
    flex-wrap: wrap;
}
.impersonation-banner .imp-text { display: flex; align-items: center; gap: 0.45rem; }
.impersonation-banner .imp-text i { color: #b45309; font-size: 16px; line-height: 1; }
.impersonation-banner .imp-text strong { color: #78350f; }
.impersonation-banner .imp-stop {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.3rem 0.7rem; font-size: 12px;
    font-family: inherit; font-weight: 600;
    color: #fff; background: #b45309;
    border: 1px solid #b45309; border-radius: 5px;
    text-decoration: none; cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.impersonation-banner .imp-stop:hover { background: #92400e; border-color: #92400e; color: #fff; }
.impersonation-banner .imp-stop i { font-size: 14px; line-height: 1; }
.impersonation-banner form { margin: 0; }

/* ── Content ───────────────────────────── */
.content { flex: 1; padding: 1.5rem; }

/* ── Page header ───────────────────────── */
.page-header { margin-bottom: 1.25rem; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.page-header-text h1 { font-size: 1.15rem; font-weight: 700; color: #1a2332; letter-spacing: -0.01em; margin: 0; }
.page-header-text p { font-size: 13px; color: #6b7a90; margin: 0.2rem 0 0; }
.page-header-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ── Buttons ───────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.9rem;
    height: 34px;
    font-size: 13px;
    font-family: inherit;
    font-weight: 600;
    color: #fff;
    background: #206bc4;
    border: 1px solid #206bc4;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.btn-primary:hover { background: #1a5ba8; border-color: #1a5ba8; color: #fff; }
.btn-primary:disabled { background: #9aa5b4; border-color: #9aa5b4; cursor: not-allowed; }
.btn-primary i { font-size: 14px; line-height: 1; }

.btn-row {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0 0.7rem; height: 34px; font-size: 12px;
    font-family: inherit; font-weight: 600;
    color: #3d4a5c; background: #fff;
    border: 1px solid #ccd3dd; border-radius: 5px;
    text-decoration: none; cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn-row:hover { background: #f0f2f5; border-color: #b0bac8; color: #1a2332; }
/* Set while an action is in flight (e.g. an SMTP test, which can run to a 20s timeout) so the
   button visibly stops accepting clicks rather than looking merely unresponsive. */
.btn-row:disabled { opacity: 0.6; cursor: not-allowed; background: #f5f7fa; }
.btn-row:disabled:hover { background: #f5f7fa; border-color: #ccd3dd; color: inherit; }
.btn-row.danger { color: #991b1b; border-color: #f5c2c2; }
.btn-row.danger:hover { background: #fff0f0; border-color: #d63939; color: #991b1b; }
.btn-row form { display: inline; margin: 0; }
.btn-row button { background: none; border: none; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.btn-row i { font-size: 14px; line-height: 1; }

/* Square icon-only button (table row actions) */
.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; padding: 0;
    color: #5a6b80; background: #fff;
    border: 1px solid #ccd3dd; border-radius: 6px;
    text-decoration: none; cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn-icon:hover { background: #f0f2f5; border-color: #b0bac8; color: #206bc4; }
.btn-icon i { font-size: 16px; line-height: 1; }

/* Confirmation modal (typed-delete) */
.modal-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(26,35,50,0.45);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
    background: #fff; border-radius: 12px; width: 100%; max-width: 420px;
    padding: 1.4rem; box-shadow: 0 16px 48px rgba(26,35,50,0.28);
}
.modal-box h3 { font-size: 16px; font-weight: 700; color: #1a2332; margin-bottom: 0.5rem; }
.modal-box p { font-size: 13px; color: #6b7a90; margin-bottom: 1rem; }
.modal-box .form-input { margin-top: 0.35rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }

/* Semantic action buttons — edit (amber), save (green), delete (red); uniform height, icon + text */
.btn-edit, .btn-save, .btn-delete {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0 0.9rem; height: 34px; font-size: 13px;
    font-family: inherit; font-weight: 600;
    border-radius: 6px; border: 1px solid transparent;
    color: #fff; text-decoration: none; cursor: pointer;
    transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn-edit i, .btn-save i, .btn-delete i { font-size: 14px; line-height: 1; }
.btn-edit { background: #f59f00; border-color: #f59f00; }
.btn-edit:hover { background: #e08e00; border-color: #e08e00; color: #fff; }
.btn-save { background: #2fb344; border-color: #2fb344; }
.btn-save:hover { background: #28a03c; border-color: #28a03c; color: #fff; }
.btn-delete { background: #d63939; border-color: #d63939; }
.btn-delete:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-edit:disabled, .btn-save:disabled, .btn-delete:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-danger {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0 0.9rem; height: 34px; font-size: 13px;
    font-family: inherit; font-weight: 600;
    color: #fff; background: #d63939;
    border: 1px solid #d63939; border-radius: 6px;
    text-decoration: none; cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-danger:disabled { background: #f5c2c2; border-color: #f5c2c2; cursor: not-allowed; }
.btn-danger i { font-size: 14px; line-height: 1; }

.btn-block { width: 100%; justify-content: center; }

/* Transparent (ghost) buttons across the console — fill colors removed; the icon conveys intent.
   Declared last so it overrides the colored definitions above (equal specificity → later wins). */
.btn-primary, .btn-danger, .btn-edit, .btn-save, .btn-delete, .btn-row, .btn-icon {
    background: transparent;
    color: #3d4a5c;
    border: 1px solid #ccd3dd;
}
.btn-primary:hover, .btn-danger:hover, .btn-edit:hover, .btn-save:hover,
.btn-delete:hover, .btn-row:hover, .btn-icon:hover {
    background: #f0f2f5;
    border-color: #b0bac8;
    color: #1a2332;
}
.btn-primary:disabled, .btn-danger:disabled, .btn-edit:disabled,
.btn-save:disabled, .btn-delete:disabled {
    background: transparent; color: #aab2bf; border-color: #e6e9ef; opacity: 1; cursor: not-allowed;
}

/* ── Card ──────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid #e6e9ef;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(26,35,50,0.05);
    overflow: hidden;
}
.card + .card { margin-top: 1.25rem; }
/* A trailing card after a multi-card <form> (e.g. the Actions card on the client editor) needs the
   same inter-card gap, which `.card + .card` can't supply across the form boundary. */
form + .card { margin-top: 1.25rem; }

/* Danger zone — destructive actions, visually set apart */
.danger-zone { border-color: #f1c0c0; }
.danger-zone .card-header { border-bottom-color: #f3d4d4; }
.danger-zone .card-header h2 { color: #b42318; }
.danger-zone-body {
    padding: 0.9rem 1.25rem;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
}
.card-header {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid #e6e9ef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.card-header h2 { font-size: 13.5px; font-weight: 700; color: #1a2332; margin: 0; }
.card-body { padding: 1.25rem; }

/* ── Table ─────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    padding: 0.55rem 1rem;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: #6b7a90;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid #e6e9ef;
    white-space: nowrap;
    background: #f9fafb;
}
tbody td {
    padding: 0.7rem 1rem;
    font-size: 13.5px;
    color: #1a2332;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f9fafb; }
.row-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.cell-strong { font-weight: 600; color: #1a2332; }
.cell-sub { font-size: 11.5px; color: #6b7a90; }

/* ── Badges ────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-orange { background: #ffedd5; color: #9a3412; }

/* ── Form controls ─────────────────────── */
.form-input {
    padding: 0.45rem 0.65rem;
    font-size: 13.5px; font-family: inherit;
    color: #1a2332; background: #fff;
    border: 1px solid #ccd3dd; border-radius: 6px;
    outline: none; width: 100%;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.form-input:focus { border-color: #206bc4; box-shadow: 0 0 0 3px rgba(32,107,196,0.15); }
.form-input.error, .form-input.input-validation-error {
    border-color: #d63939;
    box-shadow: 0 0 0 3px rgba(214,57,57,0.12);
}
.form-input:disabled, .form-input[readonly] {
    background: #f9fafb; color: #6b7a90; cursor: not-allowed;
}
.form-textarea { resize: vertical; min-height: 72px; }
.form-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.form-label {
    display: block;
    font-size: 12px; font-weight: 600; color: #3d4a5c;
    margin-bottom: 0.35rem;
}
.field-help { display: block; font-size: 12px; color: #6b7a90; margin-top: 0.25rem; }
.field-validation-error { display: block; font-size: 12px; color: #d63939; margin-top: 0.25rem; }
.check-group { display: flex; align-items: center; gap: 0.5rem; font-size: 13px; color: #3d4a5c; }
.check-group input[type="checkbox"] { width: 16px; height: 16px; accent-color: #206bc4; cursor: pointer; }
.required-marker { color: #d63939; margin-left: 0.15rem; font-weight: 700; }

/* ── Form layout helpers (porting addition) ──── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.25rem;
}
.form-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .field-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; }
.form-actions {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #f0f2f5;
}
.form-actions.no-divider { margin-top: 1rem; padding-top: 0; border-top: none; }
/* When a no-divider action bar is the lone content of a card body, drop the top margin so the
   card padding stays symmetric (e.g. the client editor's standalone Save/Cancel card). */
.card-body > .form-actions.no-divider:only-child { margin-top: 0; }
.form-actions .spacer { flex: 1; }

.toolbar-row {
    display: flex; align-items: flex-end; gap: 0.75rem; flex-wrap: wrap;
}
.toolbar-row .form-group { flex: 0 0 auto; min-width: 180px; }
.toolbar-row .toolbar-actions { display: flex; gap: 0.4rem; align-items: center; padding-bottom: 1px; }
/* Free-text search needs real typing room next to fixed-width filter controls. */
.toolbar-row .vm-search-group { flex: 1 1 240px; min-width: 240px; }

/* ── Sortable table column headers ────────── */
.sort-link {
    display: inline-flex; align-items: center; gap: 0.3rem;
    color: inherit; text-decoration: none; cursor: pointer;
}
.sort-link:hover { color: #206bc4; }
.sort-icon { font-size: 13px; }
.is-stale-row { opacity: 0.6; }

/* ── Count drill-through pill (Hypervisor "host count" / Host "VM count") ──────────────────────────
   A chip-shaped link so a count reads as clickable and has a real hit area, instead of a bare number.
   Shared by Views/Servers/Hypervisor.cshtml and Host.cshtml. */
.host-count-pill {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.25rem 0.6rem; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 1;
    text-decoration: none; white-space: nowrap;
    background: #eff4fb; color: #206bc4;
    border: 1px solid #d6e2f2;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.host-count-pill i { font-size: 14px; }
.host-count-pill .host-count-arrow { font-size: 13px; opacity: 0.7; transition: transform 0.12s, opacity 0.12s; }
a.host-count-pill:hover { background: #206bc4; color: #fff; border-color: #206bc4; }
a.host-count-pill:hover .host-count-arrow { transform: translateX(2px); opacity: 1; }
a.host-count-pill:focus-visible { outline: 2px solid #206bc4; outline-offset: 2px; }
.host-count-pill.is-empty { background: #f1f5f9; color: #94a3b8; border-color: #e2e8f0; }

/* ── Flash messages ────────────────────── */
.alert-flash {
    border-radius: 6px; padding: 0.65rem 0.85rem; font-size: 13px;
    margin-bottom: 1rem;
}
.alert-flash:last-child { margin-bottom: 0; }
.alert-flash.success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-flash.error   { background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239; }
.alert-flash.warning { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }
.alert-flash.info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.alert-flash i { margin-right: 0.35rem; }

/* ── Empty state ───────────────────────── */
.empty { text-align: center; padding: 3rem 1.5rem; color: #9aa5b4; }
.empty i, .empty svg { width: 40px; height: 40px; margin-bottom: 0.75rem; opacity: 0.4; font-size: 40px; line-height: 1; display: inline-block; }
.empty p { font-size: 14px; margin: 0; }
.empty .empty-cta { margin-top: 1rem; }

/* ── Pager ─────────────────────────────── */
.pager {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; padding: 0.75rem 1.25rem;
    border-top: 1px solid #e6e9ef; background: #f9fafb;
    font-size: 13px; color: #475569; flex-wrap: wrap;
}
.pager-info { color: #6b7280; }
.pager-info strong { color: #1a2332; font-weight: 600; }
.pager-controls { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
.pager-btn {
    display: inline-flex; align-items: center;
    padding: 0.3rem 0.6rem;
    font-size: 12px; font-weight: 600;
    color: #3d4a5c; background: #fff; border: 1px solid #ccd3dd;
    border-radius: 5px; text-decoration: none; cursor: pointer;
}
.pager-btn:hover:not(.disabled) { background: #f0f2f5; border-color: #b0bac8; color: #1a2332; }
.pager-btn.current { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.pager-btn.disabled { color: #c0c8d4; cursor: default; background: #fafbfc; }
.pager-size { display: flex; align-items: center; gap: 0.4rem; margin: 0; }
.pager-size label { font-size: 12px; color: #6b7280; }
.pager-size select {
    padding: 0.25rem 0.4rem;
    font-size: 12px;
    border: 1px solid #ccd3dd;
    border-radius: 5px;
    background: #fff;
}

/* ── Delete confirm ────────────────────── */
.delete-confirm-row {
    display: flex; flex-direction: column; gap: 0.35rem;
    margin-bottom: 1rem;
}
.delete-confirm-row label {
    font-size: 12px; font-weight: 600; color: #3d4a5c;
}
.delete-confirm-row label code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px; padding: 1px 5px;
    background: #fff0f0; color: #991b1b;
    border-radius: 3px; border: 1px solid #f5c2c2;
}
.delete-confirm-row input[type=text] {
    padding: 0.4rem 0.65rem;
    font-size: 13.5px; font-family: inherit;
    color: #1a2332; background: #fff;
    border: 1px solid #ccd3dd; border-radius: 6px;
    outline: none;
    max-width: 320px;
}
.delete-confirm-row input[type=text]:focus {
    border-color: #d63939; box-shadow: 0 0 0 3px rgba(214,57,57,0.15);
}
.delete-confirm-actions { display: flex; gap: 0.5rem; }

/* ── Module card grid ──────────────────── */
.module-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem;
}
.module-card {
    background: #fff; border: 1px solid #e6e9ef; border-radius: 10px;
    padding: 1.1rem 1.15rem; text-decoration: none; color: inherit;
    display: flex; align-items: center; gap: 0.9rem;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.12s;
}
.module-card:hover { box-shadow: 0 4px 16px rgba(26,35,50,0.1); border-color: #b0bac8; transform: translateY(-1px); }
.module-icon { width: 40px; height: 40px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 20px; }
.module-icon i { font-size: 20px; line-height: 1; }
.module-icon svg { width: 20px; height: 20px; }
.module-info { flex: 1; min-width: 0; }
.module-name { font-size: 13.5px; font-weight: 700; color: #1a2332; margin-bottom: .15rem; }
.module-desc { font-size: 12px; color: #6b7a90; line-height: 1.4; }
.module-arrow { color: #9aa5b4; flex-shrink: 0; transition: color .12s, transform .12s; font-size: 16px; }
.module-arrow i { font-size: 16px; line-height: 1; }

.module-card:hover .module-arrow { color: #206bc4; transform: translateX(3px); }

/* ── Meta grid (detail page) ───────────── */
.meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; padding: 1rem 1.25rem; }
.meta-cell label { display: block; font-size: 11px; font-weight: 700; color: #6b7a90; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .25rem; }
.meta-cell .value { font-size: 13.5px; color: #1a2332; font-weight: 600; word-break: break-word; }
.meta-cell .value .muted { color: #6b7a90; font-weight: 400; }
.meta-cell .value code { font-size: 12px; }

/* ── Definition list (key/value rows in cards) ── */
.def-list { display: grid; grid-template-columns: 160px 1fr; gap: 0.5rem 1rem; font-size: 13px; }
.def-list dt { color: #6b7a90; font-weight: 500; }
.def-list dd { color: #1a2332; font-weight: 500; margin: 0; word-break: break-word; }
.def-list dd code { font-size: 12px; }

/* ── Progress bar ──────────────────────── */
.progress-bar-wrap { display: flex; align-items: center; gap: 0.5rem; }
.progress-bar { flex: 1; height: 6px; background: #e6e9ef; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: #206bc4; border-radius: 3px; }
.progress-label { font-size: 11.5px; color: #6b7a90; white-space: nowrap; }

/* ── Auth pages (centered single card) ──── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: #f0f2f5;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem 1.75rem;
    background: #fff;
    border: 1px solid #e6e9ef;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(26,35,50,0.05);
}
.auth-card.wide { max-width: 520px; }
.auth-brand {
    display: flex; align-items: center; justify-content: center;
    gap: 0.55rem; margin-bottom: 1.5rem;
    font-size: 15px; font-weight: 700;
    color: #1a2332; text-decoration: none;
    letter-spacing: -0.01em;
}
.auth-title {
    font-size: 1.15rem; font-weight: 700; color: #1a2332;
    letter-spacing: -0.01em; margin: 0 0 0.25rem;
    text-align: center;
}
.auth-sub {
    font-size: 13px; color: #6b7a90; text-align: center;
    margin: 0 0 1.5rem;
}
.auth-hero {
    display: flex; justify-content: center; align-items: center;
    margin-bottom: 0.75rem; font-size: 2rem; line-height: 1;
    color: #206bc4;
}
.auth-hero.success { color: #166534; }
.auth-hero.danger  { color: #d63939; }
.auth-card .form-group + .form-group { margin-top: 1rem; }
.auth-card .form-actions { margin-top: 1.25rem; padding-top: 0; border-top: none; }
.auth-foot {
    margin-top: 1.5rem; text-align: center;
    font-size: 11.5px; color: #9aa5b4;
}
.auth-card .pw-wrap { position: relative; }
.auth-card .pw-toggle {
    position: absolute; right: 0.35rem; top: 50%;
    transform: translateY(-50%);
    background: transparent; border: none;
    padding: 0.3rem 0.45rem;
    color: #6b7a90; cursor: pointer; line-height: 1;
    border-radius: 4px; font-size: 14px;
}
.auth-card .pw-toggle:hover { background: #f0f2f5; color: #1a2332; }

/* ── Tenant context header (admin) ────── */
.tenant-context {
    margin-bottom: 1rem;
    padding: 0.85rem 1.1rem;
    background: #fff;
    border: 1px solid #e6e9ef;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(26,35,50,0.05);
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; flex-wrap: wrap;
}
.tenant-context .crumb {
    font-size: 11px; color: #6b7a90;
    text-transform: uppercase; letter-spacing: 0.06em;
    font-weight: 700;
    display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap;
}
.tenant-context .crumb a { color: #6b7a90; text-decoration: none; }
.tenant-context .crumb a:hover { color: #206bc4; }
.tenant-context .tenant-name {
    font-size: 1rem; font-weight: 700; color: #1a2332;
    margin-top: 0.1rem;
}
.tenant-context .tenant-slug {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px; color: #6b7a90;
}
.tenant-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tenant-tabs .btn-row.active {
    background: #206bc4; border-color: #206bc4; color: #fff;
}

/* ── Metric tile (dashboard) ───────────── */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.metric-tile {
    background: #fff;
    border: 1px solid #e6e9ef;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(26,35,50,0.05);
    padding: 1rem 1.1rem;
    display: flex; align-items: center; gap: 0.85rem;
}
.metric-icon {
    width: 40px; height: 40px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 18px;
}
.metric-label {
    font-size: 11px; font-weight: 700; color: #6b7a90;
    text-transform: uppercase; letter-spacing: 0.06em;
}
.metric-value {
    font-size: 1.25rem; font-weight: 700; color: #1a2332;
    line-height: 1.1; margin-top: 0.1rem;
}
.metric-meta { font-size: 11.5px; color: #6b7a90; margin-top: 0.15rem; }

/* ── Dashboard (single screen, panels scroll internally) ── */
.badge-teal { background: #ccfbf1; color: #0f766e; }

.dashboard {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: calc(100vh - 168px);
}
.dash-metrics {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    flex-shrink: 0;
}
.dash-metrics .metric-tile { text-decoration: none; color: inherit; }
a.metric-tile { transition: box-shadow 0.14s, transform 0.14s, border-color 0.14s; }
a.metric-tile:hover { box-shadow: 0 4px 16px rgba(26,35,50,0.1); border-color: #b0bac8; transform: translateY(-1px); }

.dash-panels {
    flex: 1;
    min-height: 0;
    display: grid;
    gap: 1rem;
    grid-template-columns: 1.5fr 1fr 1.1fr;
    grid-template-rows: minmax(0, 1.05fr) minmax(0, 0.95fr);
    grid-template-areas:
        "activity security charts"
        "activity tenants  tenants";
}

/* Panel shell */
.panel {
    background: #fff;
    border: 1px solid #e6e9ef;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(26,35,50,0.05);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.7rem 1rem; border-bottom: 1px solid #eef1f6; flex-shrink: 0;
}
.panel-head h2 { font-size: 13px; font-weight: 700; color: #1a2332; margin: 0; letter-spacing: -0.01em; }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0.35rem 0.5rem; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0.9rem 1rem; }
.panel-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.4rem; height: 100%; color: #9aa6b6; font-size: 13px; padding: 1rem;
}
.panel-empty i { font-size: 24px; }
.panel-empty.small { flex-direction: row; height: auto; padding: 0.5rem; }

/* Activity feed */
.feed-row {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.45rem 0.55rem; border-radius: 7px;
}
.feed-row:hover { background: #f7f9fc; }
.feed-row + .feed-row { border-top: 1px solid #f1f4f8; }
.feed-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.feed-user { font-size: 12.5px; font-weight: 600; color: #1a2332; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-sub { font-size: 11px; color: #6b7a90; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-time { font-size: 11px; color: #9aa6b6; white-space: nowrap; flex-shrink: 0; }

/* Security panel */
.sec-meter-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; color: #3d4a5c; margin-bottom: 0.4rem; }
.sec-meter-label strong { font-size: 15px; color: #1a2332; }
.meter { height: 8px; border-radius: 999px; background: #eef1f6; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #2fb344, #4caf50); }
.sec-list { list-style: none; margin: 0.9rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.sec-list li { display: flex; align-items: center; justify-content: space-between; padding: 0.45rem 0; font-size: 12.5px; color: #3d4a5c; }
.sec-list li + li { border-top: 1px solid #f1f4f8; }
.sec-list li span:first-child { display: inline-flex; align-items: center; gap: 0.45rem; }
.sec-list li i { font-size: 15px; color: #8a96a6; }

/* Charts */
.chart-label { font-size: 11px; font-weight: 700; color: #6b7a90; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.45rem; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 56px; }
.spark-bar { flex: 1; min-width: 0; background: #c7d6ea; border-radius: 2px 2px 0 0; transition: background 0.12s; }
.spark-bar:hover { background: #206bc4; }
.evbars { display: flex; flex-direction: column; gap: 0.4rem; }
.evbar-row { display: flex; align-items: center; gap: 0.5rem; font-size: 11.5px; }
.evbar-name { width: 92px; flex-shrink: 0; color: #3d4a5c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evbar-track { flex: 1; height: 8px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.evbar-fill { display: block; height: 100%; background: #6c8fc4; border-radius: 999px; }
.evbar-num { width: 26px; flex-shrink: 0; text-align: right; color: #6b7a90; font-weight: 600; }

/* Mini table (per-tenant) */
.mini-table { width: 100%; border-collapse: collapse; }
.mini-table th { position: sticky; top: 0; background: #fff; text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: #8a96a6; font-weight: 700; padding: 0.4rem 0.6rem; border-bottom: 1px solid #eef1f6; }
.mini-table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid #f4f6fa; font-size: 12.5px; vertical-align: middle; }
.mini-table tbody tr:last-child td { border-bottom: 0; }
.mini-table .tenant-link { font-weight: 600; color: #1a2332; text-decoration: none; margin-right: 0.4rem; }
.mini-table .tenant-link:hover { color: #206bc4; text-decoration: underline; }

@media (max-width: 1100px) {
    .dash-metrics { grid-template-columns: repeat(3, 1fr); }
    .dash-panels {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "activity activity"
            "security charts"
            "tenants  tenants";
    }
}
@media (max-width: 700px) {
    .dashboard { min-height: 0; }
    .dash-metrics { grid-template-columns: repeat(2, 1fr); }
    .dash-panels { grid-template-columns: 1fr; grid-template-areas: "activity" "security" "charts" "tenants"; }
    .panel { min-height: 220px; }
}

/* ── Misc utility helpers (porting addition) ── */
.text-muted { color: #6b7a90; }
.text-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-inline {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    background: #f1f5f9;
    color: #1a2332;
    padding: 1px 5px; border-radius: 3px;
    border: 1px solid #e6e9ef;
}
/* Truncate a long inline value (e.g. a login URL) so it never widens the table. */
.code-inline.is-truncated {
    display: inline-block; max-width: 280px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    vertical-align: middle;
}
.stack { display: flex; flex-direction: column; gap: 1.25rem; }
.cluster { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.spacer-1 { height: 1rem; }
.text-success { color: #166534; }
.text-danger { color: #d63939; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.w-1 { width: 1px; white-space: nowrap; }

/* ── Responsive ────────────────────────── */
@media (max-width: 768px) {
    .user-name { display: none; }
    .meta-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
    .def-list { grid-template-columns: minmax(0, 1fr); gap: 0.2rem 0; }
    .def-list dt { padding-top: 0.5rem; }
    .content { padding: 1rem; }
    .topbar { padding: 0.4rem 1rem; }
    .topbar-right { margin-left: auto; }
    .topnav { order: 2; flex-basis: 100%; }
}

/* Impersonation banner */
.impersonation-banner {
    background: #fef3c7;
    border-bottom: 1px solid #f59e0b;
    color: #92400e;
    font-size: .8125rem;
    font-weight: 500;
    padding: .5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.impersonation-exit {
    margin-left: auto;
    background: #f59e0b;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: .25rem .75rem;
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
}
.impersonation-exit:hover { background: #d97706; }
