@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===== DESIGN TOKENS ===== */
:root {
    --app-bg: #0f1117;
    --app-surface: #1a1d2e;
    --app-surface-2: #151827;
    --app-border: rgba(255, 255, 255, 0.06);
    --app-border-strong: rgba(37, 211, 102, 0.18);
    --app-text: #e4e6eb;
    --app-text-muted: rgba(255, 255, 255, 0.55);
    --app-text-subtle: rgba(255, 255, 255, 0.38);
    --app-primary: #25D366;
    --app-primary-2: #128C7E;
    --app-warning: #ffa726;
    --app-danger: #ef5350;
    --app-radius-sm: 10px;
    --app-radius-md: 14px;
    --app-radius-lg: 18px;
    --app-shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.22);
    --app-shadow-strong: 0 18px 48px rgba(0, 0, 0, 0.35);
}

/* ===== GLOBAL ===== */
html, body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100%;
    max-width: 100%;
    background:
        radial-gradient(circle at top left, rgba(37, 211, 102, 0.08), transparent 28%),
        radial-gradient(circle at bottom right, rgba(18, 140, 126, 0.08), transparent 24%),
        var(--app-bg);
    color: var(--app-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body {
    font-size: 0.96rem;
    line-height: 1.55;
}

* {
    box-sizing: border-box;
}

a {
    color: inherit;
}

button,
.mud-button-root,
.mud-icon-button {
    transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

button:focus-visible,
.mud-button-root:focus-visible,
.mud-icon-button:focus-visible,
.mud-input-root:focus-within,
.mud-select:focus-within,
.mud-picker:focus-within {
    outline: 2px solid rgba(37, 211, 102, 0.45);
    outline-offset: 2px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.03);
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* ===== APP SHELL ===== */
.app-bar-custom {
    background: rgba(15, 17, 23, 0.9) !important;
    backdrop-filter: blur(18px) saturate(1.1) !important;
    -webkit-backdrop-filter: blur(18px) saturate(1.1) !important;
    border-bottom: 1px solid var(--app-border) !important;
}

.app-bar-title {
    font-weight: 700 !important;
    font-size: 1.02rem !important;
    letter-spacing: -0.02em;
    color: #ffffff !important;
}

.app-main-content {
    background:
        radial-gradient(circle at top right, rgba(37, 211, 102, 0.04), transparent 22%),
        var(--app-bg);
    min-height: 100vh;
    width: auto;
    max-width: none;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
    overflow-x: hidden;
}

.theme-light {
    --app-bg: #eef3f8;
    --app-surface: #ffffff;
    --app-surface-2: #f7f9fc;
    --app-border: rgba(15, 23, 42, 0.08);
    --app-border-strong: rgba(37, 211, 102, 0.22);
    --app-text: #0f172a;
    --app-text-muted: rgba(15, 23, 42, 0.68);
    --app-text-subtle: rgba(15, 23, 42, 0.52);
    color-scheme: light;
}

.theme-dark {
    color-scheme: dark;
}

.page-shell {
    width: 100%;
    max-width: none;
    min-width: 0;
    padding: 24px 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-x: clip;
}

.page-shell > * {
    min-width: 0;
    max-width: 100%;
}

@media (max-width: 960px) {
    .page-shell {
        padding: 18px 16px 24px;
    }
}

.app-bar-email {
    color: var(--app-text-muted) !important;
    font-size: 0.8rem !important;
    font-weight: 500;
}

.app-bar-action-btn {
    color: rgba(255, 255, 255, 0.64) !important;
}

.app-bar-action-btn:hover {
    color: rgba(255, 255, 255, 0.9) !important;
}

.theme-light .app-bar-custom,
.theme-light .sidebar-custom {
    background: rgba(255, 255, 255, 0.86) !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
}

.theme-light .app-bar-custom {
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
}

.theme-light .app-bar-title,
.theme-light .page-title,
.theme-light .instance-name,
.theme-light .empty-state-title,
.theme-light .stat-value,
.theme-light .stat-label,
.theme-light .login-title,
.theme-light .not-found-code {
    color: #0f172a !important;
}

.theme-light .app-bar-email,
.theme-light .page-subtitle,
.theme-light .empty-state-text {
    color: rgba(15, 23, 42, 0.62) !important;
}

.theme-light .app-bar-action-btn {
    color: rgba(15, 23, 42, 0.64) !important;
}

.theme-light .app-bar-action-btn:hover {
    color: rgba(15, 23, 42, 0.88) !important;
}

.theme-light .instance-detail {
    color: rgba(15, 23, 42, 0.62) !important;
}

.theme-light .instance-detail .mud-icon-root {
    color: rgba(15, 23, 42, 0.46) !important;
}

.theme-light .admin-table .mud-table-head .mud-table-row {
    background: rgba(15, 23, 42, 0.03) !important;
}

.theme-light .admin-table .mud-table-head th {
    color: rgba(15, 23, 42, 0.74) !important;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
}

.theme-light .admin-table .mud-table-body .mud-table-row:hover {
    background: rgba(37, 211, 102, 0.08) !important;
}

.theme-light .admin-table .mud-table-body td {
    color: rgba(15, 23, 42, 0.82) !important;
    border-bottom: 1px solid rgba(15, 23, 42, 0.07) !important;
}

.theme-light .admin-table .mud-table-body td .mud-icon-root {
    color: rgba(15, 23, 42, 0.45) !important;
}

.theme-light .admin-table .mud-table-body .mud-typography-caption {
    color: rgba(15, 23, 42, 0.62) !important;
}

.theme-light .instances-page .mud-input-slot,
.theme-light .instances-page .mud-select-input,
.theme-light .history-page .mud-input-slot,
.theme-light .history-page .mud-select-input,
.theme-light .tenants-page .mud-input-slot,
.theme-light .tenants-page .mud-select-input,
.theme-light .users-page .mud-input-slot,
.theme-light .users-page .mud-select-input {
    color: rgba(15, 23, 42, 0.88) !important;
}

.theme-light .instances-page .mud-input-label,
.theme-light .history-page .mud-input-label,
.theme-light .tenants-page .mud-input-label,
.theme-light .users-page .mud-input-label,
.theme-light .instances-page .mud-input-adornment,
.theme-light .history-page .mud-input-adornment,
.theme-light .tenants-page .mud-input-adornment,
.theme-light .users-page .mud-input-adornment,
.theme-light .instances-page .mud-select-icon,
.theme-light .history-page .mud-select-icon,
.theme-light .tenants-page .mud-select-icon,
.theme-light .users-page .mud-select-icon {
    color: rgba(15, 23, 42, 0.62) !important;
}

.theme-light .history-page .history-toolbar .toolbar-field,
.theme-light .history-page .history-date-filter .mud-input-control,
.theme-light .history-page .search-field,
.theme-light .instances-page .toolbar-field-wide {
    background: rgba(15, 23, 42, 0.03) !important;
}

.theme-light .logs-page .log-content {
    color: rgba(15, 23, 42, 0.9) !important;
}

.theme-light .logs-page .log-empty-icon {
    color: rgba(15, 23, 42, 0.26) !important;
}

.theme-light .logs-page .log-empty-text {
    color: rgba(15, 23, 42, 0.55) !important;
}

.theme-light .mud-dialog {
    background: rgba(255, 255, 255, 0.97) !important;
    border: 1px solid rgba(15, 23, 42, 0.12) !important;
    box-shadow: 0 20px 44px rgba(15, 23, 42, 0.18) !important;
    color: rgba(15, 23, 42, 0.9) !important;
}

.theme-light .mud-dialog-title,
.theme-light .mud-dialog-content,
.theme-light .mud-dialog-actions {
    color: rgba(15, 23, 42, 0.9) !important;
}

.theme-light .mud-dialog .mud-input-slot,
.theme-light .mud-dialog .mud-select-input {
    color: rgba(15, 23, 42, 0.88) !important;
}

.theme-light .mud-dialog .mud-input-label,
.theme-light .mud-dialog .mud-input-adornment,
.theme-light .mud-dialog .mud-select-icon {
    color: rgba(15, 23, 42, 0.64) !important;
}

.theme-light .mud-dialog .mud-input-outlined-border,
.theme-light .mud-dialog .mud-select-outlined-border {
    border-color: rgba(15, 23, 42, 0.14) !important;
}

.theme-light .toolbar-surface,
.theme-light .surface-card,
.theme-light .dialog-shell,
.theme-light .admin-table-container,
.theme-light .section-card,
.theme-light .instance-card,
.theme-light .stat-card,
.theme-light .login-card,
.theme-light .log-container,
.theme-light .not-found-container {
    background: rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08) !important;
}

.theme-light .sidebar-custom .mud-nav-link {
    color: rgba(15, 23, 42, 0.82) !important;
}

.theme-light .sidebar-custom .mud-nav-link.active {
    background: rgba(37, 211, 102, 0.12) !important;
    color: #0f172a !important;
}

.theme-light .login-background {
    background:
        radial-gradient(circle at top left, rgba(37, 211, 102, 0.12), transparent 28%),
        radial-gradient(circle at bottom right, rgba(18, 140, 126, 0.1), transparent 24%),
        linear-gradient(135deg, #eef3f8 0%, #f8fbff 44%, #eff6ff 100%);
}

.theme-light .login-card {
    backdrop-filter: blur(16px) saturate(1.05);
}

.theme-light .input-surface .mud-input-root {
    background: rgba(15, 23, 42, 0.03) !important;
}

.theme-toggle-minimal {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 30;
}

.theme-toggle-button {
    color: rgba(255, 255, 255, 0.68) !important;
}

.theme-light .theme-toggle-button {
    color: rgba(15, 23, 42, 0.72) !important;
}

.sidebar-custom {
    background: rgba(15, 17, 23, 0.96) !important;
    border-right: 1px solid var(--app-border) !important;
}

.sidebar-custom .mud-nav-link {
    border-radius: var(--app-radius-sm) !important;
    margin: 2px 8px !important;
    padding: 10px 14px !important;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.82) !important;
}

.sidebar-custom .mud-nav-link:hover {
    background: rgba(37, 211, 102, 0.08) !important;
}

.sidebar-custom .mud-nav-link.active {
    background: rgba(37, 211, 102, 0.12) !important;
    color: #ffffff !important;
}

.sidebar-custom .mud-nav-link .mud-icon-root {
    color: inherit !important;
}

.impersonation-bar {
    background: linear-gradient(90deg, rgba(255, 167, 38, 0.14), rgba(255, 167, 38, 0.06)) !important;
    border-bottom: 1px solid rgba(255, 167, 38, 0.18);
    padding: 6px 16px;
}

/* ===== LOGIN PAGE ===== */
.login-background {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at top left, rgba(37, 211, 102, 0.16), transparent 28%),
        radial-gradient(circle at bottom right, rgba(18, 140, 126, 0.16), transparent 24%),
        linear-gradient(135deg, #0f1117 0%, #121522 44%, #0c1a2c 100%);
    position: relative;
    overflow: hidden;
}

.login-background::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 211, 102, 0.08) 0%, transparent 70%);
    top: -200px;
    right: -100px;
    animation: pulse-glow 8s ease-in-out infinite;
}

