:root {
    --ff-bg: #f5f7fb;
    --ff-card: #ffffff;
    --ff-text: #1b2638;
    --ff-muted: #667287;
    --ff-primary: #2d4264;
    --ff-primary-dark: #17243b;
    --ff-border: #d8e0eb;
    --ff-success: #347d79;
    --ff-danger: #a43a51;
    --ff-shadow: 0 10px 28px rgba(23, 36, 59, .10);
}

* { box-sizing: border-box; }
html { font-size: 18px; }
body { margin: 0; }
button, input { font: inherit; }
a { color: inherit; }

.ff-body {
    min-height: 100vh;
    background: var(--ff-bg);
    color: var(--ff-text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

.ff-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 74px;
    padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: linear-gradient(135deg, #17243b 0%, #2d4264 100%);
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.12);
}

.ff-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 900;
}

.ff-brand img {
    width: 48px;
    height: 48px;
    padding: 4px;
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
}
.ff-brand img.ff-shop-logo { width: 38px; height: 38px; }

.ff-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: .9rem;
    font-weight: 700;
}
.ff-user a {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,.6);
    border-radius: 10px;
    text-decoration: none;
}

.ff-main {
    width: min(780px, 100%);
    margin: 0 auto;
    padding: 22px 16px calc(36px + env(safe-area-inset-bottom));
}

.ff-flash {
    margin: 0 0 18px;
    padding: 16px 18px;
    border: 2px solid #d38316;
    border-radius: 14px;
    background: #fff4d7;
    color: #4b2a00;
    font-weight: 850;
    box-shadow: var(--ff-shadow);
}

.ff-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 4px 0 18px;
}
.ff-hero h1, .ff-section-title h2 { margin: 0; line-height: 1.12; }
.ff-hero p, .ff-section-title p { margin: 6px 0 0; color: var(--ff-muted); }
.ff-article-hero { align-items: flex-start; }
.ff-code {
    margin: 0 0 4px !important;
    color: var(--ff-primary-dark) !important;
    font-size: .95rem;
    font-weight: 950;
    letter-spacing: .04em;
}

.ff-step {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--ff-primary);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 950;
    box-shadow: 0 5px 0 var(--ff-primary-dark);
}

.ff-card {
    margin: 0 0 20px;
    padding: 20px;
    border: 1px solid var(--ff-border);
    border-radius: 18px;
    background: var(--ff-card);
    box-shadow: var(--ff-shadow);
}
.ff-card h2 { margin: 0 0 12px; line-height: 1.2; }
.ff-card p { margin-top: 8px; }

.ff-button {
    width: 100%;
    min-height: 58px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 13px 18px;
    border: 2px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    font-weight: 900;
    line-height: 1.15;
}
.ff-button:focus-visible, input:focus-visible, .ff-file-button:focus-within {
    outline: 4px solid #49638b;
    outline-offset: 3px;
}
.ff-button:disabled { opacity: .5; cursor: not-allowed; }
.ff-button-primary {
    color: #fff;
    background: linear-gradient(180deg, #2d4264 0%, #21324f 100%);
    border-color: #17243b;
    box-shadow: 0 5px 0 #111c30;
}
.ff-button-primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #111c30; }
.ff-button-secondary {
    color: #233451;
    background: #fff;
    border-color: #d5dde8;
}
.ff-button-danger {
    color: #fff;
    background: var(--ff-danger);
    border-color: #731010;
}
.ff-button-camera { min-height: 76px; font-size: 1.25rem; }

.ff-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0;
    color: var(--ff-muted);
    font-weight: 800;
}
.ff-divider::before, .ff-divider::after { content: ""; height: 1px; flex: 1; background: var(--ff-border); }

