/* =============================================
   TIMBRATRICE DIGITALE — Coo.A.Di. Soc. Coop.
   Brand: Navy Blue + Gold
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Space+Mono:wght@400;700&display=swap');

:root {
    /* ── Tema Fresco ── teal/verde acqua, arancione come accento */
    --bg: #f0f7f6;
    --bg-warm: #e6f2f0;
    --surface: #ffffff;
    --surface-raised: #eaf4f2;
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-light: #14b8a6;
    --accent: #f59e0b;
    --accent-bg: #fef6e7;
    --accent-glow: rgba(245, 158, 11, 0.18);
    --blue: #0d9488;
    --blue-bg: #e6f5f3;
    --blue-light: #7fd1c8;
    --green: #0d9488;
    --green-bg: #e6f5f3;
    --red: #e11d48;
    --red-bg: #fff1f3;
    --text: #0f2e2a;
    --text-secondary: #3d5c57;
    --text-muted: #7a978f;
    --border: #d4e6e2;
    --border-light: #e4f0ed;
    --radius: 18px;
    --radius-sm: 11px;
    --radius-xs: 7px;
    --shadow-sm: 0 1px 2px rgba(13, 148, 136, 0.05);
    --shadow: 0 3px 14px rgba(13, 148, 136, 0.10);
    --shadow-lg: 0 14px 40px rgba(13, 148, 136, 0.18);
    --shadow-glow: 0 0 0 3px rgba(13, 148, 136, 0.14);
    --font: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --font-mono: 'Space Mono', 'Courier New', monospace;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ─── Login Screen ─── */
.login-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, #065f56 0%, #0d9488 45%, #14b8a6 75%, #0d9488 100%);
    padding: 20px; position: relative;
}
.login-wrapper::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse at 30% 40%, rgba(139, 189, 224, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(219, 184, 84, 0.06) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.025'%3E%3Cpath d='M20 0 L40 20 L20 40 L0 20Z'/%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.login-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 40px 36px 36px;
    max-width: 440px; width: 100%;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255,255,255,0.05);
    position: relative; z-index: 1;
}

.login-logo-area {
    text-align: center; margin-bottom: 28px;
}
.login-logo-area img {
    height: 56px; width: auto;
    margin-bottom: 8px;
}
.login-logo {
    width: 60px; height: 60px; border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 28px; margin-bottom: 14px;
    box-shadow: 0 4px 12px rgba(13, 59, 94, 0.25);
}
.login-title {
    font-size: 22px; font-weight: 700; color: var(--text);
    letter-spacing: -0.5px;
}
.login-subtitle {
    color: var(--text-muted); font-size: 13px; margin-top: 4px;
}
.login-company-info {
    font-size: 11px; color: var(--text-muted); margin-top: 6px;
    line-height: 1.4;
}

.operator-list {
    display: flex; flex-direction: column; gap: 8px; margin: 24px 0 20px;
}

.operator-btn {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border-radius: 12px;
    border: 2px solid var(--border-light); background: var(--surface);
    cursor: pointer; transition: all var(--transition); text-align: left; width: 100%;
    font-family: var(--font);
}
.operator-btn:hover {
    border-color: var(--border); background: var(--surface-raised);
    transform: translateY(-1px); box-shadow: var(--shadow-sm);
}
.operator-btn.selected {
    border-color: var(--primary); background: var(--blue-bg);
    box-shadow: 0 0 0 3px rgba(13, 59, 94, 0.08);
}

.operator-avatar {
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--bg-warm); color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; flex-shrink: 0;
    transition: all var(--transition);
}
.operator-btn.selected .operator-avatar {
    background: var(--primary); color: #fff;
    box-shadow: 0 2px 8px rgba(13, 59, 94, 0.3);
}

.operator-name { font-weight: 600; font-size: 15px; color: var(--text); }
.operator-role { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.pin-section { animation: slideUp 0.3s ease; }
.pin-row { display: flex; gap: 8px; }

.pin-input {
    flex: 1; padding: 14px 16px; border-radius: 10px;
    border: 2px solid var(--border); font-size: 22px; text-align: center;
    letter-spacing: 10px; font-family: var(--font-mono); outline: none;
    transition: all var(--transition); background: var(--surface-raised);
}
.pin-input:focus { border-color: var(--primary); box-shadow: var(--shadow-glow); background: var(--surface); }
.pin-input.error { border-color: var(--red); }

.pin-submit {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; border: none; border-radius: 10px; padding: 0 28px;
    font-size: 18px; font-weight: 600; cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 2px 6px rgba(13, 59, 94, 0.25);
}
.pin-submit:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(13, 59, 94, 0.35); }
.pin-submit:disabled { opacity: 0.4; cursor: default; }

