@import url('https://fonts.bunny.net/css?family=inter:400,500,600,700,800&display=swap');

/* ===================================================================
 *  IDEAL Caffè Sales — Design System (stile PWA · oro + nero · caffè)
 * =================================================================== */

:root {
    --ideal-950: #0a0a0c;
    --ideal-900: #111114;
    --ideal-800: #1a1a20;
    --ideal-700: #25252d;
    --ideal-600: #3a3a44;
    --ideal-500: #5c5c68;
    --ideal-400: #8a8a95;
    --ideal-300: #b8b8c2;
    --ideal-200: #e2e2e8;
    --ideal-100: #f3f3f6;
    --ideal-50:  #fafafa;

    --gold-50:  #fffbf0;
    --gold-100: #f9f1d8;
    --gold-200: #f1e1b1;
    --gold-300: #e6c87a;
    --gold-400: #d4af52;
    --gold-500: #c79a30;
    --gold-600: #a87d22;
    --gold-700: #7a5a18;

    --gold-grad: linear-gradient(135deg, #f1d774 0%, #c79a30 45%, #8a6515 100%);
    --gold-grad-soft: linear-gradient(135deg, #f1d774 0%, #d4af52 50%, #c79a30 100%);
    --gold-glow: rgba(199, 154, 48, 0.35);

    --font: 'Inter', system-ui, sans-serif;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --sidebar-w: 256px;
    --topbar-h: 60px;
    --bottom-nav-h: 68px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --shadow-dash: 0 0 0 1px rgba(255,255,255,0.06), 0 25px 50px -12px rgba(0,0,0,0.55), 0 0 80px rgba(199,154,48,0.12);
}

*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ideal-800);
}

/* ── Utilities (PWA-style) ── */
.glass {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.glass-dark {
    background: rgba(10, 10, 12, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.text-gradient-gold {
    background: linear-gradient(135deg, #f1d774 0%, #d4af52 40%, #c79a30 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero-glow {
    background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(199, 154, 48, 0.28), transparent);
}
.grid-bg {
    background-image:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 60px 60px;
}
.dash-shadow { box-shadow: var(--shadow-dash); }

.card-shine {
    position: relative;
    overflow: hidden;
}
.card-shine::before {
    content: '';
    position: absolute;
    top: 0; left: -75%;
    width: 50%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
    transform: skewX(-25deg);
    transition: left 0.6s ease;
    pointer-events: none;
    z-index: 1;
}
.card-shine:hover::before { left: 125%; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
@keyframes shimmer {
    0% { left: -100%; }
    40%, 100% { left: 150%; }
}

.animate-fade-in { animation: fadeIn 0.5s var(--ease) both; }
.animate-slide-up { animation: slideUp 0.65s var(--ease) both; }
.animate-float { animation: float 6s ease-in-out infinite; }
.stagger-1 { animation-delay: 0.08s; }
.stagger-2 { animation-delay: 0.16s; }
.stagger-3 { animation-delay: 0.24s; }
.stagger-4 { animation-delay: 0.32s; }
.stagger-5 { animation-delay: 0.4s; }

.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.65s var(--ease), transform 0.65s var(--ease);
    transition-delay: calc(var(--i, 0) * 0.08s);
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
    .animate-fade-in, .animate-slide-up, .animate-float, .reveal {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: 0;
    border-radius: 12px;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
    touch-action: manipulation;
    white-space: nowrap;
}
.btn-primary {
    background: var(--gold-grad);
    color: var(--ideal-950);
    box-shadow: 0 4px 20px var(--gold-glow);
}
.btn-primary:hover {
    filter: brightness(1.06);
    transform: translateY(-2px);
    box-shadow: 0 8px 28px var(--gold-glow);
}
.btn-glass {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--ideal-300);
    backdrop-filter: blur(8px);
}
.btn-glass:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    transform: translateY(-2px);
}
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: 16px; }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn-touch { min-height: 48px; }

/* ── Icon system (Lucide-style) ── */
.icon {
    width: 1.15em;
    height: 1.15em;
    flex-shrink: 0;
    display: block;
}
.btn .icon { width: 1.1em; height: 1.1em; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s, background 0.2s, color 0.2s, border-color 0.2s;
    touch-action: manipulation;
    vertical-align: middle;
}
.btn-icon .icon { width: 20px; height: 20px; stroke-width: 2.25px; }
.btn-icon--sm { width: 40px; height: 40px; border-radius: 10px; }
.btn-icon--sm .icon { width: 18px; height: 18px; }
.btn-icon--md { width: 44px; height: 44px; }
.btn-icon--lg { width: 48px; height: 48px; border-radius: 14px; }
.btn-icon--primary {
    background: var(--gold-grad);
    color: var(--ideal-950);
    box-shadow: 0 2px 12px var(--gold-glow);
}
.btn-icon--primary:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--gold-glow);
}
.btn-icon--outline {
    background: #fff;
    border: 1px solid var(--ideal-200);
    color: var(--ideal-700);
}
.btn-icon--outline:hover {
    background: var(--ideal-50);
    border-color: rgba(199, 154, 48, 0.45);
    color: var(--gold-700);
}
.btn-icon--danger {
    background: #fff;
    border: 1px solid rgba(200, 54, 74, 0.25);
    color: #b42338;
}
.btn-icon--danger:hover {
    background: #fef2f4;
    border-color: rgba(200, 54, 74, 0.45);
}
.btn-icon--ghost {
    background: transparent;
    border: 1px dashed var(--ideal-300);
    color: var(--ideal-600);
}
.btn-icon--ghost:hover { background: var(--ideal-100); }
.btn-icon:focus-visible {
    outline: 2px solid var(--gold-500);
    outline-offset: 2px;
}
.btn-icon:active { transform: translateY(0); }
.btn-icon--with-label {
    width: auto;
    min-height: 44px;
    padding: 0 16px 0 12px;
}
.btn-icon__label { white-space: nowrap; }

