* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f3f6fa;
    color: #222;
}

a {
    text-decoration: none;
}

/* LOGIN */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0b3c5d, #1d6f9f);
}

.login-box {
    width: 360px;
    background: white;
    padding: 35px;
    border-radius: 16px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.25);
    text-align: center;
}

.login-box h1 {
    margin: 0;
    color: #0b3c5d;
}

.login-box p {
    color: #666;
    margin-bottom: 25px;
}

.login-box input {
    width: 100%;
    padding: 13px;
    margin-bottom: 14px;
    border: 1px solid #ccc;
    border-radius: 9px;
    font-size: 15px;
}

.login-box button {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 9px;
    background: #0b6fa4;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

.login-box button:hover {
    background: #095b86;
}

/* FLASH */

.flash {
    padding: 11px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
}

.flash.error {
    background: #fdecea;
    color: #b3261e;
}

.flash.success {
    background: #e7f6ec;
    color: #137333;
}

/* TOPBAR */

.topbar {
    background: #0b3c5d;
    color: white;
    padding: 22px 35px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar h1 {
    margin: 0;
    font-size: 26px;
}

.top-actions {
    display: flex;
    gap: 10px;
}

/* BUTTONS */

.btn {
    display: inline-block;
    padding: 11px 17px;
    border-radius: 9px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

.btn.green {
    background: #198754;
    color: white;
}

.btn.red {
    background: #dc3545;
    color: white;
}

.btn.grey {
    background: #6c757d;
    color: white;
}

.btn.blue {
    background: #0d6efd;
    color: white;
}

/* SEARCH */

.search-box {
    padding: 25px 35px 5px;
}

.search-box form {
    display: flex;
    gap: 10px;
}

.search-box input {
    flex: 1;
    padding: 13px;
    border: 1px solid #ccd3da;
    border-radius: 9px;
    font-size: 15px;
}

.search-box button {
    padding: 13px 22px;
    border: none;
    border-radius: 9px;
    background: #0b6fa4;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

/* DASHBOARD */

.tickets-container {
    padding: 25px 35px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 18px;
}

.ticket-card {
    background: white;
    border-radius: 14px;
    padding: 18px;
    color: #222;
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    border-left: 6px solid #0b6fa4;
    transition: 0.15s;
}

.ticket-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(0,0,0,0.13);
}

.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ticket-header strong {
    color: #0b3c5d;
}

.ticket-header span {
    background: #e7f1ff;
    color: #0b6fa4;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
}

.ticket-body h3 {
    margin-bottom: 6px;
    color: #222;
}

.ticket-body p {
    color: #666;
    margin: 0;
}

.ticket-footer {
    margin-top: 16px;
    color: #777;
    font-size: 13px;
}

/* FORM */

.form-container {
    max-width: 760px;
    margin: 45px auto;
    background: white;
    padding: 35px;
    border-radius: 16px;
    box-shadow: 0 5px 18px rgba(0,0,0,0.08);
}

.form-container h1 {
    margin-top: 0;
    color: #0b3c5d;
}

.form-container input,
.form-container select,
.form-container textarea {
    width: 100%;
    padding: 13px;
    margin-bottom: 16px;
    border: 1px solid #ccd3da;
    border-radius: 9px;
    font-size: 15px;
}

.form-container textarea {
    resize: vertical;
}

.buttons {
    display: flex;
    gap: 10px;
}

/* DETAIL */

.detail-container {
    max-width: 900px;
    margin: 40px auto;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-header h1 {
    color: #0b3c5d;
}

.detail-card {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 5px 18px rgba(0,0,0,0.08);
}

.detail-card h2 {
    margin-top: 0;
    color: #222;
}

.descrizione {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 18px;
    line-height: 1.5;
    white-space: pre-wrap;
}



/* RESPONSIVE */

@media (max-width: 700px) {
    .topbar {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .search-box form {
        flex-direction: column;
    }

    .tickets-container {
        grid-template-columns: 1fr;
        padding: 20px;
    }

    .form-container,
    .detail-container {
        margin: 20px;
    }
}

.messages-box {
    margin-top: 15px;
}

.message-card {
    background: #f8f9fa;
    border-left: 5px solid #0b6fa4;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 14px;
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: #0b3c5d;
}

.message-header span {
    color: #777;
    font-size: 13px;
}

.message-text {
    white-space: pre-wrap;
    line-height: 1.5;
}

.reply-form {
    margin-top: 25px;
}

.reply-form textarea {
    width: 100%;
    padding: 13px;
    border: 1px solid #ccd3da;
    border-radius: 9px;
    font-size: 15px;
    resize: vertical;
    margin-bottom: 12px;
}

.empty-text {
    color: #777;
    font-style: italic;
}

.stato-form {
    display: flex;
    gap: 10px;
    margin: 15px 0;
}

.stato-form select {
    padding: 11px;
    border-radius: 9px;
    border: 1px solid #ccd3da;
    font-size: 14px;
}

.message-card.ruolo-cliente {
    border-left-color: #0b6fa4;
    background: #f8fbff;
}

.message-card.ruolo-operatore {
    border-left-color: #198754;
    background: #f4fbf7;
}

.message-card.ruolo-admin {
    border-left-color: #dc3545;
    background: #fff6f6;
}

.users-container {
    max-width: 1100px;
    margin: 25px auto 50px;
    display: grid;
    gap: 15px;
}

.user-card {
    background: white;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-between;
    gap: 20px;
    border-left: 6px solid #0b6fa4;
}

.user-card h3 {
    margin: 0 0 6px;
    color: #0b3c5d;
}

.user-card p {
    margin: 5px 0;
}

.user-actions {
    min-width: 260px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-actions form {
    display: flex;
    gap: 8px;
}

.user-actions input {
    padding: 10px;
    border: 1px solid #ccd3da;
    border-radius: 8px;
}

.status-ok {
    color: #198754;
    font-weight: bold;
}

.status-ko {
    color: #dc3545;
    font-weight: bold;
}

.filter-form {
    align-items: center;
}

.filter-form select,
.filter-form input[type="date"] {
    padding: 13px;
    border: 1px solid #ccd3da;
    border-radius: 9px;
    font-size: 15px;
    background: white;
}

.ticket-card.stato-card-aperto {
    border-left-color: #0d6efd;
}

.ticket-card.stato-card-in-lavorazione {
    border-left-color: #fd7e14;
}

.ticket-card.stato-card-in-attesa-cliente {
    border-left-color: #6f42c1;
}

.ticket-card.stato-card-chiuso {
    border-left-color: #198754;
    opacity: 0.82;
}

.badge-stato,
.badge-priorita {
    display: inline-block;
    padding: 6px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: bold;
}

.badge-stato.stato-aperto {
    background: #e7f1ff;
    color: #0d6efd;
}

.badge-stato.stato-in-lavorazione {
    background: #fff3e6;
    color: #c85c00;
}

.badge-stato.stato-in-attesa-cliente {
    background: #f1e8ff;
    color: #5e2ca5;
}

.badge-stato.stato-chiuso {
    background: #e7f6ec;
    color: #198754;
}

.badge-priorita {
    margin-top: 8px;
}

.badge-priorita.priorita-normale {
    background: #e7f1ff;
    color: #0d6efd;
}

.badge-priorita.priorita-alta {
    background: #fff3e6;
    color: #c85c00;
}

.badge-priorita.priorita-urgente {
    background: #fdecea;
    color: #dc3545;
}

.compact-form {
    padding: 22px;
    margin-bottom: 20px;
}

.compact-form h2 {
    margin-top: 0;
}

.filter-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-form input,
.filter-form select {
    padding: 13px;
    border: 1px solid #ccd3da;
    border-radius: 9px;
    font-size: 15px;
    background: white;
}

.filter-form input[type="text"] {
    min-width: 300px;
    flex: 1;
}

.compact-form {
    padding: 22px;
    margin-top: 25px;
    margin-bottom: 20px;
}

.admin-filter-bar {
    display: flex;
    justify-content: flex-end;
    padding: 14px 35px;
}

.admin-filter-bar .filter-form {
    display: flex;
    gap: 8px;
    align-items: center;
    background: white;
    padding: 10px 12px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.06);
}

.admin-filter-bar input,
.admin-filter-bar select {
    padding: 8px 10px;
    border: 1px solid #ccd3da;
    border-radius: 7px;
    font-size: 13px;
    height: 36px;
}

.admin-filter-bar input {
    width: 220px;
}

.admin-filter-bar select {
    width: 180px;
}

.admin-filter-bar button,
.admin-filter-bar .btn {
    height: 36px;
    padding: 0 12px;
    font-size: 13px;
}

.check-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    background: white;
    padding: 10px 12px;
    border-radius: 9px;
    border: 1px solid #ccd3da;
    font-size: 14px;
    white-space: nowrap;
}

.check-filter input {
    width: auto;
}

.closed-ticket-warning {
    margin-top: 20px;
    padding: 16px;
    background: #e7f6ec;
    color: #198754;
    border: 1px solid #b9e2c6;
    border-radius: 10px;
    font-weight: bold;
    text-align: center;
}

.login-logo {
    text-align: center;
    margin-bottom: 18px;
}

.login-logo img {
    max-width: 140px;
    max-height: 90px;
    object-fit: contain;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

.powered-by {
    margin-top: 28px;
    text-align: center;
    font-size: 12px;
    color: #888;
}

.powered-by strong {
    color: #0b3c5d;
}

.economic-form {
    background: #f8f9fa;
    padding: 18px;
    border-radius: 12px;
    border: 1px solid #dde3ea;
}

.economic-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.economic-form label {
    display: block;
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 5px;
    color: #0b3c5d;
}

.economic-form input,
.economic-form select,
.economic-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccd3da;
    border-radius: 8px;
    font-size: 14px;
}

.economic-form textarea {
    margin-bottom: 12px;
    resize: vertical;
}

@media (max-width: 900px) {
    .economic-grid {
        grid-template-columns: 1fr;
    }
}

.report-container {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 25px;
}

.report-filter {
    background: white;
    padding: 16px;
    border-radius: 14px;
    box-shadow: 0 5px 18px rgba(0,0,0,0.08);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.report-filter input,
.report-filter select {
    padding: 10px;
    border: 1px solid #ccd3da;
    border-radius: 8px;
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.report-summary div {
    background: white;
    padding: 18px;
    border-radius: 14px;
    box-shadow: 0 5px 18px rgba(0,0,0,0.08);
}

.report-summary strong {
    display: block;
    color: #0b3c5d;
}

.report-summary span {
    font-size: 24px;
    font-weight: bold;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 5px 18px rgba(0,0,0,0.08);
}

.report-table th {
    background: #0b3c5d;
    color: white;
    padding: 12px;
    text-align: left;
}

.report-table td {
    padding: 11px;
    border-bottom: 1px solid #e5e9ef;
}

.report-table .num {
    text-align: right;
}
