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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 28px;
    font-weight: 600;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background: white;
    color: #667eea;
}

.btn-primary:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-edit {
    background: #28a745;
    color: white;
    padding: 6px 12px;
    font-size: 12px;
    margin-right: 5px;
}

.btn-edit:hover {
    background: #218838;
}

.btn-delete {
    background: #dc3545;
    color: white;
    padding: 6px 12px;
    font-size: 12px;
}

.btn-delete:hover {
    background: #c82333;
}

.table-container {
    overflow-x: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead {
    background: #f8f9fa;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
}

td {
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
    color: #212529;
}

tbody tr:hover {
    background: #f8f9fa;
}

tbody tr:last-child td {
    border-bottom: none;
}

a {
    color: #667eea;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    opacity: 0.7;
}

form {
    padding: 30px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 30px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-state p {
    font-size: 16px;
    margin-top: 10px;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.login-header h1 {
    font-size: 32px;
    margin-bottom: 10px;
}

.login-header p {
    font-size: 16px;
    opacity: 0.9;
}

.login-box form {
    padding: 30px;
}

.btn-block {
    width: 100%;
    margin-top: 10px;
}

.error-message {
    color: #dc3545;
    font-size: 14px;
    margin-top: 10px;
    margin-bottom: 10px;
    display: none;
}

/* Responsive - Mobile First */
@media (max-width: 768px) {
    body {
        padding: 8px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }

    .container {
        border-radius: 12px;
        margin: 0;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    }

    header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 18px 12px;
    }

    header h1 {
        font-size: 20px;
        margin: 0;
    }

    header > div {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    #usernameDisplay {
        display: none;
    }

    .btn {
        width: 100%;
        padding: 16px;
        font-size: 16px;
        font-weight: 600;
        border-radius: 10px;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .btn-primary {
        box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
    }

    .table-container {
        padding: 12px 8px;
        overflow-x: visible;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 14px;
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
    }

    thead {
        display: none;
    }

    tbody tr {
        display: block;
        margin-bottom: 12px;
        border: none;
        border-radius: 12px;
        background: white;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        overflow: hidden;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    tbody tr:active {
        transform: scale(0.98);
        box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    }

    .mobile-card-row td {
        display: block;
        padding: 0;
        border: none;
    }

    .mobile-card {
        padding: 16px;
    }

    .mobile-card-header {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 16px;
        padding-bottom: 16px;
        border-bottom: 2px solid #f0f0f0;
    }

    .mobile-card-name {
        font-size: 20px;
        font-weight: 700;
        color: #667eea;
        line-height: 1.3;
        word-break: break-word;
    }

    .mobile-card-actions {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    .mobile-card-actions .btn {
        flex: 1;
        padding: 12px;
        font-size: 14px;
        font-weight: 600;
        border-radius: 8px;
    }

    .mobile-card-body {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }

    .mobile-card-item {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 10px;
        background: #f8f9fa;
        border-radius: 8px;
    }

    .mobile-label {
        font-weight: 700;
        color: #495057;
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .mobile-card-item span:not(.mobile-label) {
        color: #212529;
        font-size: 15px;
        word-break: break-word;
        line-height: 1.5;
    }

    .mobile-card-item a {
        color: #667eea;
        text-decoration: none;
        font-weight: 500;
        word-break: break-all;
    }

    .mobile-card-item a:active {
        opacity: 0.7;
    }

    th, td {
        padding: 0;
        font-size: 14px;
    }

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

    .empty-state p {
        font-size: 15px;
        line-height: 1.6;
    }

    .modal {
        padding: 0;
    }

    .modal-content {
        width: 100%;
        margin: 0;
        max-height: 100vh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .modal-header {
        padding: 18px 16px;
        border-radius: 0;
        flex-shrink: 0;
    }

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

    .close {
        font-size: 32px;
        padding: 0;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: transparent;
    }

    form {
        padding: 20px 16px;
        overflow-y: auto;
        flex: 1;
        -webkit-overflow-scrolling: touch;
    }

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

    .form-group label {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 8px;
        color: #495057;
    }

    .form-group input {
        padding: 16px;
        font-size: 16px;
        border-radius: 10px;
        border: 2px solid #e0e0e0;
        -webkit-appearance: none;
        appearance: none;
    }

    .form-group input:focus {
        border-color: #667eea;
        outline: none;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    }

    .form-actions {
        flex-direction: column;
        gap: 12px;
        margin-top: 24px;
        padding-top: 20px;
        border-top: 1px solid #e0e0e0;
        position: sticky;
        bottom: 0;
        background: white;
    }

    .form-actions .btn {
        width: 100%;
        padding: 16px;
        font-size: 16px;
        font-weight: 600;
    }

    .login-container {
        padding: 12px;
    }

    .login-box {
        max-width: 100%;
        margin: 0;
        border-radius: 12px;
    }

    .login-header {
        padding: 24px 20px;
    }

    .login-header h1 {
        font-size: 26px;
    }

    .login-header p {
        font-size: 15px;
    }

    .login-box form {
        padding: 24px 20px;
    }

    .btn-block {
        margin-top: 16px;
        padding: 16px;
        font-size: 16px;
        font-weight: 600;
    }
}

/* Mobile muito pequeno */
@media (max-width: 480px) {
    body {
        padding: 6px;
    }

    header {
        padding: 16px 12px;
    }

    header h1 {
        font-size: 18px;
    }

    .table-container {
        padding: 10px 6px;
    }

    .mobile-card {
        padding: 14px;
    }

    .mobile-card-name {
        font-size: 18px;
    }

    .mobile-card-item {
        padding: 8px;
    }

    .mobile-label {
        font-size: 12px;
    }

    .mobile-card-item span:not(.mobile-label) {
        font-size: 14px;
    }

    .modal-header {
        padding: 16px 14px;
    }

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

    form {
        padding: 18px 14px;
    }

    .form-group input {
        padding: 14px;
        font-size: 16px;
    }

    .login-header {
        padding: 20px 16px;
    }

    .login-header h1 {
        font-size: 24px;
    }

    .login-box form {
        padding: 20px 16px;
    }
}