.btn-back {
    gap: 6px;
    padding: 8px 14px 8px 10px;
}
.btn-back .icon { width: 18px; height: 18px; }

@media (prefers-reduced-motion: reduce) {
    .btn-icon, .btn { transition: none !important; }
}

/* ═══════════════════════════════════════
   LANDING (dark · oro · caffè · stile PWA)
   ═══════════════════════════════════════ */
.landing-pwa {
    background: var(--ideal-950);
    color: #fff;
    min-height: 100dvh;
    overflow-x: hidden;
}
.landing-pwa .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
}
.landing-pwa .orb-1 {
    width: min(700px, 90vw);
    height: min(700px, 90vw);
    top: -20%;
    left: -15%;
    background: rgba(199, 154, 48, 0.18);
    animation: float 14s ease-in-out infinite;
}
.landing-pwa .orb-2 {
    width: min(500px, 70vw);
    height: min(500px, 70vw);
    bottom: 10%;
    right: -10%;
    background: rgba(199, 154, 48, 0.1);
    animation: float 18s ease-in-out infinite reverse;
}

.landing-nav {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 50;
    padding: calc(12px + var(--safe-top)) 16px 12px;
    transition: background 0.3s, box-shadow 0.3s, border 0.3s;
}
.landing-nav.is-scrolled {
    background: rgba(10, 10, 12, 0.92);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
.landing-nav-inner {
    max-width: 72rem;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.landing-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
}
/* ── Logo IDEAL (SVG inline, proporzioni corrette) ── */
.logo-ideal,
svg.logo-ideal {
    display: block;
    width: auto;
    height: var(--logo-h, 38px);
    max-width: var(--logo-w, 120px);
    flex-shrink: 0;
}
.logo-ideal[data-size="sm"],
svg.logo-ideal[data-size="sm"] { --logo-w: 100px; --logo-h: 30px; }
.logo-ideal[data-size="md"],
svg.logo-ideal[data-size="md"] { --logo-w: 120px; --logo-h: 38px; }
.logo-ideal[data-size="lg"],
svg.logo-ideal[data-size="lg"] { --logo-w: 140px; --logo-h: 46px; }
.sidebar-brand svg.logo-ideal { --logo-w: 108px; --logo-h: 34px; }
.landing-nav-brand svg.logo-ideal { --logo-w: 112px; --logo-h: 36px; filter: drop-shadow(0 4px 12px var(--gold-glow)); }
svg.logo-ideal.mx-auto { margin-left: auto; margin-right: auto; }
.guest-auth-brand svg.logo-ideal { --logo-w: 128px; --logo-h: 42px; }

.landing-nav-brand span {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}
.landing-nav-brand em {
    font-style: normal;
    font-weight: 400;
    color: var(--gold-300);
}
.landing-nav-links {
    display: none;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-radius: 99px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(10,10,12,0.6);
    backdrop-filter: blur(12px);
}
@media (min-width: 768px) {
    .landing-nav-links { display: flex; }
}
.landing-nav-links a {
    padding: 8px 14px;
    border-radius: 99px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ideal-300);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.landing-nav-links a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.landing-hero-section {
    position: relative;
    min-height: 100dvh;
    padding: calc(100px + var(--safe-top)) 20px 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.landing-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 99px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    font-size: 0.78rem;
    color: var(--ideal-300);
    margin-bottom: 28px;
}
.landing-badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34d399;
    animation: pulse-dot 2s ease-in-out infinite;
}
.landing-hero-section h1 {
    font-size: clamp(2.4rem, 6vw, 4.2rem);
    font-weight: 800;
    line-height: 1.06;
    letter-spacing: -0.03em;
    margin: 0 0 20px;
    color: #fff;
    max-width: 14ch;
}
.landing-hero-lead {
    max-width: 36rem;
    margin: 0 auto 32px;
    font-size: clamp(1rem, 2.2vw, 1.2rem);
    color: var(--ideal-400);
    line-height: 1.6;
}
.landing-hero-lead strong { color: #fff; font-weight: 500; }
.landing-hero-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-bottom: 48px;
}

