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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #ffffff;
    color: #111111;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Login page */
.login-body {
    background: #ffffff;
    color: black;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Documenti page */
.doc-body {
    background: #ffffff;
    color: #0b74b4;
    display: block;
    padding: 0;
}

/* Container */
.container {
    width: 100%;
    max-width: 500px;
    padding: 24px;
}

.doc-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px;
}

/* Card minimalissima */
.card {
    background: #ffffff;
    border: 2px solid #0b74b4;
    border-radius: 16px;
}

/* Header essenziale */
.header {
    padding: 40px 24px 24px;
    text-align: center;
}

.logo {
    width: 48px;
    height: 48px;
    background: #111111;
    border-radius: 12px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 500;
    color: #ffffff;
}

.header h1 {
    font-size: 24px;
    font-weight: 500;
    color: #111111;
    margin-bottom: 8px;
}

.header p {
    font-size: 14px;
    color: #666666;
}

/* Content */
.content {
    padding: 24px;
}

/* QR section minimal */
.qr-section {
    background: #f8f8f8;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.qr-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666666;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
}

.qr-code-display {
    background: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 10px;
    padding: 16px;
    font-family: 'SF Mono', monospace;
    color: #111111;
    text-align: center;
    font-size: 15px;
    word-break: break-all;
}

/* Form ultra-minimal */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #666666;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #eaeaea;
    border-radius: 10px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    background: #ffffff;
    transition: border 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #111111;
}

.form-group input::placeholder {
    color: #aaaaaa;
}

/* Buttons essenziali */
.btn-login {
    width: 100%;
    padding: 14px;
    background: #0b74b4;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 8px;
}

.btn-login:hover {
    opacity: 0.8;
}

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

.btn-back {
    background: none;
    border: 1px solid #eaeaea;
    padding: 10px 18px;
    border-radius: 30px;
    color: #666666;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 24px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-back:hover {
    border-color: #111111;
    color: #111111;
}