.ff-code-form label, .ff-login-card label {
    display: block;
    margin-bottom: 8px;
    font-weight: 900;
}
.ff-code-form input, .ff-login-card input {
    width: 100%;
    min-height: 60px;
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 2px solid #777;
    border-radius: 12px;
    background: #fff;
    color: #111;
    font-size: 1.08rem;
}
.ff-help { margin-bottom: 0; color: var(--ff-muted); font-size: .9rem; font-weight: 650; }
.ff-text-link { color: #2d4264; font-weight: 900; }

.ff-camera-box {
    position: relative;
    margin-top: 16px;
    overflow: hidden;
    border-radius: 16px;
    background: #111;
    color: #fff;
}
.ff-camera-box video {
    width: 100%;
    min-height: 300px;
    max-height: 58vh;
    display: block;
    object-fit: cover;
    background: #111;
}
.ff-camera-frame {
    position: absolute;
    top: 38%;
    left: 50%;
    width: min(82%, 460px);
    height: 150px;
    transform: translate(-50%, -50%);
    border: 5px solid #49638b;
    border-radius: 20px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,.20);
    pointer-events: none;
}
.ff-camera-status { padding: 12px 14px; margin: 0 !important; text-align: center; font-weight: 850; color: #fff !important; }
.ff-camera-box .ff-button { margin: 0 12px 14px; width: calc(100% - 24px); }

.ff-big-steps { margin: 0 0 18px; padding-left: 1.5rem; }
.ff-big-steps li { margin: 12px 0; }

.ff-back-row { margin: 0 0 18px; }
.ff-back-row .ff-button { width: auto; }

.ff-status-card { display: grid; gap: 15px; }
.ff-status-row { display: flex; align-items: center; gap: 14px; }
.ff-status-row b { display: block; font-size: 1.08rem; }
.ff-status-row small { display: block; margin-top: 3px; color: var(--ff-muted); }
.ff-status-dot { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px currentColor; }
.ff-status-dot.is-on { color: var(--ff-success); background: var(--ff-success); }
.ff-status-dot.is-off { color: #777; background: #777; }

.ff-blocked-card { border-color: #c63d3d; background: #fff0f0; }
.ff-warning { padding: 12px 14px; border-radius: 10px; background: #fff0d2; color: #5d3300; font-weight: 800; }

.ff-section-title { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.ff-upload-form, .ff-publication-form { display: grid; gap: 14px; }

.ff-file-button {
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 15px 18px;
    border: 3px dashed #49638b;
    border-radius: 14px;
    background: #eaf0f8;
    color: #233451;
    cursor: pointer;
    text-align: center;
    font-size: 1.12rem;
    font-weight: 950;
}
.ff-file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ff-file-button-small { min-height: 54px; border-width: 2px; font-size: .95rem; }

.ff-photo-preview {
    display: grid;
    gap: 8px;
    justify-items: center;
    padding: 12px;
    border-radius: 14px;
    background: #eef8ef;
    color: var(--ff-success);
}
.ff-photo-preview img { width: min(100%, 360px); max-height: 300px; object-fit: contain; border-radius: 12px; }

.ff-check-row {
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border: 2px solid var(--ff-border);
    border-radius: 12px;
    background: #fff;
    font-weight: 850;
}
.ff-check-row input { width: 28px; height: 28px; flex: 0 0 28px; accent-color: var(--ff-primary); }
.ff-check-row-large { font-size: 1.08rem; }
.ff-check-row.is-disabled { opacity: .6; background: #eee; }

.ff-empty-photo { min-height: 170px; display: grid; place-items: center; align-content: center; color: var(--ff-muted); text-align: center; }
.ff-empty-photo span { font-size: 3rem; }

.ff-photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.ff-photo-card { overflow: hidden; border: 2px solid var(--ff-border); border-radius: 16px; background: #f8f8f8; }
.ff-photo-card.is-main { border-color: var(--ff-success); box-shadow: 0 0 0 3px rgba(24,117,60,.15); }
.ff-photo-image { position: relative; aspect-ratio: 4 / 3; background: #e7e7e7; }
.ff-photo-image img { width: 100%; height: 100%; display: block; object-fit: cover; }
.ff-photo-image span { position: absolute; left: 8px; bottom: 8px; padding: 6px 9px; border-radius: 999px; background: var(--ff-success); color: #fff; font-size: .8rem; font-weight: 900; }
.ff-photo-actions { display: grid; gap: 9px; padding: 12px; }
.ff-photo-actions .ff-button { min-height: 50px; padding: 10px; font-size: .9rem; }

.ff-login-body { display: grid; place-items: center; padding: 20px; }
.ff-login-wrap { width: min(480px, 100%); }
.ff-login-card { padding: 24px; border: 1px solid var(--ff-border); border-radius: 20px; background: #fff; box-shadow: var(--ff-shadow); }
.ff-login-card h1 { margin: 10px 0 4px; text-align: center; }
.ff-login-card > p { margin: 0 0 20px; text-align: center; color: var(--ff-muted); }
.ff-login-card small { display: block; margin-top: 16px; color: var(--ff-muted); text-align: center; }
.ff-login-logos { display: flex; align-items: center; justify-content: center; gap: 12px; }
.ff-login-logos img { width: 82px; height: 82px; object-fit: contain; padding: 6px; border-radius: 14px; background: #fff; border: 1px solid var(--ff-border); }

@media (max-width: 640px) {
    html { font-size: 17px; }
    .ff-main { padding-left: 12px; padding-right: 12px; }
    .ff-card { padding: 16px; border-radius: 15px; }
    .ff-user span { display: none; }
    .ff-brand span { font-size: 1.08rem; }
    .ff-brand img { width: 42px; height: 42px; }
    .ff-brand img.ff-shop-logo { display: none; }
    .ff-photo-grid { grid-template-columns: 1fr; }
    .ff-back-row .ff-button { width: 100%; }
    .ff-camera-box video { min-height: 340px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}


/* v45: flusso continuo, permessi e prossimo articolo */
.ff-permission-info {
    margin: 16px 0 0;
    padding: 13px 15px;
    border: 1px solid #b8b1a6;
    border-radius: 12px;
    background: #f7f5f0;
    color: #3c3a36;
    font-size: .9rem;
    font-weight: 700;
}
.ff-permission-info[data-state="granted"] { border-color: #63a97a; background: #edf8f0; color: #125b2e; }
.ff-permission-info[data-state="denied"] { border-color: #d16a6a; background: #fff0f0; color: #7d1717; }
.ff-complete-card {
    border: 3px solid var(--ff-success);
    background: #eef9f1;
    text-align: center;
}
.ff-complete-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 10px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--ff-success);
    color: #fff;
    font-size: 2rem;
    font-weight: 950;
}
.ff-complete-card h2 { margin-bottom: 6px; }
.ff-next-article-button { margin-top: 12px; }
.ff-next-sticky {
    position: sticky;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 45;
    margin-top: 22px;
    padding: 8px;
    border-radius: 17px;
    background: rgba(245, 247, 251, .94);
    box-shadow: 0 4px 24px rgba(0,0,0,.22);
    backdrop-filter: blur(8px);
}
.ff-showcase-tools small { display: block; margin-top: 12px; color: var(--ff-muted); }


/* v100: Foto Facile allineata alla palette amministrativa Mercantico */
.ff-card, .ff-login-card {
    border-color: #d8e0eb;
    box-shadow: 0 12px 28px rgba(23,36,59,.10);
}
.ff-step {
    background: linear-gradient(145deg,#49638b 0%,#30486d 100%);
    box-shadow: 0 5px 0 #17243b;
}
.ff-button-primary:hover {
    background: linear-gradient(180deg,#405a82 0%,#293f60 100%);
}
.ff-button-secondary {
    background: linear-gradient(180deg,#ffffff 0%,#f2f5f9 100%);
    color: #233451;
    border-color: #d5dde8;
    box-shadow: 0 7px 16px rgba(23,36,59,.07);
}
.ff-file-button {
    border-color: #49638b;
    background: #eaf0f8;
    color: #233451;
}
.ff-warning { background: #faece7; color: #8a4939; }
.ff-blocked-card { border-color: #a43a51; background: #f9e8ed; }
.ff-photo-preview, .ff-complete-card { background: #e5f2f0; }
.ff-permission-info { border-color: #d8e0eb; background: #f5f7fb; color: #3b5277; }


/* v134: Foto facile compatta su mobile */
.ff-hero h1{font-size:clamp(2.1rem,6vw,3.2rem)}
.ff-hero p{font-size:clamp(1rem,3.6vw,1.2rem)}
.ff-button-camera{min-height:64px;font-size:1.05rem;padding:12px 16px}
.ff-permission-info{font-size:.84rem;line-height:1.45}
.ff-article-hero h1{
    font-size:clamp(1.55rem,5.4vw,2.45rem);
    line-height:1.08;
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
    overflow:hidden;
    max-width:100%;
}
.ff-article-hero p:last-child{font-size:clamp(.95rem,3.8vw,1.15rem)}
.ff-section-title--with-action{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap}
.ff-section-title--with-action .ff-section-copy{min-width:0;flex:1 1 240px}
.ff-section-save-top{width:auto;min-width:150px;min-height:52px;align-self:flex-start;flex:0 0 auto}
.ff-upload-form .ff-button-primary.ff-save-bottom{display:none}
@media (max-width:640px){
  .ff-main{padding-top:16px}
  .ff-step{width:48px;height:48px;flex-basis:48px;font-size:1.25rem}
  .ff-hero{gap:14px;margin-bottom:14px}
  .ff-hero h1{font-size:clamp(1.72rem,7.2vw,2.25rem)}
  .ff-hero p{font-size:1rem}
  .ff-button-camera{min-height:58px;font-size:.96rem;padding:10px 14px}
  .ff-permission-info{font-size:.8rem;padding:11px 12px}
  .ff-code{font-size:.9rem}
  .ff-article-hero h1{font-size:clamp(1.35rem,6vw,1.85rem)}
  .ff-section-title--with-action{align-items:stretch}
  .ff-section-title--with-action .ff-section-copy{flex-basis:100%}
  .ff-section-save-top{width:100%;min-height:50px}
}