.pin-error { color: var(--red); font-size: 13px; margin-top: 6px; font-weight: 500; }
.pin-hint { color: var(--text-muted); font-size: 12px; margin-top: 8px; text-align: center; }

/* ─── Badge Scan Login ─── */
.badge-scan-area {
    text-align: center; padding: 32px 20px; margin: 20px 0 8px;
    border: 2px dashed var(--border); border-radius: 16px;
    background: var(--surface-raised); position: relative;
    transition: all var(--transition); cursor: pointer;
}
.badge-scan-area.active {
    border-color: var(--primary); background: var(--blue-bg);
    box-shadow: 0 0 0 4px rgba(13, 59, 94, 0.08);
}
.badge-scan-icon { font-size: 40px; margin-bottom: 10px; }
.badge-scan-label { font-size: 16px; font-weight: 700; color: var(--text); }
.badge-scan-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.badge-input {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer; font-size: 16px;
}

/* ─── App Layout ─── */
.app-header {
    background: var(--primary);
    color: #fff; padding: 0 24px; height: 52px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 1px 4px rgba(13, 59, 94, 0.15);
    position: relative; z-index: 10;
}
.app-brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 600; font-size: 15px;
}
.app-brand .header-logo {
    height: 26px; width: auto;
    filter: brightness(0) invert(1);
    opacity: 0.95;
}
.app-brand .brand-sep {
    color: var(--accent); font-size: 18px; font-weight: 300;
    opacity: 0.6;
}
.app-brand .brand-label {
    font-size: 14px; font-weight: 500;
    opacity: 0.85; letter-spacing: -0.2px;
}
.app-user { display: flex; align-items: center; gap: 10px; }

.user-badge {
    background: rgba(255,255,255,0.1); border-radius: var(--radius-sm);
    padding: 5px 12px 5px 5px; font-size: 13px;
    display: flex; align-items: center; gap: 8px;
    border: 1px solid rgba(255,255,255,0.1);
}
.user-badge .avatar {
    width: 28px; height: 28px; border-radius: 7px;
    background: rgba(255,255,255,0.15); display: flex; align-items: center;
    justify-content: center; font-weight: 700; font-size: 11px;
}

.btn-logout {
    background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7); border: none;
    border-radius: var(--radius-sm); padding: 8px 14px;
    font-size: 13px; cursor: pointer; font-weight: 500;
    font-family: var(--font); transition: all var(--transition);
    border: 1px solid rgba(255,255,255,0.08);
}
.btn-logout:hover { color: #fff; background: rgba(255,255,255,0.15); }

/* ─── Navigation ─── */
.app-nav {
    background: var(--surface); border-bottom: 1px solid var(--border-light);
    padding: 6px 16px; display: flex; gap: 4px;
    overflow-x: auto; box-shadow: var(--shadow-sm);
}
.nav-btn {
    background: transparent; color: var(--text-secondary);
    border: none; border-radius: var(--radius-sm);
    padding: 10px 16px; font-size: 13px; font-weight: 600;
    cursor: pointer; display: flex; align-items: center; gap: 6px;
    white-space: nowrap; font-family: var(--font);
    transition: all var(--transition);
}
.nav-btn:hover { color: var(--text); background: var(--bg-warm); }
.nav-btn.active {
    background: var(--primary); color: #fff;
    box-shadow: 0 2px 6px rgba(13, 59, 94, 0.25);
}

.app-content { padding: 20px; max-width: 1280px; margin: 0 auto; }
/* Roadmap e diagrammi di flusso usano tutta la larghezza disponibile */
.app-content.full-width { max-width: 100%; padding: 20px 32px; }

/* ─── Stats Cards ─── */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px; margin-bottom: 24px;
}
.stat-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    transition: all var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-label {
    font-size: 11px; color: var(--text-muted); font-weight: 700;
    letter-spacing: 0.8px; text-transform: uppercase;
}
.stat-value {
    font-size: 30px; font-weight: 700; color: var(--text);
    margin-top: 6px; letter-spacing: -1px;
}