.login-background::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 136, 255, 0.06) 0%, transparent 70%);
    bottom: -150px;
    left: -100px;
    animation: pulse-glow 10s ease-in-out infinite reverse;
}

@keyframes pulse-glow {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 1; }
}

.login-card {
    background: rgba(26, 29, 46, 0.84) !important;
    backdrop-filter: blur(20px) saturate(1.15);
    -webkit-backdrop-filter: blur(20px) saturate(1.15);
    border: 1px solid rgba(255, 255, 255, 0.07) !important;
    border-radius: 20px !important;
    box-shadow: var(--app-shadow-strong), 0 0 60px rgba(37, 211, 102, 0.04) !important;
    transition: transform 180ms ease, box-shadow 180ms ease;
    max-width: 420px;
    width: 100%;
}

.login-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 54px rgba(0, 0, 0, 0.45), 0 0 88px rgba(37, 211, 102, 0.08) !important;
}

.login-logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.login-logo-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, #25D366, #128C7E);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.25);
    margin-bottom: 1rem;
    animation: float-logo 6s ease-in-out infinite;
}

@keyframes float-logo {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.login-logo-icon .mud-icon-root {
    color: white !important;
    font-size: 32px !important;
}

.login-title {
    font-weight: 700 !important;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff, #a0aec0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--app-text-muted) !important;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* ===== BUTTONS ===== */
.btn-login {
    border-radius: var(--app-radius-sm) !important;
    font-weight: 600 !important;
    letter-spacing: 0.3px;
    text-transform: none !important;
    height: 48px !important;
    background: linear-gradient(135deg, #25D366, #128C7E) !important;
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.22) !important;
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 28px rgba(37, 211, 102, 0.28) !important;
}

.btn-login:active {
    transform: translateY(0);
}

/* ===== INPUTS ===== */
.mud-input-control {
    margin-bottom: 0.5rem;
}

/* ===== APP BAR ===== */
/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.page-header > * {
    min-width: 0;
    max-width: 100%;
}

.header-title-wrap,
.header-actions-wrap,
.responsive-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    width: auto;
    min-width: 0;
    max-width: none;
}

.header-title-wrap {
    gap: 16px;
    flex: 1 1 auto;
}

.header-actions-wrap {
    flex: 0 0 auto;
    margin-left: auto;
    justify-content: flex-end;
}

.responsive-toolbar {
    flex: 1 1 480px;
}

.responsive-toolbar > * {
    min-width: 0;
    max-width: 100%;
}

.toolbar-field {
    flex: 1 1 180px;
}

.toolbar-field-wide {
    flex: 2 1 260px;
}

.toolbar-field-compact {
    flex: 0 1 120px;
}

.toolbar-button {
    flex: 0 1 auto;
}

.page-header .d-flex,
.page-header .flex-grow-1,
.page-header .mud-input-control,
.page-header .mud-select,
.page-header .mud-picker,
.page-header .mud-button-root {
    min-width: 0;
    max-width: 100%;
}

.page-title {
    font-weight: 700 !important;
    font-size: clamp(1.45rem, 2vw, 1.85rem) !important;
    letter-spacing: -0.03em;
    color: #ffffff !important;
}

.page-title-icon {
    color: #25D366 !important;
    margin-right: 0.5rem;
    font-size: 1.55rem !important;
}

.page-subtitle {
    color: var(--app-text-muted) !important;
    margin-top: 0.15rem;
}

.page-header-block {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.toolbar-surface,
.surface-card,
.dialog-shell,
.admin-table-container,
.section-card {
    background: rgba(26, 29, 46, 0.7) !important;
    border: 1px solid var(--app-border) !important;
    border-radius: var(--app-radius-md) !important;
    box-shadow: var(--app-shadow-soft) !important;
    width: 100%;
}

.mud-grid,
.mud-grid-item,
.mud-item,
.mud-paper,
.mud-card {
    min-width: 0;
    max-width: 100%;
}

.toolbar-surface {
    padding: 0.9rem 1rem;
}

.surface-card {
    padding: 1rem;
}

.section-card {
    overflow: hidden;
}

.section-card-header {
    padding: 1rem 1rem 0.75rem 1rem;
    border-bottom: 1px solid var(--app-border);
}

.section-card-body {
    padding: 1rem;
}

.page-summary-grid {
    margin-top: 0;
}

/* ===== INSTANCE CARDS ===== */
.instance-card {
    background: rgba(26, 29, 46, 0.64) !important;
    border: 1px solid var(--app-border) !important;
    border-radius: var(--app-radius-md) !important;
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease !important;
    overflow: hidden;
}

.instance-card:hover {
    border-color: rgba(37, 211, 102, 0.2) !important;
    box-shadow: var(--app-shadow-soft), 0 0 40px rgba(37, 211, 102, 0.05) !important;
    transform: translateY(-2px);
}

.instance-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.instance-name {
    font-weight: 600 !important;
    font-size: 1.05rem !important;
    color: #ffffff !important;
}

.instance-detail {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.45) !important;
    font-size: 0.8rem;
    margin-top: 0.35rem;
}

.instance-detail .mud-icon-root {
    font-size: 16px !important;
    color: rgba(255, 255, 255, 0.35) !important;
}

/* Status chips */
.status-connected {
    background: rgba(37, 211, 102, 0.12) !important;
    color: #25D366 !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    font-size: 0.7rem !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-disconnected {
    background: rgba(239, 83, 80, 0.12) !important;
    color: #ef5350 !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    font-size: 0.7rem !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-connecting {
    background: rgba(255, 167, 38, 0.12) !important;
    color: #ffa726 !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    font-size: 0.7rem !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-default {
    background: rgba(255, 255, 255, 0.08) !important;
    color: rgba(255, 255, 255, 0.5) !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    font-size: 0.7rem !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Instance card actions */
.instance-actions {
    border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
    padding: 8px 12px !important;
}

.instance-actions .mud-button-root {
    border-radius: 8px !important;
    font-weight: 500 !important;
    text-transform: none !important;
    font-size: 0.78rem !important;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4.5rem 2rem;
    text-align: center;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: rgba(37, 211, 102, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.empty-state-icon .mud-icon-root {
    color: rgba(37, 211, 102, 0.5) !important;
    font-size: 40px !important;
}

.empty-state-title {
    font-weight: 600 !important;
    color: rgba(255, 255, 255, 0.9) !important;
    margin-bottom: 0.5rem !important;
}

.empty-state-text {
    color: rgba(255, 255, 255, 0.4) !important;
    font-size: 0.875rem;
    max-width: 320px;
}

/* ===== ADMIN TABS ===== */
.admin-tabs .mud-tabs-toolbar {
    background: rgba(26, 29, 46, 0.5) !important;
    border-radius: 14px !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    padding: 4px !important;
}

.admin-tabs .mud-tab {
    border-radius: 10px !important;
    font-weight: 500 !important;
    text-transform: none !important;
    color: rgba(255, 255, 255, 0.85) !important;
    transition: all 0.2s ease !important;
}

.admin-tabs .mud-tab.mud-tab-active {
    background: rgba(37, 211, 102, 0.2) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
}

/* ===== STATS CARDS ===== */
.stat-card {
    background: rgba(26, 29, 46, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 16px !important;
    transition: all 0.3s ease !important;
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.1) !important;
    transform: translateY(-2px);
}

.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon-wrapper.green {
    background: rgba(37, 211, 102, 0.12);
}

.stat-icon-wrapper.green .mud-icon-root {
    color: #25D366 !important;
}

.stat-icon-wrapper.blue {
    background: rgba(66, 165, 245, 0.12);
}

.stat-icon-wrapper.blue .mud-icon-root {
    color: #42a5f5 !important;
}

.stat-value {
    font-weight: 700 !important;
    font-size: 1.75rem !important;
    color: #ffffff !important;
    line-height: 1.2;
}

.stat-label {
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 0.8rem !important;
    font-weight: 500;
}

/* ===== TABLE ===== */
.admin-table .mud-table {
    background: transparent !important;
    border-radius: 0 !important;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
}

.admin-table-container {
    overflow-x: auto;
}

.admin-table .mud-table-container {
    max-width: 100%;
    overflow-x: auto;
}

.admin-table .mud-table-head .mud-table-row {
    background: rgba(255, 255, 255, 0.02) !important;
}

.admin-table .mud-table-head th {
    color: rgba(255, 255, 255, 0.8) !important;
    font-weight: 600 !important;
    font-size: 0.72rem !important;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.admin-table .mud-table-body .mud-table-row {
    transition: background 0.2s ease;
}

.admin-table .mud-table-body .mud-table-row:hover {
    background: rgba(37, 211, 102, 0.04) !important;
}

.admin-table .mud-table-body td {
    color: rgba(255, 255, 255, 0.75) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03) !important;
    font-size: 0.85rem;
    padding-top: 0.95rem;
    padding-bottom: 0.95rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* ===== DIALOG ===== */
.mud-dialog {
    background: rgba(26, 29, 46, 0.95) !important;
    backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 16px !important;
}

.mud-dialog-title {
    font-weight: 700 !important;
    color: #ffffff !important;
}

/* ===== QR CODE ===== */
.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
}

.qr-image {
    background: white;
    padding: 16px;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    max-width: 280px;
    width: 100%;
}

.qr-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 1rem;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

/* ===== IMPERSONATION BAR ===== */
.impersonation-bar {
    background: linear-gradient(90deg, rgba(255, 167, 38, 0.1), rgba(255, 167, 38, 0.05)) !important;
    border-bottom: 1px solid rgba(255, 167, 38, 0.2);
    padding: 6px 16px;
}

/* ===== GENERAL BUTTONS ===== */
.btn-primary-gradient {
    background: linear-gradient(135deg, #25D366, #128C7E) !important;
    color: white !important;
    font-weight: 600 !important;
    text-transform: none !important;
    border-radius: var(--app-radius-sm) !important;
    letter-spacing: 0.2px;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.18) !important;
}

.btn-primary-gradient:hover {
    box-shadow: 0 8px 22px rgba(37, 211, 102, 0.24) !important;
    transform: translateY(-1px);
}

.btn-secondary-surface {
    background: rgba(255, 255, 255, 0.04) !important;
    color: rgba(255, 255, 255, 0.84) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: var(--app-radius-sm) !important;
    text-transform: none !important;
}

.btn-secondary-surface:hover {
    background: rgba(255, 255, 255, 0.07) !important;
}

.input-surface .mud-input-outlined-border,
.input-surface .mud-select-outlined-border,
.input-surface .mud-picker-input {
    border-color: rgba(255, 255, 255, 0.12) !important;
}

.input-surface .mud-input-control,
.input-surface .mud-select {
    background: rgba(255, 255, 255, 0.02) !important;
    border-radius: var(--app-radius-sm) !important;
}

.input-surface .mud-input-root,
.input-surface .mud-select,
.input-surface .mud-picker {
    border-radius: var(--app-radius-sm) !important;
}

/* ===== NOT FOUND PAGE ===== */
.not-found-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    text-align: center;
}

.not-found-code {
    font-size: 6rem !important;
    font-weight: 800 !important;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 0.5rem;
}

/* ===== BLAZOR DEFAULTS ===== */
.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeInUp 0.4s ease-out;
}

.animate-fade-in-delay-1 {
    animation: fadeInUp 0.4s ease-out 0.1s both;
}

.animate-fade-in-delay-2 {
    animation: fadeInUp 0.4s ease-out 0.2s both;
}

.animate-fade-in-delay-3 {
    animation: fadeInUp 0.4s ease-out 0.3s both;
}

@media (max-width: 960px) {
    .page-header {
        align-items: flex-start;
    }

    .toolbar-surface {
        padding: 0.8rem;
    }

    .header-title-wrap,
    .header-actions-wrap,
    .responsive-toolbar {
        width: 100%;
        max-width: 100%;
    }

    .page-header .mud-input-control,
    .page-header .mud-select,
    .page-header .mud-picker,
    .page-header .mud-button-root,
    .page-header .flex-grow-1,
    .toolbar-field,
    .toolbar-field-wide,
    .toolbar-field-compact,
    .toolbar-button {
        width: 100%;
        min-width: 0 !important;
        max-width: 100%;
    }

    .header-actions-wrap {
        justify-content: stretch;
    }

    .countdown-badge {
        width: 100%;
        justify-content: center;
    }

    .app-bar-email {
        display: none !important;
    }

    .instance-card-header {
        align-items: flex-start;
    }

    .instance-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .instance-actions .mud-button-root {
        flex: 1 1 calc(50% - 6px);
        margin-right: 0 !important;
    }

    .admin-table .mud-table-small-device .mud-table-cell {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        text-align: left !important;
    }

    .admin-table .mud-table-small-device .mud-table-cell[data-label="Ações"],
    .admin-table .mud-table-small-device .mud-table-cell[data-label="AÃ§Ãµes"] {
        display: flex;
        justify-content: flex-start;
        gap: 6px;
    }
}

@media (max-width: 640px) {
    .login-card {
        margin: 1rem;
    }

    .page-title {
        font-size: 1.35rem !important;
    }

    .page-title-icon {
        font-size: 1.3rem !important;
    }

    .empty-state {
        padding: 3rem 1.25rem;
    }

    .page-shell {
        padding: 14px 12px 20px;
        gap: 16px;
    }

    .toolbar-surface,
    .surface-card,
    .admin-table-container,
    .section-card {
        border-radius: 12px !important;
    }

    .header-title-wrap {
        gap: 10px;
    }

    .header-actions-wrap,
    .responsive-toolbar {
        gap: 8px;
    }

    .search-field {
        max-width: none !important;
        flex-basis: 100%;
    }

    .mud-dialog {
        margin: 10px !important;
        max-height: calc(100vh - 20px);
    }

    .qr-image {
        max-width: 220px;
    }
}
