/* Luna v2 — Design System. Dark theme, mobile-first, CSS custom properties. */

:root {
    --primary: #c8a97a;
    /* --bg, --surface, --surface-2: see Premium Edition :root below */
    --text: #e0e0e0;
    --text-muted: #888;
    --accent: #c8a97a;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --border: #2a2a2a;
    --radius: 12px;
    --radius-sm: 8px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* Transitions for real-time theme changes */
    transition: --primary 0.3s, --bg 0.3s, --surface 0.3s, --text 0.3s, --accent 0.3s;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    overscroll-behavior-y: contain;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* Prevent iOS input zoom */
input, textarea, select { font-size: 16px; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout Shell --- */

#app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    max-width: 100%;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.app-header .logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.app-header .status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.app-header .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.app-header .credits-badge {
    background: rgba(200,169,122,0.12);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--primary);
    font-weight: 700;
    border: 1px solid rgba(200,169,122,0.15);
    cursor: pointer;
    transition: all 0.2s;
}

.app-header .credits-badge:hover {
    background: rgba(200,169,122,0.2);
}

.credits-empty {
    color: var(--error) !important;
    background: rgba(239,68,68,0.1) !important;
    border-color: rgba(239,68,68,0.2) !important;
}

.credits-low {
    color: var(--warning) !important;
    background: rgba(245,158,11,0.1) !important;
    border-color: rgba(245,158,11,0.2) !important;
}

.credits-banner {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.credits-banner-empty {
    background: rgba(239,68,68,0.08);
    color: var(--error);
    border-bottom: 1px solid rgba(239,68,68,0.15);
}

.credits-banner-low {
    background: rgba(245,158,11,0.08);
    color: var(--warning);
    border-bottom: 1px solid rgba(245,158,11,0.15);
    cursor: pointer;
}

.app-header .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid var(--border);
    transition: border-color 0.2s;
}

.app-header .avatar:hover {
    border-color: var(--primary);
}

/* Fallback avatar when image fails */
.app-header .avatar-fallback {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid rgba(200,169,122,0.3);
    transition: border-color 0.2s;
}

.app-header .avatar-fallback:hover {
    border-color: var(--primary);
}

/* --- Content Area --- */

.app-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Desktop: sidebar chat + main content --- */

.app-desktop-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100dvh - 52px); /* matches .app-header height */
}

.app-sidebar {
    width: 380px;
    min-width: 380px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-chat-wrap {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar-chat-wrap .chat-messages { flex: 1; overflow-y: auto; }

.app-main {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
}

/* Desktop app-home grid: bigger icons */
@media (min-width: 901px) {
    .app-home-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 16px;
        max-width: 800px;
        margin: 0 auto;
        padding: 16px 0;
    }
    .app-home-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 20px 8px;
        border-radius: var(--radius);
        background: var(--surface);
        border: 1px solid var(--border);
        cursor: pointer;
        transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    }
    .app-home-item:hover {
        border-color: var(--primary);
        transform: translateY(-2px);
        box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    }
    .app-home-item:active { transform: scale(0.97); }
    .app-home-icon { font-size: 36px; line-height: 1; }
    .app-home-label { font-size: 12px; color: var(--text); text-align: center; font-weight: 500;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}

/* Desktop focused block (opened from grid) */
.block-focused {
    animation: blockEnter 0.25s ease-out;
    max-width: 900px;
    margin: 0 auto;
}

.block-focused-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.block-focused-header h3 {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.block-focused-back {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.block-focused-back:hover {
    background: var(--surface-2);
    color: var(--text);
}

.block-focused-body {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

/* --- Mobile: app-home grid (phone-style icons) --- */
@media (max-width: 900px) {
    .app-home-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 12px;
        padding: 16px;
    }
    .app-home-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 16px 4px;
        border-radius: 16px;
        background: var(--surface);
        border: 1px solid var(--border);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.15s, border-color 0.2s;
    }
    .app-home-item:active { transform: scale(0.92); }
    .app-home-item:hover { border-color: rgba(200,169,122,0.2); }
    .app-home-icon { font-size: 32px; line-height: 1; }
    .app-home-label { font-size: 11px; color: var(--text); text-align: center; font-weight: 500;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}

/* --- Mobile: block fullscreen overlay --- */
.block-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    animation: blockEnter 0.2s ease-out;
}

.block-fullscreen-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.block-fullscreen-header h3 {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.block-fullscreen-back {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.block-fullscreen-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.block-fullscreen-body > .block {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 0;
    overflow: visible;
}

.block-fullscreen-body .block-body {
    flex: 1;
    overflow-y: auto;
}

.block-fullscreen-body .chat-messages {
    flex: 1;
    max-height: none;
    overflow-y: auto;
}

.block-fullscreen-body .chat-input-area {
    flex-shrink: 0;
}

/* [Removed] Old mobile-chat-fab/overlay + chatSlideUp — replaced by bottom-nav + mobile-chat-fullscreen */

/* --- Desktop: sidebar chat fix --- */
@media (min-width: 901px) {
    .app-sidebar .block {
        border: none;
        border-radius: 0;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .app-sidebar .chat-messages {
        flex: 1;
        max-height: none;
        overflow-y: auto;
    }
    .app-sidebar .chat-input-area {
        flex-shrink: 0;
    }
}

/* --- Block Grid (legacy fallback) --- */

.blocks-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* --- Block Base --- */

.block {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: border-color 0.2s, transform 0.1s;
}

.block:hover {
    border-color: rgba(200,169,122,0.2);
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.block-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.block-body {
    padding: 16px;
}

/* Notification bell & panel */
.notif-bell {
    position: relative;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.notif-bell:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text);
}
.notif-bell:has(.notif-badge) {
    color: var(--primary);
    background: rgba(200, 169, 122, 0.08);
    border-color: rgba(200, 169, 122, 0.2);
}
.notif-bell:has(.notif-badge):hover {
    background: rgba(200, 169, 122, 0.15);
    border-color: rgba(200, 169, 122, 0.35);
}
/* Bell shake quando unread */
.notif-bell:has(.notif-badge) svg {
    animation: bell-shake 4s ease-in-out infinite;
    transform-origin: top center;
}
@keyframes bell-shake {
    0%, 92%, 100% { transform: rotate(0); }
    94% { transform: rotate(-8deg); }
    96% { transform: rotate(8deg); }
    98% { transform: rotate(-4deg); }
}

.notif-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    pointer-events: none;
    line-height: 1;
    border: 2px solid var(--bg, #111);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    animation: notif-badge-pulse 2.5s ease-in-out infinite;
}
@keyframes notif-badge-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}
.notif-panel { position: absolute; top: calc(100% + 8px); right: -20px; width: 320px; max-height: 420px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5); z-index: 200; overflow: hidden;
    animation: blockEnter 0.2s ease-out; }
.notif-header { display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text); }
.notif-readall { font-size: 11px; color: var(--primary); cursor: pointer; font-weight: 500; }
.notif-readall:hover { text-decoration: underline; }
.notif-list { overflow-y: auto; max-height: 360px; }
.notif-item { display: flex; gap: 10px; padding: 12px 16px; cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.03); transition: background 0.15s; }
.notif-item:hover { background: rgba(255,255,255,0.03); }
.notif-unread { background: rgba(200,169,122,0.06); }
.notif-unread .notif-title { font-weight: 600; }
.notif-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; color: var(--text); line-height: 1.3; }
.notif-body { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.notif-empty { padding: 32px 16px; text-align: center; font-size: 13px; color: var(--text-muted); }
.notif-expanded { background: rgba(200,169,122,0.08); }
.notif-body-full { font-size: 13px; color: var(--text); margin-top: 4px; line-height: 1.5;
    white-space: pre-wrap; word-wrap: break-word; }

@media (max-width: 480px) {
    .notif-panel { position: fixed; left: 12px; right: 12px; top: 56px; width: auto; max-height: 70vh; }
}

/* App blocks (sandboxed mini-apps) */
.app-block .block-body { padding: 0; overflow: hidden; }
.app-block iframe { display: block; background: var(--bg); }
.app-loading { position: absolute; inset: 0; display: flex; align-items: center;
    justify-content: center; background: var(--surface); z-index: 1; border-radius: 0 0 12px 12px; }

/* Block animations */
.block-enter {
    animation: blockEnter 0.4s ease-out;
}

@keyframes blockEnter {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.block-exit {
    animation: blockExit 0.3s ease-in forwards;
}

@keyframes blockExit {
    to { opacity: 0; transform: translateY(10px); height: 0; margin: 0; padding: 0; overflow: hidden; }
}

/* --- Chat Block (Full Height) --- */

.block-chat {
    display: flex;
    flex-direction: column;
}

.block-chat.prominent {
    grid-column: 1 / -1;
    min-height: 60vh;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 60vh;
}

.chat-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.65;
    word-wrap: break-word;
    animation: msgFadeIn 0.25s ease-out;
}

@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--primary);
    color: #0a0a0a;
    border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
    align-self: flex-start;
    background: var(--surface-2);
    color: var(--text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

.chat-msg.assistant .model-tag {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Luna thinking animation */
.luna-thinking {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.luna-thinking-orb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    animation: orbPulse 1.5s ease-in-out infinite;
}

@keyframes orbPulse {
    0%, 100% { transform: scale(0.8); opacity: 0.4; }
    50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 12px rgba(200,169,122,0.4); }
}

.luna-thinking-text {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

.chat-input-area {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    padding-bottom: 8px;
    background: var(--surface);
    align-items: flex-end;
    border-top: 1px solid var(--border);
}

.chat-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 10px 16px;
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    resize: none;
    outline: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.4;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(200,169,122,0.1);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-send {
    background: var(--primary);
    color: #0a0a0a;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    min-width: 44px;
    font-weight: 600;
    font-size: 18px;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-send:hover { opacity: 0.85; transform: scale(1.05); }
.chat-send:active { transform: scale(0.95); }
.chat-send:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

.chat-cost-hint {
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 16px 8px;
    text-align: right;
}

/* Chat option buttons */
.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 4px;
    align-self: flex-start;
    max-width: 95%;
    animation: optionsFadeIn 0.4s ease-out;
}

@keyframes optionsFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-option-btn {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 15px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.3;
}

.chat-option-btn:hover {
    background: var(--primary);
    color: #0a0a0a;
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(200, 169, 122, 0.2);
}

.chat-option-btn:active {
    transform: scale(0.97);
}

/* Multi-select: selected state */
.chat-option-btn.selected {
    background: var(--primary);
    color: #0a0a0a;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(200, 169, 122, 0.3);
}

/* Confirm button for multi-select */
.chat-option-confirm {
    background: var(--primary);
    color: #0a0a0a;
    border: none;
    border-radius: 12px;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-top: 4px;
}

.chat-option-confirm:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.chat-option-confirm.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

/* Multi-mode label hint */
.chat-options.multi-mode::before {
    content: "Puoi selezionarne più di una";
    display: block;
    width: 100%;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* Streaming indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 8px 12px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* --- Credits Block --- */

.credits-balance {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary);
    text-align: center;
    padding: 20px 0 4px;
    letter-spacing: -0.02em;
}

.credits-label {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Pricing plan cards */
.plan-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.plan-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.plan-card:active {
    transform: scale(0.98);
}

.plan-card.popular {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--surface), rgba(200,169,122,0.08));
}

.plan-card.popular::before {
    content: 'Consigliato';
    position: absolute;
    top: 0;
    right: 0;
    background: var(--primary);
    color: #0a0a0a;
    padding: 4px 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom-left-radius: var(--radius-sm);
}

.plan-price {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}

.plan-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.plan-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Pricing info section */
.pricing-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 20px;
}

.pricing-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.pricing-info-item .price {
    color: var(--primary);
    font-weight: 700;
    margin-left: auto;
}

@media (max-width: 480px) {
    .pricing-info {
        grid-template-columns: 1fr;
    }
}

/* --- Stats Block --- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-card {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.stat-card:hover {
    border-color: rgba(200,169,122,0.2);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

/* --- Bots Block --- */

.bot-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bot-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all 0.15s;
}

.bot-item:hover {
    border-color: rgba(200,169,122,0.15);
    background: rgba(26,26,26,0.8);
}

.bot-item .bot-name {
    font-weight: 600;
    font-size: 14px;
}

.bot-item .bot-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
}

.bot-status.active { background: #22c55e20; color: var(--success); }
.bot-status.paused { background: #f59e0b20; color: var(--warning); }
.bot-status.error { background: #ef444420; color: var(--error); }
.bot-status.done { background: #6366f120; color: #a5b4fc; }

/* --- Bot Tracker Block --- */

.bot-tracker-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bot-tracker-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
    gap: 12px;
}

.bot-tracker-info {
    flex: 1;
    min-width: 0;
}

/* --- Gallery Block --- */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.gallery-grid img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
}

.gallery-grid img:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    z-index: 1;
    position: relative;
}

/* --- Text Block --- */

.text-content {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
}

.text-content h1, .text-content h2, .text-content h3 {
    color: var(--primary);
    margin: 16px 0 8px;
}

.text-content p { margin-bottom: 12px; }

.text-content code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}

/* --- Buttons --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: opacity 0.15s, transform 0.1s;
    min-height: 44px;
    min-width: 44px;
}

.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: #0a0a0a;
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--surface);
    color: var(--text);
}

/* Destructive variant */
.btn-danger {
    background: rgba(239,68,68,0.1);
    color: var(--error);
    border: 1px solid rgba(239,68,68,0.2);
}

.btn-danger:hover {
    background: rgba(239,68,68,0.2);
}

.btn-full { width: 100%; }

/* --- Landing Page --- */

.landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 32px 24px;
    text-align: center;
}

.landing-logo {
    font-size: 48px;
    margin-bottom: 16px;
}

.landing h1 {
    font-size: 36px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.landing .subtitle {
    font-size: 16px;
    color: var(--text-muted);
    max-width: 400px;
    margin-bottom: 36px;
    line-height: 1.7;
}

.landing .google-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    color: #333;
    padding: 14px 28px;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    min-height: 52px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.landing .google-btn:hover {
    box-shadow: 0 6px 20px rgba(255,255,255,0.15);
    transform: translateY(-1px);
}

.landing .google-btn:active {
    transform: scale(0.98);
}

.landing .google-btn svg {
    width: 20px;
    height: 20px;
}

.landing footer {
    position: absolute;
    bottom: 24px;
    font-size: 12px;
    color: var(--text-muted);
}

.landing footer a {
    color: var(--text-muted);
    text-decoration: underline;
}

/* Landing use cases — conversational examples */
.landing-usecases {
    max-width: 380px;
    margin: 0 auto 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.landing-usecase {
    background: var(--surface, #161616);
    border-radius: 16px;
    padding: 14px 16px;
    border: 1px solid rgba(255,255,255,0.06);
}

.landing-usecase-q {
    font-size: 13px;
    color: var(--text, #e8e8e8);
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
}

.landing-usecase-q::before {
    content: '';
    position: absolute;
    left: 0;
    top: 3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent, #c8a97a);
    opacity: 0.6;
}

.landing-usecase-a {
    font-size: 12px;
    color: var(--text-secondary, #888);
    padding-left: 20px;
    line-height: 1.4;
    font-style: italic;
}

.landing-features {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    margin-bottom: 40px;
}

.landing-feature {
    font-size: 13px;
    color: var(--text-secondary, #888);
    display: flex;
    align-items: center;
    gap: 8px;
}

.landing-feature-icon {
    font-size: 16px;
}

/* Activity feed — empty state */
.af-empty {
    text-align: center;
    padding: 32px 16px;
    background: var(--surface, #161616);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 20px;
}

.af-empty-icon {
    margin-bottom: 16px;
    opacity: 0.8;
}

.af-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text, #e8e8e8);
    margin: 0 0 8px 0;
}

.af-empty-desc {
    font-size: 13px;
    color: var(--text-secondary, #888);
    line-height: 1.5;
    max-width: 320px;
    margin: 0 auto;
}

/* Activity item expanded detail */
.af-item-detail {
    font-size: 12px;
    color: var(--text, #e8e8e8);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.af-item {
    cursor: pointer;
}

/* --- Onboarding --- */

.onboarding-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.onboarding-overlay .app-header {
    background: transparent;
    border-bottom: 1px solid rgba(200, 169, 122, 0.15);
}

.onboarding-overlay .block-chat {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
    border: none;
    background: transparent;
}

.onboarding-overlay .chat-messages {
    max-height: none;
    flex: 1;
    padding: 24px 16px;
}

.onboarding-overlay .chat-msg.assistant {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(200, 169, 122, 0.1);
    font-size: 16px;
    line-height: 1.7;
    max-width: 95%;
}

.onboarding-overlay .chat-msg.user {
    font-size: 15px;
}

.onboarding-overlay .chat-input-area {
    background: transparent;
    border-top: 1px solid rgba(200, 169, 122, 0.15);
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
    padding: 16px;
}

.onboarding-overlay .chat-options {
    max-width: 100%;
    justify-content: center;
    padding: 16px 0;
}

.onboarding-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.onboarding-building {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
    gap: 16px;
}

.onboarding-building .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* --- Loading --- */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    color: var(--text-muted);
}

/* --- Settings --- */

.settings-section {
    margin-bottom: 16px;
}

.settings-section h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding: 0 4px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 2px;
}

.settings-row:first-of-type { border-radius: var(--radius) var(--radius) 0 0; }
.settings-row:last-of-type { border-radius: 0 0 var(--radius) var(--radius); margin-bottom: 0; }
.settings-row:only-of-type { border-radius: var(--radius); }

.settings-row label {
    font-size: 14px;
    color: var(--text-muted);
}

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

/* Profile hero card */
.profile-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 20px 24px;
    background: var(--surface);
    border-radius: var(--radius-lg, 16px);
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.profile-hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), rgba(200,169,122,0.3));
    opacity: 0.15;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}

.profile-email {
    font-size: 13px;
    color: var(--text-muted);
    position: relative;
    z-index: 1;
}

.profile-balance {
    margin-top: 16px;
    padding: 12px 24px;
    background: rgba(200,169,122,0.1);
    border-radius: var(--radius);
    text-align: center;
    position: relative;
    z-index: 1;
}

.profile-balance-amount {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
}

.profile-balance-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Profile action buttons */
.profile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.profile-actions .btn {
    font-size: 13px;
    padding: 12px 8px;
}

/* Danger zone */
.danger-zone {
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 24px;
}

.danger-zone h2 {
    color: var(--error) !important;
    font-size: 13px !important;
}

.settings-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    width: 200px;
}

.settings-input:focus {
    border-color: var(--primary);
}

/* --- Toast Notifications --- */

.toast {
    position: fixed;
    bottom: calc(24px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-2);
    color: var(--text);
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    z-index: 10000;
    animation: toastIn 0.3s ease-out;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    border: 1px solid var(--border);
    max-width: calc(100vw - 48px);
    text-align: center;
}

.toast-out {
    animation: toastOut 0.25s ease-in forwards;
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(-50%) translateY(10px); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}


/* --- Welcome card --- */
.space-welcome {
    padding: 0 4px 8px;
}

.space-welcome-card {
    background: linear-gradient(135deg, var(--surface), rgba(200,169,122,0.06));
    border: 1px solid rgba(200,169,122,0.15);
    border-radius: 20px;
    padding: 28px 24px;
    text-align: center;
    animation: blockEnter 0.5s ease-out;
}

.space-welcome-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.space-welcome-card h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.space-welcome-card p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 4px;
}

/* --- Empty state --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.empty-state-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.empty-state-text {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 240px;
}

/* --- Subtle glow on primary elements --- */
.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(200,169,122,0.25);
}

/* --- Header right section grouping --- */
.app-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Better focus ring for accessibility --- */
.btn:focus-visible,
.chat-input:focus-visible,
.chat-option-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* --- Smooth page transitions --- */
.app-content {
    animation: pageIn 0.2s ease-out;
}

@keyframes pageIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Credits block: improved --- */
.credits-block-hero {
    text-align: center;
    padding: 20px 16px;
}

.credits-block-hero .credits-balance {
    padding: 4px 0;
}

/* --- Better bot status chips --- */
.bot-status {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 16px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* --- Gallery: masonry-like on desktop --- */
@media (min-width: 600px) {
    .gallery-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
}

/* --- Pulse animation (reusable) --- */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* --- Skeleton loading --- */
.skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Utility --- */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.p-16 { padding: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(200,169,122,0.2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(200,169,122,0.4); }

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- Chat attach & voice buttons --- */
.chat-attach {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 16px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.15s;
    flex-shrink: 0;
    opacity: 0.7;
}
.chat-attach:active { opacity: 1; }
.chat-attach:hover { background: var(--surface-2); }
.chat-attach input[type="file"] {
    display: none;
}

.chat-voice {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    border-radius: 50%;
    transition: background 0.15s;
    flex-shrink: 0;
    opacity: 0.7;
}
.chat-voice:active { opacity: 1; }
.chat-voice:hover { background: var(--surface-2); }
.chat-voice.recording {
    background: var(--error);
    animation: pulse 1s infinite;
}
.chat-voice:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-attachment-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 16px;
    border-top: 1px solid var(--border);
}
.attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 5px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.remove-attach {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    margin-left: 2px;
}
.remove-attach:hover { color: var(--error); }

.voice-recording-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.voice-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--error);
    animation: pulse 1s infinite;
}
.voice-timer { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.voice-label { font-size: 13px; color: var(--text-secondary); flex: 1; }
.voice-stop {
    background: var(--error);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    font-weight: 600;
    cursor: pointer;
}

.chat-cost-hint {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    padding: 2px 16px 0;
}

/* ============================================= */
/* Luna Design System — Premium Edition          */
/* One layer. No conflicts. No !important spam.  */
/* ============================================= */

/* === 1. EXTENDED DESIGN TOKENS === */

:root {
    /* Surfaces — less contrast, more depth */
    --bg: #08080c;
    --surface: rgba(255, 255, 255, 0.025);
    --surface-hover: rgba(255, 255, 255, 0.045);
    --surface-active: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.04);

    /* Typography scale */
    --text-xs: 11px;
    --text-sm: 13px;
    --text-base: 15px;
    --text-lg: 18px;
    --text-xl: 24px;
    --text-2xl: 36px;
    --text-hero: 48px;
    --tracking-tight: -0.025em;
    --tracking-tighter: -0.04em;

    /* Semantic accents */
    --accent-blue: #6366f1;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-violet: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-orange: #f97316;
    --accent-pink: #ec4899;
    --accent-teal: #14b8a6;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.5);

    /* Spring easing */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);

    /* Glass */
    --glass-bg: rgba(12, 12, 16, 0.75);
    --glass-border: rgba(255, 255, 255, 0.04);
}

/* === 2. BASE OVERRIDES === */

body {
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 10% 20%, rgba(200, 169, 122, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 85% 80%, rgba(99, 102, 241, 0.03) 0%, transparent 55%);
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 3px; }
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.08) transparent; }

::selection { background: rgba(200, 169, 122, 0.25); }

/* === 3. HEADER — clean, quiet === */

.app-header {
    background: rgba(10, 10, 18, 0.85);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding: 0 20px;
    height: 52px;
    gap: 12px;
}

.app-header .logo {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-right: auto;
}

.app-header .credits-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #a0a0a0);
    font-variant-numeric: tabular-nums;
}

.app-header .credits-badge:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.header-viewing {
    background: rgba(200, 169, 122, 0.12);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.01em;
}

.app-header .avatar {
    width: 30px;
    height: 30px;
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    transition: border-color 0.2s;
}

.app-header .avatar:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.app-header .avatar-fallback {
    width: 30px;
    height: 30px;
    font-size: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.08);
}

/* === 4. BENTO GRID — Desktop === */

@media (min-width: 901px) {
    .app-home-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        grid-auto-rows: auto;
        gap: 10px;
        max-width: 840px;
        margin: 0 auto;
        padding: 32px 24px;
    }

    /* Wide cards */
    .app-home-item[data-type="admin-dashboard"],
    .app-home-item[data-type="admin_dashboard"] { grid-column: span 2; }
    .app-home-item[data-type="artstone-status"] { grid-column: span 2; }

    .app-home-item {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 14px;
        padding: 18px 20px;
        min-height: 80px;
        border-radius: 14px;
        border: none;
        background: var(--surface);
        cursor: pointer;
        transition: background 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
        position: relative;
        overflow: hidden;
    }

    .app-home-item:hover {
        background: var(--surface-hover);
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

    .app-home-item:active {
        transform: scale(0.98);
        transition-duration: 0.1s;
    }

    /* Icon: tinted container */
    .app-home-icon {
        width: 42px;
        height: 42px;
        min-width: 42px;
        border-radius: 11px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        background: var(--icon-tint, rgba(200, 169, 122, 0.1));
        transition: transform 0.3s var(--ease);
        line-height: 1;
    }

    .app-home-item:hover .app-home-icon {
        transform: scale(1.08);
    }

    /* Text */
    .app-home-text {
        flex: 1;
        min-width: 0;
    }

    .app-home-label {
        font-size: var(--text-sm);
        font-weight: 600;
        color: var(--text);
        text-transform: none;
        white-space: normal;
        word-break: break-word;
        text-align: left;
        max-width: none;
        letter-spacing: -0.01em;
        line-height: 1.3;
    }

    .app-home-desc {
        font-size: var(--text-xs);
        color: rgba(255, 255, 255, 0.35);
        margin-top: 2px;
        white-space: normal;
        line-height: 1.3;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Entrance */
    .app-home-item {
        animation: gridIn 0.35s var(--ease) backwards;
    }
    .app-home-item:nth-child(1) { animation-delay: 0s; }
    .app-home-item:nth-child(2) { animation-delay: 0.03s; }
    .app-home-item:nth-child(3) { animation-delay: 0.06s; }
    .app-home-item:nth-child(4) { animation-delay: 0.09s; }
    .app-home-item:nth-child(5) { animation-delay: 0.12s; }
    .app-home-item:nth-child(6) { animation-delay: 0.15s; }
    .app-home-item:nth-child(7) { animation-delay: 0.18s; }
    .app-home-item:nth-child(8) { animation-delay: 0.21s; }
    .app-home-item:nth-child(9) { animation-delay: 0.24s; }
    .app-home-item:nth-child(10) { animation-delay: 0.27s; }

    @keyframes gridIn {
        from { opacity: 0; transform: translateY(8px); }
        to { opacity: 1; transform: translateY(0); }
    }
}

/* Per-type icon tints */
.app-home-item[data-type="admin-dashboard"],
.app-home-item[data-type="admin_dashboard"] { --icon-tint: rgba(99, 102, 241, 0.12); }
.app-home-item[data-type="activity-feed"]   { --icon-tint: rgba(245, 158, 11, 0.12); }
.app-home-item[data-type="social-dashboard"]{ --icon-tint: rgba(236, 72, 153, 0.12); }
.app-home-item[data-type="bots"],
.app-home-item[data-type="bots_dashboard"]  { --icon-tint: rgba(16, 185, 129, 0.12); }
.app-home-item[data-type="artstone-status"] { --icon-tint: rgba(249, 115, 22, 0.12); }
.app-home-item[data-type="chat-analytics"]  { --icon-tint: rgba(139, 92, 246, 0.12); }
.app-home-item[data-type="admin-users"],
.app-home-item[data-type="admin_users"]     { --icon-tint: rgba(6, 182, 212, 0.12); }
.app-home-item[data-type="admin-costs"]     { --icon-tint: rgba(20, 184, 166, 0.12); }
.app-home-item[data-type="admin-dm-inbox"],
.app-home-item[data-type="admin_dm_inbox"],
.app-home-item[data-type="direct_message"]  { --icon-tint: rgba(244, 63, 94, 0.12); }
.app-home-item[data-type="file_gallery"],
.app-home-item[data-type="gallery"]         { --icon-tint: rgba(20, 184, 166, 0.12); }
.app-home-item[data-type="chat"]            { --icon-tint: rgba(200, 169, 122, 0.12); }

/* === 5. MOBILE GRID === */

@media (max-width: 900px) {
    .app-home-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 16px 14px;
    }

    .app-home-item[data-type="artstone-status"] { grid-column: span 2; }

    .app-home-item {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 16px;
        min-height: 80px;
        border-radius: 14px;
        border: none;
        background: var(--surface);
        position: relative;
    }

    .app-home-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        background: var(--icon-tint, rgba(200, 169, 122, 0.1));
    }

    .app-home-text { width: 100%; }

    .app-home-label {
        font-size: 13px;
        font-weight: 600;
        color: var(--text);
        text-transform: none;
        text-align: left;
        max-width: none;
    }

    .app-home-desc {
        font-size: 11px;
        color: rgba(255, 255, 255, 0.3);
        margin-top: 1px;
    }
}

/* === 6. BLOCKS — borderless, elevated === */

.block {
    background: var(--surface);
    border: none;
    border-radius: 16px;
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--glass-border);
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
    overflow: hidden;
}