/* ─── Stamp Area ─── */
.stamp-card {
    background: var(--surface); border-radius: 18px;
    padding: 32px; box-shadow: var(--shadow); text-align: center;
    border: 1px solid var(--border-light);
    position: relative; overflow: hidden;
}
.stamp-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--blue-light), var(--accent));
}
.stamp-card h2 { font-size: 20px; margin-bottom: 4px; letter-spacing: -0.3px; }
.stamp-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

.scan-btn {
    width: 100%; padding: 28px; border-radius: var(--radius);
    border: 2px dashed var(--border); background: var(--surface-raised);
    cursor: pointer; margin-bottom: 16px; transition: all var(--transition);
    font-family: var(--font);
}
.scan-btn:hover {
    border-color: var(--blue); background: var(--blue-bg);
    transform: translateY(-1px); box-shadow: var(--shadow);
}
.scan-btn .icon { font-size: 36px; margin-bottom: 8px; }
.scan-btn .label { color: var(--text-secondary); font-weight: 600; font-size: 15px; }
.scan-btn .hint { color: var(--text-muted); font-size: 12px; margin-top: 6px; }

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

.divider {
    display: flex; align-items: center; gap: 12px;
    color: var(--text-muted); font-size: 12px; margin-bottom: 16px;
    text-transform: uppercase; letter-spacing: 1px; font-weight: 500;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border-light); }

.doc-input-row { display: flex; gap: 8px; }

.doc-input {
    flex: 1; padding: 16px 18px; border-radius: 12px;
    border: 2px solid var(--border); font-size: 17px;
    font-family: var(--font-mono); font-weight: 700;
    outline: none; text-transform: uppercase;
    transition: all var(--transition);
    background: var(--surface-raised); letter-spacing: 2px;
}
.doc-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 59, 94, 0.08);
    background: var(--surface);
}

.stamp-submit {
    width: 100%; margin-top: 14px; padding: 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; border: none; border-radius: 12px;
    font-size: 17px; font-weight: 700; cursor: pointer;
    letter-spacing: 0.5px; text-transform: uppercase;
    transition: all var(--transition); font-family: var(--font);
    box-shadow: 0 4px 12px rgba(13, 59, 94, 0.3);
}
.stamp-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(13, 59, 94, 0.4);
}
.stamp-submit:disabled { background: var(--border); box-shadow: none; cursor: default; }

/* ─── Two-button Inizia/Fine ─── */
.stamp-actions {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 12px; margin-top: 16px;
}
.stamp-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; padding: 22px 16px; border: none; border-radius: 14px;
    font-family: var(--font); cursor: pointer;
    transition: all var(--transition);
    min-height: 90px;
}
.stamp-btn:disabled { opacity: 0.35; cursor: default; transform: none !important; box-shadow: none !important; }
.stamp-btn-icon { font-size: 28px; }
.stamp-btn-label { font-size: 16px; font-weight: 800; letter-spacing: 1.5px; }

.stamp-btn-inizio {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}
.stamp-btn-inizio:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.4);
}

.stamp-btn-fine {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #fff;
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3);
}
.stamp-btn-fine:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(22, 163, 74, 0.4);
}

/* ─── Working State (locked) ─── */
.working-badge {
    display: inline-flex; align-items: center; gap: 10px;
    background: #fef3c7; color: #92400e;
    padding: 8px 20px; border-radius: 50px;
    font-size: 13px; font-weight: 700; letter-spacing: 1px;
    margin-bottom: 20px;
}
.working-pulse {
    width: 10px; height: 10px; border-radius: 50%;
    background: #f59e0b;
    animation: pulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5);
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}
.working-doc-id {
    font-family: var(--font-mono); font-size: 28px; font-weight: 700;
    color: var(--primary); letter-spacing: 2px;
    padding: 16px; background: var(--surface-raised);
    border-radius: 12px; border: 2px solid var(--border-light);
    margin-bottom: 20px;
}
.working-info {
    text-align: left; margin: 0 auto; max-width: 300px;
}
.working-info-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}
.working-info-row:last-child { border-bottom: none; }
.working-info-label { color: var(--text-muted); font-weight: 500; }