/* Dashboard mockup */
.landing-mockup-wrap {
    position: relative;
    width: 100%;
    max-width: 56rem;
    margin: 0 auto;
}
.landing-mockup-glow {
    position: absolute;
    inset: -16px;
    background: linear-gradient(180deg, rgba(199,154,48,0.2), transparent);
    border-radius: 28px;
    filter: blur(24px);
    pointer-events: none;
}
.landing-mockup {
    position: relative;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(17, 17, 20, 0.85);
    backdrop-filter: blur(16px);
    overflow: hidden;
    text-align: left;
}
.landing-mockup-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.landing-mockup-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.landing-mockup-url {
    flex: 1;
    text-align: center;
    font-size: 0.72rem;
    color: var(--ideal-500);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.landing-mockup-body {
    display: grid;
    grid-template-columns: 180px 1fr;
    min-height: 280px;
}
@media (max-width: 640px) {
    .landing-mockup-body { grid-template-columns: 1fr; }
    .landing-mockup-sidebar { display: none; }
}
.landing-mockup-sidebar {
    padding: 16px 12px;
    border-right: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.2);
}
.mock-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--ideal-400);
    margin-bottom: 4px;
}
.mock-nav-item.active {
    background: rgba(199,154,48,0.15);
    color: var(--gold-300);
}
.mock-nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.landing-mockup-main { padding: 20px; }
.mock-stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.mock-stat {
    padding: 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
}
.mock-stat label {
    display: block;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ideal-500);
    margin-bottom: 4px;
}
.mock-stat strong {
    font-size: 1.25rem;
    color: var(--gold-300);
}
.mock-table {
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    overflow: hidden;
}
.mock-table-head {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    padding: 8px 12px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ideal-500);
    background: rgba(255,255,255,0.03);
}
.mock-table-row {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    padding: 10px 12px;
    font-size: 0.78rem;
    border-top: 1px solid rgba(255,255,255,0.04);
    color: var(--ideal-300);
}
.mock-table-row span:last-child {
    color: var(--gold-400);
    font-weight: 600;
}

/* Features section */
.landing-features-section {
    position: relative;
    padding: 80px 20px;
    max-width: 72rem;
    margin: 0 auto;
}
.landing-features-section h2 {
    text-align: center;
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 800;
    margin: 0 0 12px;
    color: #fff;
}
.landing-features-sub {
    text-align: center;
    color: var(--ideal-400);
    max-width: 32rem;
    margin: 0 auto 40px;
}
.landing-features-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.landing-feature-card {
    padding: 24px;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    transition: transform 0.25s var(--ease), border-color 0.25s, background 0.25s;
}
.landing-feature-card:hover {
    transform: translateY(-4px);
    border-color: rgba(199,154,48,0.35);
    background: rgba(199,154,48,0.06);
}
.landing-feature-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(199,154,48,0.25), rgba(199,154,48,0.08));
    color: var(--gold-300);
    margin-bottom: 16px;
}
.landing-feature-icon svg { width: 24px; height: 24px; }
.landing-feature-card h3 {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
}
.landing-feature-card p {
    margin: 0;
    font-size: 0.88rem;
    color: var(--ideal-400);
    line-height: 1.55;
}

/* Coffee strip */
.landing-coffee-strip {
    padding: 48px 20px;
    border-block: 1px solid rgba(255,255,255,0.06);
    background: rgba(199,154,48,0.04);
}
.landing-coffee-inner {
    max-width: 72rem;
    margin: 0 auto;
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    text-align: center;
}
.landing-coffee-stat strong {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: var(--gold-300);
    font-variant-numeric: tabular-nums;
}
.landing-coffee-stat span {
    font-size: 0.78rem;
    color: var(--ideal-400);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.landing-cta-section {
    position: relative;
    padding: 80px 20px;
    text-align: center;
}
.landing-cta-box {
    max-width: 36rem;
    margin: 0 auto;
    padding: 48px 32px;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(199,154,48,0.25);
    background: linear-gradient(135deg, rgba(199,154,48,0.12), rgba(10,10,12,0.8));
}
.landing-cta-box h2 {
    margin: 0 0 8px;
    font-size: 1.75rem;
    color: #fff;
}
.landing-cta-box p {
    color: var(--ideal-400);
    margin: 0 0 24px;
}

.landing-footer-pwa {
    padding: 32px 20px calc(32px + var(--safe-bottom));
    text-align: center;
    font-size: 0.82rem;
    color: var(--ideal-500);
    border-top: 1px solid rgba(255,255,255,0.06);
}
.landing-footer-pwa a { color: var(--gold-400); text-decoration: none; }
.landing-footer-pwa a:hover { color: var(--gold-300); }

/* ═══════════════════════════════════════
   LOGIN (split · PWA guest · oro/nero)
   ═══════════════════════════════════════ */
.guest-page body,
body.guest {
    margin: 0;
    padding: 0;
    background: var(--ideal-950);
    min-height: 100dvh;
}
.guest-auth {
    position: relative;
    display: grid;
    min-height: 100dvh;
    overflow: hidden;
}
@media (min-width: 900px) {
    .guest-auth { grid-template-columns: 1fr 1fr; }
}
.guest-auth-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.guest-auth-bg .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
}
.guest-auth-bg .orb-1 {
    width: 600px; height: 600px;
    top: -20%; left: -10%;
    background: rgba(199,154,48,0.2);
    animation: float 12s ease-in-out infinite;
}
.guest-auth-bg .orb-2 {
    width: 400px; height: 400px;
    bottom: -10%; right: 20%;
    background: rgba(199,154,48,0.1);
    animation: float 16s ease-in-out infinite reverse;
}
.guest-auth-bg .grid-bg {
    position: absolute;
    inset: 0;
    opacity: 0.5;
}