/* Pulsante download tutto */
.btn-download-all {
    background: none;
    color: #0b74b4;
    border: solid 1px #0b74b4;
    padding: 10px 18px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 24px;    
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.btn-download-all:hover {
    color: white;
    background: #0b74b4;
}

.btn-download-all:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-download-all i {
    font-size: 14px;
}

/* Mobile responsive per il pulsante */
@media (max-width: 768px) {
    .page-title > div {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .btn-download-all {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .btn-download-all {
        padding: 8px 16px;
        font-size: 12px;
    }
}

.btn-icon {
    width: 34px;
    height: 34px;
    border: 1px solid #eaeaea;
    border-radius: 8px;
    background: #ffffff;
    color: #666666;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-icon:hover {
    border-color: #111111;
    color: #0b74b4;
}

.btn-primary {
    background: #111111;
    color: #ffffff;
    border: none;
    padding: 10px 24px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    opacity: 0.8;
}

/* Messages puliti */
.message {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 500;
}

.message.error {
    background: #fff1f0;
    color: #c2410c;
}

.message.success {
    background: #f0f9f0;
    color: #0f6e3f;
}

.message.info {
    background: #f0f5ff;
    color: #1e4a7a;
}

/* Loading minimal */
.loading {
    display: none;
    text-align: center;
    margin: 20px 0;
}

.loading.active {
    display: block;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 2px solid #eaeaea;
    border-top-color: #111111;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 0 auto;
}

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

.loading-spinner {
    text-align: center;
    padding: 40px;
    color: #666666;
    font-size: 14px;
}

.loading-spinner i {
    font-size: 28px;
    color: #111111;
    margin-bottom: 12px;
}

/* Navbar essenziale */
.navbar {
    background: #ffffff;
    border-bottom: 1px solid #eaeaea;
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-mini {
    width: 40px;
    height: 40px;
    background: #111111;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 500;
    font-size: 18px;
}

.cantiere-info {
    display: flex;
    flex-direction: column;
}

.cantiere-nome {
    font-weight: 500;
    color: #111111;
    font-size: 15px;
}

.cantiere-codice {
    font-size: 12px;
    color: #888888;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #f8f8f8;
    padding: 6px 16px 6px 20px;
    border-radius: 40px;
}

.user-name {
    font-weight: 500;
    color: #111111;
    font-size: 13px;
}

.logout-btn {
    background: none;
    border: none;
    color: #c2410c;
    cursor: pointer;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 20px;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #c2410c;
    color: white;
}

/* Page title pulito */
.page-title {
    margin-bottom: 32px;
}

.page-title h2 {
    font-size: 20px;
    font-weight: 500;
    color: #111111;
    margin-bottom: 4px;
}

.page-title p {
    color: #888888;
    font-size: 13px;
}

/* Grids minimal */
.document-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 10px;
}

/* Cards minimalissime */
.folder-card {
    background: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 14px;
    padding: 20px;
    transition: border 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.folder-card:hover {
    border-color: #111111;
}

.folder-icon {
    width: 44px;
    height: 44px;
    background: #f8f8f8;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: #0b74b4;
    font-size: 22px;
}

.folder-name {
    font-weight: 500;
    color: #111111;
    margin-bottom: 6px;
    font-size: 15px;
}

.folder-meta {
    color: #888888;
    font-size: 12px;
}

.folder-card .btn-icon {
    margin-left: auto;
    flex-shrink: 0;
}

.file-card {
    background: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    padding: 14px;
    align-items: center;
    gap: 12px;
    transition: border 0.2s;
    display: flex;
    position: relative;
    cursor: pointer;
}

.file-card:hover {
    border-color: #111111;
}

.file-icon {
    width: 38px;
    height: 38px;
    background: #f8f8f8;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0b74b4;
    font-size: 18px;
    flex-shrink: 0;
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    color: #111111;
    margin-bottom: 4px;
    font-size: 13px;
    word-break: break-word;
}

.file-meta {
    font-size: 11px;
    color: #888888;
    display: flex;
    gap: 12px;
}

.file-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .file-card {
        flex-wrap: wrap;
    }
    
    .file-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 8px;
    }
    
    .folder-card .btn-icon {
        margin-left: 0;
    }
}

/* Breadcrumb minimal */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    color: #888888;
    font-size: 13px;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: #111111;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

/* Path navigation */
.path-navigation {
    background: #f8f8f8;
    border-radius: 30px;
    padding: 12px 18px;
    margin-bottom: 24px;
    font-size: 13px;
    word-break: break-all;
}

.path-navigation span:first-child {
    color: #888888;
    margin-right: 8px;
}

.path-navigation .path-current {
    color: #111111;
    font-weight: 500;
}

/* Empty state minimale */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 16px;
    color: #888888;
}

.empty-state i {
    font-size: 44px;
    color: #cccccc;
    margin-bottom: 16px;
}

.empty-state h3 {
    color: #111111;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 16px;
}

/* Access denied */
.access-denied {
    text-align: center;
    padding: 80px 20px;
    background: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 16px;
}

.access-denied i {
    font-size: 56px;
    color: #cccccc;
    margin-bottom: 20px;
}

.access-denied h2 {
    color: #111111;
    font-weight: 500;
    margin-bottom: 10px;
    font-size: 20px;
}

.access-denied p {
    color: #666666;
    margin-bottom: 24px;
    font-size: 14px;
}

/* Error message */
.error-message {
    background: #fff1f0;
    color: #c2410c;
    padding: 14px;
    border-radius: 30px;
    text-align: center;
    margin: 20px 0;
    font-size: 13px;
    border: 1px solid #ffccc7;
}

/* Footer minimale */
.footer {
    text-align: center;
    margin-top: 24px;
    color: #888888;
    font-size: 12px;
}

/* Utility */
h3 {
    font-size: 16px;
    font-weight: 500;
    color: #111111;
    margin-bottom: 16px;
}

/* Tablet (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .doc-container {
        padding: 28px;
    }

    .document-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .file-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .navbar {
        padding: 16px 28px;
    }

    .folder-card {
        padding: 18px;
    }

    .modal-content {
        width: 90%;
        max-width: 800px;
    }
}

/* Mobile landscape (480px - 768px) */
@media (min-width: 480px) and (max-width: 768px) {
    .doc-container {
        padding: 20px;
    }

    .container {
        padding: 16px;
    }

    .card {
        border-radius: 14px;
    }

    .header {
        padding: 30px 20px 20px;
    }

    .logo {
        width: 44px;
        height: 44px;
        font-size: 18px;
        margin-bottom: 20px;
    }

    .header h1 {
        font-size: 22px;
    }

    .content {
        padding: 20px;
    }

    .qr-section {
        padding: 16px;
    }

    .qr-code-display {
        padding: 14px;
        font-size: 14px;
    }

    .form-group input {
        padding: 10px 12px;
    }

    .btn-login {
        padding: 12px;
    }

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

    .folder-card {
        padding: 16px;
    }

    .folder-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
        margin-bottom: 12px;
    }

    .folder-name {
        font-size: 14px;
    }

    .file-card {
        padding: 12px;
    }

    .file-icon {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }

    .file-name {
        font-size: 12px;
    }

    .file-meta {
        font-size: 10px;
        flex-direction: column;
        gap: 4px;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    .path-navigation {
        padding: 10px 14px;
        font-size: 12px;
    }

    .page-title h2 {
        font-size: 18px;
    }

    .page-title p {
        font-size: 12px;
    }

    .btn-back {
        padding: 8px 16px;
        font-size: 12px;
    }

    .empty-state {
        padding: 40px 16px;
    }

    .empty-state i {
        font-size: 40px;
    }

    .empty-state h3 {
        font-size: 15px;
    }

    .modal-content {
        width: 95%;
        margin: 10px auto;
        padding: 16px;
    }

    .btn-download,
    .btn-primary {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
        font-size: 12px;
    }
}

/* Mobile portrait (fino a 480px) */
@media (max-width: 480px) {
    .doc-container {
        padding: 16px;
    }

    .container {
        padding: 12px;
    }

    .card {
        border-radius: 12px;
    }

    .header {
        padding: 24px 16px 16px;
    }

    .logo {
        width: 40px;
        height: 40px;
        font-size: 16px;
        border-radius: 10px;
        margin-bottom: 16px;
    }

    .header h1 {
        font-size: 20px;
        margin-bottom: 6px;
    }

    .header p {
        font-size: 13px;
    }

    .content {
        padding: 16px;
    }

    .qr-section {
        padding: 14px;
        margin-bottom: 20px;
    }

    .qr-label {
        font-size: 12px;
        margin-bottom: 10px;
    }

    .qr-code-display {
        padding: 12px;
        font-size: 13px;
        border-radius: 8px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .form-group label {
        font-size: 12px;
        margin-bottom: 4px;
    }

    .form-group input {
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 8px;
    }

    .btn-login {
        padding: 12px;
        font-size: 13px;
        border-radius: 8px;
    }

    .message {
        padding: 10px 14px;
        font-size: 12px;
        border-radius: 8px;
        margin-bottom: 16px;
    }

    /* Navbar mobile */
    .navbar {
        padding: 12px 16px;
        gap: 12px;
    }

    .logo-area {
        width: 100%;
        justify-content: space-between;
    }

    .logo-mini {
        width: 36px;
        height: 36px;
        font-size: 16px;
        border-radius: 8px;
    }

    .cantiere-nome {
        font-size: 14px;
    }

    .cantiere-codice {
        font-size: 11px;
    }

    .user-info {
        width: 100%;
        padding: 4px 12px 4px 16px;
        border-radius: 30px;
        justify-content: space-between;
    }

    .user-name {
        font-size: 12px;
    }

    .logout-btn {
        font-size: 12px;
        padding: 4px 6px;
    }

    /* Grids */
    .document-grid,
    .file-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .folder-card {
        padding: 14px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .folder-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
        border-radius: 8px;
        margin-bottom: 0;
    }

    .folder-name {
        font-size: 13px;
        margin-bottom: 0;
        flex: 1;
    }

    .folder-meta {
        font-size: 11px;
    }

    .file-card {
        padding: 12px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .file-icon {
        width: 32px;
        height: 32px;
        font-size: 15px;
        border-radius: 8px;
    }

    .file-details {
        flex: 1;
        min-width: 0;
    }

    .file-name {
        font-size: 12px;
        margin-bottom: 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .file-meta {
        font-size: 10px;
        gap: 8px;
    }

    .file-actions {
        gap: 4px;
    }

    .btn-icon {
        width: 30px;
        height: 30px;
        border-radius: 6px;
        font-size: 12px;
    }

    /* Navigation */
    .path-navigation {
        padding: 10px 12px;
        font-size: 11px;
        border-radius: 20px;
        margin-bottom: 20px;
    }

    .page-title {
        margin-bottom: 24px;
    }

    .page-title h2 {
        font-size: 18px;
    }

    .page-title p {
        font-size: 12px;
    }

    .btn-back {
        padding: 8px 14px;
        font-size: 12px;
        border-radius: 20px;
        margin-bottom: 20px;
    }

    /* Breadcrumb */
    .breadcrumb {
        font-size: 12px;
        gap: 6px;
        margin-bottom: 16px;
    }

    /* Empty state */
    .empty-state {
        padding: 40px 16px;
        border-radius: 12px;
    }

    .empty-state i {
        font-size: 36px;
        margin-bottom: 12px;
    }

    .empty-state h3 {
        font-size: 15px;
        margin-bottom: 6px;
    }

    .empty-state p {
        font-size: 12px;
    }

    /* Access denied */
    .access-denied {
        padding: 50px 16px;
        border-radius: 12px;
    }

    .access-denied i {
        font-size: 48px;
        margin-bottom: 16px;
    }

    .access-denied h2 {
        font-size: 18px;
        margin-bottom: 8px;
    }

    .access-denied p {
        font-size: 13px;
        margin-bottom: 20px;
    }

    /* Modal */
    .modal-content {
        width: 95%;
        margin: 10px auto;
        padding: 16px;
        border-radius: 12px;
    }

    .modal-header h2 {
        font-size: 16px;
    }

    .modal-close {
        width: 30px;
        height: 30px;
        font-size: 18px;
    }

    .btn-download,
    .btn-primary {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
        font-size: 12px;
        border-radius: 20px;
    }

    /* Footer */
    .footer {
        font-size: 11px;
        margin-top: 20px;
    }

    /* Loading */
    .loading-spinner {
        padding: 30px;
        font-size: 13px;
    }

    .loading-spinner i {
        font-size: 24px;
    }

    .spinner {
        width: 24px;
        height: 24px;
        border-width: 2px;
    }

    /* Error message */
    .error-message {
        padding: 12px;
        font-size: 12px;
        border-radius: 20px;
        margin: 16px 0;
    }
}

/* Extra small devices (fino a 360px) */
@media (max-width: 360px) {
    .doc-container {
        padding: 12px;
    }

    .container {
        padding: 8px;
    }

    .header h1 {
        font-size: 18px;
    }

    .logo {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .qr-code-display {
        font-size: 12px;
        word-break: break-all;
    }

    .file-meta {
        flex-direction: column;
        gap: 2px;
    }

    .file-actions {
        flex-direction: column;
    }

    .btn-icon {
        width: 28px;
        height: 28px;
    }

    .cantiere-nome {
        font-size: 13px;
    }

    .user-info {
        flex-wrap: wrap;
        gap: 8px;
    }

    .path-navigation {
        font-size: 10px;
        word-break: break-all;
    }
}

/* Stampa */
@media print {
    .navbar,
    .btn-back,
    .file-actions,
    .btn-download,
    .btn-primary,
    .logout-btn {
        display: none !important;
    }

    .doc-container {
        padding: 0;
        max-width: 100%;
    }

    .file-card,
    .folder-card {
        border: 1px solid #000;
        break-inside: avoid;
    }

    .path-navigation {
        border: 1px solid #000;
        background: none;
    }
}

/* Touch devices optimization */
@media (hover: none) and (pointer: coarse) {
    .folder-card:hover,
    .file-card:hover,
    .btn-icon:hover,
    .btn-back:hover {
        border-color: #eaeaea;
    }

    .folder-card:active,
    .file-card:active {
        background-color: #f8f8f8;
    }

    .btn-icon:active {
        background-color: #f8f8f8;
        border-color: #eaeaea;
    }
}