/* ─── Recent List ─── */
.recent-header {
    font-size: 12px; color: var(--text-muted); font-weight: 700;
    letter-spacing: 1px; text-transform: uppercase; margin: 28px 0 10px;
}
.recent-item {
    background: var(--surface); border-radius: 12px;
    padding: 14px 16px; margin-bottom: 6px;
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; box-shadow: var(--shadow-sm);
    transition: all var(--transition); border: 1px solid var(--border-light);
}
.recent-item:hover { transform: translateX(4px); box-shadow: var(--shadow); border-color: var(--border); }
.recent-item .check { color: var(--green); font-size: 18px; margin-right: 10px; }
.recent-item .doc-id { font-family: var(--font-mono); font-weight: 700; font-size: 14px; }
.recent-item .time { color: var(--text-muted); font-size: 13px; font-family: var(--font-mono); }

/* ─── Table ─── */
.data-table {
    background: var(--surface); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow); width: 100%;
    border: 1px solid var(--border-light);
}
.data-table .thead {
    display: grid; padding: 14px 16px; background: var(--surface-raised);
    border-bottom: 2px solid var(--border-light); font-size: 11px;
    font-weight: 700; color: var(--text-muted); letter-spacing: 0.8px; text-transform: uppercase;
}
.data-table .trow {
    display: grid; padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px; cursor: pointer; transition: all var(--transition);
}
.data-table .trow:hover { background: var(--blue-bg); }
.data-table .trow:last-child { border-bottom: none; }
.table-3col .thead, .table-3col .trow { grid-template-columns: 1fr 1.2fr 1.5fr; }
.table-4col .thead, .table-4col .trow { grid-template-columns: 1.2fr 0.7fr 1fr 1.3fr; }
.cell-mono { font-family: var(--font-mono); font-weight: 700; }
.cell-muted { color: var(--text-secondary); }
.cell-small { font-size: 13px; font-family: var(--font-mono); color: var(--text-secondary); }

/* ─── Operator Bar ─── */
.op-bar-row { padding: 14px 16px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; gap: 12px; }
.op-bar-row:last-child { border-bottom: none; }
.op-bar-avatar { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.op-bar-track { height: 8px; background: var(--bg-warm); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.op-bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.op-bar-count { font-size: 22px; font-weight: 700; min-width: 40px; text-align: right; letter-spacing: -0.5px; }
.badge-you { font-size: 10px; color: var(--blue); margin-left: 6px; background: var(--blue-bg); padding: 2px 8px; border-radius: 6px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase; }

/* ─── Filter & Buttons ─── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select { padding: 9px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font); outline: none; background: var(--surface); transition: all var(--transition); }
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,59,94,0.06); }

.btn-secondary { background: var(--surface); color: var(--text-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: var(--font); transition: all var(--transition); }
.btn-secondary:hover { border-color: var(--primary); color: var(--text); background: var(--blue-bg); }
.btn-secondary.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.btn-export { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; border: none; border-radius: var(--radius-sm); padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: var(--font); transition: all var(--transition); box-shadow: 0 2px 6px rgba(13,59,94,0.15); }
.btn-export:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(13,59,94,0.25); }

.btn-danger { background: transparent; color: var(--red); border: 1px solid #e8b4b4; border-radius: var(--radius-sm); padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: var(--font); transition: all var(--transition); }
.btn-danger:hover { background: var(--red-bg); }

/* ─── Forms ─── */
.form-card { background: var(--surface); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 16px; border: 1px solid var(--border-light); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font); outline: none; background: var(--surface-raised); transition: all var(--transition); }
.form-group input:focus, .form-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,59,94,0.06); background: var(--surface); }

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; border: none; border-radius: var(--radius-sm); padding: 11px 24px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--font); transition: all var(--transition); box-shadow: 0 2px 6px rgba(13,59,94,0.15); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(13,59,94,0.25); }

/* ─── Modals ─── */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,30,48,0.6); display: flex; align-items: center; justify-content: center; z-index: 999; animation: fadeIn 0.25s ease; backdrop-filter: blur(4px); }
.modal-content { background: var(--surface); border-radius: 18px; padding: 36px; max-width: 440px; width: 90%; text-align: center; animation: slideUp 0.35s ease; position: relative; box-shadow: var(--shadow-lg); }
.modal-success { font-size: 12px; color: var(--green); font-weight: 700; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 18px; }