.guest-auth-brand {
    position: relative;
    display: none;
    flex-direction: column;
    justify-content: center;
    padding: 48px;
    z-index: 1;
}
@media (min-width: 900px) {
    .guest-auth-brand { display: flex; }
}
.guest-auth-brand h2 {
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    font-weight: 800;
    line-height: 1.15;
    color: #fff;
    margin: 32px 0 16px;
}
.guest-auth-brand p {
    color: var(--ideal-400);
    font-size: 1.05rem;
    max-width: 28rem;
    margin: 0 0 32px;
}
.guest-auth-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 360px;
}
.guest-auth-metrics div {
    padding: 16px;
    border-radius: 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
}
.guest-auth-metrics strong {
    display: block;
    font-size: 1.1rem;
    color: var(--gold-300);
}
.guest-auth-metrics span {
    font-size: 0.7rem;
    color: var(--ideal-500);
}

.guest-auth-form-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 32px 24px;
    z-index: 1;
}
@media (min-width: 900px) {
    .guest-auth-form-wrap {
        background: var(--ideal-50);
    }
}
.guest-auth-back {
    margin: 0 0 16px;
    max-width: 400px;
    width: 100%;
    margin-inline: auto;
}
.guest-auth-back a {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gold-600);
    text-decoration: none;
}
.guest-auth-card {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 36px;
    border-radius: var(--radius-xl);
    background: #fff;
    box-shadow: 0 4px 24px rgba(10,10,12,0.08);
    border: 1px solid var(--ideal-200);
}
@media (max-width: 899px) {
    .guest-auth-card {
        background: rgba(255,255,255,0.04);
        border-color: rgba(255,255,255,0.1);
        backdrop-filter: blur(12px);
    }
    .guest-auth-card h1,
    .guest-auth-card label { color: #fff; }
    .guest-auth-card .muted { color: var(--ideal-400); }
    .guest-auth-card input {
        background: rgba(255,255,255,0.06);
        border-color: rgba(255,255,255,0.12);
        color: #fff;
    }
    .guest-auth-back a { color: var(--gold-300); }
}
.guest-auth-card h1 {
    margin: 0 0 4px;
    font-size: 1.65rem;
    font-weight: 800;
}
.guest-auth-logo-mobile {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}
@media (min-width: 900px) {
    .guest-auth-logo-mobile { display: none; }
}

/* ═══════════════════════════════════════
   APP SHELL (sidebar PWA · content chiaro)
   ═══════════════════════════════════════ */
body.app-auth {
    padding: 0;
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
    background: var(--ideal-100);
}
@media (min-width: 768px) {
    body.app-auth { padding-bottom: 0; }
}

.app-shell { display: flex; min-height: 100dvh; }

.app-sidebar {
    display: none;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    z-index: 70;
    flex-direction: column;
    background: linear-gradient(180deg, var(--ideal-950), var(--ideal-900) 50%, var(--ideal-950));
    border-right: 1px solid rgba(199,154,48,0.15);
    box-shadow: 4px 0 32px rgba(0,0,0,0.25);
    padding-top: var(--safe-top);
}
@media (min-width: 768px) {
    .app-sidebar { display: flex; }
}
@media (max-width: 767px) {
    .app-sidebar.is-open { display: flex; }
}

.sidebar-brand {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
}
.sidebar-brand strong {
    display: block;
    font-weight: 800;
    font-size: 1rem;
}
.sidebar-brand small {
    display: block;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--gold-500);
}

.sidebar-quick {
    padding: 12px 12px 0;
}
.sidebar-quick a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: 12px;
    background: var(--gold-grad);
    color: var(--ideal-950);
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    box-shadow: 0 4px 16px var(--gold-glow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.sidebar-quick a:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 24px var(--gold-glow);
}
.sidebar-quick svg { width: 18px; height: 18px; }

