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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #4c6971 0%, #b32f3b 100%);
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

/* Accessibility: Skip link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #4c6971;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

.logo-bottom-right {
    position: fixed;
    bottom: 60px; /* Moved up to account for footer (40px footer + 20px margin) */
    right: 20px;
    z-index: 100;
    opacity: 0.9;
    transition: opacity 0.3s;
}

.logo-bottom-right:hover {
    opacity: 1;
}

.logo-bottom-right img {
    max-width: 150px;
    height: auto;
    display: block;
}

@media (max-width: 768px) {
    .logo-bottom-right {
        bottom: 70px; /* Moved up more on mobile due to taller footer (50px footer + 20px margin) */
        right: 10px;
    }
    
    .logo-bottom-right img {
        max-width: 100px;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 40px;
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
        border-radius: 0;
        margin: 0;
    }
    
    body {
        padding: 0;
    }
}

h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 2.5em;
}

h2 {
    color: #555;
    margin: 30px 0 20px 0;
    font-size: 1.5em;
    border-bottom: 2px solid #4c6971;
    padding-bottom: 10px;
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.8em;
    }
    
    h2 {
        font-size: 1.3em;
        margin: 20px 0 15px 0;
    }
    
    .subtitle {
        font-size: 0.9em;
    }
    
    /* Mobile table responsiveness */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    
    table th,
    table td {
        font-size: 0.9em;
        padding: 8px;
    }
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
}

.nav-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

@media (max-width: 768px) {
    .nav-buttons {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

.btn {
    padding: 20px;
    background: linear-gradient(135deg, #4c6971 0%, #b32f3b 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    text-align: center;
    font-size: 1.1em;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    cursor: pointer;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(76, 105, 113, 0.4);
}

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

label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="time"],
input[type="tel"],
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.3s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #4c6971;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 5px;
}

.radio-group label {
    display: flex;
    align-items: center;
    font-weight: normal;
}

.radio-group input[type="radio"] {
    width: auto;
    margin-right: 5px;
}

.submit-btn {
    width: 100%;
    padding: 15px;
    margin-top: 20px;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: #4c6971;
    text-decoration: none;
    font-weight: 600;
}

.back-link:hover {
    text-decoration: underline;
}

.success-message {
    background: #4caf50;
    color: white;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    display: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    overflow-x: auto;
    display: block;
}

thead, tbody, tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    word-wrap: break-word;
}

th {
    background: #4c6971;
    color: white;
    font-weight: 600;
}

@media (max-width: 768px) {
    /* Wrapper for horizontal scroll */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        font-size: 0.7em;
    }
    
    thead, tbody {
        display: table;
        width: 100%;
        min-width: 600px;
    }
    
    tr {
        display: table-row;
    }
    
    th, td {
        display: table-cell;
        padding: 8px 6px;
        white-space: nowrap;
        font-size: 1em;
    }
    
    th {
        font-size: 0.9em;
    }
}

tbody tr:hover {
    background: #e8f4f8;
    cursor: pointer;
}

tbody tr {
    transition: background-color 0.2s;
}

/* Mobile card layout for tables */
@media (max-width: 768px) {
    .mobile-card-container {
        display: block;
    }
    
    .mobile-card {
        background: white;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 15px;
        margin-bottom: 15px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        cursor: pointer;
        transition: transform 0.2s, box-shadow 0.2s;
    }
    
    .mobile-card:active {
        transform: scale(0.98);
        box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }
    
    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 2px solid #4c6971;
    }
    
    .mobile-card-id {
        font-weight: bold;
        color: #4c6971;
        font-size: 1.1em;
    }
    
    .mobile-card-date {
        color: #666;
        font-size: 0.9em;
    }
    
    .mobile-card-body {
        display: grid;
        gap: 8px;
    }
    
    .mobile-card-row {
        display: flex;
        flex-direction: column;
    }
    
    .mobile-card-label {
        font-weight: 600;
        color: #555;
        font-size: 0.85em;
        margin-bottom: 2px;
    }
    
    .mobile-card-value {
        color: #333;
        font-size: 0.95em;
    }
    
    .mobile-card-actions {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid #eee;
    }
    
    .mobile-delete-btn {
        background: #f44336;
        color: white;
        border: none;
        padding: 8px 16px;
        border-radius: 5px;
        font-size: 0.9em;
        cursor: pointer;
        width: 100%;
    }
    
    /* Hide tables on mobile, show cards instead */
    table.hide-on-mobile {
        display: none !important;
    }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-number {
        font-size: 2em;
    }
}

.stat-card {
    background: linear-gradient(135deg, #4c6971 0%, #b32f3b 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.3s;
}

.clickable-stat {
    cursor: pointer;
}

.clickable-stat:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(76, 105, 113, 0.5);
}

.stat-card.stat-active {
    box-shadow: 0 0 0 4px #ffd700;
    transform: scale(1.05);
}

.stat-number {
    font-size: 2.5em;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9em;
    opacity: 0.9;
}