.label-preview { border: 2px dashed var(--border); border-radius: 10px; padding: 22px 26px; margin: 0 auto 22px; font-family: var(--font-mono); background: #fdfcf8; max-width: 320px; text-align: left; position: relative; overflow: hidden; }
.label-preview .perforation-top, .label-preview .perforation-bottom { position: absolute; left: 0; right: 0; height: 4px; background: repeating-linear-gradient(90deg, var(--primary) 0, var(--primary) 4px, transparent 4px, transparent 8px); }
.label-preview .perforation-top { top: 0; }
.label-preview .perforation-bottom { bottom: 0; }
.label-preview .label-title { font-weight: 700; font-size: 16px; margin-bottom: 10px; letter-spacing: 1px; color: var(--primary); }
.label-preview .label-row { font-size: 13px; margin-bottom: 5px; }
.label-preview .label-key { color: var(--text-muted); }
.barcode-fake { display: flex; gap: 1px; justify-content: center; margin-top: 14px; height: 34px; }
.barcode-bar { background: var(--primary); }
.barcode-id { text-align: center; font-size: 10px; margin-top: 4px; color: var(--text-muted); }

.btn-modal-close { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; border: none; border-radius: 10px; padding: 14px 32px; font-size: 15px; font-weight: 600; cursor: pointer; width: 100%; font-family: var(--font); transition: all var(--transition); box-shadow: 0 2px 8px rgba(13,59,94,0.25); }
.btn-modal-close:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(13,59,94,0.35); }
.btn-print-label { background: transparent; color: var(--primary); border: 1px solid var(--border); border-radius: 10px; padding: 12px 24px; font-size: 14px; font-weight: 600; cursor: pointer; width: 100%; margin-bottom: 8px; font-family: var(--font); transition: all var(--transition); }
.btn-print-label:hover { background: var(--blue-bg); border-color: var(--blue); }