.sidebar-section-label {
    margin: 16px 16px 6px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
}
.sidebar-nav {
    flex: 1;
    padding: 0 10px;
    overflow-y: auto;
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 12px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    transition: background 0.15s, color 0.15s;
}
.sidebar-link svg { width: 20px; height: 20px; opacity: 0.85; }
.sidebar-link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}
.sidebar-link.is-active {
    background: rgba(199,154,48,0.18);
    color: var(--gold-200);
    box-shadow: inset 0 0 0 1px rgba(199,154,48,0.3);
}
.sidebar-link.is-active::after {
    content: '';
    width: 6px;
    height: 6px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--gold-400);
    box-shadow: 0 0 8px var(--gold-400);
    animation: pulse-dot 2s infinite;
}

.sidebar-user-link {
    text-decoration: none;
    color: inherit;
    border-radius: 12px;
    transition: background 0.15s;
}
.sidebar-user-link:hover,
.sidebar-user-link.is-active {
    background: rgba(255,255,255,0.06);
}
.sidebar-user-link small {
    display: block;
    font-size: 0.68rem;
    color: rgba(255,255,255,0.45);
    margin-top: 2px;
}
.sidebar-user-link.is-active small { color: var(--gold-300); }

.sidebar-foot {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-bottom: calc(12px + var(--safe-bottom));
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    color: #fff;
    font-size: 0.85rem;
}
.sidebar-user .avatar,
.topbar-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--gold-grad);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--ideal-950);
}
.sidebar-logout {
    display: block;
    text-align: center;
    padding: 8px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logout:hover {
    color: #ffb4bc;
    border-color: rgba(200,54,74,0.4);
    background: rgba(200,54,74,0.1);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}
.sidebar-backdrop[hidden] { display: none !important; }
@media (min-width: 768px) {
    .sidebar-backdrop { display: none !important; }
}

.app-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
}
@media (min-width: 768px) {
    .app-stage { margin-left: var(--sidebar-w); }
}

.topbar-user-link {
    text-decoration: none;
    border-radius: 12px;
    transition: box-shadow 0.15s, transform 0.15s;
}
.topbar-user-link:hover {
    box-shadow: 0 0 0 2px rgba(199,154,48,0.35);
    transform: scale(1.03);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: calc(var(--topbar-h) + var(--safe-top));
    padding: var(--safe-top) 16px 0;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--ideal-200);
}
.topbar-menu {
    display: flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ideal-200);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
}
.topbar-menu svg { width: 22px; height: 22px; }
@media (min-width: 768px) {
    .topbar-menu { display: none; }
}
.topbar-titles { flex: 1; min-width: 0; }
.topbar-kicker {
    display: block;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold-600);
}
.topbar-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--ideal-950);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.shell {
    flex: 1;
    width: 100%;
    max-width: none;
    padding: 20px clamp(12px, 2vw, 24px) 28px;
}

.section {
    width: 100%;
    max-width: none;
    margin-bottom: 24px;
}

/* Cards app */
.card {
    width: 100%;
    background: #fff;
    border: 1px solid var(--ideal-200);
    border-radius: var(--radius-xl);
    box-shadow: 0 1px 3px rgba(10,10,12,0.04);
    overflow: hidden;
}
.card--elevated {
    box-shadow: 0 4px 20px rgba(10,10,12,0.06);
    transition: box-shadow 0.2s, transform 0.2s;
}
.card--elevated:hover {
    box-shadow: 0 12px 40px rgba(10,10,12,0.08);
}
.card-head {
    padding: 18px 20px;
    border-bottom: 1px solid var(--ideal-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.card-head h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--ideal-950);
}
.card-sub { margin: 4px 0 0; font-size: 0.85rem; color: var(--ideal-500); }
.card-body--flush { padding: 0 !important; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    padding: 18px 20px;
    border-radius: var(--radius-lg);
    background: #fff;
    border: 1px solid var(--ideal-200);
    box-shadow: 0 1px 3px rgba(10,10,12,0.04);
    transition: transform 0.2s var(--ease);
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card--gold {
    background: linear-gradient(135deg, #fff, var(--gold-50));
    border-color: rgba(199,154,48,0.25);
}
.stat-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ideal-500);
    margin-bottom: 4px;
}
.stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--ideal-950);
    font-variant-numeric: tabular-nums;
}
.stat-value--sm { font-size: 1.15rem; }

.page-eyebrow {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--ideal-950);
}
.page-sub { margin: 4px 0 0; color: var(--ideal-500); font-size: 0.92rem; }

/* Tables — full width schermo */
table.data {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.94rem;
    color: var(--ideal-800);
    table-layout: auto;
}
table.data thead th {
    text-align: left;
    padding: 14px 16px;
    background: var(--ideal-950);
    color: var(--gold-300);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(199, 154, 48, 0.35);
    position: sticky;
    top: 0;
    z-index: 3;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}