.filter-section {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.filter-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

@media (max-width: 768px) {
    .filter-group {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .filter-section {
        padding: 15px;
    }
}


/* Print styles */
@media print {
    body {
        background: white;
        padding: 0;
        margin: 0;
    }
    
    .container {
        box-shadow: none;
        max-width: 100%;
        padding: 20px;
        margin: 0;
    }
    
    .back-link,
    .btn,
    .nav-buttons,
    #reportActions,
    .user-header,
    .filter-section,
    .stats-grid,
    .no-print {
        display: none !important;
    }
    
    .success-message {
        background: white;
        color: black;
        border: 1px solid #ddd;
    }
    
    h1, h2 {
        color: black;
        page-break-after: avoid;
    }
    
    table {
        page-break-inside: avoid;
    }
    
    tr {
        page-break-inside: avoid;
    }
    
    /* Report view specific */
    #reportContent table {
        border: 1px solid #000;
    }
    
    #reportContent th,
    #reportContent td {
        border: 1px solid #000;
        padding: 8px;
    }
    
    #reportContent th {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    /* Attachments section */
    #attachmentsSection {
        page-break-before: avoid;
        margin-top: 20px;
        border-top: 2px solid #000;
        padding-top: 20px;
    }
    
    #attachmentsList ul {
        list-style: none;
        padding: 0;
    }
    
    #attachmentsList li {
        border: 1px solid #ddd;
        padding: 10px;
        margin: 5px 0;
    }
    
    /* Logo */
    img {
        max-width: 200px;
        height: auto;
    }
}


/* User header styles */
.user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-badge {
    padding: 4px 10px;
    background: #4c6971;
    color: white;
    border-radius: 12px;
    font-size: 0.85em;
}

.user-actions {
    display: flex;
    gap: 10px;
}

.header-btn {
    padding: 8px 16px;
    background: #4c6971;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.9em;
    white-space: nowrap;
}

.logout-btn {
    background: #b32f3b;
}

@media (max-width: 768px) {
    .user-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .user-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .header-btn {
        width: 100%;
        text-align: center;
    }
    
    .btn-text {
        display: inline;
    }
}

@media (max-width: 480px) {
    .btn-text {
        display: none;
    }
}

/* Modal mobile improvements */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 20px;
        margin: 10% auto;
    }
    
    .checkbox-group {
        grid-template-columns: 1fr;
    }
}

/* Action buttons mobile */
@media (max-width: 768px) {
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons button {
        width: 100%;
    }
}

/* Report actions mobile */
@media (max-width: 768px) {
    #reportActions > div {
        flex-direction: column;
    }
    
    #reportActions button {
        width: 100%;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn, button, a {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    input, select, textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}


/* Stats header */
.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.filter-indicator {
    display: none;
    padding: 8px 16px;
    background: #fff3cd;
    color: #856404;
    border-radius: 5px;
    font-size: 0.9em;
}

@media (max-width: 768px) {
    .stats-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .stats-header h2 {
        margin: 0;
        font-size: 1.3em;
    }
    
    .stats-header > div {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        width: 100%;
    }
    
    .stats-header button.btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 120px;
        max-width: calc(50% - 4px);
        font-size: 0.75em !important;
        padding: 10px 8px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .filter-indicator {
        font-size: 0.8em;
        padding: 6px 12px;
        width: 100%;
        text-align: center;
        flex: 1 1 100%;
    }
    
    /* Export section mobile improvements */
    .container > div[style*="margin-top: 40px"] {
        margin-top: 20px !important;
        padding: 20px 15px !important;
    }
    
    .container > div[style*="margin-top: 40px"] h3 {
        font-size: 1.1em !important;
        margin-bottom: 15px !important;
    }
    
    .container > div[style*="margin-top: 40px"] button {
        font-size: 0.85em !important;
        padding: 10px 16px !important;
        flex: 1 1 calc(50% - 5px) !important;
        min-width: 0 !important;
    }
    
    .container > div[style*="margin-top: 40px"] p {
        font-size: 0.8em !important;
    }
}

/* Improve table scrolling on mobile */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    thead, tbody {
        display: table;
        width: 100%;
    }
}


/* Multi-step form styles */
.step-indicator {
    font-size: 0.85em;
    color: #999;
    font-weight: 600;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.3s;
}

.step-indicator.active {
    color: #4c6971;
    background: #e8f4f8;
}

.step-indicator.completed {
    color: #4caf50;
}

.form-step {
    display: none;
}

.form-step.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.step-navigation button {
    padding: 12px 30px;
    font-size: 1em;
}

@media (max-width: 768px) {
    .step-indicator {
        font-size: 0.7em;
        padding: 4px;
    }
    
    .step-navigation {
        flex-direction: column;
        gap: 10px;
    }
    
    .step-navigation button {
        width: 100%;
    }
}

/* Version Footer */
.version-footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    color: #999;
    font-size: 0.75em;
    border-top: 1px solid #e0e0e0;
}

.version-footer a {
    color: #999;
    text-decoration: none;
}

.version-footer a:hover {
    color: #4c6971;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border: 1px solid #888;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
}

.modal-content .close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 20px;
    cursor: pointer;
    transition: color 0.3s;
}

.modal-content .close:hover,
.modal-content .close:focus {
    color: #000;
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }
}