/* ─── Quick Confirmation Overlay ─── */
.confirm-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(22, 163, 74, 0.92);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s ease;
    transition: opacity 0.3s ease;
}
.confirm-box { text-align: center; color: #fff; }
.confirm-icon { font-size: 64px; margin-bottom: 12px; animation: scaleIn 0.3s ease; }
.confirm-text { font-size: 28px; font-weight: 700; letter-spacing: 1px; }
.confirm-doc {
    font-family: var(--font-mono); font-size: 18px;
    margin-top: 8px; opacity: 0.8; letter-spacing: 2px;
}
@keyframes scaleIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.empty-state { background: var(--surface); border-radius: var(--radius); padding: 48px; text-align: center; color: var(--text-muted); border: 1px solid var(--border-light); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; padding: 14px 28px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 1000; animation: slideUp 0.3s ease; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* ─── Camera ─── */
.camera-overlay { position: fixed; inset: 0; z-index: 998; background: #000; display: flex; flex-direction: column; animation: fadeIn 0.2s ease; }
.camera-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: rgba(0,0,0,0.8); color: #fff; font-weight: 600; font-size: 16px; z-index: 2; }
.btn-close-camera { background: rgba(255,255,255,0.2); color: #fff; border: none; width: 36px; height: 36px; border-radius: 50%; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.camera-viewfinder { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.camera-viewfinder video { width: 100%; height: 100%; object-fit: cover; }
.viewfinder-frame { position: absolute; width: 240px; height: 240px; border: 3px solid rgba(255,255,255,0.8); border-radius: 16px; pointer-events: none; box-shadow: 0 0 0 9999px rgba(0,0,0,0.4); animation: pulse-frame 2s ease-in-out infinite; }
@keyframes pulse-frame { 0%, 100% { border-color: rgba(255,255,255,0.8); } 50% { border-color: rgba(26,107,170,0.9); } }
.camera-footer { padding: 16px; text-align: center; background: rgba(0,0,0,0.8); color: rgba(255,255,255,0.7); font-size: 14px; }

/* ─── Android Terminal ─── */
@media (max-width: 480px) {
    .operator-btn { min-height: 56px; }
    .nav-btn { padding: 12px 14px; min-height: 48px; }
    .scan-btn { padding: 20px 16px; min-height: 80px; }
    .stamp-submit { padding: 18px; font-size: 18px; min-height: 56px; }
    .recent-item { min-height: 52px; padding: 14px 16px; }
    .btn-modal-close, .btn-print-label { min-height: 50px; }
    .doc-input { font-size: 20px; padding: 16px; }
    .stat-value { font-size: 32px; }
    .app-content { padding: 10px; }
    .stamp-card { padding: 20px; }
    .login-card { padding: 28px 22px; }
}
@media (max-width: 360px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stamp-card .subtitle { display: none; }
    .app-brand .brand-label { display: none; }
    .app-brand .brand-sep { display: none; }
    .login-subtitle, .login-company-info { display: none; }
}

/* ─── Print ─── */
@media print {
    body * { visibility: hidden; }
    .label-preview, .label-preview * { visibility: visible; }
    .label-preview { position: absolute; left: 0; top: 0; width: 62mm; font-size: 10px; border: none; padding: 4mm; background: #fff; }
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
    .app-content { padding: 12px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .filter-bar { flex-direction: column; }
    .filter-bar input, .filter-bar select, .filter-bar button { width: 100%; }
    .form-grid { grid-template-columns: 1fr; }
    .user-badge span.user-name-text { display: none; }
    #rpt-charts-grid { grid-template-columns: 1fr; }
    .data-table .thead, .data-table .trow { font-size: 12px; }
    .table-3col .thead, .table-3col .trow { grid-template-columns: 1fr 0.8fr 1.2fr; }
    .table-4col .thead, .table-4col .trow { grid-template-columns: 1fr 0.6fr 0.7fr 1fr; }
}

/* ─── Inventory Department Buttons ─── */
.inv-reparto-btn {
    background: var(--surface); border: 2px solid var(--border-light);
    border-radius: 14px; padding: 20px 12px; font-size: 15px;
    font-weight: 700; color: var(--text); cursor: pointer;
    font-family: var(--font); transition: all var(--transition);
    line-height: 1.4; text-align: center;
}
.inv-reparto-btn:hover {
    border-color: var(--primary); background: var(--blue-bg);
    transform: translateY(-2px); box-shadow: var(--shadow);
}

/* ─── Tastierino numerico inventario ─── */
.numpad-btn {
    padding: 18px 0; font-size: 22px; font-weight: 700;
    background: var(--surface); border: 1.5px solid var(--border);
    border-radius: 12px; color: var(--text); cursor: pointer;
    font-family: var(--font); transition: all 0.1s; user-select: none;
}
.numpad-btn:active {
    background: var(--primary); color: #fff; transform: scale(0.95);
}

/* ─── Roadmap ─── */
.roadmap-canvas {
    position: relative; width: 100%; min-height: 600px;
    background: #f8fafc;
    background-image: radial-gradient(circle, #e2e8f0 1px, transparent 1px);
    background-size: 24px 24px;
    border-radius: var(--radius); overflow: auto; border: 1px solid var(--border);
}
.roadmap-canvas svg { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 2; min-height: 600px; overflow: visible; }
.roadmap-canvas .rm-node, .roadmap-canvas .flow-node { z-index: 3; }
.rm-node {
    position: absolute; width: 210px; padding: 14px 16px; border-radius: 12px;
    background: #fff; border: 2px solid var(--rm-c, #94a3b8);
    box-shadow: 0 3px 10px rgba(0,0,0,.08); z-index: 1; cursor: grab;
    transition: box-shadow .15s; touch-action: none;
}
.rm-node:hover { box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.rm-node.dragging { cursor: grabbing; opacity: .85; z-index: 10; }
.rm-node .rm-badge { display:inline-block; font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.5px; color:var(--rm-c); background:var(--rm-bg); padding:2px 8px; border-radius:4px; margin-bottom:6px; }
.rm-node .rm-title { font-size:14px; font-weight:700; color:var(--text); line-height:1.25; margin-bottom:6px; }
.rm-node .rm-meta { font-size:11px; color:var(--text-muted); line-height:1.4; }
.rm-node .rm-bar { height:5px; background:#eef1f5; border-radius:3px; margin-top:8px; overflow:hidden; }
.rm-node .rm-bar > i { display:block; height:100%; background:var(--rm-c); border-radius:3px; }
.rm-node .rm-prio { position:absolute; top:10px; right:12px; font-size:13px; }
.rm-todo { --rm-c:#94a3b8; --rm-bg:#f1f5f9; }
.rm-prog { --rm-c:#2563eb; --rm-bg:#dbeafe; }
.rm-pause { --rm-c:#d97706; --rm-bg:#fef3c7; }
.rm-done { --rm-c:#16a34a; --rm-bg:#dcfce7; }
.rm-empty { text-align:center; padding:80px 20px; color:var(--text-muted); }

/* ─── Flow editor (passi flusso) ─── */
.flow-node {
    position: absolute; min-width: 130px; max-width: 200px; padding: 12px 16px;
    background: #fff; border: 2px solid var(--fn-c, #2563eb);
    box-shadow: 0 3px 10px rgba(0,0,0,.08); z-index: 1; cursor: grab;
    font-size: 13px; font-weight: 600; color: var(--text); text-align: center;
    touch-action: none; transition: box-shadow .15s;
}
.flow-node:hover { box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.flow-node.dragging { cursor: grabbing; opacity: .85; z-index: 10; }
.flow-node.fn-azione { border-radius: 10px; }
.flow-node.fn-inizio, .flow-node.fn-fine { border-radius: 28px; }
.flow-node.fn-decisione { border-radius: 10px; background: #fffbeb; border-color: #d97706; --fn-c: #d97706; }
.flow-node .fn-state { display:block; font-size:10px; font-weight:700; text-transform:uppercase; margin-top:4px; letter-spacing:.5px; }
.fn-todo { --fn-c: #94a3b8; }
.fn-prog { --fn-c: #2563eb; }
.fn-done { --fn-c: #16a34a; }
.flow-node.fn-done-flag { opacity: .7; }
.flow-node.fn-done-flag::before { content: '✓ '; color: #16a34a; }

/* ─── Liste checkbox (persone, dipendenze, collegamenti) ─── */
#rm-persone-list label:hover,
#rm-dipende label:hover,
#fs-collega label:hover { background: var(--surface-raised); }
#rm-persone-list label:has(:checked),
#rm-dipende label:has(:checked),
#fs-collega label:has(:checked) { background: var(--blue-bg, #eff6ff); }

/* ─── Hub Gestione a icone ─── */
.admin-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}
.admin-tile {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    padding: 20px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; cursor: pointer; text-align: left; font-family: var(--font);
    transition: all 0.15s; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.admin-tile:hover {
    border-color: var(--primary); transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(13,59,94,.12);
}
.admin-tile-icon { font-size: 34px; line-height: 1; margin-bottom: 6px; }
.admin-tile-label { font-size: 15px; font-weight: 700; color: var(--text); }
.admin-tile-desc { font-size: 12px; color: var(--text-muted); line-height: 1.3; }
.admin-back {
    background: none; border: none; color: var(--primary); font-weight: 600;
    font-size: 14px; cursor: pointer; padding: 8px 0; margin-bottom: 12px;
    font-family: var(--font);
}
.admin-back:hover { text-decoration: underline; }

/* ─── Powered By Footer ─── */
.powered-by {
    position: fixed; bottom: 0; left: 0; right: 0;
    text-align: center; padding: 10px; font-size: 11px;
    color: rgba(255,255,255,0.35); z-index: 2;
}
.powered-by a { color: rgba(255,255,255,0.45); text-decoration: none; transition: color 0.2s; }
.powered-by a:hover { color: rgba(255,255,255,0.7); }
.powered-by.app-footer {
    position: static; color: var(--text-muted); padding: 20px; font-size: 11px; opacity: 0.6;
}
.powered-by.app-footer a { color: var(--text-muted); }
.powered-by.app-footer a:hover { color: var(--primary); }

/* ─── Animations ─── */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px) } to { opacity: 1; transform: translateY(0) } }
@keyframes spin { to { transform: rotate(360deg) } }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Gestione Scarichi (calendario mensile) ─── */
.cal-dow-row {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px;
}
.cal-dow {
    text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .6px; color: var(--text-muted); padding: 4px 0;
}
.cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.cal-cell {
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    min-height: 116px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
    position: relative; transition: border-color .12s;
}
.cal-cell:hover { border-color: var(--primary); }
.cal-cell.fuori { background: var(--surface-raised); opacity: .5; }
.cal-cell.weekend { background: var(--surface-raised); }
.cal-cell.oggi { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(13,59,94,.14); }
.cal-num {
    font-size: 13px; font-weight: 700; color: var(--text-secondary);
    display: flex; align-items: center; justify-content: space-between;
}
.cal-cell.oggi .cal-num { color: var(--primary); }
.cal-cell.oggi .cal-num .n {
    background: var(--primary); color: #fff; border-radius: 50%;
    width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px;
}
.cal-add {
    opacity: 0; border: none; background: none; color: var(--text-muted);
    cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px;
    font-family: var(--font); transition: opacity .12s;
}
.cal-cell:hover .cal-add { opacity: 1; }
.cal-add:hover { color: var(--primary); }
.cal-ev {
    background: var(--surface-raised); border-left: 3px solid var(--primary);
    border-radius: 4px; padding: 3px 5px; cursor: pointer; transition: transform .1s;
    overflow: hidden;
}
.cal-ev:hover { transform: translateX(2px); }
.cal-ev.arrivato { border-left-color: #f59e0b; }
.cal-ev.scaricato { border-left-color: #16a34a; opacity: .6; }
.cal-ev .ora { font-size: 11px; font-weight: 800; color: var(--primary); }
.cal-ev.arrivato .ora { color: #b45309; }
.cal-ev.scaricato .ora { color: #15803d; }
.cal-ev .forn {
    font-size: 11px; font-weight: 600; line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-piu { font-size: 10px; color: var(--text-muted); padding-left: 4px; cursor: pointer; }
.cal-piu:hover { color: var(--primary); text-decoration: underline; }

@media (max-width: 900px) {
    .cal-cell { min-height: 84px; }
    .cal-ev .forn { font-size: 10px; }
}

/* ─── Dashboard PC ─── */
.dash-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.dash-stat .n { font-size: 32px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.dash-stat .l { font-size: 12px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-top: 6px; }
.dash-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.dash-card-head { display: flex; align-items: center; gap: 8px; padding: 16px 18px 12px; font-size: 15px; font-weight: 700; }
.dash-card-head .ico { font-size: 18px; }
.dash-card-head .cnt { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--text-muted); background: var(--surface-raised); padding: 2px 10px; border-radius: 12px; }
.dash-card-body { padding: 0 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.dash-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-raised); border-radius: var(--radius-sm); font-size: 13px; }
.dash-row .ora { font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-row .txt { flex: 1; min-width: 0; }
.dash-row .txt .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-row .txt .t2 { font-size: 11px; color: var(--text-muted); }
.dash-row .tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.dash-tag-ferie { background: #fef3c7; color: #b45309; }
.dash-tag-malattia { background: var(--red-bg); color: var(--red); }
.dash-tag-festivita { background: #dbeafe; color: #2563eb; }
.dash-tag-inizio { background: var(--green-bg); color: var(--green); }
.dash-tag-fine { background: var(--accent-bg); color: #b45309; }
.dash-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dash-empty { text-align: center; color: var(--text-muted); font-size: 13px; padding: 18px 0; }
.dash-shortcuts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.dash-shortcut { display: flex; align-items: center; gap: 8px; padding: 12px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 600; transition: var(--transition); font-family: var(--font); color: var(--text); text-align: left; }
.dash-shortcut:hover { border-color: var(--primary); background: var(--accent-bg); transform: translateY(-1px); }
.dash-shortcut .ico { font-size: 20px; }
.dash-card.wide { grid-column: 1 / -1; }
/* Config modal */
.dash-cfg-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; cursor: grab; }
.dash-cfg-item.dragging { opacity: .5; }
.dash-cfg-item .grip { color: var(--text-muted); cursor: grab; font-size: 16px; }
.dash-cfg-item .lbl { flex: 1; font-size: 14px; font-weight: 600; }
.dash-cfg-item .sw { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.dash-cfg-item .sw input { opacity: 0; width: 0; height: 0; }
.dash-cfg-item .sw .slider { position: absolute; inset: 0; background: var(--border); border-radius: 24px; transition: .2s; cursor: pointer; }
.dash-cfg-item .sw .slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.dash-cfg-item .sw input:checked + .slider { background: var(--primary); }
.dash-cfg-item .sw input:checked + .slider::before { transform: translateX(20px); }