table.data tbody td {
    padding: 14px 16px;
    border-top: 1px solid var(--ideal-200);
    vertical-align: middle;
    background: #fff;
    color: var(--ideal-800);
    white-space: normal;
    word-break: break-word;
}
table.data tbody tr:nth-child(even) td {
    background: rgba(243, 243, 246, 0.55);
}
table.data tbody tr:hover td {
    background: rgba(199, 154, 48, 0.1);
}
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .col-action { width: 56px; min-width: 56px; }
table.data td:has(.btn-icon) { text-align: center; padding-left: 8px; padding-right: 8px; }
table.data .col-code { width: 120px; }
table.data .col-qty { width: 100px; }
table.data .col-fill { width: auto; }
table.data .strike td { text-decoration: line-through; color: var(--ideal-400); }
table.data tfoot td {
    background: var(--ideal-100);
    font-weight: 700;
    padding: 14px 16px;
    border-top: 2px solid var(--ideal-200);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    background: #fff;
    -webkit-overflow-scrolling: touch;
}
.table-scroll-y,
.catalog-table-wrap {
    width: 100%;
    min-height: 320px;
    max-height: min(72vh, 720px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
}
.catalog-table-wrap table.data {
    width: 100%;
    table-layout: auto;
    min-width: 0;
}
.catalog-table-wrap tbody tr {
    visibility: visible;
}
.catalog-empty td {
    padding: 40px 16px !important;
    text-align: center;
    color: var(--ideal-500) !important;
    font-weight: 500;
    font-size: 0.95rem;
}
.card--table {
    overflow: visible;
}
.card--table .table-wrap,
.card--table .catalog-table-wrap {
    border-bottom-left-radius: var(--radius-xl);
    border-bottom-right-radius: var(--radius-xl);
}

/* Profilo operatore */
.profile-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--ideal-200);
    background: #fff;
}
.avatar-lg {
    width: 44px;
    height: 44px;
    font-size: 1rem;
}
.form-grid--profile {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.form-grid-span-2 { grid-column: 1 / -1; }
.profile-form-actions { align-items: center; gap: 16px; flex-wrap: wrap; }
@media (max-width: 640px) {
    .profile-form-actions { flex-direction: column; align-items: stretch; }
    .profile-form-actions .btn { width: 100%; }
}

/* Toasts */
.toast {
    padding: 14px 18px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 0.88rem;
    animation: fadeIn 0.35s var(--ease);
}
.toast-success { background: #e8f4ec; color: #1c4f2e; border-left: 4px solid #2f8a4d; }
.alert { padding: 12px 14px; border-radius: 10px; font-size: 0.88rem; line-height: 1.45; }
.alert-warning { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
.alert-info { background: #eff6ff; border: 1px solid #93c5fd; color: #1e40af; }
.toast-error { background: #fbeaec; color: #6f1822; border-left: 4px solid #c8364a; }
.toast-info { background: #eaf2fb; color: #1a3f6b; border-left: 4px solid #2f6fb5; }

/* Forms */
label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ideal-600);
    display: block;
    margin-bottom: 6px;
}
input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--ideal-200);
    border-radius: 12px;
    font: inherit;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold-500);
    box-shadow: 0 0 0 3px rgba(199,154,48,0.15);
}
.field-touch { margin-bottom: 14px; }
.field-touch input { min-height: 48px; font-size: 16px; }
.muted { color: var(--ideal-500); }
.mt-3 { margin-top: 20px; }

/* Bottom nav (phone) */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    display: flex;
    background: linear-gradient(180deg, var(--ideal-900), var(--ideal-950));
    border-top: 1px solid rgba(199,154,48,0.2);
    padding: 6px 8px calc(6px + var(--safe-bottom));
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
}
@media (min-width: 768px) {
    .bottom-nav { display: none !important; }
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 52px;
    border: 0;
    background: transparent;
    color: rgba(255,255,255,0.55);
    font: inherit;
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 12px;
    cursor: pointer;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.is-active {
    color: var(--gold-300);
    background: rgba(199,154,48,0.12);
}

/* Bottom sheet, install banner, network */
.bottom-sheet[hidden] { display: none !important; }
.bottom-sheet {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.bottom-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}
.bottom-sheet-panel {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 16px 16px calc(20px + var(--safe-bottom));
    animation: slideUp 0.3s var(--ease);
}
.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--ideal-200);
    border-radius: 99px;
    margin: 0 auto 16px;
}
.bottom-sheet-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--ideal-200);
}
.bottom-sheet-link {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: 12px;
    background: var(--ideal-100);
    color: var(--ideal-800);
    font-weight: 600;
    text-decoration: none;
    border: 0;
    width: 100%;
    font: inherit;
    cursor: pointer;
}
.bottom-sheet-link.danger { background: #fbeaec; color: #c8364a; }
.bottom-sheet-link.is-active { background: rgba(199,154,48,0.12); color: var(--gold-700); font-weight: 700; }
.bottom-sheet-link.muted { background: transparent; justify-content: center; color: var(--ideal-500); }

.app-footer--slim {
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--ideal-500);
    border-top: 1px solid var(--ideal-200);
}
.app-footer--slim a { color: var(--gold-600); }
html.standalone .app-footer--slim { display: none; }