.block:hover {
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* Block header: quiet label style (Linear pattern) */
.block-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.block-header h3 {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.block-body {
    padding: 20px 22px;
}

/* Block badge */
.block-badge {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 99px;
    font-weight: 500;
    background: var(--surface);
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border);
}

/* Focused block */
.block-focused-header {
    padding: 20px 0 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.block-focused-header h3 {
    font-size: var(--text-xl);
    font-weight: 800;
    letter-spacing: var(--tracking-tight);
    color: var(--text);
}

.block-focused-back {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: none;
    color: var(--text-muted);
    transition: all 0.2s;
}

.block-focused-back:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* === 7. STAT CARDS — hero numbers, no inner borders === */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    background: var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.stat-card {
    background: var(--bg);
    border: none;
    border-radius: 0;
    padding: 24px 20px;
    text-align: center;
    transition: background 0.2s;
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.015);
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: 800;
    letter-spacing: var(--tracking-tighter);
    line-height: 1;
    color: var(--primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Scale down if value is long text (cron, words) */
.stat-value:not(:empty) {
    max-width: 100%;
}

.stat-label {
    font-size: var(--text-xs);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 8px;
}

/* Individual stat colors via nth-child */
.stat-card:nth-child(1) .stat-value { color: var(--accent-blue); }
.stat-card:nth-child(2) .stat-value { color: var(--accent-emerald); }
.stat-card:nth-child(3) .stat-value { color: var(--accent-amber); }
.stat-card:nth-child(4) .stat-value { color: var(--accent-violet); }

/* === 8. CHAT === */

.chat-messages {
    padding: 20px;
    gap: 14px;
}

.chat-msg {
    max-width: 82%;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.65;
    animation: msgIn 0.25s var(--ease);
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
    background: linear-gradient(135deg, var(--primary), #b8944d);
    color: #0a0a0a;
    padding: 12px 16px;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 12px rgba(200, 169, 122, 0.12);
}

.chat-msg.assistant {
    background: var(--surface);
    color: rgba(255, 255, 255, 0.85);
    border: none;
    border-left: 2px solid rgba(200, 169, 122, 0.3);
    padding: 12px 16px;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.chat-msg.assistant strong { color: var(--primary); }
.chat-msg.assistant code {
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
}

.chat-input-area {
    background: transparent;
    border-top: 1px solid var(--border);
    padding: 14px 16px;
}

.chat-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 11px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input:focus {
    border-color: rgba(200, 169, 122, 0.4);
    box-shadow: 0 0 0 3px rgba(200, 169, 122, 0.06);
}

.chat-send {
    background: var(--primary);
    box-shadow: none;
    transition: transform 0.2s, opacity 0.2s;
}

.chat-send:hover:not(:disabled) {
    transform: scale(1.06);
    opacity: 0.9;
}

.chat-option-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 14px;
    transition: all 0.2s var(--ease);
}

.chat-option-btn:hover {
    background: var(--primary);
    color: #0a0a0a;
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* === 9. LIST ITEMS (shared) === */

.luna-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 22px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.luna-list-item:hover {
    background: var(--surface-hover);
}

.luna-list-item:last-child { border-bottom: none; }
.luna-list-item.compact { padding: 8px 22px; font-size: 12px; }

.luna-list-dot {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}

.luna-list-name { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.luna-list-meta { font-size: var(--text-xs); color: rgba(255, 255, 255, 0.35); margin-top: 1px; }
.luna-list-info { flex: 1; min-width: 0; }
.luna-list-right { text-align: right; flex-shrink: 0; }
.luna-list-value { font-size: var(--text-sm); font-weight: 700; }
.luna-list-accent { font-size: 10px; color: var(--primary); margin-top: 2px; }
.luna-list-status { font-weight: 700; font-size: 14px; min-width: 16px; flex-shrink: 0; }

/* === 10. BOT ITEMS === */

.bot-item {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 13px 22px;
    transition: background 0.15s;
}

.bot-item:hover {
    background: var(--surface-hover);
    box-shadow: none;
}

.bot-item .bot-name { font-size: var(--text-base); font-weight: 600; }

.bot-status {
    font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 500;
}

.bot-detail {
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid var(--border);
    padding: 16px 22px;
}

.bot-actions { display: flex; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

.bot-action-btn {
    padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 500;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    cursor: pointer; transition: all 0.15s; font-family: var(--font);
}

.bot-action-btn:hover { background: var(--surface-hover); }
.bot-action-btn.run { color: var(--accent-emerald); border-color: rgba(16, 185, 129, 0.2); }
.bot-action-btn.run:hover { background: rgba(16, 185, 129, 0.1); }
.bot-action-btn.delete { color: var(--accent-rose); border-color: rgba(244, 63, 94, 0.15); }
.bot-action-btn.delete:hover { background: rgba(244, 63, 94, 0.08); }
.bot-action-btn.edit { color: var(--primary); }
.bot-action-btn.edit:hover { background: rgba(200, 169, 122, 0.08); }
.bot-action-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* === 11. TRACKER === */

.tracker-item { display: flex; align-items: center; gap: 12px; padding: 11px 22px; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.tracker-item:hover { background: var(--surface-hover); }
.tracker-item.completed { opacity: 0.5; }
.tracker-check { width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.tracker-check.active { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); }
.tracker-check.completed { background: rgba(200, 169, 122, 0.1); color: var(--primary); }
.tracker-check.paused { background: var(--surface); color: var(--text-muted); }
.tracker-info { flex: 1; min-width: 0; }
.tracker-name { font-size: var(--text-sm); font-weight: 600; }
.tracker-meta { font-size: var(--text-xs); color: rgba(255, 255, 255, 0.35); margin-top: 2px; }
.tracker-progress { height: 3px; background: var(--surface); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.tracker-progress-bar { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.5s var(--ease); }
.tracker-progress-bar.completed { background: var(--accent-emerald); }
.tracker-actions { display: flex; gap: 4px; }
.tracker-btn { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.tracker-btn:hover { background: var(--surface-hover); color: var(--text); }

/* === 12. SIDEBAR === */

.app-sidebar {
    background: rgba(8, 8, 12, 0.6);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
}

@media (min-width: 901px) {
    .app-sidebar { width: 360px; min-width: 360px; }
}

/* === 13. GALLERY === */

.gallery-tabs { display: flex; gap: 4px; padding: 0 12px 10px; overflow-x: auto; scrollbar-width: none; }
.gallery-tabs::-webkit-scrollbar { display: none; }
.gallery-tab { padding: 6px 14px; border-radius: 8px; border: none; font-size: 13px; cursor: pointer; white-space: nowrap; background: var(--surface); color: var(--text-muted); font-family: var(--font); transition: all 0.15s; }
.gallery-tab:hover { background: var(--surface-hover); color: var(--text); }
.gallery-tab.active { background: var(--primary); color: #0a0a0a; font-weight: 600; }

.gallery-image-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
@media (min-width: 600px) { .gallery-image-grid { grid-template-columns: repeat(4, 1fr); } }
.gallery-thumb { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 8px; background: var(--surface); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s var(--ease); }
.gallery-thumb:hover img { transform: scale(1.06); }
.gallery-thumb-link { display: block; width: 100%; height: 100%; }
.gallery-download { position: absolute; bottom: 4px; right: 4px; background: rgba(0, 0, 0, 0.7); color: #fff; border-radius: 50%; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: 13px; text-decoration: none; opacity: 0; transition: opacity 0.15s; }
.gallery-thumb:hover .gallery-download { opacity: 1; }
.gallery-video-list { display: flex; flex-direction: column; gap: 6px; }
.gallery-video-item { border-radius: 8px; overflow: hidden; background: var(--surface); }
.gallery-video-name { padding: 6px 10px; font-size: 12px; color: var(--text-muted); }
.gallery-file-list { display: flex; flex-direction: column; gap: 4px; }
.gallery-file-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--text); transition: background 0.15s; }
.gallery-file-item:hover { background: var(--surface-hover); }
.gallery-file-icon { font-size: 22px; flex-shrink: 0; }
.gallery-file-dl { font-size: 16px; opacity: 0.4; transition: opacity 0.15s; }
.gallery-file-item:hover .gallery-file-dl { opacity: 1; }

/* === 14. SOCIAL === */

.social-section { margin-top: 16px; }
.social-section-title { font-size: var(--text-xs); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255, 255, 255, 0.35); margin-bottom: 8px; }
.social-bot-grid { display: flex; gap: 8px; }
.social-bot-card { flex: 1; padding: 12px 14px; background: var(--surface); border: none; border-radius: 10px; }
.social-bot-label { font-size: var(--text-xs); color: rgba(255, 255, 255, 0.35); text-transform: uppercase; letter-spacing: 0.04em; }
.social-bot-status { font-size: 14px; font-weight: 700; margin-top: 4px; }
.social-last-post { margin-top: 12px; padding: 12px 14px; background: var(--surface); border-radius: 10px; }
.social-post-text { font-size: 12px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* === 15. ADMIN USERS === */

.luna-list-wrap { border-bottom: 1px solid var(--border); }
.luna-chevron { margin-left: 8px; font-size: 12px; color: var(--text-muted); }
.user-detail { padding: 12px 22px 16px; background: rgba(0, 0, 0, 0.12); border-top: 1px solid var(--border); }
.user-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; font-size: 12px; color: rgba(255, 255, 255, 0.4); }
.user-detail-grid strong { color: var(--text); }
.credit-btns { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.credit-btn { padding: 5px 12px; border-radius: 6px; border: 1px solid rgba(200, 169, 122, 0.2); background: transparent; color: var(--primary); font-size: 12px; font-weight: 500; cursor: pointer; font-family: var(--font); transition: all 0.15s; }
.credit-btn:hover { background: rgba(200, 169, 122, 0.1); }
.credit-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.credit-btn.primary { background: var(--primary); color: #0a0a0a; border: none; }
.credit-custom { display: flex; gap: 3px; }
.credit-input { width: 70px; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12px; font-family: var(--font); }
.credit-input:focus { border-color: var(--primary); outline: none; }

/* === 16. BLOCK TAP CTA === */

.block-tap-cta { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; text-align: center; color: var(--text-muted); }
.block-tap-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 10px; }

/* === 17. NOTIFICATIONS === */

.notif-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
}

/* === 18. SETTINGS === */

.profile-hero {
    background: linear-gradient(180deg, rgba(200, 169, 122, 0.05) 0%, transparent 100%);
    border-radius: 16px;
    border: 1px solid var(--border);
}

.profile-avatar {
    border: 2px solid rgba(200, 169, 122, 0.25);
}

.settings-section h2 {
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.3);
}

.settings-row {
    background: var(--surface);
    transition: background 0.15s;
}

.settings-row:hover { background: var(--surface-hover); }

/* === 19. BUTTONS === */

.btn-primary {
    background: var(--primary);
    box-shadow: none;
    font-weight: 600;
    transition: transform 0.15s, opacity 0.15s;
}

.btn-primary:hover { transform: translateY(-1px); opacity: 0.9; }

.btn-outline {
    border: 1px solid rgba(200, 169, 122, 0.2);
    color: var(--primary);
    background: transparent;
}

.btn-outline:hover { background: rgba(200, 169, 122, 0.06); }

/* === 20. CREDITS === */

.credits-balance {
    font-size: var(--text-hero);
    font-weight: 800;
    letter-spacing: var(--tracking-tighter);
    color: var(--primary);
}

.plan-card { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); transition: all 0.2s var(--ease); }
.plan-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.plan-card.popular { border-color: rgba(200, 169, 122, 0.2); }
.plan-price { font-size: 32px; font-weight: 800; letter-spacing: var(--tracking-tight); }

/* === 21. MOBILE OVERLAY HEADERS === */

@media (max-width: 900px) {
    .mobile-chat-fab {
        background: var(--primary);
        box-shadow: 0 4px 20px rgba(200, 169, 122, 0.2);
    }

    .mobile-chat-header,
    .block-fullscreen-header {
        background: var(--glass-bg);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-bottom: 1px solid var(--border);
    }
}

/* === 22. TOAST === */

.toast {
    border-radius: 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
}

/* === 23. LUNA THINKING === */

.luna-thinking-orb {
    background: var(--primary);
    box-shadow: 0 0 8px rgba(200, 169, 122, 0.25);
}

/* ============================================= */
/* Luna — Final Quality Fixes                    */
/* ============================================= */

/* --- Section headers inside blocks (inline styled in blocks.js) --- */

.block-body > div[style*="font-size:12px"][style*="font-weight:600"] {
    font-size: var(--text-xs) !important;
    font-weight: 500 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    color: rgba(255, 255, 255, 0.3) !important;
    margin-bottom: 8px !important;
}

/* --- Badge: consistent styling --- */

.block-badge,
.block-header .block-badge,
.block-header span[style*="color:var(--success)"],
.block-header span[style*="color:var(--error)"] {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 99px;
    font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--border);
}

/* --- Stat value: auto-shrink for long text --- */

.stat-value {
    font-size: clamp(18px, 5vw, 36px);
}

/* Short numeric values stay big */
.stat-card .stat-value {
    font-variant-numeric: tabular-nums;
}

/* --- Chat sidebar: better message flow --- */

.app-sidebar .chat-messages {
    padding: 16px 14px;
    gap: 12px;
}

.app-sidebar .chat-msg {
    max-width: 95%;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 14px;
}

.app-sidebar .chat-msg.user {
    border-bottom-right-radius: 4px;
}

.app-sidebar .chat-msg.assistant {
    border-bottom-left-radius: 4px;
    border-left-width: 2px;
}

/* Chat option buttons: better visibility */
.chat-options {
    padding: 10px 4px;
    gap: 6px;
}

.chat-option-btn {
    padding: 8px 14px;
    font-size: 13px;
}

/* --- Mobile label fix --- */

@media (max-width: 900px) {
    .app-home-label {
        font-size: 13px;
        white-space: normal;
        word-break: break-word;
        line-height: 1.3;
    }

    .app-home-desc {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* --- Sidebar width: slightly wider for readability --- */

@media (min-width: 901px) {
    .app-sidebar .chat-input-area {
        padding: 12px 14px;
    }
}

/* --- Fix: stat card separator line visible on dark bg --- */

.stats-grid {
    background: rgba(255, 255, 255, 0.06);
}

/* --- Inner block section: "Ultimi 5 run" style label --- */

.block-body > div > div[style*="font-size:12px"][style*="font-weight:600"][style*="margin-bottom"] {
    font-size: var(--text-xs) !important;
    font-weight: 500 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    color: rgba(255, 255, 255, 0.3) !important;
}

/* --- Luna thinking: cleaner --- */

.luna-thinking {
    gap: 8px;
}

.luna-thinking-orb {
    width: 10px;
    height: 10px;
}

.luna-thinking-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
}

/* --- Credits block improvements --- */

.credits-balance {
    font-variant-numeric: tabular-nums;
}

.credits-label {
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 0.08em;
}

/* --- Notification items --- */

.notif-item {
    transition: background 0.15s;
}

.notif-item:hover {
    background: var(--surface-hover);
}

.notif-unread {
    background: rgba(200, 169, 122, 0.04);
}

/* --- Empty state refinement --- */

.empty-state-icon {
    opacity: 0.4;
}

.empty-state-text {
    color: rgba(255, 255, 255, 0.3);
}

/* --- Landing page touch-up --- */

.landing h1 {
    letter-spacing: var(--tracking-tighter);
}

.landing .google-btn {
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

/* --- PWA install banner --- */

.pwa-install-banner,
div[style*="Installa Luna"] {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    background: var(--glass-bg, rgba(20, 20, 30, 0.92)) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border, rgba(255,255,255,0.08));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    font-size: 14px;
    color: var(--text, #e0e0e0);
    animation: pwa-slide-up 0.35s ease-out;
}

.pwa-install-banner span {
    flex: 1;
    line-height: 1.3;
}

@keyframes pwa-slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* ============================================= */
/* Luna — Final Touch: greeting + SVG icons      */
/* ============================================= */

/* --- Hero Greeting --- */

.home-hero {
    max-width: 840px;
    margin: 0 auto;
    padding: 28px 24px 0;
}

.home-hero-greeting {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
    line-height: 1.2;
}

.home-hero-sub {
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.3);
    margin-top: 4px;
}

@media (max-width: 900px) {
    .home-hero {
        padding: 20px 16px 0;
    }
    .home-hero-greeting {
        font-size: 22px;
    }
}

/* --- SVG icons in containers --- */

.app-home-icon {
    color: currentColor;
}

.app-home-icon svg {
    display: block;
}

/* ═══ Activity Feed ═══ */

.activity-feed {
    padding: 0 16px;
}

.af-loading {
    display: flex;
    justify-content: center;
    padding: 32px;
}

.af-pulse {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent, #c8a97a);
    opacity: 0.4;
    animation: af-pulse-anim 1.2s ease-in-out infinite;
}

@keyframes af-pulse-anim {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.3); opacity: 0.1; }
}

/* Summary stats row */
.af-summary {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.af-stat {
    flex: 1;
    background: var(--surface, #161616);
    border-radius: 12px;
    padding: 14px 12px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.06);
}

.af-stat-num {
    font-size: 20px;
    font-weight: 700;
    color: var(--text, #e8e8e8);
    letter-spacing: -0.5px;
}

.af-stat-label {
    font-size: 11px;
    color: var(--text-secondary, #888);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Section headers */
.af-section {
    margin-bottom: 16px;
}

.af-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #888);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 10px 0;
    padding: 0 4px;
}

/* Activity stream */
.af-stream {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--surface, #161616);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.06);
}

.af-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    transition: background 0.15s;
    cursor: default;
}

.af-item:hover {
    background: rgba(255,255,255,0.03);
}

.af-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.af-ok { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.af-err { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,0.4); }
.af-run { background: #f59e0b; animation: af-blink 1.5s infinite; }

@keyframes af-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.af-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.af-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #e8e8e8);
}

.af-item-summary {
    font-size: 12px;
    color: var(--text-secondary, #888);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.af-item-time {
    font-size: 11px;
    color: var(--text-muted, #555);
    flex-shrink: 0;
}

/* Templates / quick actions */
.af-templates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.af-tpl {
    background: var(--surface, #161616);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text, #e8e8e8);
}

.af-tpl:hover {
    border-color: var(--accent, #c8a97a);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.af-tpl-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.af-tpl-desc {
    font-size: 11px;
    color: var(--text-secondary, #888);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ═══ Bottom Navigation ═══ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: rgba(10, 10, 18, 0.85);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-top: 1px solid rgba(255,255,255,0.04);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 10px 0 8px;
    background: none;
    border: none;
    color: var(--text-muted, #555);
    cursor: pointer;
    transition: color 0.15s, transform 0.15s;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.3px;
    -webkit-tap-highlight-color: transparent;
}

.bnav-item:active {
    transform: scale(0.92);
}

.bnav-item svg {
    transition: color 0.15s;
}

.bnav-active {
    color: var(--accent, #c8a97a);
    position: relative;
}

.bnav-active::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent, #c8a97a);
    box-shadow: 0 0 6px rgba(200, 169, 122, 0.4);
}

.bnav-active svg {
    stroke: var(--accent, #c8a97a);
}

/* ═══ Mobile chat fullscreen (bottom nav mode) ═══ */

.mobile-chat-fullscreen > * {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.mobile-chat-fullscreen {
    position: fixed;
    top: 52px; /* matches .app-header height */
    left: 0;
    right: 0;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px)); /* bottom nav + safe area */
    z-index: 50;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Content area with bottom nav padding */
.app-content-tabbed {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important; /* bottom nav + safe area */
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 901px) {
    .bottom-nav { display: none; }
    .mobile-chat-fullscreen { display: none; }
}

@media (max-width: 900px) {
    .mobile-chat-fab { display: none !important; }
    /* removed: overlay now used by ChatFAB */
}



/* ═══ KEYBOARD — JS shifts bottom via visualViewport ═══ */

/* Prevent iOS zoom on input focus */

/* Prevent iOS zoom on input focus */
.chat-input, .dm-input {
    font-size: 16px !important;
}

/* File attachment hint */
.chat-file-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.5;
    padding: 4px 0 2px;
    padding-bottom: 2px;
    cursor: pointer;
    transition: opacity 0.3s;
}
.chat-file-hint:hover {
    opacity: 1;
}
@keyframes hintPulse {
    0% { opacity: 0; transform: translateY(4px); }
    40% { opacity: 0.9; transform: translateY(0); }
    100% { opacity: 0.75; transform: translateY(0); }
}
/* ============================================================= */
/* Luna Design System — Launch Polish                            */
/* Patch layer: fixes contrast, landing, animations, skeletons   */
/* Applied AFTER existing style.css                              */
/* ============================================================= */

/* === 0. GLOBAL FIXES === */

html {
    color-scheme: dark;
    scrollbar-gutter: stable;
}

/* Noise texture for depth */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0.015;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    pointer-events: none;
}

/* === 1. CONTRAST FIXES (WCAG AA) === */
/* All muted text: minimum rgba(255,255,255,0.5) = ~4.6:1 on #08080c */

.stat-label,
.luna-list-meta,
.tracker-meta,
.home-hero-sub,
.af-stat-label,
.af-section-title,
.af-tpl-desc,
.af-item-summary,
.social-section-title,
.social-bot-label,
.app-home-desc,
.empty-state-text,
.luna-thinking-text,
.settings-section h2,
.credits-label,
.landing-usecase-a,
.landing-feature,
.notif-body,
.notif-time,
.gallery-video-name,
.user-detail-grid,
.voice-label,
.chat-file-hint {
    color: rgba(255, 255, 255, 0.5) !important;
}

/* Section headers inside blocks — override the inline style selectors */
.block-body > div[style*="font-size:12px"][style*="font-weight:600"],
.block-body > div > div[style*="font-size:12px"][style*="font-weight:600"][style*="margin-bottom"] {
    color: rgba(255, 255, 255, 0.5) !important;
}

/* === 2. LANDING PAGE — Premium entrance === */

.landing {
    position: relative;
    overflow: hidden;
}

/* Subtle radial glow behind logo */
.landing::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(200, 169, 122, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.landing > * {
    position: relative;
    z-index: 1;
}

/* Staggered entrance animations */
.landing-logo {
    animation: landingFadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) backwards;
    animation-delay: 0.1s;
}

.landing h1 {
    animation: landingFadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) backwards;
    animation-delay: 0.2s;
}

.landing .subtitle {
    animation: landingFadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) backwards;
    animation-delay: 0.35s;
}

#google-btn-container {
    animation: landingFadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) backwards;
    animation-delay: 0.5s;
}

.landing-usecases {
    animation: landingFadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) backwards;
    animation-delay: 0.65s;
}

.landing-features {
    animation: landingFadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) backwards;
    animation-delay: 0.8s;
}

@keyframes landingFadeUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fix footer: no more absolute positioning */
.landing footer {
    position: relative !important;
    bottom: auto !important;
    margin-top: auto;
    padding-top: 32px;
    padding-bottom: 24px;
}

/* Better landing title gradient */
.landing h1 {
    font-size: 42px;
    background: linear-gradient(135deg, #ffffff 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Use-case cards: glass effect */
.landing-usecase {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: border-color 0.3s, transform 0.3s;
}

.landing-usecase:hover {
    border-color: rgba(200, 169, 122, 0.15);
    transform: translateY(-1px);
}

/* Use-case dot: subtle glow */
.landing-usecase-q::before {
    opacity: 0.8;
    box-shadow: 0 0 8px rgba(200, 169, 122, 0.3);
}

/* Feature items: more visible */
.landing-feature {
    font-size: 14px;
    gap: 10px;
    padding: 6px 0;
}

/* Landing subtitle: better contrast */
.landing .subtitle {
    color: rgba(255, 255, 255, 0.55);
    font-size: 17px;
    line-height: 1.6;
}

/* === 3. SKELETON LOADING SYSTEM === */

.skeleton-block {
    padding: 20px 22px;
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg,
        rgba(255,255,255,0.03) 25%,
        rgba(255,255,255,0.06) 50%,
        rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    margin-bottom: 10px;
}

.skeleton-line:last-child {
    margin-bottom: 0;
}

.skeleton-line.w-75 { width: 75%; }
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-33 { width: 33%; }
.skeleton-line.w-full { width: 100%; }

.skeleton-line.h-8 { height: 8px; }
.skeleton-line.h-16 { height: 16px; }
.skeleton-line.h-24 { height: 24px; }
.skeleton-line.h-32 { height: 32px; }

.skeleton-circle {
    border-radius: 50%;
    background: linear-gradient(90deg,
        rgba(255,255,255,0.03) 25%,
        rgba(255,255,255,0.06) 50%,
        rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
}

.skeleton-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    overflow: hidden;
}

.skeleton-stat-card {
    background: var(--bg);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* === 4. ANIMATION CONSOLIDATION === */

/* Core primitives — use these everywhere */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* === 5. BUTTON STATES — complete === */

.btn {
    position: relative;
    overflow: hidden;
}

/* Ripple effect prep */
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.08);
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: inherit;
}

.btn:active::after {
    opacity: 1;
}

/* Primary button: full states */
.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(200, 169, 122, 0.15);
}

/* Secondary button: proper hover */
.btn-secondary:hover {
    background: var(--surface-hover, rgba(255,255,255,0.045));
    transform: translateY(-1px);
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Ghost button: subtle states */
.btn-ghost:focus-visible {
    background: var(--surface);
    outline: 2px solid rgba(200, 169, 122, 0.3);
    outline-offset: 2px;
}

.btn-ghost:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Outline button: hover fill */
.btn-outline:hover {
    background: rgba(200, 169, 122, 0.08);
    transform: translateY(-1px);
}

.btn-outline:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Danger button: proper states */
.btn-danger:focus-visible {
    outline: 2px solid var(--error);
    outline-offset: 2px;
}

.btn-danger:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* === 6. MICRO-INTERACTIONS === */

/* Links: subtle underline on hover */
a:hover {
    text-decoration-color: rgba(200, 169, 122, 0.4);
    text-underline-offset: 2px;
}

/* Cards: subtle border glow on hover */
.block:hover {
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.35)),
                0 0 0 1px rgba(200, 169, 122, 0.06);
}

/* Inputs: smooth focus transitions */
input, textarea, select {
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

/* === 7. MOBILE POLISH === */

@media (max-width: 900px) {
    /* Bottom nav: safe areas on sides */
    .bottom-nav {
        padding-left: env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
    }

    /* Better touch targets */
    .bnav-item {
        min-height: 44px;
    }

    /* Landing: responsive title */
    .landing h1 {
        font-size: 32px;
    }

    .landing .subtitle {
        font-size: 15px;
    }

    /* Cards: better spacing */
    .app-home-item {
        min-height: 88px;
    }

    /* Chat: prevent content shift */
    .mobile-chat-fullscreen .chat-messages {
        overscroll-behavior: contain;
    }
}

/* iPhone SE / small phones */
@media (max-width: 375px) {
    .landing h1 {
        font-size: 28px;
    }

    .landing-usecases {
        max-width: 100%;
    }

    .app-home-grid {
        gap: 6px;
        padding: 12px 10px;
    }

    .app-home-item {
        padding: 12px;
    }
}

/* === 8. TOAST VARIANTS === */

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-success {
    border-left: 3px solid var(--success, #22c55e);
}

.toast-error {
    border-left: 3px solid var(--error, #ef4444);
}

.toast-warning {
    border-left: 3px solid var(--warning, #f59e0b);
}

.toast-info {
    border-left: 3px solid var(--accent-blue, #6366f1);
}

/* === 9. EMPTY STATE IMPROVEMENTS === */

.block-tap-cta {
    min-height: 120px;
    transition: opacity 0.2s;
}

.block-tap-cta:hover {
    opacity: 0.8;
}

.block-tap-icon {
    background: rgba(200, 169, 122, 0.06);
    border: 1px solid rgba(200, 169, 122, 0.08);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.block-tap-cta:hover .block-tap-icon {
    transform: scale(1.05);
}

/* === 10. PRINT STYLES === */

@media print {
    .app-header,
    .bottom-nav,
    .chat-input-area,
    .pwa-install-banner {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .block {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* === 11. SELECTION STYLE === */

::selection {
    background: rgba(200, 169, 122, 0.3);
    color: #fff;
}

/* === 12. BETTER FOCUS INDICATORS === */

*:focus-visible {
    outline: 2px solid rgba(200, 169, 122, 0.5);
    outline-offset: 2px;
}

/* Remove focus on mouse click */
*:focus:not(:focus-visible) {
    outline: none;
}

/* === 13. LOADING SPINNER IMPROVEMENT === */

.loading {
    flex-direction: column;
    gap: 16px;
}

.loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid rgba(200, 169, 122, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* === 14. BLOCK ENTER ANIMATION IMPROVEMENT === */

.block-enter {
    animation: slideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

/* === 15. HEADER LOGO — subtle gold accent dot */

.app-header .logo::after {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
    margin-left: 3px;
    vertical-align: super;
    opacity: 0.6;
}

/* === 16. CHAT MESSAGE — better markdown rendering === */

.chat-msg p {
    margin-bottom: 8px;
}

.chat-msg p:last-child {
    margin-bottom: 0;
}

.chat-msg ul, .chat-msg ol {
    padding-left: 20px;
    margin: 8px 0;
}

.chat-msg li {
    margin-bottom: 4px;
}

.chat-msg pre {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.5;
}

.chat-msg a {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-color: rgba(200, 169, 122, 0.3);
    text-underline-offset: 2px;
}

.chat-msg a:hover {
    text-decoration-color: var(--primary);
}

/* === 17. STAT CARD — subtle gradient on hover === */

.stat-card:hover {
    background: linear-gradient(135deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
}

/* === 18. PROFILE HERO — gradient border === */

.profile-hero {
    position: relative;
}

.profile-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid transparent;
    background: linear-gradient(135deg, rgba(200,169,122,0.15), transparent 50%) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* === FEATURES SECTION — horizontal card layout === */

.landing-features {
    display: flex !important;
    flex-direction: row !important;
    gap: 12px !important;
    align-items: stretch !important;
    max-width: 420px;
    margin: 0 auto 40px !important;
}

.landing-feature {
    flex: 1;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 16px 12px !important;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    font-size: 12px !important;
    text-align: center;
    transition: border-color 0.3s, transform 0.3s;
}

.landing-feature:hover {
    border-color: rgba(200, 169, 122, 0.12);
    transform: translateY(-2px);
}

.landing-feature-icon {
    font-size: 22px !important;
    margin-bottom: 2px;
}

@media (max-width: 480px) {
    .landing-features {
        flex-direction: column !important;
        max-width: 300px;
    }
    .landing-feature {
        flex-direction: row !important;
        padding: 12px 16px !important;
    }
}

/* === LANDING — better use-case card layout === */

.landing-usecase {
    transition: border-color 0.3s, transform 0.3s, box-shadow 0.3s;
}

.landing-usecase:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* === PWA BANNER — don't overlap footer === */

.landing {
    padding-bottom: 80px !important;
}

/* === FINAL POLISH — Launch Ready === */

/* Landing: Google button container — reduce gap above use-cases */
#google-btn-container {
    margin-bottom: 28px !important;
}

/* Landing use-case answer text: slightly brighter for readability */
.landing-usecase-a {
    color: rgba(255, 255, 255, 0.5) !important;
    font-style: italic;
    line-height: 1.5;
}

/* Landing use-case question: slightly larger */
.landing-usecase-q {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

/* Google button area: subtle animation */
#google-btn-container > div {
    transition: transform 0.2s, box-shadow 0.2s;
}

#google-btn-container > div:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.08);
}

/* Landing: title — ensure gradient shows correctly */
.landing h1 {
    background: linear-gradient(145deg, #ffffff 20%, var(--primary, #c8a97a) 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

/* Skeleton shimmer: ensure visible on dark bg */
.skeleton-line,
.skeleton-circle {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.02) 25%,
        rgba(255,255,255,0.06) 50%,
        rgba(255,255,255,0.02) 75%) !important;
    background-size: 200% 100% !important;
    animation: shimmer 1.5s ease-in-out infinite !important;
}

/* Feature cards: responsive text */
.landing-feature span {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.3;
}

/* PWA install banner: ensure it doesn't block footer */
.pwa-install-banner,
div[style*=Installa Luna] {
    position: fixed;
    bottom: 0;
    z-index: 9999;
}

/* Smooth scroll for all containers */
.chat-messages,
.app-main,
.app-content,
.block-fullscreen-body {
    scroll-behavior: smooth;
}

/* Better placeholder text styling */
::placeholder {
    color: rgba(255, 255, 255, 0.25);
    opacity: 1;
}

/* Links in footer: proper styling */
.landing footer a {
    color: rgba(255, 255, 255, 0.4) !important;
    text-decoration: none;
    transition: color 0.2s;
}

.landing footer a:hover {
    color: rgba(255, 255, 255, 0.7) !important;
    text-decoration: underline;
}

/* Block context menu: better styling */
.block-actions-menu {
    background: var(--glass-bg, rgba(12, 12, 16, 0.85));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.block-actions-menu button {
    transition: background 0.15s;
    border-radius: 0;
}

.block-actions-menu button:hover {
    background: rgba(255, 255, 255, 0.05);
}

.block-actions-menu button:first-child {
    border-radius: 12px 12px 0 0;
}

.block-actions-menu button:last-child {
    border-radius: 0 0 12px 12px;
}

/* Responsive image in chat */
.chat-msg img {
    max-width: 100%;
    border-radius: 12px;
    margin: 8px 0;
}

/* Chat msg: better table rendering */
.chat-msg table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.chat-msg th,
.chat-msg td {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: left;
}

.chat-msg th {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
/* ============================================================= */
/* Luna Dashboard — Big Tech Polish v2                           */
/* Complete dashboard redesign for launch                        */
/* ============================================================= */

/* === HERO GREETING — animated gradient text === */

.home-hero-greeting {
    font-size: 32px !important;
    font-weight: 800 !important;
    letter-spacing: -0.035em !important;
    background: linear-gradient(135deg, #ffffff 0%, var(--primary, #c8a97a) 60%, #e8c88a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background-size: 200% 200%;
    animation: greetingShimmer 6s ease-in-out infinite;
}

@keyframes greetingShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.home-hero-sub {
    color: rgba(255, 255, 255, 0.5) !important;
    font-size: 14px !important;
    margin-top: 4px;
}

@media (min-width: 901px) {
    .home-hero-greeting {
        font-size: 36px !important;
    }
}

/* === STAT CARDS — borderless, colored, modern === */

.af-summary {
    gap: 10px !important;
    margin-bottom: 24px !important;
}

.af-stat {
    background: rgba(255, 255, 255, 0.025) !important;
    border: none !important;
    border-radius: 16px !important;
    padding: 20px 16px !important;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s;
}

.af-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Subtle top accent line per stat */
.af-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    border-radius: 0 0 2px 2px;
    opacity: 0.6;
}

.af-stat:nth-child(1)::before { background: var(--accent-emerald, #10b981); }
.af-stat:nth-child(2)::before { background: var(--accent-blue, #6366f1); }
.af-stat:nth-child(3)::before { background: var(--accent-amber, #f59e0b); }

.af-stat:nth-child(1) .af-stat-num { color: var(--accent-emerald, #10b981) !important; }
.af-stat:nth-child(2) .af-stat-num { color: var(--accent-blue, #6366f1) !important; }
.af-stat:nth-child(3) .af-stat-num { color: var(--accent-amber, #f59e0b) !important; }

.af-stat-num {
    font-size: 28px !important;
    font-weight: 800 !important;
    letter-spacing: -0.03em !important;
    line-height: 1 !important;
    font-variant-numeric: tabular-nums;
}

.af-stat-label {
    font-size: 11px !important;
    color: rgba(255, 255, 255, 0.45) !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase !important;
    margin-top: 6px !important;
    font-weight: 500 !important;
}

/* === SECTION HEADERS — readable, not screaming === */

.af-section-title {
    font-size: 12px !important;
    font-weight: 600 !important;
    color: rgba(255, 255, 255, 0.4) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.08em !important;
    margin-bottom: 12px !important;
    padding-left: 2px !important;
}

/* === ACTIVITY FEED — polished items === */

.af-stream {
    background: rgba(255, 255, 255, 0.02) !important;
    border: none !important;
    border-radius: 16px !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.af-item {
    padding: 14px 18px !important;
    gap: 12px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03) !important;
    transition: background 0.15s !important;
}

.af-item:last-child {
    border-bottom: none !important;
}

.af-item:hover {
    background: rgba(255, 255, 255, 0.03) !important;
}

/* Status dots: bigger with subtle glow */
.af-status {
    width: 10px !important;
    height: 10px !important;
}

.af-ok {
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5) !important;
}

.af-item-name {
    font-size: 14px !important;
    font-weight: 600 !important;
}

.af-item-summary {
    font-size: 13px !important;
    color: rgba(255, 255, 255, 0.4) !important;
    line-height: 1.4 !important;
}

.af-item-time {
    font-size: 12px !important;
    color: rgba(255, 255, 255, 0.3) !important;
    font-variant-numeric: tabular-nums;
}

/* === AUTOMATION TEMPLATE CARDS === */

.af-templates {
    gap: 10px !important;
}

.af-tpl {
    background: rgba(255, 255, 255, 0.025) !important;
    border: 1px solid rgba(255, 255, 255, 0.04) !important;
    border-radius: 14px !important;
    padding: 18px !important;
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1) !important;
    position: relative;
    overflow: hidden;
}

.af-tpl::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s;
    background: linear-gradient(135deg, rgba(200, 169, 122, 0.06), transparent 60%);
}

.af-tpl:hover::before {
    opacity: 1;
}

.af-tpl:hover {
    border-color: rgba(200, 169, 122, 0.12) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3) !important;
}

.af-tpl-name {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: var(--text) !important;
    margin-bottom: 4px !important;
}

.af-tpl-desc {
    font-size: 12px !important;
    color: rgba(255, 255, 255, 0.4) !important;
    line-height: 1.4 !important;
}

/* === BENTO GRID — enhanced cards === */

@media (min-width: 901px) {
    .app-home-item {
        transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1) !important;
        position: relative;
    }

    /* Gradient border on hover */
    .app-home-item::before {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: inherit;
        padding: 1px;
        background: linear-gradient(135deg, rgba(200, 169, 122, 0.2), transparent 50%);
        -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
        -webkit-mask-composite: xor;
        mask-composite: exclude;
        opacity: 0;
        transition: opacity 0.3s;
        pointer-events: none;
    }

    .app-home-item:hover::before {
        opacity: 1;
    }

    .app-home-item:hover {
        background: rgba(255, 255, 255, 0.04) !important;
        transform: translateY(-3px) !important;
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35) !important;
    }

    /* Description: more visible */
    .app-home-desc {
        color: rgba(255, 255, 255, 0.4) !important;
        font-size: 12px !important;
    }

    /* Icon: subtle scale on hover */
    .app-home-item:hover .app-home-icon {
        transform: scale(1.1) !important;
    }

    /* Label: slightly larger */
    .app-home-label {
        font-size: 14px !important;
        font-weight: 600 !important;
    }
}

/* Mobile bento grid polish */
@media (max-width: 900px) {
    .app-home-item {
        transition: transform 0.15s, background 0.15s !important;
    }

    .app-home-item:active {
        transform: scale(0.96) !important;
        background: rgba(255, 255, 255, 0.04) !important;
    }

    .app-home-desc {
        color: rgba(255, 255, 255, 0.4) !important;
    }
}

/* === CHAT SIDEBAR — polish === */

.app-sidebar {
    background: rgba(6, 6, 10, 0.7) !important;
}

/* Chat buttons in sidebar */
.app-sidebar .chat-option-btn {
    font-size: 13px !important;
    padding: 8px 14px !important;
    border-radius: 10px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    transition: all 0.2s !important;
}

.app-sidebar .chat-option-btn:hover {
    background: var(--primary) !important;
    color: #0a0a0a !important;
    border-color: transparent !important;
}

/* Chat send button: subtle glow */
.chat-send {
    box-shadow: 0 2px 12px rgba(200, 169, 122, 0.2) !important;
}

.chat-send:hover:not(:disabled) {
    box-shadow: 0 4px 20px rgba(200, 169, 122, 0.35) !important;
}

/* Chat input placeholder */
.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.25) !important;
}

/* Chat attach/voice buttons */
.chat-attach,
.chat-voice {
    color: rgba(255, 255, 255, 0.35) !important;
    transition: color 0.15s, background 0.15s !important;
}

.chat-attach:hover,
.chat-voice:hover {
    color: rgba(255, 255, 255, 0.7) !important;
    background: rgba(255, 255, 255, 0.05) !important;
}

/* Messages: better assistant styling */
.chat-msg.assistant {
    background: rgba(255, 255, 255, 0.03) !important;
    border-left: 2px solid rgba(200, 169, 122, 0.25) !important;
}

.chat-msg.assistant strong,
.chat-msg.assistant b {
    color: var(--primary) !important;
}

/* User message: richer gradient */
.chat-msg.user {
    background: linear-gradient(135deg, var(--primary) 0%, #b8944d 100%) !important;
    box-shadow: 0 2px 12px rgba(200, 169, 122, 0.15) !important;
}

/* === NOTIFICATION PANEL — glass upgrade === */

.notif-panel {
    background: #14141c !important;
    backdrop-filter: blur(20px) saturate(1.3) !important;
    -webkit-backdrop-filter: blur(20px) saturate(1.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 14px !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(200, 169, 122, 0.08) !important;
}

/* === CREDITS BADGE — header === */

.app-header .credits-badge {
    font-size: 13px !important;
    font-weight: 600 !important;
    padding: 6px 14px !important;
    border-radius: 10px !important;
    font-variant-numeric: tabular-nums !important;
}

/* === SETTINGS PAGE — polish === */

.profile-hero {
    border: none !important;
    background: linear-gradient(180deg, rgba(200, 169, 122, 0.06) 0%, rgba(255,255,255,0.02) 100%) !important;
    border-radius: 20px !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.03) !important;
}

.settings-section h2 {
    font-size: 11px !important;
    color: rgba(255, 255, 255, 0.35) !important;
    letter-spacing: 0.1em !important;
    margin-bottom: 10px !important;
}

.settings-row {
    border-radius: 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03) !important;
    margin-bottom: 0 !important;
    padding: 16px 18px !important;
    transition: background 0.15s !important;
}

.settings-row:hover {
    background: rgba(255, 255, 255, 0.025) !important;
}

.settings-row:first-of-type {
    border-radius: 14px 14px 0 0 !important;
}

.settings-row:last-of-type {
    border-radius: 0 0 14px 14px !important;
    border-bottom: none !important;
}

.settings-row:only-of-type {
    border-radius: 14px !important;
}

/* === BLOCK FULLSCREEN — mobile overlay === */

.block-fullscreen-header {
    background: rgba(10, 10, 18, 0.9) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    padding: 14px 18px !important;
}

.block-fullscreen-header h3 {
    font-size: 17px !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em !important;
}

/* === BOT ITEMS — cleaner === */

.bot-item {
    padding: 14px 20px !important;
    transition: background 0.15s !important;
}

.bot-item:hover {
    background: rgba(255, 255, 255, 0.03) !important;
}

.bot-item .bot-name {
    font-size: 15px !important;
    font-weight: 600 !important;
}

/* Bot status pills: refined */
.bot-status.active {
    background: rgba(16, 185, 129, 0.12) !important;
    color: #34d399 !important;
}

.bot-status.paused {
    background: rgba(245, 158, 11, 0.12) !important;
    color: #fbbf24 !important;
}

.bot-status.error {
    background: rgba(239, 68, 68, 0.12) !important;
    color: #f87171 !important;
}

/* Bot action buttons: pill style */
.bot-action-btn {
    border-radius: 10px !important;
    padding: 7px 16px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
}

/* === ORDINI XML / GALLERY — consistent card style === */

.gallery-thumb {
    border-radius: 10px !important;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.gallery-thumb:hover {
    transform: scale(1.02) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
}

/* === WELCOME CARD — premium feel === */

.space-welcome-card {
    background: linear-gradient(135deg, rgba(200, 169, 122, 0.04), rgba(99, 102, 241, 0.03)) !important;
    border: 1px solid rgba(200, 169, 122, 0.08) !important;
    border-radius: 20px !important;
    padding: 32px 28px !important;
}

.space-welcome-card h2 {
    background: linear-gradient(135deg, #fff, var(--primary)) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

/* === ADMIN BLOCKS — consistent design === */

/* Admin stat cards in dashboard */
.block-body .stats-grid {
    border-radius: 14px !important;
    overflow: hidden !important;
}

.block-body .stat-card {
    padding: 20px 16px !important;
}

.block-body .stat-value {
    font-size: 24px !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em !important;
}

.block-body .stat-label {
    font-size: 11px !important;
    color: rgba(255, 255, 255, 0.4) !important;
    margin-top: 6px !important;
}

/* === TRACKER ITEMS — better progress bars === */

.tracker-progress {
    height: 4px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border-radius: 4px !important;
}

.tracker-progress-bar {
    border-radius: 4px !important;
    background: linear-gradient(90deg, var(--primary), #e8c88a) !important;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.tracker-progress-bar.completed {
    background: linear-gradient(90deg, var(--accent-emerald, #10b981), #34d399) !important;
}

/* === ONBOARDING — cleaner chat === */

.onboarding-overlay {
    background: radial-gradient(ellipse at 50% 30%, rgba(200, 169, 122, 0.04), var(--bg) 60%) !important;
}

.onboarding-overlay .chat-msg.assistant {
    background: rgba(255, 255, 255, 0.03) !important;
    border: none !important;
    border-left: 2px solid rgba(200, 169, 122, 0.25) !important;
    max-width: 90% !important;
}

/* === CREDITS BLOCK — hero display === */

.credits-balance {
    font-size: 48px !important;
    background: linear-gradient(135deg, var(--primary), #e8c88a) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

.credits-label {
    color: rgba(255, 255, 255, 0.4) !important;
}

/* Plan card hover: gradient border */
.plan-card:hover {
    border-color: rgba(200, 169, 122, 0.2) !important;
}

.plan-card.popular {
    position: relative;
}

.plan-card.popular::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, var(--primary), rgba(200, 169, 122, 0.1));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* === DM BLOCK — refined === */

.dm-input-area {
    border-top: 1px solid rgba(255, 255, 255, 0.04) !important;
    padding: 12px 16px !important;
}

/* === GLOBAL REFINEMENTS === */

/* Smoother transitions on all interactive elements */
button, a, input, textarea, select, .btn, [role="button"] {
    transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

/* No text selection on UI controls */
.app-header, .bottom-nav, .bnav-item, .app-home-item, .af-tpl, .block-header {
    user-select: none;
    -webkit-user-select: none;
}

/* Improve text rendering globally */
body {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* Hide file hint on mobile — space is precious */
@media (max-width: 900px) {
    .chat-file-hint { display: none; }
}

/* Fix: Google button hover glow troppo aggressivo */
#google-btn-container .nsm7Bb-HzV7m-LgbsSe:hover .nsm7Bb-HzV7m-LgbsSe-MJoBVe,
#google-btn-container .nsm7Bb-HzV7m-LgbsSe:focus .nsm7Bb-HzV7m-LgbsSe-MJoBVe,
#google-btn-container .nsm7Bb-HzV7m-LgbsSe:active .nsm7Bb-HzV7m-LgbsSe-MJoBVe {
    background: rgba(255, 255, 255, 0.06) !important;
}

#google-btn-container > div:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Collapsible activity section */
.af-collapsible .af-section-title {
    padding-left: 14px !important;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 8px;
    transition: background 0.2s, border-color 0.2s;
}
.af-collapsible .af-section-title:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(200, 169, 122, 0.2);
}
.af-chevron {
    font-size: 11px;
    transition: transform 0.25s ease;
    opacity: 0.4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
}
.af-collapsible .af-section-title:hover .af-chevron {
    opacity: 0.7;
    background: rgba(200, 169, 122, 0.12);
}
.af-chevron-open {
    transform: rotate(90deg);
}

/* Fix: collapsible title centered padding */
.af-collapsible .af-section-title {
    padding: 10px 14px !important;
}

/* Fix: hero subtitle spacing */
.home-hero-sub {
    margin-bottom: 16px !important;
}

/* Hide block actions menu button in fullscreen/focused view */
.block-fullscreen-header .block-actions,
.block-focused-header .block-actions {
    display: none !important;
}

/* Fix: fullscreen block body must scroll */
.block-fullscreen-body {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px !important;
}

/* Fix: non-chat blocks in fullscreen should show all content, not flex-constrain */
.block-fullscreen-body > .block:not(:has(.chat-messages)) {
    flex: none !important;
    overflow: visible !important;
}
.block-fullscreen-body > .block:not(:has(.chat-messages)) .block-body {
    flex: none !important;
    overflow: visible !important;
}

/* Fix: cost stat text fits in card */
.af-stat:nth-child(3) .af-stat-num {
    font-size: 22px !important;
    white-space: nowrap;
}

/* === Chat FAB === */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary, #c8a97a);
    color: #111;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(200, 169, 122, 0.35);
    z-index: 200;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}
.chat-fab:active {
    transform: scale(0.95);
}


/* Chat overlay (mobile) */
.mobile-chat-overlay {
    position: fixed;
    inset: 0;
    z-index: 180;
    background: var(--bg);
    animation: chatSlideUp 0.25s ease-out;
}
@keyframes chatSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Hide old bottom nav */
.bottom-nav { display: none !important; }

/* Remove bottom padding that was for the old nav */
.app-content-tabbed { padding-bottom: 16px !important; }

/* Logo clickable hint */
.logo {
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
}
.logo:hover {
    opacity: 0.8;
}
.logo svg {
    flex-shrink: 0;
}

/* === Chat overlay — header sopra (home button sempre accessibile) === */
.mobile-chat-overlay {
    position: fixed !important;
    top: 52px !important;          /* lascia spazio all'app-header */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 180 !important;
    background: var(--bg, #111) !important;
    display: flex !important;
    flex-direction: column !important;
}
/* App-header rimane sopra la chat overlay */
.app-header { z-index: 200 !important; }
.mobile-chat-overlay .mobile-chat-fullscreen {
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}
.mobile-chat-overlay .block-chat {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
}
.mobile-chat-overlay .chat-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    max-height: none !important;
    padding: 16px 12px 8px !important;
}
.mobile-chat-overlay .chat-input-area {
    flex-shrink: 0 !important;
    padding: 24px 96px 24px 16px !important;
    min-height: 104px !important;
    align-items: center !important;
    background: var(--surface, #1a1a1a) !important;
    border-top: 1px solid rgba(255,255,255,0.06) !important;
}
/* FAB sits on top of chat overlay */
.chat-fab {
    z-index: 200 !important;
}


.chat-fab-active:hover {
    background: rgba(255, 255, 255, 0.14) !important;
    transform: none !important;
}
/* Give chat messages top padding for the close button */
.mobile-chat-overlay .chat-messages {
    padding-top: 56px !important;
}

/* Bot notification cards */
.bot-card {
    transition: background 0.2s;
}
.bot-card:hover {
    background: rgba(255, 255, 255, 0.04) !important;
}
.bot-card details summary {
    list-style: none;
}
.bot-card details summary::-webkit-details-marker {
    display: none;
}
.bot-card details summary::before {
    content: '▸ ';
}
.bot-card details[open] summary::before {
    content: '▾ ';
}

/* Chat readability */
.chat-msg.assistant > div {
    line-height: 1.6;
}

/* Admin API cost badge */
.api-cost-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    cursor: default;
    transition: color 0.2s, background 0.2s;
}
.api-cost-badge:hover {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.08);
}


/* === Block Settings Panel === */

.block-settings-gear {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-left: 4px;
    flex-shrink: 0;
}
.block-settings-gear:hover {
    background: var(--surface-hover, rgba(255,255,255,0.08));
    color: var(--text);
}

.settings-status-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid var(--bg);
}
.settings-status-dot.dot-ok { background: #22c55e; }
.settings-status-dot.dot-warn { background: #f59e0b; }
.settings-status-dot.dot-err {
    background: #ef4444;
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Backdrop */
.settings-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    z-index: 199;
    pointer-events: none;
    transition: background 0.3s ease;
}
.settings-backdrop.open {
    background: rgba(0,0,0,0.5);
    pointer-events: auto;
}

/* Panel */
.settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: 100vw;
    background: var(--surface);
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(0,0,0,0.3);
}
.settings-panel.open {
    transform: translateX(0);
}

.settings-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.settings-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}
.settings-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
}
.settings-panel-close:hover {
    background: var(--surface-hover, rgba(255,255,255,0.08));
    color: var(--text);
}

.settings-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.settings-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 32px 0;
    font-size: 14px;
}

/* Section */
.settings-section {
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg);
}

.settings-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.settings-section-icon { font-size: 18px; }
.settings-section-label {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.settings-section-status {
    font-size: 14px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.settings-section-status.sec-ok { color: #22c55e; }
.settings-section-status.sec-warn { color: #f59e0b; }
.settings-section-status.sec-empty { color: var(--text-secondary); }

.settings-section-fields {
    padding: 12px 16px;
}

/* Fields */
.settings-field {
    margin-bottom: 14px;
}
.settings-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.settings-field label .req { color: #ef4444; }

.settings-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}
.settings-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(200,169,122,0.15);
}
.settings-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.settings-field-masked {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}
.masked-value {
    flex: 1;
    font-size: 13px;
    color: #22c55e;
    font-family: monospace;
}
.settings-field-change {
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}
.settings-field-change:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.field-hint {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Save button */
.settings-save-btn {
    width: 100%;
    padding: 10px;
    margin-top: 4px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #000;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.settings-save-btn:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
}
.settings-save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Mobile */
@media (max-width: 768px) {
    .settings-panel {
        width: 100vw;
        border-left: none;
    }
}



/* === Archive Modal === */

.archive-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 998;
    animation: fade-in 0.2s ease;
}

.archive-modal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(680px, calc(100vw - 32px));
    max-height: 80vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modal-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-in {
    from { opacity: 0; transform: translate(-50%, -45%) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.archive-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.archive-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}
.archive-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    font-size: 18px;
    transition: all 0.15s ease;
}
.archive-modal-close:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}

.archive-modal-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}
.archive-upload-new {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--primary);
    color: #000;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s ease;
}
.archive-upload-new:hover { filter: brightness(1.1); }

.archive-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.archive-search {
    flex: 1;
    min-width: 180px;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
}
.archive-search:focus {
    outline: none;
    border-color: var(--primary);
}

.archive-filters {
    display: flex;
    gap: 6px;
}
.archive-filter {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.archive-filter.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(200, 169, 122, 0.1);
}

.archive-grid {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    align-content: start;
}

.archive-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    background: var(--bg);
    transition: all 0.15s ease;
}
.archive-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.archive-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 6px;
    background: var(--surface);
}

.archive-icon {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 6px;
    color: var(--text-secondary);
}

.archive-name {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-all;
}

.archive-empty {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Mobile */
@media (max-width: 600px) {
    .archive-modal {
        width: calc(100vw - 16px);
        max-height: 90vh;
    }
    .archive-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }
}


/* === Spazio per FAB universale dentro la chat === */



/* Su viewport molto stretti, l'archivio button + padding FAB occupano molto spazio.
   Riduco il padding lateralmente mantenendo la riserva a destra */



/* === Chat toolbar: bilanciamento elementi === */



/* Archive button 44px per parità touch target con FAB */
.chat-attach {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}
.chat-attach svg {
    width: 18px;
    height: 18px;
}



/* Allineamento verticale + gap consistente */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

/* Textarea min-height 44px per allinearsi agli altri */
.chat-input {
    min-height: 44px;
    flex: 1;
}

/* Su schermi molto stretti, margini laterali ridotti */




/* Toolbar chat: flex baseline-aligned, gap coerente */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.chat-input-area .chat-input {
    flex: 1;
    min-height: 44px;
}

/* === FAB: stessa posizione, stessa dimensione, in home e in chat === */
/* (base style in line 4758 resta invariato: fixed bottom:24px right:20px 56px) */

/* Quando la chat è aperta, la toolbar ha un'area di interazione che include il FAB.
   L'altezza della toolbar è tale che il centro del FAB (bottom:24 + 28) = 52px dal bottom
   coincide con il centro verticale della toolbar.
   Toolbar height target: 104px → center a 52px → match perfetto con FAB */
.mobile-chat-fullscreen .chat-input-area,
.block-fullscreen-body .chat-input-area,
.app-sidebar .chat-input-area {
    padding: 24px 96px 24px 16px;
    min-height: 104px;
    box-sizing: border-box;
    align-items: center;
}

/* Textarea allineata al centro della toolbar (matcha centro del FAB) */
.mobile-chat-fullscreen .chat-input-area .chat-input,
.block-fullscreen-body .chat-input-area .chat-input {
    min-height: 44px;
}

/* Archive button: pari altezza alla textarea, centrato */
.mobile-chat-fullscreen .chat-input-area .chat-attach,
.block-fullscreen-body .chat-input-area .chat-attach {
    height: 44px;
    width: 44px;
}


/* === Textarea chat: design premium === */

.mobile-chat-fullscreen .chat-input,
.block-fullscreen-body .chat-input,
.app-sidebar .chat-input {
    /* Forma */
    border-radius: 22px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    padding: 12px 18px !important;

    /* Tipografia */
    font-family: inherit;
    font-size: 15px !important;
    line-height: 1.4;
    color: var(--text) !important;
    letter-spacing: 0.01em;

    /* Scrollbar interno nascosto */
    scrollbar-width: none;
    -ms-overflow-style: none;
    resize: none !important;

    /* Transizioni fluide */
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.mobile-chat-fullscreen .chat-input::-webkit-scrollbar,
.block-fullscreen-body .chat-input::-webkit-scrollbar,
.app-sidebar .chat-input::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* Placeholder raffinato */
.mobile-chat-fullscreen .chat-input::placeholder,
.block-fullscreen-body .chat-input::placeholder,
.app-sidebar .chat-input::placeholder {
    color: rgba(255, 255, 255, 0.35) !important;
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* Focus state: accento oro, glow sottile, bordo più definito */
.mobile-chat-fullscreen .chat-input:focus,
.block-fullscreen-body .chat-input:focus,
.app-sidebar .chat-input:focus {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(200, 169, 122, 0.35) !important;
    box-shadow:
        0 0 0 3px rgba(200, 169, 122, 0.08),
        0 0 20px rgba(200, 169, 122, 0.04) !important;
}

/* Hover lievemente più chiaro (non su touch) */
@media (hover: hover) {
    .mobile-chat-fullscreen .chat-input:hover:not(:focus),
    .block-fullscreen-body .chat-input:hover:not(:focus),
    .app-sidebar .chat-input:hover:not(:focus) {
        border-color: rgba(255, 255, 255, 0.15) !important;
        background: rgba(255, 255, 255, 0.04) !important;
    }
}

/* Disabled state quando Luna risponde */
.mobile-chat-fullscreen .chat-input:disabled,
.block-fullscreen-body .chat-input:disabled,
.app-sidebar .chat-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* === FAB: stile sobrio, discreto === */

/* Base shadow: netta e contenuta, nessun glow spread */
.chat-fab {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(200, 169, 122, 0.25) !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    animation: none !important;
}

/* Hover: lift 1px, ombra leggermente più profonda, niente glow esplosivo */
@media (hover: hover) and (pointer: fine) {
    .chat-fab:hover:not(.chat-fab-recording):not(.chat-fab-streaming):not(.chat-fab-uploading) {
        transform: translateY(-1px);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(200, 169, 122, 0.3) !important;
        filter: brightness(1.05);
    }
}

/* Active/press: compressione visibile ma sottile */
.chat-fab:active {
    transform: scale(0.96);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35) !important;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

/* === FAB stati attivi (sobri) === */

/* Recording: pulse discreto + colore rosso sull'icona stop */
.chat-fab-recording {
    animation: fab-pulse-recording 1.4s ease-in-out infinite;
}
@keyframes fab-pulse-recording {
    0%, 100% {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(239, 68, 68, 0.35);
    }
    50% {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), 0 0 0 6px rgba(239, 68, 68, 0);
    }
}
.chat-fab-recording svg rect,
.chat-fab-recording svg path,
.chat-fab-recording svg line {
    fill: #ef4444;
    stroke: #ef4444;
}

/* Streaming: pulse sottile per comunicare 'in corso' */
.chat-fab-streaming {
    animation: fab-pulse-streaming 1.8s ease-in-out infinite;
}
@keyframes fab-pulse-streaming {
    0%, 100% { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(200, 169, 122, 0.35); }
    50% { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), 0 0 0 5px rgba(200, 169, 122, 0); }
}

/* Uploading: opacità ridotta, no pointer */
.chat-fab-uploading {
    pointer-events: none;
    opacity: 0.85;
}

/* Spinner */
.fab-spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid rgba(0, 0, 0, 0.2);
    border-top-color: #1a1a1a;
    border-radius: 50%;
    animation: fab-spin 0.8s linear infinite;
}
@keyframes fab-spin { to { transform: rotate(360deg); } }

/* === Attachment Picker: tabs + list === */

.picker-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

.picker-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}
.picker-tab:hover {
    background: rgba(255,255,255,0.03);
    color: var(--text);
}
.picker-tab.active {
    background: rgba(200, 169, 122, 0.12);
    border-color: rgba(200, 169, 122, 0.3);
    color: var(--primary);
}
.picker-tab svg { flex-shrink: 0; }

.picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    cursor: pointer;
    transition: all 0.15s ease;
}
.picker-item:hover {
    border-color: var(--primary);
    background: rgba(200, 169, 122, 0.05);
    transform: translateX(2px);
}

.picker-item-emoji,
.picker-item-icon {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px;
    background: rgba(200, 169, 122, 0.10);
    color: var(--primary, #c8a97a);
    flex-shrink: 0;
}
.picker-item-icon svg { width: 20px; height: 20px; }
.picker-item-icon-muted {
    background: rgba(255,255,255,0.04);
    color: var(--text-muted, rgba(255,255,255,0.35));
}

.picker-item-body {
    flex: 1;
    min-width: 0;
}

.picker-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.picker-item-sub {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.picker-item-action {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    padding: 4px 10px;
    border: 1px solid rgba(200, 169, 122, 0.3);
    border-radius: 14px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Modal archivio sopra tutto (anche header) === */
body.has-attachment-picker .mobile-chat-overlay {
    z-index: 300 !important;
}
body.has-attachment-picker .archive-modal-backdrop { z-index: 9998 !important; }
body.has-attachment-picker .archive-modal { z-index: 9999 !important; }

/* === Admin badge: stile SVG === */
.admin-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--primary, #c8a97a);
    transition: all 0.15s ease;
    background: rgba(200, 169, 122, 0.08);
    border: 1px solid rgba(200, 169, 122, 0.2);
}
.admin-badge:hover {
    background: rgba(200, 169, 122, 0.15);
    border-color: rgba(200, 169, 122, 0.4);
    transform: scale(1.05);
}

/* Indicatore 'stai impersonando' nel header */
.header-viewing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 14px;
    color: #ef4444;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    margin-right: 6px;
}
.header-viewing:hover { background: rgba(239, 68, 68, 0.2); }


    to { transform: translateY(0); opacity: 1; }
}


/* === Admin badge in impersonation mode: rosso, pulse sottile === */
.admin-badge.admin-badge-impersonating {
    color: #fff !important;
    background: rgba(239, 68, 68, 0.3) !important;
    border-color: rgba(239, 68, 68, 0.6) !important;
    animation: admin-badge-pulse 2s ease-in-out infinite;
}
.admin-badge.admin-badge-impersonating:hover {
    background: rgba(239, 68, 68, 0.5) !important;
    border-color: rgba(239, 68, 68, 0.8) !important;
}
@keyframes admin-badge-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
}

/* === Chat cost hint: dentro toolbox, sopra textbox === */
.chat-input-area { position: relative; }

.chat-input-area .chat-cost-hint {
    position: absolute !important;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 3px 10px !important;
    margin: 0 !important;
    background: var(--surface, #1a1a1a) !important;
    border: 1px solid rgba(200, 169, 122, 0.2) !important;
    border-radius: 12px !important;
    font-size: 10px !important;
    width: fit-content !important;
    max-width: 90%;
    animation: cost-hint-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-secondary) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 5;
    white-space: nowrap;
    pointer-events: none;
    letter-spacing: 0.02em;
}

@keyframes cost-hint-in {
    from { opacity: 0; transform: translateY(2px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-cost-label {
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.02em;
}

.chat-cost-hint.chat-cost-admin .chat-cost-label {
    color: #22c55e;
}
.chat-cost-hint.chat-cost-free .chat-cost-label {
    color: #22c55e;
}
.chat-cost-hint.chat-cost-paid .chat-cost-label {
    color: var(--primary);
}

.chat-cost-sub {
    color: var(--text-secondary);
    opacity: 0.7;
    font-weight: 400;
}

.chat-cost-model {
    margin-left: auto;
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 10px;
    color: rgba(200, 169, 122, 0.5);
    padding: 1px 6px;
    border-radius: 8px;
    background: rgba(200, 169, 122, 0.08);
    border: 1px solid rgba(200, 169, 122, 0.15);
    text-transform: lowercase;
    letter-spacing: 0.04em;
}

/* ==========================================================
   Economia — stile Luna big tech (oro + dark premium)
   ========================================================== */
.finx-body { padding: 26px 20px 22px; }

/* Hero — netto totale prominente */
.finx-hero {
    text-align: center;
    padding: 4px 0 28px;
    position: relative;
}
.finx-hero::after {
    content: ''; position: absolute; left: 50%; bottom: 0;
    transform: translateX(-50%); width: 40px; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(200,169,122,0.35), transparent);
}
.finx-net-label {
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.2em; text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    margin-bottom: 14px;
}
.finx-net {
    font-size: clamp(42px, 11vw, 58px); font-weight: 700;
    line-height: 1; letter-spacing: -0.035em;
    font-variant-numeric: tabular-nums;
    transition: color .3s;
}
.finx-net--pos { color: var(--primary, #c8a97a); }
.finx-net--neg { color: #f87171; }

/* Breakdown rows — stacked, linee sottili, no card colorate */
.finx-rows { display: flex; flex-direction: column; margin-top: 22px; }
.finx-row {
    display: flex; align-items: center; gap: 14px;
    padding: 15px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-variant-numeric: tabular-nums;
    animation: finx-row-in .35s cubic-bezier(.2,.8,.2,1) backwards;
    animation-delay: var(--finx-delay, 0ms);
}
.finx-row:last-child { border-bottom: 0; }
@keyframes finx-row-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.finx-row-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: rgba(255,255,255,0.22); flex-shrink: 0;
    box-shadow: 0 0 0 4px rgba(255,255,255,0.03);
}
.finx-row--pos .finx-row-dot { background: #4ade80; box-shadow: 0 0 0 4px rgba(34,197,94,0.1); }
.finx-row-dot--brand { background: var(--primary, #c8a97a); box-shadow: 0 0 0 4px rgba(200,169,122,0.12); }

.finx-row-label {
    flex: 1; font-size: 14px; color: rgba(255,255,255,0.88);
    font-weight: 500; letter-spacing: 0.005em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.finx-row-sub {
    font-size: 11px; color: rgba(255,255,255,0.45);
    font-weight: 400; margin-left: 4px;
}
.finx-row-amount {
    font-size: 15px; font-weight: 600; color: var(--text);
    flex-shrink: 0;
}
.finx-row--pos .finx-row-amount { color: #4ade80; }

/* Subrow — meta info sotto una row (es. override Anthropic) */
.finx-subrow {
    display: flex; flex-direction: column;
    padding: 8px 4px 14px 25px; /* indent sotto il dot */
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 11px;
}
.finx-subrow:last-child { border-bottom: 0; }
.finx-subrow-view {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-wrap: wrap;
}
.finx-subrow-label {
    color: rgba(255,255,255,0.5); font-weight: 400;
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
}
.finx-subrow-btn {
    min-height: 26px; padding: 4px 10px;
    border-radius: 7px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.6);
    font-size: 11px; font-weight: 500;
    cursor: pointer; font-family: inherit;
    transition: color .15s, border-color .15s, background .15s;
    display: inline-flex; align-items: center; justify-content: center;
}
.finx-subrow-btn:hover {
    color: var(--primary, #c8a97a);
    border-color: rgba(200,169,122,0.4);
    background: rgba(200,169,122,0.04);
}
.finx-subrow-btn--link {
    border-color: transparent; padding: 4px 8px;
    text-decoration: underline; text-decoration-color: rgba(200,169,122,0.4);
    text-underline-offset: 3px;
}
.finx-subrow-btn--link:hover { text-decoration-color: var(--primary); }
.finx-subrow-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.finx-anthropic-edit { display: flex; flex-direction: column; gap: 8px; }
.finx-anthropic-input-row {
    display: flex; gap: 6px; align-items: center;
    margin-top: 4px;
}
.finx-anthropic-input-row .finx-input { min-height: 36px; padding: 8px 12px; font-size: 13px; }
.finx-anthropic-input-row .finx-input--amount { flex: 0 0 90px; }
.finx-anthropic-input-row .finx-save {
    min-height: 36px; padding: 8px 14px; font-size: 12px;
}
.finx-subrow-link {
    align-self: flex-start;
    background: transparent; border: 0;
    color: rgba(255,255,255,0.5); font-size: 11px; font-family: inherit;
    cursor: pointer; padding: 2px 0; margin-top: 4px;
    text-decoration: underline; text-decoration-color: rgba(255,255,255,0.2);
    text-underline-offset: 3px;
    transition: color .15s;
}
.finx-subrow-link:hover { color: #f87171; }

/* Activity feed — widget bilancio mensile (sostituisce spesa oggi) */
.af-stat.af-balance-pos .af-stat-num,
.af-stat.af-balance-pos .af-cost-real { color: #4ade80 !important; }
.af-stat.af-balance-neg .af-stat-num,
.af-stat.af-balance-neg .af-cost-real { color: #f87171 !important; }
.af-stat-balance { font-variant-numeric: tabular-nums; }

/* Automazioni hub — stile Luna big tech */
.botx-body { padding: 18px 16px 18px; display: flex; flex-direction: column; gap: 14px; }

.botx-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
    padding: 4px 0 4px;
}
.botx-stat {
    display: flex; flex-direction: column; gap: 2px; text-align: center;
    padding: 10px 8px;
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px;
}
.botx-stat-value {
    font-size: 18px; font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.botx-stat-value--err { color: #f87171; }
.botx-stat-label {
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.1em; text-transform: uppercase;
    color: rgba(255,255,255,0.5);
}

.botx-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.botx-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.botx-item:last-child { border-bottom: 0; }
.botx-item--off { opacity: 0.55; }
.botx-item-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.03);
}
.botx-item-body { flex: 1; min-width: 0; }
.botx-item-name {
    font-size: 14px; color: var(--text); font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.botx-item-meta {
    font-size: 11px; color: rgba(255,255,255,0.5);
    margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.botx-owner { color: var(--primary, #c8a97a); }
.botx-item-right { text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.botx-item-sr { font-size: 13px; font-weight: 700; }
.botx-item-runs { font-size: 10px; color: rgba(255,255,255,0.5); margin-top: 2px; }

.botx-new {
    margin-top: 4px; min-height: 42px; padding: 10px 14px;
    border-radius: 10px;
    background: rgba(200,169,122,0.08); border: 1px solid rgba(200,169,122,0.28);
    color: var(--primary, #c8a97a);
    font-size: 13px; font-weight: 600; cursor: pointer;
    font-family: inherit;
    transition: background .15s, border-color .15s;
}
.botx-new:hover { background: rgba(200,169,122,0.14); border-color: var(--primary, #c8a97a); }
.botx-new:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Empty state (nessun bot creato) */
.botx-empty {
    padding: 40px 20px 32px; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.botx-empty-icon {
    font-size: 48px; margin-bottom: 4px;
    filter: grayscale(0.3) opacity(0.7);
}
.botx-empty-title {
    font-size: 18px; font-weight: 600; color: var(--text);
    letter-spacing: -0.01em;
}
.botx-empty-desc {
    font-size: 13px; color: rgba(255,255,255,0.6);
    max-width: 320px; line-height: 1.55;
    margin-bottom: 10px;
}
.botx-cta {
    min-height: 44px; padding: 12px 22px;
    border-radius: 12px;
    background: var(--primary, #c8a97a); color: #0c0c10;
    border: 0; font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit;
    letter-spacing: 0.01em;
    transition: filter .15s, transform .1s;
    box-shadow: 0 2px 12px rgba(200,169,122,0.15);
}
.botx-cta:hover { filter: brightness(1.08); }
.botx-cta:active { transform: scale(0.98); }
.botx-cta:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.botx-empty-hint {
    font-size: 11px; color: rgba(255,255,255,0.4);
    margin-top: 6px; font-style: italic;
}

/* Footer home Luna — termini, privacy, brand */
.luna-footer {
    margin-top: 32px; padding: 22px 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: 12px; color: rgba(255,255,255,0.4);
    text-align: center;
}
.luna-footer-links {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    justify-content: center;
}
.luna-footer-links a {
    color: rgba(255,255,255,0.55); text-decoration: none;
    padding: 4px 8px; border-radius: 6px;
    transition: color .15s, background .15s;
}
.luna-footer-links a:hover {
    color: var(--primary, #c8a97a);
    background: rgba(200,169,122,0.06);
}
.luna-footer-links a:focus-visible {
    outline: 2px solid var(--primary); outline-offset: 2px;
}
.luna-footer-sep { color: rgba(255,255,255,0.25); user-select: none; }
.luna-footer-brand {
    font-size: 11px; color: rgba(255,255,255,0.3);
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
}

/* Strumenti Luna — grid ufficiali (stile big tech, card orizzontali con chevron) */
.luna-official-sec { margin-top: 4px; }
.luna-official-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 4px 0 14px;
}
/* Desktop wide: 4 card in una sola riga */
@media (min-width: 820px) {
    .luna-official-grid { grid-template-columns: repeat(4, 1fr); }
}

.luna-official-card {
    /* layout */
    display: flex; align-items: center; gap: 12px;
    min-width: 0;
    padding: 14px;

    /* surface */
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 14px;
    color: var(--text);
    font-family: inherit; text-align: left; cursor: pointer;
    position: relative;
    transition: transform .12s ease, border-color .2s ease, background .2s ease;
}
.luna-official-card::before {
    /* subtle gold glow sulla sinistra, identità Luna */
    content: ''; position: absolute; left: 0; top: 14px; bottom: 14px;
    width: 2px; border-radius: 2px;
    background: var(--card-tint, var(--primary, #c8a97a));
    opacity: 0.35;
    transition: opacity .2s ease, width .2s ease;
}
.luna-official-card:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(200,169,122,0.3);
}
.luna-official-card:hover::before { opacity: 0.8; width: 3px; }
.luna-official-card:active { transform: scale(0.985); }
.luna-official-card:focus-visible {
    outline: 2px solid var(--primary, #c8a97a); outline-offset: 2px;
}

.luna-official-badge {
    width: 38px; height: 38px; flex-shrink: 0;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--card-tint, #c8a97a) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--card-tint, #c8a97a) 22%, transparent);
}
.luna-official-badge svg { width: 18px; height: 18px; }

.luna-official-text { flex: 1; min-width: 0; }
.luna-official-title {
    font-size: 14px; font-weight: 600; color: var(--text);
    letter-spacing: -0.005em; line-height: 1.2;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.luna-official-desc {
    font-size: 11px; color: rgba(255,255,255,0.55);
    line-height: 1.35; margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.luna-official-chevron {
    color: rgba(255,255,255,0.3); flex-shrink: 0;
    transition: color .2s ease, transform .15s ease;
}
.luna-official-card:hover .luna-official-chevron {
    color: var(--primary, #c8a97a); transform: translateX(2px);
}

/* Mobile: card leggermente più compatte */
@media (max-width: 540px) {
    .luna-official-card { padding: 12px 12px; gap: 10px; }
    .luna-official-badge { width: 34px; height: 34px; }
    .luna-official-title { font-size: 13px; }
    .luna-official-desc { font-size: 10.5px; }
}

/* Fallback per browser senza color-mix */
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
    .luna-official-badge {
        background: rgba(200,169,122,0.12);
        border-color: rgba(200,169,122,0.22);
    }
}

/* --- AziendaBlock (Art Stone pinned per admin, empty state citizen) --- */
.aziendax-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.aziendax-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border-radius: 14px;
    background: linear-gradient(135deg, rgba(200,169,122,0.09), rgba(200,169,122,0.02));
    border: 1px solid rgba(200,169,122,0.25);
}
.aziendax-logo {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; flex-shrink: 0;
    background: rgba(200,169,122,0.14);
}
.aziendax-info { flex: 1; min-width: 0; }
.aziendax-name {
    font-size: 16px; font-weight: 700; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    letter-spacing: -0.005em;
}
.aziendax-meta { font-size: 12px; color: rgba(255,255,255,0.55); margin-top: 2px; }
.aziendax-status {
    font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
    padding: 4px 8px; border-radius: 6px; flex-shrink: 0;
}
.aziendax-status--active {
    background: rgba(34,197,94,0.14); color: #4ade80;
    border: 1px solid rgba(34,197,94,0.28);
}
.aziendax-automations {
    padding: 14px 2px 6px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.aziendax-sec-title {
    font-size: 10px; font-weight: 600; letter-spacing: 0.14em;
    text-transform: uppercase; color: rgba(255,255,255,0.5); margin-bottom: 10px;
}
.aziendax-auto-list { list-style: none; margin: 0; padding: 0; }
.aziendax-auto {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 13px;
}
.aziendax-auto:last-child { border-bottom: 0; }
.aziendax-auto-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 3px rgba(34,197,94,0.14);
    flex-shrink: 0;
}
.aziendax-auto-name { flex: 1; color: rgba(255,255,255,0.88); }
.aziendax-auto-schedule {
    font-size: 11px; color: rgba(255,255,255,0.5);
    font-variant-numeric: tabular-nums;
}
.aziendax-link-btn {
    min-height: 42px; padding: 10px 14px;
    border-radius: 10px; background: transparent;
    border: 1px dashed rgba(255,255,255,0.16);
    color: rgba(255,255,255,0.65);
    font-size: 13px; font-weight: 500; cursor: pointer;
    font-family: inherit;
    transition: color .15s, border-color .15s;
}
.aziendax-link-btn:hover {
    color: var(--primary, #c8a97a);
    border-color: rgba(200,169,122,0.4);
}
/* Empty state citizen */
.aziendax-empty {
    padding: 40px 20px 32px; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.aziendax-empty-icon { font-size: 48px; filter: grayscale(0.3) opacity(0.7); margin-bottom: 4px; }
.aziendax-empty-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.aziendax-empty-desc {
    font-size: 13px; color: rgba(255,255,255,0.6);
    max-width: 320px; line-height: 1.55; margin-bottom: 10px;
}
.aziendax-cta {
    min-height: 44px; padding: 12px 22px;
    border-radius: 12px;
    background: var(--primary, #c8a97a); color: #0c0c10;
    border: 0; font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit; letter-spacing: 0.01em;
    box-shadow: 0 2px 12px rgba(200,169,122,0.15);
    transition: filter .15s, transform .1s;
}
.aziendax-cta:hover { filter: brightness(1.08); }
.aziendax-cta:active { transform: scale(0.98); }
.aziendax-empty-hint { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 6px; font-style: italic; }

/* Header: spacer per spingere logo a destra (nessun bell/admin-badge qui) */
.app-header-spacer { flex: 1; }
.app-header .logo { cursor: pointer; }

/* Attività recente: pill unica con titolo a sx + icone nested a dx */
.home-overview .af-activity-head {
    display: flex; align-items: center; gap: 4px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 4px 6px 4px 14px;
    transition: background .15s, border-color .2s;
}
.home-overview .af-activity-head:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(200,169,122,0.18);
}
/* Resetta il pill nativo del title dentro head (evita doppio bordo) */
.home-overview .af-activity-head .af-section-title,
.home-overview .af-activity-head .af-section-title--clickable {
    flex: 1; min-width: 0; margin: 0 !important;
    padding: 8px 0 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    cursor: pointer;
}
.home-overview .af-activity-head .af-section-title:hover {
    background: transparent !important;
    border-color: transparent !important;
}

/* Tre toggle coordinati nella pill — data-head-open guida lo stato visuale. */

/* Base: elementi della pill restano fissi, cambiano solo opacity quando attivi */
.home-overview .af-activity-head .af-section-title,
.home-overview .af-activity-head .af-section-title--clickable {
    opacity: 1;
    transition: opacity .3s ease;
}
.af-activity-actions {
    display: flex; align-items: center; gap: 2px;
    flex: 0 0 auto;
    opacity: 1;
    transition: opacity .3s ease;
}
.home-overview .af-activity-head .notif-bell,
.home-overview .af-activity-head .admin-badge {
    opacity: 1;
    transition: opacity .3s ease,
                background .25s ease, border-color .25s ease, color .25s ease;
}
.af-chevron {
    transition: transform .4s cubic-bezier(.4,0,.2,1), background .2s;
}

/* ── STATO 1: activity aperto — icone dimmate, chevron ruota e rimane ── */
.home-overview .af-activity-head[data-head-open="activity"] .af-activity-actions {
    opacity: 0.3;
    pointer-events: none;
}

/* ── STATO 2: notif aperto — bell resta, title + admin dimmed ── */
.home-overview .af-activity-head[data-head-open="notif"] .af-section-title,
.home-overview .af-activity-head[data-head-open="notif"] .af-activity-actions .admin-badge {
    opacity: 0.3;
    pointer-events: none;
}
.home-overview .af-activity-head[data-head-open="notif"] .notif-bell {
    background: rgba(200,169,122,0.12) !important;
    border-color: rgba(200,169,122,0.4) !important;
    color: var(--primary, #c8a97a) !important;
    animation: luna-soft-glow .55s cubic-bezier(.3,.7,.3,1) both;
}

/* ── STATO 3: admin aperto — switch-user resta, altri dimmed ── */
.home-overview .af-activity-head[data-head-open="admin"] .af-section-title,
.home-overview .af-activity-head[data-head-open="admin"] .af-activity-actions .notif-bell,
.home-overview .af-activity-head[data-head-open="admin"] .af-activity-actions .admin-inbox-icon {
    opacity: 0.3;
    pointer-events: none;
}
.home-overview .af-activity-head[data-head-open="admin"] .admin-badge:not(.admin-inbox-icon) {
    background: rgba(200,169,122,0.12) !important;
    border-color: rgba(200,169,122,0.4) !important;
    color: var(--primary, #c8a97a) !important;
    animation: luna-soft-glow .55s cubic-bezier(.3,.7,.3,1) both;
}

/* ── STATO 4: inbox aperto — inbox resta, altri dimmed ── */
.home-overview .af-activity-head[data-head-open="inbox"] .af-section-title,
.home-overview .af-activity-head[data-head-open="inbox"] .af-activity-actions .notif-bell,
.home-overview .af-activity-head[data-head-open="inbox"] .af-activity-actions .admin-badge:not(.admin-inbox-icon) {
    opacity: 0.3;
    pointer-events: none;
}
.home-overview .af-activity-head[data-head-open="inbox"] .admin-inbox-icon {
    background: rgba(200,169,122,0.12) !important;
    border-color: rgba(200,169,122,0.4) !important;
    color: var(--primary, #c8a97a) !important;
    animation: luna-soft-glow .55s cubic-bezier(.3,.7,.3,1) both;
}

/* Glow pulse sobrio: leggero scale + soft box-shadow, una volta */
@keyframes luna-soft-glow {
    0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(200,169,122,0); }
    40%  { transform: scale(1.06); box-shadow: 0 0 0 4px rgba(200,169,122,0.15); }
    100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(200,169,122,0); }
}

/* Reduced motion: elimina il glow pulse ma mantiene fade opacity */
@media (prefers-reduced-motion: reduce) {
    .home-overview .af-activity-head[data-head-open="notif"] .notif-bell,
    .home-overview .af-activity-head[data-head-open="admin"] .admin-badge {
        animation: none !important;
    }
}

/* Allineamento sezioni home: h3 e grid al bordo card dell'overview */
.af-section .af-section-title {
    padding-left: 2px !important;
    padding-right: 2px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}
.af-section .luna-official-grid,
.af-section .app-home-grid {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

/* Breathing room: più aria laterale su tutta la app (non top, evita taglio in chat/fullscreen) */
.app-content {
    padding: 16px 22px !important;
}
@media (max-width: 380px) {
    .app-content { padding: 12px 16px !important; }
}

/* Overflow visible quando una tab è aperta → il panel può uscire dalla pill */
.home-overview .af-activity-head { position: relative; }
.home-overview .af-activity-head[data-head-open]:not([data-head-open=""]) {
    overflow: visible;
}
.home-overview .af-activity-head[data-head-open]:not([data-head-open=""]) .af-activity-actions,
.home-overview .af-activity-head[data-head-open="notif"] .notif-bell,
.home-overview .af-activity-head[data-head-open="admin"] .admin-badge {
    overflow: visible;
}

/* Admin badge: cursor + position gestiti qui (erano inline) */
.admin-badge {
    cursor: pointer;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Panel INLINE stile Attività recente per notif e admin (stesso .af-stream) */
.af-stream--notif, .af-stream--admin {
    animation: luna-stream-in .25s cubic-bezier(.3,1.1,.4,1) both;
}
@keyframes luna-stream-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.af-stream-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 2px 6px;
    font-size: 10px; font-weight: 700;
    letter-spacing: 0.14em; text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    margin-bottom: 4px;
}
.af-stream-action {
    background: transparent; border: 0;
    color: var(--primary, #c8a97a);
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase;
    cursor: pointer; font-family: inherit;
    padding: 2px 4px;
    transition: opacity .15s;
}
.af-stream-action:hover { opacity: 0.8; }
.af-notif-icon {
    width: 20px; height: 20px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.af-item--unread {
    background: rgba(200,169,122,0.05);
    border-radius: 8px;
}
.af-item--unread .af-item-name { font-weight: 700; }
.af-item--active {
    background: rgba(200,169,122,0.08);
    border-radius: 8px;
}
.af-item--active .af-item-name {
    color: var(--primary, #c8a97a); font-weight: 700;
}
.af-empty-row {
    justify-content: center;
    color: rgba(255,255,255,0.5) !important;
    font-style: italic; font-size: 12px;
}
.home-overview .af-activity-actions .notif-bell,
.home-overview .af-activity-actions .admin-badge {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: rgba(255,255,255,0.6) !important;
    transition: background .15s, color .15s, border-color .15s;
}
.home-overview .af-activity-actions .notif-bell:hover,
.home-overview .af-activity-actions .admin-badge:hover {
    background: rgba(255,255,255,0.06) !important;
    color: var(--primary, #c8a97a) !important;
}

/* Notification panel: grooming big tech per uso dentro overview */
.home-overview .notif-panel {
    top: calc(100% + 10px) !important;
    right: 0 !important; left: auto !important;
    width: min(360px, calc(100vw - 32px)) !important;
    background: #14141c !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 14px !important;
    backdrop-filter: blur(20px) saturate(1.3) !important;
    -webkit-backdrop-filter: blur(20px) saturate(1.3) !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(200,169,122,0.06) !important;
    overflow: hidden;
}
.home-overview .notif-header {
    padding: 14px 18px !important;
    border-bottom: 1px solid rgba(255,255,255,0.06) !important;
    font-size: 11px !important;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55) !important;
}
.home-overview .notif-header strong {
    color: rgba(255,255,255,0.85);
    font-weight: 700;
    font-size: 11px;
}
.home-overview .notif-item {
    padding: 12px 18px !important;
    border-bottom: 1px solid rgba(255,255,255,0.04) !important;
    gap: 12px;
}
.home-overview .notif-item:last-child { border-bottom: 0 !important; }
.home-overview .notif-item:hover { background: rgba(255,255,255,0.03) !important; }
.home-overview .notif-title { font-size: 13px !important; font-weight: 500 !important; }
.home-overview .notif-unread .notif-title { font-weight: 700 !important; }
.home-overview .notif-body { font-size: 12px !important; color: rgba(255,255,255,0.5) !important; }
.home-overview .notif-time { font-size: 10px !important; color: rgba(255,255,255,0.4) !important; letter-spacing: 0.02em; }
.home-overview .notif-icon { opacity: 0.7; }

/* Dashboard overview — edge allineato con sezioni sottostanti (app-content padding gestisce il margine) */
.home-overview {
    margin: 14px 0 20px;
    padding: 16px;
    background: rgba(255,255,255,0.022);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 20px;
    display: flex; flex-direction: column; gap: 14px;
}
.home-overview .activity-feed { display: contents; }
@media (max-width: 540px) {
    .home-overview { margin: 10px 0 16px; padding: 12px; border-radius: 16px; gap: 12px; }
}

/* Hero: [Greeting + Analytics sx] · [Avatar sopra / Saldo sotto a dx, centrato] */
.home-hero {
    padding: 6px 4px 4px;
    display: flex; align-items: center; gap: 14px;
    min-width: 0;
}
.home-hero-left {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 14px;
}
.home-hero-analytics {
    width: 100%;
    /* compatta la card quando è nell'hero (eredita .af-analytics-card) */
}
.home-hero-stack {
    flex-shrink: 0;
    width: 112px;
    display: flex; flex-direction: column; align-items: stretch; gap: 18px;
}

/* Saldo card — sotto avatar, larghezza stack, testi centrati */
.home-hero-balance-card {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(200,169,122,0.07);
    border: 1px solid rgba(200,169,122,0.28);
    color: var(--text); font-family: inherit; cursor: pointer;
    text-align: center;
    transition: background .15s, border-color .2s, transform .1s;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    min-width: 0;
}
.home-hero-balance-card:hover {
    background: rgba(200,169,122,0.12);
    border-color: rgba(200,169,122,0.5);
}
.home-hero-balance-card:active { transform: scale(0.98); }
.home-hero-balance-card:focus-visible {
    outline: 2px solid var(--primary); outline-offset: 2px;
}
.home-hero-balance-lbl {
    font-size: 10px; font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase;
    color: rgba(255,255,255,0.55); white-space: nowrap;
    text-align: center;
}
.home-hero-balance-val {
    font-size: 18px; font-weight: 800;
    color: var(--primary, #c8a97a);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    line-height: 1.1;
    white-space: nowrap;
    text-align: center;
}

/* Greeting — centro, flessibile */
.home-hero-greeting {
    flex: 1; min-width: 0;
    margin: 0;
    font-size: clamp(20px, 5vw, 30px); font-weight: 700;
    letter-spacing: -0.02em; line-height: 1.15;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* Wrap per avatar + bell overlay — position:relative consente pin della bell */
.home-hero-avatar-wrap {
    position: relative;
    width: 100%; aspect-ratio: 1 / 1;
}

/* Bell overlay avatar — stile big-tech minimale, no giochi di luce */
.home-hero-notif {
    position: absolute;
    top: -2px; right: -2px;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: rgba(20,20,28,0.95);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    cursor: pointer; font-family: inherit; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    transition: border-color .18s, color .18s, background .18s;
    z-index: 3;
}
.home-hero-notif:hover {
    border-color: rgba(200,169,122,0.45);
    color: var(--primary, #c8a97a);
}
.home-hero-notif:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.home-hero-notif--active {
    background: rgba(200,169,122,0.12);
    border-color: var(--primary, #c8a97a);
    color: var(--primary, #c8a97a);
}
.home-hero-notif-dot {
    position: absolute; top: -2px; right: -2px;
    min-width: 14px; height: 14px; padding: 0 3px;
    border-radius: 7px;
    background: var(--primary, #c8a97a); color: #0c0c10;
    font-size: 9px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

@media (max-width: 540px) {
    .home-hero-notif { width: 26px; height: 26px; top: 0; right: 0; }
    .home-hero-notif svg { width: 12px; height: 12px; }
}

/* Avatar — in stack colonna, cerchio con ring dorato ben visibile */
.home-hero-avatar {
    width: 100%; aspect-ratio: 1 / 1;
    border-radius: 50%; padding: 0;
    background: rgba(200,169,122,0.12);
    border: 4px solid #e6c89d;
    overflow: hidden; cursor: pointer;
    position: relative;
    transition: box-shadow .25s, border-color .2s, transform .1s;
    display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 0 0 1px rgba(255,230,190,0.3),
                0 0 0 2.5px rgba(200,169,122,0.25),
                0 0 16px rgba(200,169,122,0.18);
}
.home-hero-avatar:hover {
    box-shadow: 0 0 0 4px rgba(200,169,122,0.35),
                0 0 20px rgba(200,169,122,0.25);
}
.home-hero-avatar img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    border-radius: inherit;
}
.home-hero-avatar-initial {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--primary, #c8a97a); font-weight: 700; font-size: 48px;
    pointer-events: none; z-index: 0;
}
.home-hero-avatar img + .home-hero-avatar-initial { display: none; }
.home-hero-avatar--fallback .home-hero-avatar-initial { display: flex; z-index: 2; }
.home-hero-avatar:active { transform: scale(0.97); }
.home-hero-avatar:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

/* Mobile: riduci stack per stare in una riga */
@media (max-width: 540px) {
    .home-hero { padding: 4px 2px; gap: 10px; }
    .home-hero-stack { width: 92px; gap: 14px; }
    .home-hero-balance-card { padding: 7px 8px; }
    .home-hero-balance-lbl { font-size: 9px; letter-spacing: 0.08em; }
    .home-hero-balance-val { font-size: 14px; }
    .home-hero-greeting { font-size: clamp(18px, 5vw, 22px); }
    .home-hero-avatar-initial { font-size: 36px; }
    .home-hero-avatar { border-width: 3px; }
    .home-hero .af-analytics-card .af-analytics-num { font-size: 17px; }
    .home-hero .af-analytics-card .af-analytics-lbl { font-size: 9px; }
    .home-hero .af-analytics-card { padding: 10px 12px 9px; }
}
@media (max-width: 380px) {
    .home-hero-stack { width: 80px; gap: 12px; }
    .home-hero-balance-card { padding: 6px 8px; }
    .home-hero-balance-val { font-size: 13px; }
    .home-hero-balance-lbl { font-size: 8px; }
    .home-hero-greeting { font-size: 16px; }
    .home-hero-avatar-initial { font-size: 30px; }
}

/* Activity feed — card Analytics unificata (click apre /analytics) */
.af-analytics-card {
    width: 100%; flex: 1;
    display: flex; flex-direction: column; gap: 10px;
    padding: 14px 16px 12px;
    border-radius: 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    color: var(--text); font-family: inherit; cursor: pointer;
    transition: background .15s, border-color .2s, transform .1s;
    position: relative;
    text-align: left;
}
.af-analytics-card:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(200,169,122,0.3);
}
.af-analytics-card:active { transform: scale(0.995); }
.af-analytics-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.af-analytics-split {
    display: flex; align-items: stretch; gap: 14px;
    font-variant-numeric: tabular-nums;
}
.af-analytics-half {
    flex: 1; min-width: 0; text-align: center;
    display: flex; flex-direction: column; gap: 3px; align-items: center;
}
.af-analytics-num {
    font-size: clamp(22px, 6vw, 28px); font-weight: 800;
    color: var(--text); line-height: 1; letter-spacing: -0.02em;
    white-space: nowrap;
}
/* Nested dentro hero: layout flex-row [stats | chev a dx], stile Strumenti Luna */
.home-hero .af-analytics-card {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 14px 12px 14px 16px;
    position: relative;
}
.home-hero .af-analytics-card .af-analytics-split {
    flex: 1; min-width: 0;
    gap: 10px;
}
.home-hero .af-analytics-card .af-analytics-num { font-size: clamp(18px, 5vw, 22px); }
.home-hero .af-analytics-card .af-analytics-lbl { font-size: 9px; letter-spacing: 0.06em; }

/* Tint bar a sx — identità Luna (come Strumenti Luna) */
.af-analytics-tint {
    position: absolute; left: 0; top: 14px; bottom: 14px;
    width: 2px; border-radius: 2px;
    background: var(--primary, #c8a97a);
    opacity: 0.35;
    transition: opacity .2s, width .2s;
}
.af-analytics-card:hover .af-analytics-tint { opacity: 0.85; width: 3px; }

/* Chevron grande a dx, chiaro segnale "apri" */
.af-analytics-side-chev {
    flex-shrink: 0;
    color: rgba(255,255,255,0.35);
    transition: color .2s, transform .2s;
}
.af-analytics-card:hover .af-analytics-side-chev {
    color: var(--primary, #c8a97a);
    transform: translateX(3px);
}
.af-analytics-pos { color: #4ade80; }
.af-analytics-neg { color: #f87171; }
.af-analytics-lbl {
    font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
    color: rgba(255,255,255,0.55); font-weight: 600;
    white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
    display: inline-flex; align-items: center; gap: 4px;
}
/* (rimosso .af-analytics-inline-chev → ora chevron grande sul lato destro della card) */
.af-analytics-divider {
    width: 1px; background: rgba(255,255,255,0.08); align-self: stretch;
}
.af-analytics-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.af-analytics-tag {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: rgba(255,255,255,0.65);
}
.af-analytics-tag svg { color: var(--primary, #c8a97a); }
.af-analytics-chev {
    color: rgba(255,255,255,0.35);
    transition: color .2s, transform .15s;
}
.af-analytics-card:hover .af-analytics-chev {
    color: var(--primary, #c8a97a); transform: translateX(2px);
}

/* Analytics block — KPI, trend, top list, breakdown */
.anx-body { padding: 16px; display: flex; flex-direction: column; gap: 20px; }
.anx-empty {
    padding: 24px 16px; text-align: center; font-size: 13px;
    color: rgba(255,255,255,0.55);
    background: rgba(255,255,255,0.03);
    border: 1px dashed rgba(255,255,255,0.08);
    border-radius: 10px;
}
.anx-kpi-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.anx-kpi {
    padding: 14px 10px; border-radius: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    text-align: center;
    display: flex; flex-direction: column; gap: 4px;
    font-variant-numeric: tabular-nums;
}
.anx-kpi--brand { border-color: rgba(200,169,122,0.25); background: rgba(200,169,122,0.05); }
.anx-kpi--pos { border-color: rgba(34,197,94,0.25); background: rgba(34,197,94,0.05); }
.anx-kpi--neg { border-color: rgba(239,68,68,0.25); background: rgba(239,68,68,0.05); }
.anx-kpi-value {
    font-size: 20px; font-weight: 700; color: var(--text);
    letter-spacing: -0.01em; line-height: 1.1;
    overflow-wrap: anywhere;
}
.anx-kpi--pos .anx-kpi-value { color: #4ade80; }
.anx-kpi--neg .anx-kpi-value { color: #f87171; }
.anx-kpi--brand .anx-kpi-value { color: var(--primary, #c8a97a); }
.anx-kpi-label {
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: rgba(255,255,255,0.5);
}
.anx-section { display: flex; flex-direction: column; gap: 10px; }
.anx-section-title {
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    margin: 0;
}
.anx-trend {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
    height: 110px; align-items: end;
    padding: 4px 0;
}
.anx-trend-col {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    height: 100%; position: relative;
}
.anx-trend-bar {
    flex: 0 0 auto; width: 100%; max-width: 28px;
    background: linear-gradient(180deg, var(--primary, #c8a97a), rgba(200,169,122,0.35));
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    margin-top: auto;
    position: relative;
    transition: background .2s;
}
.anx-trend-col:hover .anx-trend-bar {
    background: linear-gradient(180deg, #d4b88a, var(--primary, #c8a97a));
}
.anx-trend-tooltip {
    position: absolute; bottom: calc(100% + 4px); left: 50%;
    transform: translateX(-50%);
    font-size: 10px; padding: 2px 6px;
    background: #14141a; color: var(--text);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px; white-space: nowrap;
    opacity: 0; pointer-events: none;
    transition: opacity .15s;
    font-variant-numeric: tabular-nums;
}
.anx-trend-col:hover .anx-trend-tooltip { opacity: 1; }
.anx-trend-day {
    font-size: 10px; color: rgba(255,255,255,0.5);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.anx-list { list-style: none; margin: 0; padding: 0; }
.anx-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 2px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.anx-item:last-child { border-bottom: 0; }
.anx-item-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #4ade80; flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
}
.anx-item-dot--brand {
    background: var(--primary, #c8a97a);
    box-shadow: 0 0 0 3px rgba(200,169,122,0.12);
}
.anx-item-name {
    flex: 1; color: rgba(255,255,255,0.88); font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}
.anx-item-owner {
    font-size: 11px; color: var(--primary, #c8a97a);
    opacity: 0.8; flex-shrink: 0;
}
.anx-item-metric {
    font-size: 12px; color: rgba(255,255,255,0.6); flex-shrink: 0;
}
.anx-item-sr {
    font-size: 12px; font-weight: 700; flex-shrink: 0;
    min-width: 40px; text-align: right;
}
.anx-bars { display: flex; flex-direction: column; gap: 10px; }
.anx-bar-row { display: flex; flex-direction: column; gap: 4px; }
.anx-bar-head {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 13px; font-variant-numeric: tabular-nums;
}
.anx-bar-cat { color: rgba(255,255,255,0.88); }
.anx-bar-amt { color: var(--primary, #c8a97a); font-weight: 600; }
.anx-bar-track {
    height: 5px; background: rgba(255,255,255,0.04);
    border-radius: 3px; overflow: hidden;
}
.anx-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary, #c8a97a), rgba(200,169,122,0.35));
    border-radius: 3px;
    transition: width .35s cubic-bezier(.2,.8,.2,1);
}
@media (max-width: 540px) {
    .anx-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .anx-kpi-value { font-size: 18px; }
    .anx-trend { height: 90px; }
}

/* Saldo Luna — citizen only, sotto hero */
.finx-balance {
    margin-top: 18px; padding: 14px 16px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(200,169,122,0.10), rgba(200,169,122,0.03));
    border: 1px solid rgba(200,169,122,0.22);
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: baseline;
    gap: 2px 12px;
}
.finx-balance-label {
    grid-column: 1; grid-row: 1;
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.18em; text-transform: uppercase;
    color: rgba(255,255,255,0.55);
}
.finx-balance-value {
    grid-column: 2; grid-row: 1 / span 2;
    font-size: 22px; font-weight: 700;
    color: var(--primary, #c8a97a);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    align-self: center;
}
.finx-balance-sub {
    grid-column: 1; grid-row: 2;
    font-size: 11px; color: rgba(255,255,255,0.5);
}

/* Bollette servizi — righe editabili inline (admin only) */
.finx-bills {
    margin-top: 22px; padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.finx-bills-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 10px;
}
.finx-bills-head .finx-list-title { margin-bottom: 0; }
.finx-bills-list { list-style: none; margin: 0; padding: 0; }
.finx-bill {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-variant-numeric: tabular-nums;
}
.finx-bill:last-child { border-bottom: 0; }
.finx-bill-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: rgba(255,255,255,0.18); flex-shrink: 0;
}
.finx-bill--set .finx-bill-dot {
    background: var(--primary, #c8a97a);
    box-shadow: 0 0 0 3px rgba(200,169,122,0.12);
}
.finx-bill-name {
    flex: 1; font-size: 14px; color: rgba(255,255,255,0.88);
    font-weight: 500;
}
.finx-bill-amount {
    font-size: 14px; font-weight: 600; color: var(--text);
}
.finx-bill-amount--zero { color: rgba(255,255,255,0.35); font-weight: 400; }
.finx-bill-edit {
    min-height: 28px; padding: 4px 10px;
    border-radius: 7px; font-size: 11px; font-weight: 500;
    background: transparent; border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.55); cursor: pointer; font-family: inherit;
    transition: color .15s, border-color .15s, background .15s;
}
.finx-bill-edit:hover {
    color: var(--primary, #c8a97a);
    border-color: rgba(200,169,122,0.35);
    background: rgba(200,169,122,0.04);
}
.finx-bill-edit:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.finx-bill-input {
    min-height: 32px !important; padding: 6px 10px !important;
    font-size: 13px !important; flex: 0 0 100px !important;
}
.finx-bill-btn {
    min-height: 32px; min-width: 32px; padding: 4px 10px;
    border-radius: 7px; font-size: 14px;
    border: 1px solid var(--primary, #c8a97a);
    background: var(--primary, #c8a97a); color: #0c0c10;
    cursor: pointer; font-family: inherit; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center;
}
.finx-bill-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.finx-bill-btn:hover:not([disabled]) { filter: brightness(1.08); }
.finx-bill-btn--ghost {
    background: transparent; color: rgba(255,255,255,0.5);
    border-color: rgba(255,255,255,0.1); font-weight: 400;
}
.finx-bill-btn--ghost:hover { color: #f87171; border-color: rgba(239,68,68,0.3); }

/* Actions — bottoni outline, hover gold Luna */
.finx-actions {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    margin-top: 18px; padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.finx-add {
    min-height: 42px; padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.72);
    font-size: 13px; font-weight: 500;
    cursor: pointer; font-family: inherit;
    transition: border-color .18s, color .18s, background .18s, transform .1s;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    letter-spacing: 0.01em;
}
.finx-add:hover {
    border-color: rgba(200,169,122,0.4);
    color: var(--primary, #c8a97a);
    background: rgba(200,169,122,0.04);
}
.finx-add:active { transform: scale(0.98); }
.finx-add--active {
    border-color: var(--primary, #c8a97a);
    color: var(--primary, #c8a97a);
    background: rgba(200,169,122,0.08);
}
.finx-add-plus { font-weight: 400; opacity: 0.8; }
.finx-add:focus-visible { outline: 2px solid var(--primary, #c8a97a); outline-offset: 2px; }

/* Form */
.finx-form {
    margin-top: 10px; padding-top: 14px;
    display: flex; flex-direction: column; gap: 10px;
    animation: finx-form-in .25s ease-out;
}
@keyframes finx-form-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.finx-form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.finx-input {
    flex: 1; min-width: 0; min-height: 42px;
    padding: 10px 14px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.35); color: var(--text);
    font-size: 14px; font-family: inherit;
    transition: border-color .15s;
}
.finx-input::placeholder { color: rgba(255,255,255,0.3); }
.finx-input--amount { flex: 0 0 100px; font-variant-numeric: tabular-nums; font-weight: 600; }
.finx-input:focus { outline: 0; border-color: var(--primary, #c8a97a); }
.finx-save {
    min-height: 42px; padding: 10px 16px;
    border-radius: 10px; border: 0;
    background: var(--primary, #c8a97a); color: #0c0c10;
    font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: inherit;
    letter-spacing: 0.02em;
    transition: filter .15s, transform .1s;
}
.finx-save[disabled] { opacity: 0.5; cursor: not-allowed; }
.finx-save:hover:not([disabled]) { filter: brightness(1.1); }
.finx-save:active:not([disabled]) { transform: scale(0.98); }

/* Transazioni recenti — lista minimale con dot colorato */
.finx-list { margin-top: 24px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,0.05); }
.finx-list-title {
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.18em; text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    margin-bottom: 4px;
}
.finx-tx-list { list-style: none; margin: 0; padding: 0; }
.finx-tx {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 2px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background .15s;
    border-radius: 0;
}
.finx-tx:last-child { border-bottom: 0; }
.finx-tx:hover { background: rgba(255,255,255,0.015); }
.finx-tx-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.finx-tx--pos .finx-tx-dot { background: #4ade80; box-shadow: 0 0 0 3px rgba(34,197,94,0.12); }
.finx-tx--neg .finx-tx-dot { background: rgba(255,255,255,0.35); box-shadow: 0 0 0 3px rgba(255,255,255,0.05); }
.finx-tx-body { flex: 1; min-width: 0; }
.finx-tx-desc {
    font-size: 14px; color: var(--text); font-weight: 400;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.finx-tx-date { font-size: 11px; color: rgba(255,255,255,0.45); margin-top: 2px; }
.finx-tx-amt { font-size: 14px; font-weight: 600; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.finx-tx--pos .finx-tx-amt { color: #4ade80; }
.finx-tx--neg .finx-tx-amt { color: rgba(255,255,255,0.9); }
.finx-tx-del {
    width: 28px; height: 28px; flex-shrink: 0;
    border: 0; border-radius: 50%;
    background: transparent; color: rgba(255,255,255,0.3);
    cursor: pointer; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity .15s, color .15s, background .15s;
}
.finx-tx:hover .finx-tx-del,
.finx-tx:focus-within .finx-tx-del { opacity: 1; }
.finx-tx-del:hover { background: rgba(239,68,68,0.12); color: #f87171; }
.finx-tx-del:focus-visible { opacity: 1; outline: 2px solid #ef4444; outline-offset: 2px; }
@media (hover: none) {
    .finx-tx-del { opacity: 0.5; }
}

/* Confirm dialog */
.finx-dialog {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.68);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px; animation: finx-fade-in .18s ease-out;
}
@keyframes finx-fade-in { from { opacity: 0; } to { opacity: 1; } }
.finx-dialog-box {
    background: #0f0f14; border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px; padding: 22px; max-width: 340px; width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(200,169,122,0.08);
    animation: finx-pop-in .25s cubic-bezier(.2,1.2,.3,1);
}
@keyframes finx-pop-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.finx-dialog-title {
    font-size: 15px; font-weight: 500; color: var(--text);
    margin-bottom: 18px; line-height: 1.4;
}
.finx-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.finx-btn-ghost, .finx-btn-del {
    min-height: 38px; padding: 8px 16px;
    border-radius: 10px; font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: inherit;
    transition: filter .15s, background .15s;
}
.finx-btn-ghost {
    background: transparent; border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.8);
}
.finx-btn-ghost:hover { background: rgba(255,255,255,0.04); }
.finx-btn-del { background: #ef4444; border: 0; color: #fff; }
.finx-btn-del:hover { filter: brightness(1.08); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .finx-row, .finx-form, .finx-dialog, .finx-dialog-box { animation: none; }
    .finx-add, .finx-save, .finx-tx-del, .finx-tx { transition: none; }
}

/* ═══ Art Stone Dashboard overlay ══════════════════════════════════════ */
.aziendax-card--clickable {
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .12s;
}
.aziendax-card--clickable:hover {
    background: rgba(200, 169, 122, 0.08);
    border-color: rgba(200, 169, 122, 0.4);
}
.aziendax-card--clickable:active { transform: scale(0.995); }
.aziendax-arrow {
    margin-left: auto; padding-left: 10px;
    font-size: 24px; color: var(--text-muted);
    line-height: 1;
}

body.as-dash-open { overflow: hidden; }
.as-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(8px);
    display: flex; align-items: stretch; justify-content: center;
    animation: finx-fade-in .18s ease-out;
}
.as-panel {
    width: 100%; max-width: 1400px;
    margin: 20px;
    background: #0f0f14;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(200, 169, 122, 0.06);
    animation: finx-pop-in .22s cubic-bezier(.2, 1.2, .3, 1);
}
/* ===== Header big-tech: logo protagonista, stats inline con divisori ===== */
.as-header {
    display: flex; align-items: center; gap: 32px;
    padding: 22px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: transparent;
    flex-shrink: 0;
}
.as-header-brand {
    display: flex; align-items: center; gap: 18px;
    min-width: 0;
}
.as-logo {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #c8a97a22, #c8a97a11);
    border: 1px solid rgba(200, 169, 122, 0.25);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary, #c8a97a);
}
.as-logo svg { display: block; width: 26px; height: 26px; }
.as-logo-img {
    height: 56px; width: auto; display: block;
    filter: brightness(1.18) contrast(1.05);
    flex-shrink: 0;
}
@media (max-width: 720px) { .as-logo-img { height: 42px; } }

.as-header-meta {
    display: flex; flex-direction: column; gap: 2px;
    padding-left: 18px;
    border-left: 1px solid rgba(255,255,255,0.08);
    min-width: 0;
}
.as-header-eyebrow {
    font-size: 10px; font-weight: 600; letter-spacing: 0.14em;
    text-transform: uppercase; color: rgba(255,255,255,0.4);
}
.as-header-titletag {
    font-size: 14px; font-weight: 600;
    color: var(--text, #efe6d4); letter-spacing: -0.005em;
    line-height: 1.3;
}

.as-header-right {
    margin-left: auto;
    display: flex; align-items: center; gap: 24px;
}

.as-header-stats {
    display: flex; align-items: center; gap: 18px;
    margin: 0;
}
.as-stat {
    text-align: left; background: transparent; border: 0; padding: 0;
    min-width: 0;
}
.as-stat-n {
    font-size: 22px; font-weight: 700;
    color: var(--text, #efe6d4); letter-spacing: -0.025em;
    line-height: 1; font-feature-settings: "tnum" 1;
}
.as-stat-l {
    font-size: 10px; color: rgba(255,255,255,0.42);
    text-transform: uppercase; letter-spacing: 0.12em;
    font-weight: 600; margin-top: 4px;
}
.as-stat-divider {
    width: 1px; align-self: stretch;
    background: rgba(255,255,255,0.08);
    margin: 4px 0;
}
.as-close {
    width: 32px; height: 32px; border-radius: 8px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted); cursor: pointer;
    font-size: 14px; font-family: inherit;
    transition: background .15s, color .15s, border-color .15s;
}
.as-close:hover { background: rgba(239, 68, 68, 0.1); color: var(--error); border-color: rgba(239, 68, 68, 0.3); }

/* ===== Nav 2 livelli: gruppi (categorie) + tab del gruppo attivo ===== */
.as-nav { flex-shrink: 0; }
.as-nav-groups {
    display: flex; align-items: stretch; flex-wrap: wrap;
    padding: 0 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(0,0,0,0.18);
}
.as-nav-group {
    padding: 12px 16px;
    background: transparent; border: 0;
    color: rgba(255,255,255,0.45);
    font-family: inherit;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.12em;
    cursor: pointer; white-space: nowrap;
    border-bottom: 1px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
}
.as-nav-group:hover { color: var(--text, #efe6d4); }
.as-nav-group-on {
    color: var(--text, #efe6d4);
    border-bottom-color: var(--primary, #c8a97a);
}

.as-tabs {
    display: flex; gap: 0; flex-wrap: wrap;
    padding: 0 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}
.as-tab {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px; border: 0;
    background: transparent; color: rgba(255,255,255,0.5);
    font-family: inherit; font-size: 13px; font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.as-tab:hover { color: var(--text); }
.as-tab-active {
    color: var(--text, #efe6d4);
    border-bottom-color: var(--primary, #c8a97a);
    font-weight: 600;
}
.as-tab-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; color: currentColor; opacity: 0.75; }
.as-tab-active .as-tab-icon { opacity: 1; color: var(--primary, #c8a97a); }
.as-tab-icon svg { display: block; width: 16px; height: 16px; }
.as-btn-ico { display: inline-flex; align-items: center; gap: 7px; }
.as-btn-ico-svg { display: inline-flex; width: 14px; height: 14px; }
.as-btn-ico-svg svg { display: block; width: 14px; height: 14px; }

.as-body { flex: 1; overflow: auto; padding: 18px 22px; }
.as-pad { padding: 18px; }
.as-error { color: var(--error); }
.as-dim, .as-dim-cell { color: var(--text-muted); font-size: 12px; }

.as-toolbar {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.as-search, .as-select {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text);
    padding: 8px 12px; border-radius: 10px;
    font-family: inherit; font-size: 13px;
    outline: none;
    transition: border-color .15s, background .15s;
}
.as-search { flex: 1; min-width: 200px; }
.as-search:focus, .as-select:focus { border-color: rgba(200, 169, 122, 0.4); background: rgba(255, 255, 255, 0.06); }
.as-toolbar-spacer { flex: 1; }
.as-toolbar-info { font-size: 12px; color: var(--text-muted); }

.as-bulk-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; margin-bottom: 12px;
    background: rgba(200, 169, 122, 0.08);
    border: 1px solid rgba(200, 169, 122, 0.2);
    border-radius: 10px;
    font-size: 13px; color: var(--text);
}

.as-btn {
    padding: 8px 14px; border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-family: inherit; font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, filter .15s;
}
.as-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.16); }
.as-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.as-btn-primary {
    background: var(--primary); color: #1a1206; border-color: transparent;
}
.as-btn-primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--primary); }
.as-btn-ghost { background: transparent; color: var(--text-muted); }
.as-mini {
    width: 28px; height: 28px; padding: 0;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text); cursor: pointer;
    font-family: inherit; font-size: 13px;
    transition: background .15s, border-color .15s;
}
.as-mini:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(200, 169, 122, 0.3); }
.as-mini-red:hover { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.3); color: var(--error); }

.as-table-wrap { border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 12px; overflow: auto; }
.as-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.as-table thead { background: rgba(255, 255, 255, 0.03); position: sticky; top: 0; z-index: 1; }
.as-table th {
    text-align: left; padding: 10px 14px;
    font-size: 11px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.as-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text);
    vertical-align: middle;
}
.as-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.as-row-sel { background: rgba(200, 169, 122, 0.05) !important; }
.as-num { font-family: var(--font-mono, ui-monospace, monospace); font-weight: 600; color: var(--primary); }
.as-cli-name { font-weight: 500; }
.as-cli-cod { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.as-rif { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-muted); }
.as-stato {
    display: inline-block; padding: 2px 8px;
    border-radius: 8px; font-size: 11px; font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}
.as-stato-ok, .as-stato-c { background: rgba(34, 197, 94, 0.12); color: var(--success); }
.as-stato-no { background: rgba(239, 68, 68, 0.1); color: var(--error); }
.as-actions { display: flex; gap: 4px; white-space: nowrap; }
.as-empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 13px; }

.as-modal {
    position: fixed; inset: 0; z-index: 2100;
    background: rgba(0, 0, 0, 0.7);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.as-modal-panel {
    width: 100%; max-width: 800px; height: 80vh;
    background: #fff; border-radius: 14px; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.as-modal-head {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; font-size: 12px; color: #333;
    border-bottom: 1px solid #eee;
    background: #f8f8f8;
    justify-content: space-between;
}
.as-iframe { flex: 1; border: 0; width: 100%; background: #f5f3ee; }
.as-preview-panel { max-width: 820px; height: 88vh; }
.as-preview-grid-panel { max-width: 1100px; height: 94vh; }
.as-preview-head b { color: #c8963a; font-family: 'SF Mono', ui-monospace, Menlo, monospace; }
.as-preview-head {
    padding: 12px 14px 12px 20px;
    color: #14110d;
    background: #fafaf6;
    border-bottom: 1px solid #e8e0d0;
}
.as-preview-head > span {
    font-size: 13px; font-weight: 600; color: #14110d;
    letter-spacing: -0.01em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; margin-right: 12px;
}
.as-preview-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.as-preview-head .as-tool-btn {
    padding: 7px 12px;
    background: #fff;
    border: 1px solid #d9cdb5;
    color: #4a3f2a;
}
.as-preview-head .as-tool-btn:hover {
    background: #f5efe3;
    border-color: #c8963a;
    color: #1a1410;
}
.as-preview-head .as-tool-btn-primary {
    background: #14110d;
    border-color: #14110d;
    color: #fff;
}
.as-preview-head .as-tool-btn-primary:hover {
    background: #c8963a;
    border-color: #c8963a;
    color: #fff;
}
.as-preview-head .as-tool-btn[title="Chiudi"] {
    width: 36px; padding: 7px 0;
    justify-content: center;
    background: transparent;
    border-color: #e8e0d0;
    color: #8a7f65;
}
.as-preview-head .as-tool-btn[title="Chiudi"]:hover {
    background: #fdecec; border-color: #ef4444; color: #ef4444;
}

/* Ingest tab */
.as-dropzone {
    border: 2px dashed rgba(200, 169, 122, 0.35);
    border-radius: 16px;
    padding: 50px 30px;
    text-align: center;
    background: rgba(200, 169, 122, 0.03);
    transition: background .2s, border-color .2s, transform .2s;
    margin-bottom: 20px;
}
.as-dropzone-active { background: rgba(200, 169, 122, 0.1); border-color: var(--primary); transform: scale(1.005); }
.as-dropzone-busy { opacity: 0.7; border-style: solid; }
.as-dz-icon { font-size: 40px; margin-bottom: 10px; }
.as-dz-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.as-dz-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.as-dz-pick { display: inline-block; }
.as-alert { padding: 10px 14px; background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.25); border-radius: 10px; color: var(--error); font-size: 13px; margin-bottom: 14px; }
.as-sec-title { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px; }
.as-results { display: flex; flex-direction: column; gap: 12px; }
.as-result {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.02);
}
.as-result-done { border-color: rgba(34, 197, 94, 0.25); background: rgba(34, 197, 94, 0.04); }
.as-result-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; }
.as-result-file { font-size: 13px; font-weight: 500; }
.as-result-class { display: flex; align-items: center; gap: 8px; }
.as-tag {
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    text-transform: uppercase; letter-spacing: 0.03em;
}
.as-tag-clienti { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.as-tag-prodotti { background: rgba(200, 169, 122, 0.15); color: var(--primary); }
.as-tag-ceramiche { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.as-tag-ricordini { background: rgba(236, 72, 153, 0.15); color: #f472b6; }
.as-tag-sconti { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.as-tag-unknown { background: rgba(239, 68, 68, 0.12); color: var(--error); }
.as-error-inline { font-size: 12px; color: var(--error); margin-top: 6px; }
.as-ok-inline { font-size: 13px; color: var(--success); padding: 10px; background: rgba(34, 197, 94, 0.06); border-radius: 8px; }
.as-extracted { margin-top: 10px; }
.as-extracted-count { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.as-extracted-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; padding-right: 4px; }
.as-rec {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) auto;
    gap: 6px 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    align-items: end;
}
.as-rec-field { display: flex; flex-direction: column; gap: 3px; }
.as-rec-field span {
    font-size: 10px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.as-rec-field input {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text);
    padding: 5px 8px; border-radius: 6px;
    font-family: inherit; font-size: 12px;
    outline: none; min-width: 0;
}
.as-rec-field input:focus { border-color: rgba(200, 169, 122, 0.4); }
.as-result-actions { margin-top: 12px; display: flex; justify-content: flex-end; gap: 8px; }

/* Bot status + run controls in header */
.as-header-bot { display: flex; align-items: center; gap: 10px; padding: 4px 12px; border-left: 1px solid rgba(255,255,255,0.06); border-right: 1px solid rgba(255,255,255,0.06); margin-left: auto; }
.as-bot-status { display: flex; align-items: center; gap: 8px; }
.as-bot-dot { width: 10px; height: 10px; border-radius: 50%; background: #555; flex-shrink: 0; }
.as-bot-dot-ok { background: var(--success); box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.as-bot-dot-err { background: var(--error); box-shadow: 0 0 8px rgba(239,68,68,0.5); }
.as-bot-dot-run { background: var(--primary); box-shadow: 0 0 8px rgba(200,169,122,0.5); animation: as-pulse 1.2s infinite; }
.as-bot-dot-off { background: #555; }
@keyframes as-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.as-bot-meta { display: flex; flex-direction: column; }
.as-bot-line { font-size: 12px; font-weight: 600; color: var(--text); text-transform: capitalize; }
.as-bot-sub { font-size: 11px; color: var(--text-muted); }
.as-header-stats { margin-left: 0; }
.as-banner { padding: 8px 22px; background: rgba(200,169,122,0.1); border-bottom: 1px solid rgba(200,169,122,0.2); color: var(--primary); font-size: 12px; font-weight: 500; text-align: center; }

/* Record editor modal */
.as-editor-panel { width: 640px; max-width: 92vw; background: #111117; border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; display: flex; flex-direction: column; max-height: 85vh; overflow: hidden; color: var(--text); }
.as-editor-head { background: rgba(200,169,122,0.08); color: var(--text); padding: 12px 16px; font-size: 13px; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,0.08); }
.as-editor-body { padding: 18px 20px; overflow: auto; flex: 1; }
.as-editor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.as-editor-foot { padding: 12px 20px; border-top: 1px solid rgba(255,255,255,0.06); display: flex; justify-content: flex-end; gap: 8px; background: rgba(255,255,255,0.02); }
.as-flash { margin-bottom: 12px; }

/* Toast notifications */
.as-toast-host { position: fixed; bottom: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.as-toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #111117; border: 1px solid rgba(255,255,255,0.12); border-radius: 10px; color: var(--text); font-size: 13px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,0.5); pointer-events: auto; min-width: 220px; max-width: 400px; opacity: 0; transform: translateX(20px); transition: opacity .25s ease, transform .25s ease; }
.as-toast-in { opacity: 1; transform: translateX(0); }
.as-toast-out { opacity: 0; transform: translateX(20px); }
.as-toast-icon { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 12px; font-weight: 700; }
.as-toast-ok .as-toast-icon { background: rgba(34,197,94,0.18); color: var(--success); }
.as-toast-err .as-toast-icon { background: rgba(239,68,68,0.18); color: var(--error); }
.as-toast-info .as-toast-icon { background: rgba(200,169,122,0.18); color: var(--primary); }
.as-toast-ok { border-color: rgba(34,197,94,0.3); }
.as-toast-err { border-color: rgba(239,68,68,0.3); }
.as-toast-msg { flex: 1; line-height: 1.4; }

/* Edit inline celle */
.as-cell-editable { cursor: text; position: relative; }
.as-cell-editable:hover { background: rgba(200,169,122,0.06); outline: 1px dashed rgba(200,169,122,0.3); outline-offset: -1px; }
.as-cell-key { cursor: not-allowed; opacity: 0.8; font-weight: 600; }
.as-cell-edit { padding: 2px 4px !important; background: rgba(200,169,122,0.08); }
.as-cell-edit input { width: 100%; background: rgba(0,0,0,0.3); border: 1px solid var(--primary); color: var(--text); padding: 6px 8px; border-radius: 6px; font-family: inherit; font-size: 13px; outline: none; }

/* Analytics panel */
.as-analytics { border: 1px solid rgba(255,255,255,0.06); border-radius: 12px; margin-bottom: 14px; overflow: hidden; background: rgba(255,255,255,0.02); }
.as-analytics-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: transparent; border: 0; color: var(--text); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-align: left; }
.as-analytics-toggle:hover { background: rgba(255,255,255,0.02); }
.as-analytics-body { padding: 12px 14px 16px; border-top: 1px solid rgba(255,255,255,0.06); }
.as-chart { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin-bottom: 14px; padding: 4px; background: rgba(0,0,0,0.15); border-radius: 8px; overflow-x: auto; }
.as-bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 30px; height: 100%; padding: 2px 0; }
.as-bar-fill { width: 18px; background: linear-gradient(180deg, var(--primary), rgba(200,169,122,0.4)); border-radius: 3px 3px 0 0; min-height: 3px; transition: height .3s; }
.as-bar:hover .as-bar-fill { background: var(--primary); }
.as-bar-label { font-size: 9px; color: var(--text-muted); margin-top: 4px; font-family: var(--font-mono); }
.as-analytics-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.as-analytics-col .as-sec-title { margin-bottom: 6px; }
.as-analytic-row { display: flex; justify-content: space-between; gap: 8px; padding: 4px 6px; font-size: 12px; color: var(--text); border-bottom: 1px solid rgba(255,255,255,0.03); }
.as-analytic-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-analytic-count { color: var(--primary); font-weight: 700; font-family: var(--font-mono); flex-shrink: 0; }

/* Version badge (N ordini con stesso Number) */
.as-ver-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; background: rgba(200,169,122,0.18); color: var(--primary); border: 1px solid rgba(200,169,122,0.3); border-radius: 10px; font-size: 10px; font-weight: 700; font-family: var(--font-mono); cursor: help; }

/* Warning mini button (segnala) */
.as-mini-warn:hover { background: rgba(251,191,36,0.14); border-color: rgba(251,191,36,0.35); color: #fbbf24; }

/* Toolbar checkbox (raggruppa) */
.as-toolbar-check { display: flex; align-items: center; gap: 6px; padding: 0 10px; font-size: 12px; color: var(--text-muted); cursor: pointer; user-select: none; }
.as-toolbar-check input { accent-color: var(--primary); }

/* Select stato inline nella riga ordini */
.as-stato-sel {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text);
    padding: 3px 8px; border-radius: 6px;
    font-family: inherit; font-size: 11px; font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer; outline: none;
    text-transform: uppercase;
}
.as-stato-sel:hover { border-color: rgba(200,169,122,0.35); }
.as-stato-sel.as-stato-no { background: rgba(74,158,255,0.1); color: #7cb9ff; border-color: rgba(74,158,255,0.3); }
.as-stato-sel.as-stato-mod { background: rgba(251,191,36,0.1); color: #fbbf24; border-color: rgba(251,191,36,0.3); }
.as-stato-sel.as-stato-gok { background: rgba(34,197,94,0.1); color: var(--success); border-color: rgba(34,197,94,0.3); }
.as-stato-sel.as-stato-lav { background: rgba(180,180,180,0.1); color: #ccc; border-color: rgba(180,180,180,0.25); }
.as-stato-sel.as-stato-prod { background: rgba(100,220,180,0.12); color: #8de8c0; border-color: rgba(100,220,180,0.3); }
/* Nuovi stati workflow forno → consegna → pagamento */
.as-stato-sel.as-stato-fs { background: rgba(255,128,40,0.12); color: #ff9d5c; border-color: rgba(255,128,40,0.32); }
.as-stato-sel.as-stato-sok { background: rgba(56,189,248,0.12); color: #7dd3fc; border-color: rgba(56,189,248,0.3); }
.as-stato-sel.as-stato-pc { background: rgba(168,85,247,0.12); color: #c4b5fd; border-color: rgba(168,85,247,0.32); }
.as-stato-sel.as-stato-cons { background: rgba(115,115,115,0.16); color: #d4d4d4; border-color: rgba(115,115,115,0.32); }
.as-stato-sel.as-stato-consp { background: rgba(200,169,122,0.16); color: var(--primary, #c8a97a); border-color: rgba(200,169,122,0.4); font-weight: 700; }
/* Indicatore che lo stato è override manuale (non dal bot) */
.as-stato-sel.as-stato-manual { box-shadow: 0 0 0 2px rgba(200,169,122,0.25); position: relative; }
.as-stato-sel option { background: #0f0f14; color: var(--text); }

/* Riga cestinata */
.as-row-trashed td { opacity: 0.42; text-decoration: line-through; }
.as-row-trashed .as-actions { opacity: 1; text-decoration: none; }
.as-row-trashed .as-actions button { opacity: 1; text-decoration: none; }

/* Mini button "attivo" (per icona nota presente / ripristina da cestino) */
.as-mini-active { background: rgba(200,169,122,0.14); border-color: rgba(200,169,122,0.35); color: var(--primary); }

/* Textarea generica */
.as-textarea { width: 100%; background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.1); color: var(--text); padding: 10px 12px; border-radius: 8px; font-family: inherit; font-size: 13px; line-height: 1.5; resize: vertical; min-height: 80px; outline: none; }
.as-textarea:focus { border-color: rgba(200,169,122,0.4); background: rgba(0,0,0,0.35); }
.as-report-meta { font-size: 12px; color: var(--text-muted); padding: 10px 12px; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.06); border-radius: 8px; line-height: 1.6; }

/* Reports tab */
.as-reports-tab .as-toolbar { margin-bottom: 12px; }
.as-reports-list { display: flex; flex-direction: column; gap: 10px; }
.as-report-card { border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; background: rgba(255,255,255,0.02); overflow: hidden; }
.as-report-open, .as-report-working { border-left: 3px solid var(--primary); }
.as-report-done { border-left: 3px solid var(--success); }
.as-report-error { border-left: 3px solid var(--error); }
.as-report-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 13px; cursor: pointer; user-select: none; }
.as-report-head:hover { background: rgba(255,255,255,0.02); }
.as-report-badge { padding: 2px 8px; border-radius: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.as-report-badge-open { background: rgba(200,169,122,0.15); color: var(--primary); }
.as-report-badge-working { background: rgba(200,169,122,0.25); color: var(--primary); animation: as-pulse 1.5s infinite; }
.as-report-badge-done { background: rgba(34,197,94,0.15); color: var(--success); }
.as-report-badge-error { background: rgba(239,68,68,0.15); color: var(--error); }
.as-report-title { font-weight: 600; color: var(--text); font-family: var(--font-mono); }
.as-report-issue { padding: 0 14px 10px 14px; font-size: 12px; color: var(--text); line-height: 1.4; }
.as-report-detail { padding: 10px 14px 14px 14px; border-top: 1px solid rgba(255,255,255,0.05); background: rgba(0,0,0,0.12); display: flex; flex-direction: column; gap: 10px; }
.as-report-section { font-size: 12px; color: var(--text); line-height: 1.5; }
.as-report-pre { font-family: var(--font-mono); font-size: 11px; white-space: pre-wrap; word-break: break-word; margin: 4px 0 0; padding: 8px 10px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.04); border-radius: 6px; color: var(--text); }
.as-report-learning { padding: 8px 12px; background: rgba(200,169,122,0.08); border: 1px solid rgba(200,169,122,0.2); border-radius: 8px; font-size: 12px; line-height: 1.5; }

/* Bot log tab */
.as-bot-tab { }
.as-bot-runs { display: flex; flex-direction: column; gap: 10px; }
.as-run-card { border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 12px 14px; background: rgba(255,255,255,0.02); }
.as-run-success { border-left: 3px solid var(--success); }
.as-run-error { border-left: 3px solid var(--error); }
.as-run-running { border-left: 3px solid var(--primary); }
.as-run-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.as-run-status { text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; font-size: 11px; color: var(--text); }
.as-run-output { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px; color: var(--text); white-space: pre-wrap; word-break: break-word; line-height: 1.5; max-height: 200px; overflow: auto; padding: 8px 10px; background: rgba(0,0,0,0.25); border-radius: 6px; border: 1px solid rgba(255,255,255,0.04); }

@media (max-width: 760px) {
    .as-panel { margin: 0; border-radius: 0; max-width: none; }
    .as-header { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
    .as-header-stats { order: 3; flex-basis: 100%; margin: 0; gap: 6px; }
    .as-header-bot { order: 4; flex-basis: 100%; margin: 0; padding: 6px 0; border: 0; justify-content: space-between; }
    .as-stat { padding: 4px 8px; min-width: 48px; }
    .as-stat-n { font-size: 14px; }
    .as-body { padding: 12px 14px; }
    .as-table th, .as-table td { padding: 8px 10px; font-size: 12px; }
    .as-tabs { padding: 4px 10px 0; }
    .as-tab { padding: 8px 10px; font-size: 12px; }
    .as-editor-panel { width: 96vw; max-height: 92vh; }
}

/* ═══ Davide / Artstone-only view ══════════════════════════════════════ */
.as-overlay-solo { background: var(--bg); backdrop-filter: none; }
.as-overlay-solo .as-panel { margin: 0; border-radius: 0; max-width: none; border: 0; height: 100vh; height: 100dvh; box-shadow: none; }

.artstone-only-shell {
    min-height: 100vh;
    min-height: 100dvh;
    background: radial-gradient(circle at top, rgba(200,169,122,0.06), transparent 60%), var(--bg);
    display: flex; flex-direction: column;
    font-family: inherit;
}
.artstone-only-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 28px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: rgba(15, 15, 20, 0.6);
    backdrop-filter: blur(6px);
}
.artstone-only-brand { display: flex; align-items: center; gap: 14px; }
.artstone-only-logo {
    width: 46px; height: 46px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 24px;
    background: linear-gradient(135deg, rgba(200,169,122,0.25), rgba(200,169,122,0.08));
    border: 1px solid rgba(200,169,122,0.3);
    border-radius: 12px;
}
.artstone-only-title { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.artstone-only-greet { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.artstone-only-actions { display: flex; gap: 8px; }
.artstone-only-btn {
    padding: 9px 18px; border-radius: 10px;
    background: var(--primary); color: #1a1206; border: 0;
    font-family: inherit; font-size: 13px; font-weight: 700;
    cursor: pointer; transition: filter .15s, transform .12s;
}
.artstone-only-btn:hover { filter: brightness(1.08); }
.artstone-only-btn:active { transform: scale(0.98); }
.artstone-only-btn-ghost {
    background: transparent; color: var(--text-muted);
    border: 1px solid rgba(255,255,255,0.1);
}
.artstone-only-btn-ghost:hover { background: rgba(255,255,255,0.04); color: var(--text); }

.artstone-only-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.artstone-only-hero {
    text-align: center; max-width: 520px;
    padding: 40px 30px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 20px;
}
.artstone-only-hero-icon { font-size: 56px; margin-bottom: 14px; }
.artstone-only-hero-title { font-size: 26px; font-weight: 700; color: var(--text); margin-bottom: 8px; letter-spacing: -0.02em; }
.artstone-only-hero-sub { font-size: 14px; color: var(--text-muted); line-height: 1.55; margin-bottom: 24px; }
.artstone-only-cta {
    padding: 14px 34px;
    background: var(--primary); color: #1a1206; border: 0;
    font-family: inherit; font-size: 15px; font-weight: 700;
    border-radius: 12px; cursor: pointer;
    transition: filter .15s, transform .12s;
    box-shadow: 0 8px 24px rgba(200,169,122,0.25);
}
.artstone-only-cta:hover { filter: brightness(1.1); }
.artstone-only-cta:active { transform: scale(0.98); }

@media (max-width: 620px) {
    .artstone-only-header { padding: 14px 16px; }
    .artstone-only-logo { width: 40px; height: 40px; font-size: 20px; }
    .artstone-only-title { font-size: 14px; }
    .artstone-only-btn { padding: 7px 12px; font-size: 12px; }
    .artstone-only-hero { padding: 28px 18px; }
    .artstone-only-hero-title { font-size: 20px; }
    .artstone-only-hero-icon { font-size: 44px; }
}

/* ===================== Art Stone — Mail tab ===================== */
.as-mail-tab { display: flex; flex-direction: column; min-height: 100%; }
.as-mail-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.as-mail-empty {
    padding: 50px 40px; text-align: center;
    background: rgba(255,255,255,0.02);
    border: 1px dashed rgba(255,255,255,0.08);
    border-radius: 10px; margin: 20px;
}
.as-mail-empty-title { font-size: 14px; font-weight: 600; color: var(--text, #efe6d4); margin-bottom: 8px; }
.as-mail-empty-desc { font-size: 12px; color: rgba(255,255,255,0.5); line-height: 1.5; max-width: 480px; margin: 0 auto; }
.as-mail-row {
    border: 1px solid rgba(255,255,255,0.05);
    background: rgba(255,255,255,0.015);
    border-radius: 8px; overflow: hidden;
    transition: background .12s;
}
.as-mail-row:hover { background: rgba(200,169,122,0.04); }
.as-mail-row-open { background: rgba(200,169,122,0.06); border-color: rgba(200,169,122,0.22); }
.as-mail-head {
    display: grid; grid-template-columns: minmax(170px, 22%) 1fr auto;
    gap: 14px; align-items: center;
    padding: 10px 14px; cursor: pointer; user-select: none;
}
.as-mail-from {
    font-size: 12px; font-weight: 600; color: var(--primary, #c8a97a);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.as-mail-subj {
    font-size: 13px; color: var(--text, #efe6d4);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}
.as-mail-reply {
    display: inline-block; padding: 1px 6px;
    font-size: 10px; font-weight: 700; color: #60a5fa;
    background: rgba(96,165,250,0.12); border: 1px solid rgba(96,165,250,0.3);
    border-radius: 4px; margin-right: 6px;
}
.as-mail-meta { display: flex; gap: 10px; align-items: center; font-size: 11px; color: rgba(255,255,255,0.45); white-space: nowrap; }
.as-mail-date { font-family: var(--font-mono, ui-monospace, monospace); font-size: 10px; }
.as-mail-foto {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 1px 6px; font-weight: 600; color: var(--primary, #c8a97a);
    background: rgba(200,169,122,0.1); border-radius: 10px;
    font-family: var(--font-mono, ui-monospace, monospace);
}
.as-mail-link {
    display: inline-block; padding: 1px 7px;
    font-size: 10px; font-weight: 700; color: #22c55e;
    background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.25);
    border-radius: 10px; text-transform: uppercase; letter-spacing: 0.04em;
}
.as-mail-todo {
    display: inline-block; padding: 1px 7px;
    font-size: 10px; font-weight: 700; color: #f59e0b;
    background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3);
    border-radius: 10px; text-transform: uppercase; letter-spacing: 0.04em;
}
.as-mail-spam {
    display: inline-block; padding: 1px 7px;
    font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px; text-transform: uppercase; letter-spacing: 0.04em;
}
.as-mail-views {
    display: inline-flex; background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.08); border-radius: 8px;
    padding: 2px; gap: 2px;
}
.as-mail-view-btn {
    padding: 6px 12px;
    background: transparent; border: 0;
    color: rgba(255,255,255,0.55);
    font-family: inherit; font-size: 12px; font-weight: 500;
    border-radius: 6px; cursor: pointer;
    transition: background .12s, color .12s;
}
.as-mail-view-btn:hover { color: var(--text, #efe6d4); background: rgba(255,255,255,0.04); }
.as-mail-view-btn-on {
    background: rgba(200,169,122,0.14);
    color: var(--primary, #c8a97a);
    font-weight: 600;
}
.as-mail-foto .as-tool-ico { width: 12px; height: 12px; }
.as-mail-body {
    padding: 0 16px 14px; border-top: 1px solid rgba(255,255,255,0.04);
    background: rgba(0,0,0,0.2);
}
.as-mail-meta-detail {
    display: flex; gap: 18px; flex-wrap: wrap;
    font-size: 11px; color: rgba(255,255,255,0.55);
    padding: 10px 0 8px;
}
.as-mail-meta-detail b { color: rgba(255,255,255,0.8); margin-right: 4px; }
.as-mail-meta-detail code {
    font-family: var(--font-mono, ui-monospace, monospace);
    background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 3px;
    color: rgba(255,255,255,0.65);
}
.as-mail-meta-detail a { color: var(--primary, #c8a97a); text-decoration: none; }
.as-mail-meta-detail a:hover { text-decoration: underline; }
.as-mail-text {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 12px; line-height: 1.5; color: var(--text, #efe6d4);
    background: rgba(0,0,0,0.3); padding: 12px 14px; border-radius: 6px;
    max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word;
    margin: 0; border: 1px solid rgba(255,255,255,0.04);
}

/* ===================== Art Stone — Toolbar azioni (SVG line-style) ===================== */
.as-tool-bar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 14px;
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(26,22,19,0.96), rgba(26,22,19,0.88));
    backdrop-filter: blur(6px);
    border-bottom: 1px solid rgba(200,169,122,0.18);
}
.as-tool-count {
    font-size: 12px; color: rgba(255,255,255,0.6);
    padding: 6px 12px;
    background: rgba(200,169,122,0.08);
    border: 1px solid rgba(200,169,122,0.2);
    border-radius: 6px;
    white-space: nowrap;
}
.as-tool-count b { color: var(--primary, #c8a97a); font-family: var(--font-mono, ui-monospace, monospace); margin: 0 2px; }
.as-tool-btns {
    display: flex; gap: 4px; flex-wrap: wrap; align-items: center;
}
.as-tool-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: rgba(255,255,255,0.75);
    font-family: inherit; font-size: 12px; font-weight: 500;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s, transform .08s;
    user-select: none;
}
.as-tool-btn:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.2);
    color: var(--text, #efe6d4);
}
.as-tool-btn:active { transform: scale(0.97); }
.as-tool-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.as-tool-btn .as-tool-ico { display: inline-flex; width: 16px; height: 16px; }
.as-tool-btn .as-tool-ico svg { display: block; width: 16px; height: 16px; }
.as-tool-btn-primary {
    background: rgba(200,169,122,0.15);
    border-color: rgba(200,169,122,0.45);
    color: var(--primary, #c8a97a);
}
.as-tool-btn-primary:hover {
    background: rgba(200,169,122,0.25);
    border-color: var(--primary, #c8a97a);
    color: var(--primary, #c8a97a);
}
.as-tool-btn-warn { color: #f59e0b; border-color: rgba(245,158,11,0.3); }
.as-tool-btn-warn:hover { background: rgba(245,158,11,0.1); border-color: #f59e0b; color: #f59e0b; }
.as-tool-btn-danger { color: #ef4444; border-color: rgba(239,68,68,0.25); }
.as-tool-btn-danger:hover { background: rgba(239,68,68,0.12); border-color: #ef4444; color: #ef4444; }
.as-tool-btn-active {
    background: rgba(200,169,122,0.18);
    border-color: rgba(200,169,122,0.5);
    color: var(--primary, #c8a97a);
}
.as-tool-spacer { flex: 1; }
.as-tool-state {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    font-size: 11px; color: rgba(255,255,255,0.55);
}
.as-tool-state select {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: var(--text, #efe6d4);
    font-family: inherit; font-size: 12px; font-weight: 600;
    padding: 3px 6px;
    cursor: pointer;
}
@media (max-width: 760px) {
    .as-tool-bar { flex-direction: column; align-items: stretch; gap: 8px; }
    .as-tool-btn .as-tool-lbl { display: none; }
    .as-tool-btn { padding: 8px 10px; }
}

/* ===================== Art Stone — Editor ordini (click riga → stile Danea) ===================== */
.as-row-clickable { cursor: pointer; }
.as-row-clickable:hover td { background: rgba(200,169,122,0.06); }
.as-row-edited { position: relative; }
.as-row-edited td.as-num::before {
    content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
    background: var(--primary, #c8a97a); border-radius: 2px;
}
.as-edit-badge {
    display: inline-block; margin-left: 6px; padding: 1px 6px;
    font-size: 10px; font-weight: 700; font-family: var(--font-mono, ui-monospace, monospace);
    color: var(--primary, #c8a97a);
    background: rgba(200,169,122,0.12);
    border: 1px solid rgba(200,169,122,0.3);
    border-radius: 4px;
}
.as-mini-edit { color: var(--primary, #c8a97a); font-weight: 700; }
.as-mini-edit:hover { background: rgba(200,169,122,0.18); }

.as-editor-overlay {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(8,6,4,0.82); backdrop-filter: blur(8px);
    display: flex; align-items: stretch; justify-content: center;
}
.as-editor-fullpanel {
    width: min(1440px, 96vw); height: 94vh; margin: 3vh auto;
    background: #14110d; color: var(--text, #efe6d4);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(200,169,122,0.04);
    display: flex; flex-direction: column; overflow: hidden;
}
.as-editor-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 24px 16px;
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.as-editor-title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; min-width: 0; }
.as-editor-title-lbl {
    color: rgba(255,255,255,0.4); font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.14em;
}
.as-editor-title-num {
    font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
    color: var(--text, #efe6d4); line-height: 1;
    font-feature-settings: "tnum" 1;
}
.as-editor-title-sub {
    font-size: 11px; font-weight: 500;
    color: rgba(200,169,122,0.65);
    padding: 3px 8px; border-radius: 4px;
    background: rgba(200,169,122,0.08);
    letter-spacing: 0.04em;
}
.as-editor-title-cli {
    font-size: 13px; color: rgba(255,255,255,0.65); font-weight: 500;
    padding: 0; border: none; margin-left: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch;
}
.as-editor-dirty { color: #ef4444; font-size: 20px; line-height: 1; margin-left: 4px; }
.as-editor-edited {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 11px; font-weight: 700; color: var(--primary, #c8a97a);
    background: rgba(200,169,122,0.12);
    border: 1px solid rgba(200,169,122,0.25);
    border-radius: 4px; padding: 2px 6px;
}
.as-editor-actions { display: flex; gap: 10px; }

/* DbTab — stile sobrio allineato a Ordini. Drag-drop avviene su tutta la table-wrap. */
.as-db-tab { display: flex; flex-direction: column; min-height: 100%; }
.as-table-wrap { position: relative; }
.as-table-wrap-drop { outline: 2px dashed rgba(200,169,122,0.45); outline-offset: -2px; }

.as-db-import-banner {
    display: flex; align-items: center; gap: 10px;
    margin: 0 0 8px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px; font-weight: 500;
    border: 1px solid transparent;
}
.as-db-import-busy {
    background: rgba(200,169,122,0.06); border-color: rgba(200,169,122,0.2); color: var(--primary, #c8a97a);
}
.as-db-import-ok {
    background: rgba(34,197,94,0.07); border-color: rgba(34,197,94,0.25); color: rgb(134,239,172);
}
.as-db-import-x {
    margin-left: auto; background: transparent; border: none;
    color: inherit; opacity: 0.6; cursor: pointer;
    font-size: 16px; line-height: 1; padding: 0 4px;
}
.as-db-import-x:hover { opacity: 1; }

.as-db-drop-overlay {
    position: absolute; inset: 0; z-index: 5;
    background: rgba(15,12,10,0.7); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
    border-radius: 12px;
}
.as-db-drop-card {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 26px;
    background: rgba(30,22,18,0.95);
    border: 1px solid rgba(200,169,122,0.45);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.as-db-drop-card b { display: block; font-size: 14px; font-weight: 600; color: var(--text, #efe6d4); }
.as-db-drop-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 48px; height: 48px; border-radius: 12px;
    background: rgba(200,169,122,0.16); color: var(--primary, #c8a97a);
}

/* Asterisco "modificato" stile big-tech */
.as-num-val { display: inline-flex; align-items: baseline; }
.as-num-edited {
    display: inline-block;
    margin-left: 1px;
    color: var(--primary, #c8a97a);
    font-weight: 700;
    font-size: 0.95em;
    line-height: 1;
    cursor: help;
}

/* ===== Tabella ordini — colonne dinamiche, sort, drag&drop ===== */
.as-th-dyn { user-select: none; }
.as-th-sortable { cursor: pointer; transition: color .12s, background .12s; }
.as-th-sortable:hover { color: var(--text, #efe6d4); background: rgba(255,255,255,0.03); }
.as-th-sorted .as-th-lbl { color: var(--primary, #c8a97a); font-weight: 700; }
.as-th-right, .as-cell-right { text-align: right; }
.as-th-dragging { opacity: 0.45; }
.as-th-dyn[draggable="true"] { cursor: grab; }
.as-th-dyn[draggable="true"]:active { cursor: grabbing; }

.as-tipo-chip {
    display: inline-block; padding: 2px 8px;
    font-size: 10px; font-weight: 600; letter-spacing: 0.05em;
    text-transform: uppercase;
    background: rgba(200,169,122,0.08); color: var(--primary, #c8a97a);
    border: 1px solid rgba(200,169,122,0.22); border-radius: 999px;
}

.as-col-picker-wrap { position: relative; display: inline-block; }
.as-col-picker {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 100;
    width: 240px;
    background: #14110d;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    box-shadow: 0 18px 48px rgba(0,0,0,0.55);
    overflow: hidden;
}
.as-col-picker-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.as-col-picker-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
    color: rgba(255,255,255,0.55); font-weight: 600;
}
.as-col-picker-reset {
    background: transparent; border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.6); padding: 3px 8px; border-radius: 5px;
    cursor: pointer; font-size: 11px;
    font-family: inherit;
}
.as-col-picker-reset:hover { color: var(--text, #efe6d4); border-color: rgba(200,169,122,0.4); }
.as-col-picker-list { max-height: 320px; overflow-y: auto; padding: 6px 0; }
.as-col-picker-item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 14px; cursor: pointer; font-size: 13px;
    color: var(--text, #efe6d4);
    transition: background .1s;
}
.as-col-picker-item:hover { background: rgba(255,255,255,0.03); }
.as-col-picker-item input { accent-color: var(--primary, #c8a97a); }
.as-col-picker-item input:disabled + span { color: rgba(255,255,255,0.35); }
.as-col-picker-hint {
    padding: 8px 14px 10px;
    font-size: 11px; color: rgba(255,255,255,0.45);
    border-top: 1px solid rgba(255,255,255,0.06);
    line-height: 1.4;
}

.as-btn-sm {
    padding: 6px 10px; font-size: 12px;
}

/* ===== Coming Soon (WhatsApp tab placeholder) ===== */
.as-comingsoon {
    display: flex; align-items: center; justify-content: center;
    min-height: 60vh; padding: 40px 20px;
}
.as-comingsoon-card {
    max-width: 520px; text-align: center;
    padding: 40px 36px;
    background: rgba(255,255,255,0.018);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 14px;
}
.as-comingsoon-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; border-radius: 16px;
    background: rgba(200,169,122,0.08);
    color: var(--primary, #c8a97a);
    margin: 0 auto 16px;
}
.as-comingsoon-badge {
    display: inline-block;
    padding: 4px 12px; margin-bottom: 14px;
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--primary, #c8a97a);
    background: rgba(200,169,122,0.08);
    border: 1px solid rgba(200,169,122,0.2);
    border-radius: 999px;
}
.as-comingsoon-title {
    margin: 0 0 12px; font-size: 22px; font-weight: 700;
    letter-spacing: -0.015em; color: var(--text, #efe6d4);
}
.as-comingsoon-desc {
    font-size: 13px; line-height: 1.6;
    color: rgba(255,255,255,0.62);
    margin: 0 0 22px;
}
.as-comingsoon-feats {
    list-style: none; padding: 0; margin: 0;
    text-align: left; font-size: 12.5px; line-height: 1.6;
    color: rgba(255,255,255,0.7);
}
.as-comingsoon-feats li {
    padding: 6px 0 6px 22px; position: relative;
}
.as-comingsoon-feats li::before {
    content: ""; position: absolute; left: 0; top: 13px;
    width: 12px; height: 1px; background: var(--primary, #c8a97a);
}

/* ===== Manuale tab (chat composer + cronologia) ===== */
.as-manual-tab { display: flex; flex-direction: column; gap: 22px; }

.as-manual-composer {
    padding: 18px 20px 16px;
    background: rgba(255,255,255,0.018);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    transition: border-color .15s, background .15s;
}
.as-manual-composer-drop {
    border-color: rgba(200,169,122,0.45);
    background: rgba(200,169,122,0.04);
}
.as-manual-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.as-manual-head-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 10px;
    background: rgba(200,169,122,0.1);
    color: var(--primary, #c8a97a);
    flex-shrink: 0;
}
.as-manual-head-title { font-size: 14px; font-weight: 600; color: var(--text, #efe6d4); }
.as-manual-head-sub { font-size: 12px; color: rgba(255,255,255,0.55); margin-top: 2px; line-height: 1.45; }

.as-manual-text {
    width: 100%; box-sizing: border-box;
    padding: 12px 14px; background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.08); border-radius: 10px;
    color: var(--text, #efe6d4);
    font-family: inherit; font-size: 13px; line-height: 1.55;
    resize: vertical; min-height: 120px;
    transition: border-color .15s;
}
.as-manual-text:focus {
    outline: none; border-color: rgba(200,169,122,0.5);
    background: rgba(0,0,0,0.4);
}
.as-manual-text::placeholder {
    color: rgba(255,255,255,0.32); white-space: pre;
    font-size: 12px; line-height: 1.5;
}

.as-manual-files {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 10px;
}
.as-manual-file {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 6px 5px 9px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 999px;
    font-size: 11.5px; color: rgba(255,255,255,0.75);
    max-width: 280px;
}
.as-manual-file-ico { color: var(--primary, #c8a97a); display: inline-flex; }
.as-manual-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.as-manual-file-size { color: rgba(255,255,255,0.45); font-feature-settings: "tnum" 1; font-size: 11px; }
.as-manual-file-x {
    background: rgba(255,255,255,0.06); border: none;
    color: rgba(255,255,255,0.55); cursor: pointer;
    width: 18px; height: 18px; border-radius: 50%;
    line-height: 1; padding: 0; font-size: 14px;
}
.as-manual-file-x:hover:not(:disabled) { background: rgba(239,68,68,0.2); color: #fca5a5; }

.as-manual-actions {
    display: flex; align-items: center; gap: 12px;
    margin-top: 14px;
}
.as-manual-attach { cursor: pointer; }
.as-manual-hint { font-size: 11px; }

.as-manual-flash {
    margin-top: 12px; padding: 10px 14px;
    border-radius: 8px; font-size: 12.5px; font-weight: 500;
    border: 1px solid transparent;
}
.as-manual-flash-ok {
    background: rgba(34,197,94,0.07); border-color: rgba(34,197,94,0.25);
    color: rgb(134,239,172);
}
.as-manual-flash-err {
    background: rgba(239,68,68,0.07); border-color: rgba(239,68,68,0.25);
    color: rgb(252,165,165);
}

.as-manual-history {}
.as-manual-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.as-manual-card {
    background: rgba(255,255,255,0.018);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px; overflow: hidden;
}
.as-manual-card-head {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; cursor: pointer;
    font-size: 12.5px;
}
.as-manual-card-head:hover { background: rgba(255,255,255,0.02); }
.as-manual-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: rgba(255,255,255,0.3); flex-shrink: 0;
}
.as-manual-dot-ok { background: rgb(34,197,94); }
.as-manual-dot-err { background: rgb(239,68,68); }
.as-manual-dot-run { background: rgb(251,191,36); animation: as-pulse 1.4s ease-in-out infinite; }
@keyframes as-pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.as-manual-card-id {
    font-feature-settings: "tnum" 1;
    font-size: 12px; color: rgba(255,255,255,0.55);
    font-weight: 600; min-width: 36px;
}
.as-manual-card-snippet {
    color: var(--text, #efe6d4);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; min-width: 0;
}
.as-manual-card-pill {
    padding: 2px 8px; font-size: 10px; font-weight: 600;
    background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.65);
    border: 1px solid rgba(255,255,255,0.08); border-radius: 999px;
    font-feature-settings: "tnum" 1;
    white-space: nowrap;
}
.as-manual-card-pill-ai {
    background: rgba(139,92,246,0.08); color: rgb(196,181,253);
    border-color: rgba(139,92,246,0.25);
}
.as-manual-card-body { padding: 12px 16px 16px; border-top: 1px solid rgba(255,255,255,0.04); }
.as-manual-section { margin-bottom: 12px; }
.as-manual-section-lbl {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
    color: rgba(255,255,255,0.42); font-weight: 600; margin-bottom: 6px;
}
.as-manual-pre {
    margin: 0; padding: 10px 12px;
    background: rgba(0,0,0,0.2); border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.04);
    font-family: inherit; font-size: 12.5px; line-height: 1.5;
    color: rgba(255,255,255,0.78);
    white-space: pre-wrap; word-break: break-word;
}
.as-manual-report {
    padding: 10px 12px;
    background: rgba(255,255,255,0.02); border-radius: 6px;
    border-left: 2px solid var(--primary, #c8a97a);
    font-size: 12.5px; line-height: 1.55;
    color: rgba(255,255,255,0.78);
}
.as-manual-section-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .as-manual-section-row { grid-template-columns: 1fr; } }
.as-manual-mini {}
.as-manual-mini-lbl {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
    color: rgba(255,255,255,0.42); font-weight: 600; margin-bottom: 6px;
}
.as-manual-mini-val { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.as-link { color: var(--primary, #c8a97a); text-decoration: none; }
.as-link:hover { text-decoration: underline; }
.as-manual-draft-thumb {
    display: block; max-width: 100%; max-height: 240px;
    border-radius: 8px; cursor: zoom-in;
    border: 1px solid rgba(255,255,255,0.08);
}
.as-manual-error {
    margin-top: 10px; padding: 10px 12px;
    background: rgba(239,68,68,0.07); border: 1px solid rgba(239,68,68,0.25);
    border-radius: 6px; color: rgb(252,165,165); font-size: 12px;
}

/* ===== Overview / Riepilogo commessa ===== */
.as-overview { display: flex; flex-direction: column; gap: 14px; padding: 8px 0 24px; }
.as-ov-step {
    background: rgba(255,255,255,0.018);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px; overflow: hidden;
}
.as-ov-step-head {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px 12px;
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.as-ov-step-n {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px;
    background: transparent; color: rgba(255,255,255,0.32);
    font-weight: 600; font-size: 11px;
    font-feature-settings: "tnum" 1;
    letter-spacing: 0.04em;
    border-radius: 0;
}
.as-ov-step-title {
    flex: 1; font-weight: 600;
    color: var(--text, #efe6d4); font-size: 13px;
    letter-spacing: -0.005em;
}
.as-ov-step-badge {
    padding: 3px 8px; font-size: 10px; font-weight: 600;
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.55);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 999px;
    font-feature-settings: "tnum" 1;
}
.as-ov-step-body { padding: 16px 20px 18px; }
.as-ov-empty { padding: 12px; font-style: italic; color: rgba(255,255,255,0.45); font-size: 12px; text-align: center; }

/* Email origin */
.as-ov-email {}
.as-ov-email-head {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    font-size: 11px; color: rgba(255,255,255,0.5);
    margin-bottom: 6px;
}
.as-ov-email-from { color: var(--text, #efe6d4); font-weight: 600; font-size: 12px; }
.as-ov-email-date {
    color: rgba(255,255,255,0.4); font-size: 11px;
    font-feature-settings: "tnum" 1;
}
.as-ov-email-subj {
    font-size: 13px; font-weight: 600; color: var(--text, #efe6d4);
    margin-bottom: 12px; letter-spacing: -0.005em;
}
.as-ov-email-body {
    font-family: inherit;
    font-size: 13px; line-height: 1.6;
    color: rgba(255,255,255,0.78);
    background: rgba(0,0,0,0.18);
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.04);
    max-height: 240px; overflow: auto;
    white-space: pre-wrap; word-break: break-word;
    margin: 0;
}

/* Riepilogo summary */
.as-ov-summary {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 24px;
}
.as-ov-sum-col { min-width: 0; }
.as-ov-sum-lbl {
    font-size: 10px; color: rgba(255,255,255,0.42);
    text-transform: uppercase; letter-spacing: 0.1em;
    font-weight: 600; margin-bottom: 8px;
}
.as-ov-sum-big {
    display: flex; align-items: baseline; gap: 6px;
    font-feature-settings: "tnum" 1;
}
.as-ov-sum-num {
    font-size: 22px; font-weight: 700;
    color: var(--text, #efe6d4); letter-spacing: -0.025em;
    line-height: 1;
}
.as-ov-sum-sez {
    font-size: 12px; color: rgba(255,255,255,0.45); font-weight: 500;
    letter-spacing: 0.02em;
}
.as-ov-sum-code {
    font-size: 13px; font-weight: 600;
    color: var(--text, #efe6d4);
    letter-spacing: 0.02em; line-height: 1;
    padding: 4px 9px; background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08); border-radius: 6px;
    display: inline-block;
    font-feature-settings: "tnum" 1;
}
.as-ov-sum-name {
    font-size: 12px; color: rgba(255,255,255,0.7); font-weight: 500;
    margin-top: 8px; line-height: 1.35;
}
.as-ov-sum-rif {
    font-size: 14px; font-weight: 600;
    color: var(--text, #efe6d4);
    text-transform: none; line-height: 1.25;
    letter-spacing: -0.005em;
}
.as-ov-sum-prod { font-size: 12px; color: var(--text, #efe6d4); line-height: 1.4; }
.as-ov-sum-sub { font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 4px; }
.as-ov-sum-sub b { color: var(--text, #efe6d4); font-weight: 500; }
.as-ov-sum-chip {
    display: inline-block; margin-top: 6px;
    padding: 2px 8px; font-size: 9.5px; font-weight: 600;
    background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.6);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 999px; text-transform: uppercase; letter-spacing: 0.07em;
}
.as-ov-sum-col-tot { text-align: right; }
.as-ov-sum-tot {
    font-size: 22px; font-weight: 700;
    color: var(--primary, #c8a97a);
    line-height: 1;
    letter-spacing: -0.025em;
    font-feature-settings: "tnum" 1;
}
@media (max-width: 1000px) {
    .as-ov-summary { grid-template-columns: 1fr 1fr; }
}

/* Foto gallery */
.as-ov-photos {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}
.as-ov-photo {
    margin: 0;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px; overflow: hidden;
    transition: transform .12s, border-color .12s;
}
.as-ov-photo:hover { transform: translateY(-2px); border-color: rgba(200,169,122,0.3); }
.as-ov-photo img {
    display: block; width: 100%; aspect-ratio: 1; object-fit: cover;
    cursor: zoom-in; background: #14110d;
}
.as-ov-photo figcaption {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 8px; font-size: 10.5px; color: rgba(255,255,255,0.6);
    background: rgba(0,0,0,0.3); gap: 6px;
}
.as-ov-photo-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-family: var(--font-mono, ui-monospace, monospace); font-size: 10px; }
.as-ov-photo-dl {
    color: var(--primary, #c8a97a); text-decoration: none;
    padding: 2px 8px; border-radius: 4px; background: rgba(200,169,122,0.12);
    font-weight: 700;
}
.as-ov-photo-dl:hover { background: rgba(200,169,122,0.25); }
.as-ov-photo-ai { border-color: rgba(139,92,246,0.3); }
.as-ov-photo-ai:hover { border-color: rgba(139,92,246,0.6); }

/* Istruzioni */
.as-ov-instr { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.as-ov-instr li {
    padding: 8px 12px; font-size: 12px; line-height: 1.4;
    background: rgba(0,0,0,0.2); border-radius: 6px;
    border-left: 2px solid rgba(200,169,122,0.35);
    color: var(--text, #efe6d4);
}
.as-ov-instr-src {
    display: inline-block; margin-right: 8px;
    padding: 1px 7px; font-size: 9.5px; font-weight: 700;
    background: rgba(200,169,122,0.12); color: var(--primary, #c8a97a);
    border-radius: 4px; text-transform: uppercase; letter-spacing: 0.05em;
    font-family: var(--font-mono, ui-monospace, monospace);
}

/* AI Generate */
.as-ov-ai { display: flex; flex-direction: column; gap: 10px; }
.as-ov-ai-hint {
    font-size: 11.5px; line-height: 1.5; color: rgba(255,255,255,0.55);
    padding: 10px 12px; background: rgba(139,92,246,0.05);
    border: 1px solid rgba(139,92,246,0.15); border-radius: 6px;
}
.as-ov-ai-hint b { color: var(--text, #efe6d4); }
.as-ov-ai-instr {
    padding: 8px 12px;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: var(--text, #efe6d4);
    font-family: inherit; font-size: 12px; line-height: 1.4;
    resize: vertical;
}
.as-ov-ai-instr:focus { outline: none; border-color: var(--primary, #c8a97a); background: rgba(0,0,0,0.5); }
.as-ov-ai-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.as-ov-ai-results-lbl {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
    font-weight: 700; color: var(--primary, #c8a97a);
    margin: 10px 0 6px;
}

/* Lightbox */
.as-lightbox {
    position: fixed; inset: 0; z-index: 20000;
    background: rgba(0,0,0,0.9);
    display: flex; align-items: center; justify-content: center;
    padding: 40px;
    cursor: zoom-out;
}
.as-lightbox img {
    max-width: 95%; max-height: 90vh;
    object-fit: contain; border-radius: 6px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.5);
    cursor: auto;
}
.as-lightbox-close {
    position: absolute; top: 20px; right: 24px;
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(0,0,0,0.7); color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 18px; cursor: pointer;
}
.as-lightbox-close:hover { background: rgba(255,255,255,0.15); }
.as-lightbox-dl {
    position: absolute; bottom: 24px; right: 24px;
    padding: 10px 18px;
    background: var(--primary, #c8a97a); color: #14110d;
    border-radius: 999px; text-decoration: none;
    font-size: 13px; font-weight: 700;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.as-lightbox-dl:hover { filter: brightness(1.08); }

.as-ed-tabs {
    display: flex; gap: 0; flex-wrap: wrap;
    padding: 0 18px;
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.as-ed-tab {
    padding: 14px 18px 12px;
    background: transparent; border: 0;
    color: rgba(255,255,255,0.5);
    font-family: inherit; font-size: 13px; font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
    letter-spacing: -0.005em;
}
.as-ed-tab:hover { color: var(--text, #efe6d4); }
.as-ed-tab-on {
    color: var(--text, #efe6d4);
    border-bottom-color: var(--primary, #c8a97a);
    font-weight: 600;
    background: transparent;
}

.as-ed-autocomplete-wrap { position: relative; padding: 10px 14px 6px; }
.as-ed-autocomplete-input {
    width: 100%; padding: 10px 14px;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(200,169,122,0.3);
    border-radius: 8px;
    color: var(--text, #efe6d4);
    font-family: inherit; font-size: 13px;
    transition: border-color .12s;
}
.as-ed-autocomplete-input:focus {
    outline: none;
    border-color: var(--primary, #c8a97a);
    background: rgba(0,0,0,0.5);
}
.as-ed-autocomplete-input::placeholder { color: rgba(255,255,255,0.35); }
.as-ed-autocomplete-list {
    position: absolute; left: 14px; right: 14px; top: calc(100% - 0px);
    z-index: 50;
    background: #1a1613; border: 1px solid rgba(200,169,122,0.3);
    border-radius: 8px; box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    max-height: 380px; overflow-y: auto;
    margin-top: -2px;
}
.as-ed-autocomplete-item {
    display: grid; grid-template-columns: 70px 1fr;
    gap: 10px; padding: 8px 12px;
    cursor: pointer; font-size: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.as-ed-autocomplete-item:hover { background: rgba(200,169,122,0.1); }
.as-ed-autocomplete-item:last-child { border-bottom: 0; }
.as-ed-ac-cod {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 11px; font-weight: 700; color: var(--primary, #c8a97a);
    padding-top: 2px;
}
.as-ed-ac-main { min-width: 0; }
.as-ed-ac-name {
    color: var(--text, #efe6d4); font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.as-ed-ac-sub {
    color: rgba(255,255,255,0.45); font-size: 11px; margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.as-ed-row-code-cell { position: relative; overflow: visible !important; }
.as-ed-row-ac {
    position: absolute; left: 0; right: -340px; top: 100%;
    max-width: 480px; max-height: 300px;
    z-index: 40; margin-top: 2px;
}

.as-editor-loading, .as-editor-error {
    padding: 40px; text-align: center; font-size: 14px;
    color: rgba(255,255,255,0.6);
}
.as-editor-error { color: #ef4444; }

.as-editor-scroll {
    flex: 1 1 auto; overflow-y: auto; padding: 18px 22px 30px;
}
.as-ed-sec {
    margin-bottom: 22px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    background: rgba(255,255,255,0.015);
    overflow: hidden;
}
.as-ed-sec-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 14px;
    font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700;
    color: var(--primary, #c8a97a);
    background: rgba(200,169,122,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.as-ed-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px 14px;
    padding: 14px;
}
.as-ed-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.as-ed-field-wide { grid-column: span 2; }
.as-ed-field > span {
    font-size: 11px; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.05em;
}
.as-ed-field input, .as-ed-field textarea {
    padding: 8px 10px;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: var(--text, #efe6d4);
    font-family: inherit; font-size: 13px;
    transition: border-color .12s, background .12s;
    min-width: 0;
}
.as-ed-field textarea { resize: vertical; font-family: inherit; line-height: 1.4; }
.as-ed-field input:focus, .as-ed-field textarea:focus {
    outline: none;
    border-color: var(--primary, #c8a97a);
    background: rgba(0,0,0,0.5);
}

.as-ed-rows-wrap { padding: 6px 10px 14px; overflow-x: auto; }
.as-ed-rows { width: 100%; border-collapse: collapse; font-size: 12px; }
.as-ed-rows thead th {
    text-align: left; padding: 8px 6px;
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700;
    color: rgba(255,255,255,0.5);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.as-ed-rows tbody td { padding: 4px 4px; vertical-align: middle; }
.as-ed-rows tbody tr + tr td { border-top: 1px dashed rgba(255,255,255,0.04); }
.as-ed-rows input {
    width: 100%; padding: 6px 8px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 5px;
    color: var(--text, #efe6d4);
    font-family: inherit; font-size: 12px;
}
.as-ed-rows input:focus {
    outline: none;
    border-color: var(--primary, #c8a97a);
    background: rgba(0,0,0,0.45);
}
.as-ed-row-n {
    font-family: var(--font-mono, ui-monospace, monospace);
    color: rgba(255,255,255,0.35);
    text-align: center; font-size: 11px;
}
.as-ed-row-tot {
    font-family: var(--font-mono, ui-monospace, monospace);
    color: var(--primary, #c8a97a);
    text-align: right; padding-right: 10px !important; font-weight: 700;
}
.as-ed-empty { text-align: center; padding: 24px; color: rgba(255,255,255,0.4); font-style: italic; }
.as-ed-row-notes-r td { padding-top: 0 !important; padding-bottom: 6px !important; border-top: 0 !important; }
.as-ed-row-notes-r-dim .as-ed-row-notes { opacity: 0.55; }
.as-ed-row-notes-r-dim .as-ed-row-notes:focus { opacity: 1; }
.as-ed-row-notes { font-size: 11px !important; font-style: italic; }

.as-ed-totals-sec .as-ed-sec-head { background: rgba(200,169,122,0.08); }
.as-ed-totals {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 14px;
}
.as-ed-tot-box {
    display: flex; flex-direction: column; gap: 4px;
    padding: 10px 14px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
}
.as-ed-tot-box span { font-size: 11px; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.05em; }
.as-ed-tot-box b { font-family: var(--font-mono, ui-monospace, monospace); font-size: 18px; color: var(--text, #efe6d4); }
.as-ed-tot-grand { background: rgba(200,169,122,0.1); border-color: rgba(200,169,122,0.3); }
.as-ed-tot-grand b { color: var(--primary, #c8a97a); font-size: 22px; }

.as-editor-foot-info {
    padding: 10px 14px;
    font-size: 11px; color: rgba(255,255,255,0.35);
    border-top: 1px solid rgba(255,255,255,0.05);
    background: rgba(0,0,0,0.15);
}
.as-editor-foot-info code {
    font-family: var(--font-mono, ui-monospace, monospace);
    color: rgba(255,255,255,0.55);
    padding: 1px 5px; background: rgba(0,0,0,0.3); border-radius: 3px;
}

.as-btn-sm { padding: 4px 10px !important; font-size: 11px !important; }

@media (max-width: 860px) {
    .as-editor-fullpanel { width: 100vw; height: 100vh; height: 100dvh; margin: 0; border-radius: 0; border: 0; }
    .as-ed-grid { grid-template-columns: 1fr; }
    .as-ed-field-wide { grid-column: span 1; }
    .as-ed-totals { grid-template-columns: 1fr; }
    .as-ed-rows { font-size: 11px; }
}

/* ===== editor: checkbox field + sezioni collapsible + row dettaglio + email viewer ===== */
.as-ed-field-check {
    flex-direction: row; align-items: center; gap: 8px; padding: 8px 0;
}
.as-ed-field-check input[type=checkbox] {
    width: 16px; height: 16px; accent-color: var(--primary, #c8a97a); margin: 0;
}
.as-ed-field-check > span {
    font-size: 12px; color: var(--text, #efe6d4);
    text-transform: none; letter-spacing: 0;
}

.as-ed-sec-coll .as-ed-sec-head-click { cursor: pointer; user-select: none; }
.as-ed-sec-coll .as-ed-sec-head-click:hover { background: rgba(200,169,122,0.1); }
.as-ed-caret {
    display: inline-block; width: 12px; font-size: 10px; color: rgba(255,255,255,0.55);
    margin-right: 2px;
}
.as-ed-sec-hint { font-size: 11px; color: rgba(255,255,255,0.4); text-transform: none; letter-spacing: 0; font-weight: 400; }
.as-ed-sec select {
    padding: 8px 10px; background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.08); border-radius: 6px;
    color: var(--text, #efe6d4); font-family: inherit; font-size: 13px;
}
.as-ed-sec select:focus { outline: none; border-color: var(--primary, #c8a97a); }

.as-ed-tot-hint {
    padding: 0 14px 14px; font-size: 11px; color: rgba(255,255,255,0.4); line-height: 1.5;
}

.as-ed-rows .as-ed-row-notes-r > td { vertical-align: middle; }
.as-ed-row-stock {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; color: rgba(255,255,255,0.55); margin-right: 8px;
    cursor: pointer;
}
.as-ed-row-stock input[type=checkbox] {
    width: 14px; height: 14px; accent-color: var(--primary, #c8a97a); margin: 0;
}
.as-ed-row-commission, .as-ed-row-disc {
    display: inline-block !important; width: auto !important;
    min-width: 70px; max-width: 140px;
    font-size: 11px !important;
}
.as-ed-row-commission { max-width: 60px; }

/* Email viewer */
.as-ed-emails { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.as-ed-email {
    border: 1px solid rgba(255,255,255,0.08); border-radius: 8px;
    background: rgba(0,0,0,0.2); overflow: hidden;
}
.as-ed-email[open] { border-color: rgba(200,169,122,0.2); }
.as-ed-email-sum {
    display: grid; grid-template-columns: minmax(140px, 1fr) 2fr auto; gap: 12px;
    padding: 10px 14px; cursor: pointer; user-select: none; font-size: 12px;
    align-items: center;
}
.as-ed-email-sum:hover { background: rgba(255,255,255,0.03); }
.as-ed-email-sum::-webkit-details-marker { display: none; }
.as-ed-email-from { color: var(--primary, #c8a97a); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-ed-email-subj { color: var(--text, #efe6d4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-ed-email-date { color: rgba(255,255,255,0.45); font-size: 11px; font-family: var(--font-mono, ui-monospace, monospace); }
.as-ed-email-body {
    padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.15);
}
.as-ed-email-meta {
    display: flex; gap: 16px; flex-wrap: wrap;
    font-size: 11px; color: rgba(255,255,255,0.6);
    margin-bottom: 10px;
}
.as-ed-email-meta b { color: rgba(255,255,255,0.8); margin-right: 4px; }
.as-ed-email-meta code {
    font-family: var(--font-mono, ui-monospace, monospace);
    background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 3px;
    color: rgba(255,255,255,0.55);
}
.as-ed-email-meta a { color: var(--primary, #c8a97a); text-decoration: none; }
.as-ed-email-meta a:hover { text-decoration: underline; }
.as-ed-email-text {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 12px; line-height: 1.5; color: var(--text, #efe6d4);
    background: rgba(0,0,0,0.3); padding: 10px 12px; border-radius: 6px;
    max-height: 300px; overflow: auto; white-space: pre-wrap; word-break: break-word;
    margin: 0; border: 1px solid rgba(255,255,255,0.04);
}
.as-ed-email-empty {
    padding: 20px; text-align: center; font-size: 12px;
    color: rgba(255,255,255,0.5); font-style: italic;
}
.as-ed-email-err { color: #ef4444; font-style: normal; }

@media (max-width: 860px) {
    .as-ed-email-sum { grid-template-columns: 1fr; gap: 4px; }
    .as-ed-email-date { font-size: 10px; }
}


/* ════════════════════════════════════════════════════════════════════════
   MOBILE — Davide deve poter lavorare dal telefono in modo impeccabile.
   Breakpoints: 720px (mobile), 1024px (tablet). Touch-target min 44×44.
   Tabella ordini → card view su mobile. Bottom-sheet pattern dove utile.
   Safe-area inset per notch iOS. Font input ≥ 16px per evitare auto-zoom.
   ════════════════════════════════════════════════════════════════════════ */

/* === Base mobile: previeni auto-zoom su input iOS, safe area === */
@media (max-width: 720px) {
    :root { --as-mobile-pad: 14px; }

    /* iOS auto-zooma se input < 16px → forza min 16 su tutti i campi */
    input, textarea, select { font-size: 16px !important; }

    /* Tap target minimi (Apple HIG) */
    button, .as-btn, .as-mini, .as-tab, .as-nav-group { min-height: 38px; }

    body { -webkit-tap-highlight-color: rgba(200, 169, 122, 0.15); }
    button, .as-btn, .as-mini, .as-tab, .as-nav-group, .as-row-clickable, .as-stato-sel, .as-tool-btn {
        touch-action: manipulation; /* previene 300ms delay e double-tap zoom su UI */
    }

    /* Pannello dashboard a tutto schermo */
    .as-overlay { padding: 0; }
    .as-overlay-solo .as-panel,
    .as-overlay .as-panel {
        width: 100vw; max-width: 100vw;
        margin: 0; border-radius: 0;
        height: 100vh; height: 100dvh;
        border: 0;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* === Header mobile: stack verticale, logo prominente, stats compatte === */
    .as-header {
        flex-direction: column; align-items: stretch;
        gap: 14px; padding: 14px var(--as-mobile-pad);
    }
    .as-header-brand {
        gap: 12px; align-items: center;
    }
    .as-logo-img { height: 40px; }
    .as-header-meta {
        padding-left: 12px;
        flex: 1; min-width: 0;
    }
    .as-header-eyebrow { font-size: 9px; letter-spacing: 0.12em; }
    .as-header-titletag { font-size: 13px; }
    .as-header-right {
        margin-left: 0; gap: 12px;
        justify-content: space-between; flex-wrap: wrap;
    }
    .as-header-stats {
        gap: 12px; width: 100%;
        justify-content: space-between;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
    }
    .as-header-stats::-webkit-scrollbar { display: none; }
    .as-stat { flex: 1; min-width: 56px; }
    .as-stat-n { font-size: 20px; }
    .as-stat-l { font-size: 9px; letter-spacing: 0.1em; margin-top: 2px; }
    .as-stat-divider { display: none; }
    .as-header-bot {
        margin-left: 0; padding: 4px 0;
        border: 0; flex: 1; min-width: 0;
        justify-content: space-between;
    }
    .as-bot-meta { min-width: 0; }
    .as-bot-line, .as-bot-sub {
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .as-close { width: 36px; height: 36px; }

    /* === Nav mobile: scroll-snap orizzontale, tab più larghi === */
    .as-nav-groups {
        padding: 0 var(--as-mobile-pad);
        flex-wrap: nowrap; overflow-x: auto;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }
    .as-nav-groups::-webkit-scrollbar { display: none; }
    .as-nav-group {
        padding: 12px 14px;
        font-size: 11px; letter-spacing: 0.08em;
        scroll-snap-align: start;
        flex-shrink: 0;
    }
    .as-tabs {
        padding: 0 var(--as-mobile-pad);
        flex-wrap: nowrap; overflow-x: auto;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }
    .as-tabs::-webkit-scrollbar { display: none; }
    .as-tab {
        padding: 12px 14px;
        scroll-snap-align: start;
        flex-shrink: 0; min-height: 44px;
    }

    /* === Body mobile: padding ridotto === */
    .as-body { padding: 14px var(--as-mobile-pad); }

    /* === Toolbar mobile: search full + filtri impilati === */
    .as-toolbar {
        flex-wrap: wrap; gap: 8px;
    }
    .as-search { flex: 1 1 100%; min-width: 0; }
    .as-select { flex: 1 1 auto; min-width: 0; max-width: 100%; }
    .as-toolbar-spacer { display: none; }
    .as-toolbar-info {
        flex: 1 1 100%;
        text-align: right; font-size: 11px;
        order: 99;
    }
    .as-toolbar-check { padding: 0 6px; font-size: 12px; }

    /* === Analytics ordine: comprime === */
    .as-analytics-toggle { padding: 10px var(--as-mobile-pad); font-size: 12px; }
    .as-analytics-cols { grid-template-columns: 1fr !important; gap: 12px; }
    .as-chart { gap: 4px; }

    /* === TABELLA ORDINI → CARD VIEW (mobile) === */
    .as-table-wrap { border: 0; border-radius: 0; overflow: visible; }
    .as-table { display: block; }
    .as-table thead { display: none; } /* Header colonne invisibile su mobile */
    .as-table tbody { display: block; }
    .as-table tbody tr {
        display: grid; grid-template-columns: 1fr;
        background: rgba(255,255,255,0.02);
        border: 1px solid rgba(255,255,255,0.06);
        border-radius: 12px; margin-bottom: 10px;
        padding: 12px 14px; gap: 6px;
    }
    .as-table tbody tr:hover { background: rgba(200,169,122,0.04); }
    .as-table tbody tr.as-row-edited {
        border-left: 3px solid var(--primary, #c8a97a);
    }
    .as-table tbody tr.as-row-trashed { opacity: 0.5; }
    .as-table tbody td {
        display: block; border: 0; padding: 0;
        white-space: normal;
    }
    /* Sopra etichetta colonna come label tiny per le card */
    .as-table tbody td::before {
        content: attr(data-col-label);
        display: block;
        font-size: 9px; font-weight: 600; letter-spacing: 0.1em;
        text-transform: uppercase;
        color: rgba(255,255,255,0.4);
        margin-bottom: 2px;
    }
    /* Cliente in evidenza nella card */
    .as-table tbody td.as-cli .as-cli-name {
        font-size: 14px; font-weight: 600; color: var(--text, #efe6d4);
    }
    .as-table tbody td.as-cli .as-cli-cod { font-size: 11px; }
    /* Numero ordine come accent gold piccolo */
    .as-table tbody td.as-num {
        position: absolute; top: 12px; right: 14px;
        font-size: 13px; color: var(--primary, #c8a97a); font-weight: 700;
        padding: 0; background: transparent;
    }
    .as-table tbody td.as-num::before { display: none; }
    .as-table tbody tr { position: relative; padding-right: 80px; }
    /* Stato select inline grande */
    .as-table tbody td .as-stato-sel {
        width: auto; min-width: 100px;
    }
    /* Right-aligned celle: torna a sinistra su mobile */
    .as-table tbody td.as-cell-right { text-align: left; }

    /* === Bulk bar: stack verticale, full width === */
    .as-bulk-bar {
        flex-direction: column; align-items: stretch;
        position: sticky; bottom: 12px; z-index: 50;
        margin: 0 calc(-1 * var(--as-mobile-pad));
        border-radius: 0;
    }

    /* === Editor modal a tutto schermo mobile === */
    .as-editor-overlay { padding: 0; }
    .as-editor-fullpanel {
        width: 100vw; max-width: 100vw;
        height: 100vh; height: 100dvh;
        margin: 0; border-radius: 0; border: 0;
    }
    .as-editor-topbar {
        padding: 12px var(--as-mobile-pad) 10px;
        flex-wrap: wrap; gap: 8px;
    }
    .as-editor-title { gap: 8px; min-width: 0; }
    .as-editor-title-num { font-size: 22px; }
    .as-editor-title-cli { max-width: 100%; font-size: 12px; }
    .as-editor-actions {
        gap: 6px; flex: 1 1 100%;
        justify-content: flex-end;
    }
    .as-ed-tabs {
        padding: 0 var(--as-mobile-pad);
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }
    .as-ed-tabs::-webkit-scrollbar { display: none; }
    .as-ed-tab {
        padding: 12px 14px;
        font-size: 12px;
        scroll-snap-align: start;
        flex-shrink: 0;
    }
    .as-editor-scroll { padding: 12px var(--as-mobile-pad); }

    /* === Riepilogo summary 5 col → 2 col su mobile (era già 2) === */
    .as-ov-summary { grid-template-columns: 1fr 1fr !important; gap: 14px; }
    .as-ov-step-head { padding: 12px 14px 10px; }
    .as-ov-step-body { padding: 12px 14px 14px; }
    .as-ov-photos { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }

    /* === Manuale tab mobile === */
    .as-manual-composer { padding: 14px var(--as-mobile-pad); }
    .as-manual-head { flex-direction: column; gap: 8px; }
    .as-manual-text { min-height: 100px; font-size: 14px; }
    .as-manual-actions {
        flex-wrap: wrap; gap: 8px;
    }
    .as-manual-actions .as-toolbar-spacer { display: none; }
    .as-manual-attach { flex: 1; }
    .as-manual-actions .as-btn-primary { flex: 1; min-width: 140px; }
    .as-manual-hint { display: none; }
    .as-manual-section-row { grid-template-columns: 1fr; }
    .as-manual-card-snippet { display: none; }
    .as-manual-card-head { gap: 8px; padding: 10px 14px; }

    /* === Coming soon mobile === */
    .as-comingsoon { padding: 24px var(--as-mobile-pad); min-height: 50vh; }
    .as-comingsoon-card { padding: 30px 22px; }
    .as-comingsoon-icon { width: 56px; height: 56px; }
    .as-comingsoon-title { font-size: 20px; }
    .as-comingsoon-desc { font-size: 13px; }
    .as-comingsoon-feats { font-size: 12.5px; }

    /* === Db tab (clienti/prodotti) mobile === */
    .as-db-tab .as-table tbody td.as-cell-key {
        position: absolute; top: 12px; right: 14px;
        font-size: 13px; color: var(--primary, #c8a97a); font-weight: 700;
        padding: 0;
    }
    .as-db-tab .as-table tbody td.as-cell-key::before { display: none; }
    .as-db-tab .as-table tbody tr { padding-right: 80px; }
    .as-db-tab .as-actions { display: flex; justify-content: flex-end; }

    /* === Reports tab mobile === */
    .as-report-card { margin-bottom: 8px; }
    .as-report-head { flex-wrap: wrap; gap: 6px; padding: 10px 12px; }

    /* === Mail tab mobile === */
    .as-mail-list .as-mail-item {
        flex-direction: column; align-items: stretch; gap: 4px;
    }

    /* === Col picker → bottom sheet su mobile === */
    .as-col-picker {
        position: fixed;
        top: auto; bottom: 0; left: 0; right: 0;
        width: 100vw;
        border-radius: 16px 16px 0 0;
        max-height: 70vh;
        z-index: 9999;
        animation: as-sheet-up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .as-col-picker::before {
        content: ""; display: block;
        width: 36px; height: 4px; border-radius: 999px;
        background: rgba(255,255,255,0.2);
        margin: 8px auto 4px;
    }
    .as-col-picker-list { max-height: calc(70vh - 130px); }
    @keyframes as-sheet-up {
        from { transform: translateY(100%); opacity: 0.4; }
        to   { transform: translateY(0);    opacity: 1; }
    }
    /* Backdrop quando picker aperto su mobile */
    body.as-dash-open .as-col-picker-wrap .as-col-picker::after {
        content: ""; position: fixed; inset: 0;
        background: rgba(0,0,0,0.5); z-index: -1;
        pointer-events: none;
    }

    /* === Login page artstone mobile === */
    .panel { padding: 32px 24px !important; }

    /* === Lightbox foto mobile === */
    .as-lightbox { padding: 16px; }
    .as-lightbox-close { top: env(safe-area-inset-top, 16px); right: 16px; }
    .as-lightbox-dl { bottom: calc(env(safe-area-inset-bottom, 16px) + 8px); right: 16px; }

    /* === Filter tab mail (Tutte/Da lavorare/Con ordine) === */
    .as-filter-pills { flex-wrap: wrap; gap: 6px; }
    .as-filter-pill { padding: 8px 12px; font-size: 12px; }

    /* === Drag&drop colonne disabilitato su mobile (touch confonde) === */
    .as-th-dyn[draggable="true"] { cursor: pointer; }
}

/* === Tablet (720-1024) === */
@media (min-width: 721px) and (max-width: 1024px) {
    .as-header { padding: 18px 22px; }
    .as-header-stats { gap: 14px; }
    .as-stat-n { font-size: 19px; }
    .as-table-wrap { overflow-x: auto; }
    .as-ov-summary { grid-template-columns: 1fr 1fr; gap: 18px; }
    .as-ed-tabs { overflow-x: auto; }
    .as-tabs { overflow-x: auto; }
}

/* === Disabilita ::before label sulle celle desktop (le serve solo mobile) === */
@media (min-width: 721px) {
    .as-table tbody td::before { display: none; }
}


/* ════════════════════════════════════════════════════════════════════════
   MOBILE REFACTOR v2 (22/04/2026 sera) — production-grade big-tech
   - Container queries per componenti adaptive
   - dvh/svh/lvh distinti per viewport iOS dinamico
   - Focus-visible WCAG AA
   - Bottom-nav Art Stone Dashboard + touch gesture hint
   - Zero emoji: tutte icone SVG (vedi _AS_ICON_PATHS in blocks.js)
   - Scala spaziature coerente 4/8/12/16/20/24
   ════════════════════════════════════════════════════════════════════════ */

/* === Design tokens coerenti === */
:root {
    /* Viewport units moderni (fallback per browser vecchi) */
    --vh-svh: 100svh;
    --vh-dvh: 100dvh;
    --vh-lvh: 100lvh;
    /* Safe-area shorthand */
    --sa-t: env(safe-area-inset-top, 0px);
    --sa-b: env(safe-area-inset-bottom, 0px);
    --sa-l: env(safe-area-inset-left, 0px);
    --sa-r: env(safe-area-inset-right, 0px);
    /* Spaziature 4-point grid */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
    /* Touch target minimo Apple HIG */
    --touch-min: 44px;
    /* Animazioni */
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Browser senza supporto dvh/svh/lvh: fallback a vh ===
   CSS.supports è più safe, ma @supports not funziona inverso */
@supports not (height: 100dvh) {
    :root {
        --vh-svh: 100vh; --vh-dvh: 100vh; --vh-lvh: 100vh;
    }
}

/* === Focus visible WCAG AA (solo keyboard nav, non mouse) === */
*:focus { outline: none; }
*:focus-visible {
    outline: 2px solid var(--primary, #c8a97a);
    outline-offset: 2px;
    border-radius: 6px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 2px solid var(--primary, #c8a97a);
    outline-offset: 1px;
}

/* === Reduced motion WCAG 2.1 === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* === Nuove classi icone SVG === */
.btn-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: -0.15em;
    line-height: 0;
    flex-shrink: 0;
}
.btn-ico svg {
    display: block;
    width: 1em;
    height: 1em;
}
button .btn-ico + span,
button span + .btn-ico,
a .btn-ico + span { margin-left: 4px; }
button .btn-ico { margin-right: 2px; }

/* Button con solo icona: centra l'svg */
button[dangerouslySetInnerHTML],
button > svg:only-child {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.attach-chip-ico {
    display: inline-flex; align-items: center; vertical-align: -0.15em;
    color: var(--primary, #c8a97a);
    margin-right: 2px;
}

.pricing-info-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px;
    background: rgba(200, 169, 122, 0.12);
    color: var(--primary, #c8a97a);
    border-radius: 6px;
    flex-shrink: 0;
}

.af-tpl-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px;
    background: rgba(200, 169, 122, 0.10);
    color: var(--primary, #c8a97a);
    border-radius: 6px;
    flex-shrink: 0;
    margin-right: 6px;
}

.admin-dropdown-dot,
.af-notif-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 14px; height: 14px;
    color: var(--text-muted, rgba(255,255,255,0.3));
}
.admin-dropdown-dot.is-me,
.af-notif-icon.is-self {
    color: var(--primary, #c8a97a);
}

.block-tap-icon-svg {
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--primary, #c8a97a);
    opacity: 0.85;
}
.big-ico-svg { display: inline-flex; align-items: center; line-height: 0; }

/* Icone grandi per logos/hero */
.artstone-only-logo,
.artstone-only-hero-icon,
.botx-empty-icon,
.aziendax-logo,
.aziendax-empty-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    color: var(--primary, #c8a97a);
    line-height: 0;
}
.aziendax-empty-icon,
.botx-empty-icon {
    width: 64px; height: 64px;
    border-radius: 18px;
    background: rgba(200, 169, 122, 0.08);
    margin: 0 auto 16px;
}
.artstone-only-hero-icon {
    width: 96px; height: 96px;
    border-radius: 24px;
    background: rgba(200, 169, 122, 0.10);
    margin: 0 auto 20px;
}

/* Status icon dentro bot cards: colorato via style inline */
.bot-card svg { vertical-align: -0.15em; }

/* === Tracker check / pause / play buttons - layout centrato SVG === */
.tracker-check {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px;
    border-radius: 50%;
}
.tracker-check.active {
    background: rgba(200, 169, 122, 0.16);
    color: var(--primary, #c8a97a);
}
.tracker-check.completed {
    background: rgba(34, 197, 94, 0.16);
    color: #22c55e;
}
.tracker-btn {
    min-width: 32px; min-height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
}

/* === Bot-action buttons (delete) svg centrato === */
.bot-action-btn.delete {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: var(--touch-min); min-height: var(--touch-min);
    aspect-ratio: 1;
}

/* === Dz icon (drop zone) === */
.as-dz-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px;
    margin: 0 auto 12px;
    border-radius: 14px;
    background: rgba(200, 169, 122, 0.08);
    color: var(--primary, #c8a97a);
}

/* === Admin dropdown dot contiene svg === */
.admin-dropdown-dot svg, .af-notif-icon svg { width: 100%; height: 100%; }

/* === Card delete trash - svg centrato === */
.as-mini svg, .as-btn svg { display: block; }
.as-mini {
    display: inline-flex !important; align-items: center; justify-content: center;
}

/* ════════════════════════════════════════════════════════════════════════
   BREAKPOINT MAPPING
   - xs:  ≤ 375px (iPhone SE)
   - sm:  ≤ 480px (iPhone Mini)
   - md:  ≤ 720px (iPhone Pro Max / tablet portrait)
   - lg:  ≤ 1024px (tablet landscape)
   ════════════════════════════════════════════════════════════════════════ */

/* === Mobile refinements (≤720px) === */
@media (max-width: 720px) {

    /* Usa dvh per full-height su iOS (non include la barra Safari) */
    .as-overlay-solo .as-panel,
    .as-overlay .as-panel,
    .as-editor-fullpanel,
    .mobile-chat-fullscreen {
        height: var(--vh-dvh);
    }

    /* Toolbar sticky usa svh per ancorare al top statico */
    .as-header,
    .as-nav-groups,
    .as-tabs {
        /* svh = altezza minima visibile, non cambia con URL bar */
        /* non forzo height, ma è utile per sticky elements */
    }

    /* Scroll snap fluido su tutti i tab scrollabili */
    .as-nav-groups,
    .as-tabs,
    .as-ed-tabs,
    .as-filter-pills {
        overscroll-behavior-x: contain;
        scroll-padding-inline: 14px;
    }

    /* Gesture hint: fade ai lati per suggerire scroll */
    .as-nav-groups,
    .as-tabs {
        mask-image: linear-gradient(to right,
            transparent 0, black 12px,
            black calc(100% - 12px), transparent 100%);
        -webkit-mask-image: linear-gradient(to right,
            transparent 0, black 12px,
            black calc(100% - 12px), transparent 100%);
    }

    /* Maggiore padding safe-area laterale per device con notch/rounded edges */
    .as-body {
        padding-left: max(var(--as-mobile-pad), var(--sa-l));
        padding-right: max(var(--as-mobile-pad), var(--sa-r));
    }

    /* Bottom-bar Art Stone Dashboard — tabs principali sempre visibili stile iOS */
    .as-bottom-nav {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        display: flex;
        height: 56px;
        background: rgba(14, 14, 18, 0.92);
        backdrop-filter: blur(24px) saturate(1.3);
        -webkit-backdrop-filter: blur(24px) saturate(1.3);
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        padding: 0 var(--sa-l) var(--sa-b) var(--sa-r);
        z-index: 900;
        box-shadow: 0 -1px 0 rgba(0,0,0,0.4);
    }
    .as-bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: var(--touch-min);
        background: transparent;
        border: 0;
        color: rgba(255, 255, 255, 0.45);
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.04em;
        cursor: pointer;
        transition: color 0.18s var(--ease-out), transform 0.12s var(--ease-out);
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    .as-bottom-nav-item:active { transform: scale(0.94); }
    .as-bottom-nav-item svg {
        width: 22px; height: 22px;
        stroke-width: 1.8;
    }
    .as-bottom-nav-item.is-active {
        color: var(--primary, #c8a97a);
    }
    .as-bottom-nav-item.is-active::after {
        content: '';
        position: absolute;
        top: 4px;
        width: 3px; height: 3px;
        border-radius: 50%;
        background: var(--primary, #c8a97a);
    }

    /* Quando bottom-nav Art Stone è attiva, aggiungi padding al body */
    body.as-dash-has-bottom-nav .as-body {
        padding-bottom: calc(72px + var(--sa-b));
    }

    /* Mobile: nascondi nav-groups in alto (duplicano bottom-nav) */
    body.as-dash-has-bottom-nav .as-nav-groups {
        display: none;
    }
    /* Tabs in alto restano: mostrano le sottosezioni del gruppo attivo */
    body.as-dash-has-bottom-nav .as-tabs {
        background: linear-gradient(180deg, rgba(14,14,18,0.6) 0%, transparent 100%);
        padding-top: var(--sp-2);
    }
    /* Editor fullpanel: la bottom-nav resta sopra l'editor, quindi va abbassata quando editor è aperto */
    body.as-dash-has-bottom-nav:has(.as-editor-fullpanel) .as-bottom-nav {
        display: none;
    }

    /* PTR indicator - fase trascinamento */
    .as-body { position: relative; }
    .as-body.ptr-pulling { transition: none; }
    .as-body:not(.ptr-pulling) { transition: transform 0.25s var(--ease-out); }

    /* Densità info ridotta sui dettagli: più respiro */
    .as-ov-step-head { padding: var(--sp-3) var(--sp-4) var(--sp-2); }
    .as-ov-step-body { padding: var(--sp-3) var(--sp-4) var(--sp-4); }
    .as-card-title { font-size: 15px; line-height: 1.35; }

    /* Buttons touch-target full */
    .as-btn, button:not(.as-stato-sel):not(.as-toolbar-check):not(.as-tool-btn) {
        min-height: var(--touch-min);
        min-width: var(--touch-min);
    }

    /* Scrolling momentum iOS */
    .as-body, .as-editor-scroll, .as-manual-composer, .picker-list {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }

    /* Pull-to-refresh indicator (attivato da JS) */
    .as-ptr-indicator {
        position: absolute;
        top: 0; left: 50%;
        transform: translate(-50%, -100%);
        width: 40px; height: 40px;
        display: flex; align-items: center; justify-content: center;
        border-radius: 50%;
        background: rgba(14, 14, 18, 0.9);
        backdrop-filter: blur(10px);
        color: var(--primary, #c8a97a);
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
        transition: transform 0.2s var(--ease-out), opacity 0.2s;
        opacity: 0;
        pointer-events: none;
        z-index: 50;
    }
    .as-ptr-indicator.is-pulling {
        opacity: 1;
        transform: translate(-50%, 16px) rotate(var(--ptr-angle, 0deg));
    }
    .as-ptr-indicator.is-loading {
        opacity: 1;
        transform: translate(-50%, 16px);
        animation: as-ptr-spin 0.8s linear infinite;
    }
    @keyframes as-ptr-spin {
        from { transform: translate(-50%, 16px) rotate(0deg); }
        to { transform: translate(-50%, 16px) rotate(360deg); }
    }

    /* Swipe hint: piccola animazione pulsante sui tab */
    .as-tabs::after,
    .as-nav-groups::after {
        content: '';
        display: block;
        width: 4px; height: 4px;
        flex-shrink: 0;
    }
}

/* === Very small (≤380px) — iPhone SE / mini === */
@media (max-width: 380px) {
    :root { --as-mobile-pad: 12px; }
    .as-logo-img { height: 34px; }
    .as-stat-n { font-size: 17px; }
    .as-stat-l { font-size: 8px; }
    .as-table tbody tr { padding: 10px 12px; padding-right: 72px; }
    .as-editor-title-num { font-size: 20px; }
    .pricing-info-ico, .af-tpl-ico { width: 20px; height: 20px; }
}

/* === Container queries: componenti adaptive === */
@supports (container-type: inline-size) {
    .pricing-info,
    .picker-list,
    .plan-card-container,
    .as-ov-summary {
        container-type: inline-size;
    }

    /* Picker items: card view sotto 380px, list sopra */
    @container (max-width: 320px) {
        .picker-item {
            flex-wrap: wrap;
            padding: var(--sp-3);
        }
        .picker-item-action {
            width: 100%; margin-top: 6px;
            text-align: center;
        }
    }
}

/* === Landscape mobile: compatta header === */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    .as-header {
        flex-direction: row; align-items: center;
        padding: 8px 14px;
    }
    .as-header-stats { width: auto; flex: initial; }
    .as-stat-n { font-size: 16px; }
    .as-editor-topbar { padding: 8px 14px; }
}

/* === Hover capability: disabilita :hover effects su touch-only === */
@media (hover: none) {
    .picker-item:hover { transform: none; background: var(--bg); }
    .as-row-clickable:hover { background: initial; }
}

/* === Print: nascondi UI interattiva === */
@media print {
    .as-bottom-nav, .bottom-nav, .chat-fab, .pwa-install-banner,
    .as-tabs, .as-nav-groups, .as-toolbar { display: none !important; }
    body { background: white; color: black; }
}

/* ════════════════════════════════════════════════════════════════════════
   MOBILE REFACTOR v3 (notte 22→23/04/2026) — Hardening production-grade
   - Bottom-nav dot centrato + icone +2px
   - PTR indicator "is-ready" feedback visivo (accent fill + scale)
   - Card ordini: container queries + respiro aumentato
   - iOS VisualViewport keyboard handling (body.keyboard-open)
   - Mask gradient su tabs più largo (16px)
   - Safe-area ovunque
   - Focus-visible offset coerente
   ════════════════════════════════════════════════════════════════════════ */

/* ── Bottom-nav dot centrato + icone più grandi ── */
@media (max-width: 720px) {
    .as-bottom-nav { height: 60px; }
    .as-bottom-nav-item {
        position: relative;
        padding-top: 10px;
        padding-bottom: 6px;
        gap: 3px;
    }
    .as-bottom-nav-item svg { width: 24px; height: 24px; stroke-width: 1.8; }
    .as-bottom-nav-item.is-active::after {
        left: 50%;
        top: 4px;
        transform: translateX(-50%);
    }
    body.as-dash-has-bottom-nav .as-body {
        padding-bottom: calc(76px + var(--sa-b, 0px));
    }
}

/* ── PTR indicator ready state: feedback visivo soglia ── */
@media (max-width: 720px) {
    .as-ptr-indicator {
        will-change: transform, background-color;
        transition: background-color 0.18s var(--ease-out, ease), box-shadow 0.18s var(--ease-out, ease), transform 0.18s var(--ease-out, ease), color 0.18s var(--ease-out, ease);
    }
    .as-ptr-indicator.is-ready {
        background: var(--primary, #c8a97a);
        color: #0a0a0a;
        box-shadow: 0 6px 22px rgba(200, 169, 122, 0.45);
        transform: translate(-50%, 16px) rotate(var(--ptr-angle, 0deg)) scale(1.08);
    }
    .as-ptr-indicator.is-loading {
        background: var(--primary, #c8a97a);
        color: #0a0a0a;
    }
}

/* ── Card ordini: più respiro, border-radius più soft, min-height target ── */
@media (max-width: 720px) {
    .as-table tbody tr {
        padding: 14px 16px;
        padding-right: 84px;
        gap: 10px;
        margin-bottom: 12px;
        border-radius: 14px;
        min-height: var(--touch-min, 44px);
        transition: background-color 0.15s ease, border-color 0.15s ease;
    }
    .as-table tbody tr:active { background: rgba(200, 169, 122, 0.06); }
    .as-table tbody td.as-cli .as-cli-name {
        font-size: 15px;
        line-height: 1.3;
        letter-spacing: -0.01em;
    }
    .as-table tbody td.as-cli .as-cli-cod {
        font-size: 11.5px;
        opacity: 0.75;
    }
    .as-table tbody td::before {
        font-size: 10px;
        margin-bottom: 3px;
        opacity: 0.8;
    }
    .as-table tbody td.as-num {
        font-size: 14px;
        top: 14px;
        right: 16px;
    }
}

/* ── Stats header più aerate ── */
@media (max-width: 720px) {
    .as-header-stats { gap: 14px; }
    .as-stat-n { font-size: 22px; line-height: 1.05; letter-spacing: -0.01em; }
    .as-stat-l { margin-top: 3px; opacity: 0.7; }
    .as-header-eyebrow { opacity: 0.65; font-weight: 600; }
    .as-header-titletag { line-height: 1.35; font-weight: 600; font-size: 14px; }
}

/* ── Mask gradient più largo (16px) per tabs scrollabili ── */
@media (max-width: 720px) {
    .as-nav-groups,
    .as-tabs,
    .as-ed-tabs,
    .as-filter-pills {
        mask-image: linear-gradient(to right,
            transparent 0, black 16px,
            black calc(100% - 16px), transparent 100%);
        -webkit-mask-image: linear-gradient(to right,
            transparent 0, black 16px,
            black calc(100% - 16px), transparent 100%);
    }
}

/* ── iOS VisualViewport: body.keyboard-open (impostato da JS) ── */
@media (max-width: 720px) {
    body.keyboard-open .as-bottom-nav { transform: translateY(100%); pointer-events: none; }
    body.keyboard-open.as-dash-has-bottom-nav .as-body { padding-bottom: 20px; }
}

/* ── Container queries su card ordini: layout compresso se card <300px ── */
@supports (container-type: inline-size) {
    @media (max-width: 720px) {
        .as-table tbody tr {
            container-type: inline-size;
            container-name: ord-card;
        }
    }
    @container ord-card (max-width: 300px) {
        .as-table tbody td.as-num {
            top: 10px; right: 12px;
            font-size: 13px;
        }
        .as-table tbody tr {
            padding: 12px;
            padding-right: 68px;
        }
        .as-table tbody td.as-cli .as-cli-name { font-size: 14px; }
        .as-table tbody td::before { font-size: 9px; }
    }
}

/* ── Tap row clickable ── */
@media (max-width: 720px) {
    .as-row-clickable,
    .as-table tbody tr {
        -webkit-tap-highlight-color: rgba(200,169,122,0.14);
        cursor: pointer;
    }
}

/* ── Focus-visible offset più generoso mobile ── */
@media (max-width: 720px) {
    .as-bottom-nav-item:focus-visible,
    .as-tab:focus-visible,
    .as-nav-group:focus-visible,
    .as-row-clickable:focus-visible {
        outline: 2px solid var(--primary, #c8a97a);
        outline-offset: 3px;
        border-radius: 10px;
    }
}

/* ── Toolbar sticky top con backdrop blur (quando si scrolla) ── */
@media (max-width: 720px) {
    .as-toolbar {
        position: sticky;
        top: 0;
        z-index: 10;
        background: rgba(14, 14, 18, 0.82);
        backdrop-filter: blur(16px) saturate(1.2);
        -webkit-backdrop-filter: blur(16px) saturate(1.2);
        margin: 0 calc(-1 * var(--as-mobile-pad, 14px));
        padding: 10px var(--as-mobile-pad, 14px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    }
}

/* ── Safe-area inset su lightbox + bottom-sheet ── */
@media (max-width: 720px) {
    .as-col-picker {
        padding-bottom: max(16px, var(--sa-b, 0px));
        padding-left: max(14px, var(--sa-l, 0px));
        padding-right: max(14px, var(--sa-r, 0px));
    }
    .as-bulk-bar {
        padding-bottom: max(10px, var(--sa-b, 0px));
        padding-left: max(12px, var(--sa-l, 0px));
        padding-right: max(12px, var(--sa-r, 0px));
    }
}

/* ── Reduced motion: rimuovi anche mask-image transitions ── */
@media (prefers-reduced-motion: reduce) and (max-width: 720px) {
    .as-ptr-indicator { transition: none !important; }
    .as-bottom-nav-item { transition: none !important; }
    .as-table tbody tr { transition: none !important; }
}

/* ── Prefer dark scrollbar thin ── */
@media (max-width: 720px) {
    .as-body, .as-editor-scroll {
        scrollbar-width: thin;
        scrollbar-color: rgba(200,169,122,0.3) transparent;
    }
    .as-body::-webkit-scrollbar, .as-editor-scroll::-webkit-scrollbar { width: 4px; }
    .as-body::-webkit-scrollbar-thumb { background: rgba(200,169,122,0.3); border-radius: 2px; }
}

/* ── iPhone 15 Pro dynamic island: padding-top maggiore se notch è "dinamico" ── */
@supports (top: env(safe-area-inset-top)) {
    @media (max-width: 720px) {
        .as-header {
            padding-top: calc(14px + env(safe-area-inset-top, 0px));
        }
    }
}

/* ── FIX v3.1: bottom-nav hidden su tablet/desktop (>720px) ── */
@media (min-width: 721px) {
    .as-bottom-nav { display: none !important; }
}

/* ── FIX v3.1: padding-bottom body forzato per evitare overlap card/bottom-nav ── */
@media (max-width: 720px) {
    body.as-dash-has-bottom-nav .as-body {
        padding-bottom: calc(80px + var(--sa-b, 0px)) !important;
    }
    body.as-dash-has-bottom-nav.keyboard-open .as-body {
        padding-bottom: 20px !important;
    }
}

/* ── FIX v3.1: STATO select — appearance none, chevron custom (evita UI browser nativa) ── */
.as-stato-sel {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='currentColor' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px !important;
}
/* Mobile: STATO select più grande, touch target */
@media (max-width: 720px) {
    .as-stato-sel {
        min-height: 36px;
        padding: 7px 32px 7px 12px !important;
        font-size: 13px !important;
        font-weight: 600;
    }
}

/* ── FIX v3.1: card ordine — numero top-right più leggibile su mobile ── */
@media (max-width: 720px) {
    .as-table tbody td.as-num {
        top: 12px;
        right: 14px;
        font-size: 15px;
        font-weight: 700;
        letter-spacing: 0;
        padding: 2px 8px;
        background: rgba(200,169,122,0.1);
        border-radius: 6px;
        line-height: 1.2;
    }
    .as-table tbody td.as-num::before { display: none; }
    /* Spazio per il numero un po' più ampio */
    .as-table tbody tr {
        padding-right: 74px;
    }
    /* Checkbox row: più piccolo e fuori linea */
    .as-table tbody td input[type="checkbox"] {
        width: 20px; height: 20px;
        accent-color: var(--primary, #c8a97a);
    }
}

/* ── FIX v3.1: Analytics toggle più discreto in testa lista ── */
@media (max-width: 720px) {
    .as-analytics-toggle {
        padding: 10px 14px;
        font-size: 12.5px;
        background: rgba(255,255,255,0.02);
        border-radius: 10px;
        margin-bottom: 8px;
    }
}

/* ── FIX v3.1: label ::before più sottile per cliente (già prominent) ── */
@media (max-width: 720px) {
    .as-table tbody td.as-cli::before {
        display: none;
    }
    .as-table tbody td.as-cli {
        padding-right: 12px;
    }
    .as-table tbody td.as-cli .as-cli-name {
        font-size: 15.5px;
        font-weight: 600;
        line-height: 1.3;
        margin-bottom: 2px;
    }
    .as-table tbody td.as-cli .as-cli-cod {
        font-size: 11px;
        opacity: 0.6;
        letter-spacing: 0.02em;
    }
}

/* ════════════════════════════════════════════════════════════════════════
   MOBILE REFACTOR v3.2 — Card compact layout 2-cols
   Cliente full width, secondarie affiancate → altezza card dimezzata
   ════════════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
    .as-table tbody tr {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px 14px;
        padding: 12px 14px !important;
        padding-right: 78px !important;
        align-items: start;
    }
    /* Cliente: full width (span 2 cols) */
    .as-table tbody td.as-cli {
        grid-column: 1 / -1;
    }
    /* Checkbox td (id=select): no data-col-label → full width, ma allineato a sinistra */
    .as-table tbody td:not([data-col-label]) {
        grid-column: 1 / -1;
        padding: 0;
    }
    /* Stato (select): affianco a RIF per compattare la card, min-width per leggibilità */
    .as-table tbody td:has(> .as-stato-sel) {
        min-width: 0;
    }
    .as-table tbody td .as-stato-sel {
        width: 100%;
        min-width: 88px;
    }
    /* Font compatto su celle secondarie */
    .as-table tbody td.as-dim,
    .as-table tbody td.as-rif {
        font-size: 12.5px;
        line-height: 1.3;
    }
    .as-table tbody td.as-dim::before,
    .as-table tbody td.as-rif::before {
        font-size: 9px;
        margin-bottom: 2px;
        opacity: 0.55;
        letter-spacing: 0.1em;
    }
    /* Tipo chip compatto */
    .as-tipo-chip {
        font-size: 10.5px;
        padding: 2px 8px;
    }
    /* Totale allineato a sx (era a dx desktop) */
    .as-table tbody td.as-cell-right {
        text-align: left;
    }
    /* Checkbox più toccabile */
    .as-table tbody td input[type="checkbox"] {
        width: 22px;
        height: 22px;
        accent-color: var(--primary, #c8a97a);
        cursor: pointer;
    }
}

/* Card xs (<380px): colonne più strette, ulteriore compressione */
@media (max-width: 380px) {
    .as-table tbody tr {
        padding: 10px 12px !important;
        padding-right: 68px !important;
        gap: 6px 10px;
    }
    .as-table tbody td.as-cli .as-cli-name {
        font-size: 14.5px;
    }
    .as-table tbody td.as-num {
        top: 10px;
        right: 12px;
        font-size: 13px;
    }
}