.install-banner {
    position: fixed;
    left: 16px; right: 16px;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px);
    max-width: 420px;
    margin: 0 auto;
    padding: 14px 16px;
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(199,154,48,0.3);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 90;
}
.install-banner.show { display: flex; }
@media (min-width: 768px) {
    .install-banner { bottom: 16px; }
    .install-banner.show { display: flex; }
}
.install-banner .logo-ideal { --logo-w: 88px; --logo-h: 32px; }
.install-banner .text { flex: 1; }
.install-banner .text strong { display: block; }
.install-banner .text small { color: var(--ideal-500); font-size: 0.78rem; }
.install-banner .close {
    border: 0;
    background: transparent;
    font-size: 1.3rem;
    color: var(--ideal-400);
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
}

.network-status {
    position: fixed;
    top: calc(var(--topbar-h) + var(--safe-top) + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    padding: 8px 16px;
    border-radius: 99px;
    background: #c8364a;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
}
.network-status[hidden] { display: none !important; }

/* Badges, cart, hero legacy hide */
.badge.gold { background: rgba(199,154,48,0.15); color: var(--gold-700); border: 1px solid rgba(199,154,48,0.3); }
.badge.blue { background: rgba(47,111,181,0.12); color: #2f6fb5; }
.badge.red { background: rgba(200,54,74,0.12); color: #c8364a; }
.cart-summary {
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--ideal-950), var(--ideal-800));
    border: 1px solid rgba(199,154,48,0.25);
}
.hero { display: none; }
.app-header { display: none !important; }

.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.flex { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 16px; }
.mt-0 { margin-top: 0; }
.center { text-align: center; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-variant-numeric: tabular-nums; font-weight: 600; }

.table-search { position: relative; }
.table-search input { padding-left: 36px; }
.table-search svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--ideal-400);
}

.card-head-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-left: auto;
}
.table-export-bar { display: flex; align-items: center; }
.table-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    border-color: rgba(22, 120, 62, 0.35);
    color: #166534;
    background: #f0fdf4;
}
.table-export-btn:hover {
    background: #dcfce7;
    border-color: rgba(22, 120, 62, 0.5);
}
.table-export-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
@media (max-width: 640px) {
    .card-head-tools {
        width: 100%;
        margin-left: 0;
        justify-content: stretch;
    }
    .table-export-btn,
    .table-search { flex: 1 1 auto; }
    .table-search input { width: 100%; }
}

/* Operational pages (ordini, DDT, incassi) */
.section h1 { font-size: 1.5rem; font-weight: 800; color: var(--ideal-950); margin: 0 0 8px; }
.btn-outline {
    background: #fff;
    border: 1px solid var(--ideal-200);
    color: var(--ideal-800);
}
.btn-outline:hover { background: var(--ideal-100); }
.btn-ghost {
    background: transparent;
    border: 1px dashed var(--ideal-300);
    color: var(--ideal-600);
}
.btn-ghost:hover { background: var(--ideal-100); }
.btn-danger { background: #c8364a; color: #fff; }
.btn-success { background: #2f8a4d; color: #fff; }
.btn:active { transform: translateY(1px); }
.qty-input { width: 80px !important; text-align: center; }
.lotto-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}
.lotto-pill {
    background: var(--ideal-100);
    border: 1px solid var(--ideal-200);
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--ideal-800);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.lotto-pill:hover {
    background: var(--gold-50);
    border-color: var(--gold-400);
}
.lotto-pill strong { display: block; color: var(--gold-700); }
.badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}
.card-body { padding: 18px 20px; }

/* DDT MAIL flow */
.doc-type-toolbar { align-items: center; flex-wrap: wrap; gap: 10px; }
.doc-type-label { margin-right: 4px; font-size: 0.85rem; color: var(--ideal-600); }
.doc-type-select { min-width: 150px; }
.doc-type-select option.tipo-legacy { color: var(--ideal-400); }
.doc-type-select.has-legacy { opacity: 0.72; }

.ddt-mail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 1024px) {
    .ddt-mail-grid { grid-template-columns: 1.2fr 0.8fr; align-items: start; }
}

.ddt-doc-preview-wrap { font-size: 0.82rem; overflow-x: auto; }
.ddt-pdf-preview-wrap { padding: 0; background: var(--ideal-100); }
.ddt-pdf-preview-frame {
    display: block;
    width: 100%;
    min-height: 72vh;
    height: calc(100vh - 220px);
    border: 0;
    background: #525659;
}
@media (max-width: 1023px) {
    .ddt-pdf-preview-frame { min-height: 55vh; height: 480px; }
}
.ddt-doc-header { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--gold-600); padding-bottom: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.ddt-doc-brand { display: flex; gap: 10px; align-items: flex-start; }
.ddt-doc-brand img { height: 44px; }
.ddt-doc-brand h1 { margin: 0; font-size: 1.1rem; font-weight: 800; }
.ddt-doc-meta { text-align: right; }
.ddt-doc-num { display: inline-block; background: var(--gold-200); font-weight: 800; padding: 4px 10px; border-radius: 6px; margin: 4px 0; }
.ddt-doc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.ddt-doc-grid--sm { font-size: 0.78rem; }
.ddt-doc-box strong { display: block; font-size: 0.68rem; text-transform: uppercase; color: var(--ideal-500); letter-spacing: 0.04em; }
.ddt-doc-strong { font-weight: 700; margin: 2px 0; }
.ddt-doc-section { color: var(--gold-700); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--ideal-200); padding-bottom: 4px; margin: 10px 0 6px; }
.ddt-doc-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.ddt-doc-table th { background: var(--ideal-950); color: var(--gold-200); text-align: left; padding: 6px 8px; }
.ddt-doc-table td { padding: 6px 8px; border-top: 1px solid var(--ideal-200); vertical-align: top; }
.ddt-doc-lotto { color: var(--gold-700); font-size: 0.7rem; }
.ddt-doc-total { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin: 12px 0; }
.ddt-doc-total-badge { background: var(--gold-200); font-weight: 800; padding: 6px 12px; border-radius: 6px; }
.ddt-doc-notes {
    margin: 12px 0;
    padding: 10px 12px;
    border: 1px solid var(--ideal-200);
    border-radius: 8px;
    background: #fafaf8;
    font-size: 0.82rem;
    white-space: pre-wrap;
}
.ddt-doc-notes strong {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    color: var(--ideal-500);
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.ddt-doc-footer { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--ideal-200); font-size: 0.68rem; color: var(--ideal-500); text-align: center; }

.email-missing-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 28px;
    padding: 4px 8px;
    border-radius: 6px;
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #c2410c;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    touch-action: manipulation;
}
.email-missing-banner { margin-bottom: 12px; }
tr.row-email-missing td:nth-child(n) { /* hint via badge only */ }

tr.row-nota-credito td {
    background: rgba(200, 54, 74, 0.07) !important;
}
tr.row-nota-credito:hover td {
    background: rgba(200, 54, 74, 0.12) !important;
}
tr.row-nota-credito .badge.red {
    margin-right: 6px;
    vertical-align: middle;
}
.saldo-nc,
.saldo-nc a {
    color: #c8364a;
    font-weight: 700;
}

.signature-pad-wrap { margin-top: 6px; }
#signature-pad {
    width: 100%;
    height: 160px;
    border: 2px dashed var(--ideal-300);
    border-radius: 12px;
    background: #fff;
    touch-action: none;
    cursor: crosshair;
}
.input-warning { border-color: #d97706 !important; background: #fffbeb; }
.form-hint { font-size: 0.82rem; margin-top: 4px; }
.form-hint--warn { color: #b45309; }

.ddt-mail-steps { list-style: none; margin: 0; padding: 0; }
.ddt-mail-step { display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--ideal-200); align-items: flex-start; }
.ddt-mail-step:last-child { border-bottom: 0; }
.ddt-mail-step-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; }
.ddt-mail-step--ok .ddt-mail-step-icon { background: #dcfce7; color: #166534; }
.ddt-mail-step--fail .ddt-mail-step-icon { background: #fee2e2; color: #b91c1c; }
.ddt-mail-step--active .ddt-mail-step-icon { background: #dbeafe; color: #1d4ed8; animation: ddt-mail-pulse 1s ease-in-out infinite; }
.ddt-mail-step--pending .ddt-mail-step-icon { background: var(--ideal-100); color: var(--ideal-400); }
.ddt-mail-step--pending { opacity: 0.55; }
.ddt-mail-step-detail { font-size: 0.82rem; margin-top: 2px; }

.ddt-mail-progress {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(10, 10, 12, 0.55);
    backdrop-filter: blur(4px);
}
.ddt-mail-progress[hidden] { display: none !important; }
.ddt-mail-progress__panel { width: min(480px, 100%); max-height: 90vh; overflow: auto; }
body.ddt-mail-progress-open { overflow: hidden; }

@keyframes ddt-mail-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { cursor: pointer; border: 1px solid var(--ideal-200); background: var(--ideal-50); font: inherit; }
.chip-btn:hover { background: var(--gold-100); border-color: var(--gold-400); }
.ddt-mail-template-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 1024px) {
    .ddt-mail-template-grid { grid-template-columns: 1.1fr 0.9fr; align-items: start; }
}
.ddt-mail-preview-subject { margin: 0 0 8px; font-size: 0.95rem; }
.ddt-mail-preview-body {
    margin: 0;
    padding: 12px;
    background: var(--ideal-50);
    border: 1px solid var(--ideal-200);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.82rem;
    white-space: pre-wrap;
    max-height: 320px;
    overflow: auto;
}
.form-grid-span-2 { grid-column: 1 / -1; }

