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

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;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.hidden {
    display: none !important;
}

/* Login Styles */
.login-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

.login-box h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 2em;
}

.login-box p {
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
}

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

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

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

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

button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

button:hover {
    transform: translateY(-2px);
}

.error-message {
    color: #e74c3c;
    margin-top: 15px;
    font-weight: 500;
}

/* Dashboard Styles */
#dashboardContainer {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

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

header h1 {
    font-size: 1.8em;
}

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

.logout-btn {
    width: auto;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    font-size: 14px;
}

main {
    padding: 30px;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.service-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 25px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.service-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.service-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.service-name {
    font-size: 1.4em;
    font-weight: 600;
    color: #333;
}

.service-website {
    color: #667eea;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 500;
}

.service-website:hover {
    text-decoration: underline;
}

.service-provider {
    margin-bottom: 15px;
    padding: 8px 12px;
    background: #e3f2fd;
    border-radius: 6px;
    border-left: 3px solid #2196f3;
}

.provider-label {
    color: #666;
    font-size: 0.85em;
    font-weight: 500;
}

.provider-name {
    color: #2196f3;
    font-weight: 600;
    margin-left: 5px;
}

.credential-group {
    margin-bottom: 15px;
}

.credential-group label {
    display: block;
    color: #666;
    font-size: 0.9em;
    font-weight: 500;
    margin-bottom: 5px;
}

.credential-input {
    display: flex;
    gap: 8px;
    align-items: center;
}

.credential-input input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.copy-btn {
    width: auto;
    padding: 8px 12px;
    background: #28a745;
    font-size: 12px;
    white-space: nowrap;
}

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

.copy-btn.copied {
    background: #20c997;
}

/* Service Actions */
.service-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 8px;
}

.edit-btn, .delete-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.edit-btn {
    background: #007bff;
    color: white;
}

.edit-btn:hover {
    background: #0056b3;
}

.delete-btn {
    background: #dc3545;
    color: white;
}

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

/* Add Service Card */
.add-service-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px dashed #adb5bd;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    transition: all 0.3s ease;
}

.add-service-card:hover {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.add-service-content {
    text-align: center;
}

.add-icon {
    font-size: 3em;
    margin-bottom: 10px;
    opacity: 0.7;
}

.add-service-card h3 {
    margin: 0 0 8px 0;
    font-size: 1.2em;
}

.add-service-card p {
    margin: 0;
    opacity: 0.8;
    font-size: 0.9em;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e9ecef;
}

.modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 1.5em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8em;
    color: #adb5bd;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f8f9fa;
    color: #6c757d;
}

.service-form {
    padding: 25px;
}

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

.service-form .form-group:last-child {
    margin-bottom: 0;
}

.service-form label {
    display: block;
    margin-bottom: 6px;
    color: #333;
    font-weight: 500;
    font-size: 0.9em;
}

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

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

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

.form-actions button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.form-actions button[type="button"] {
    background: #6c757d;
    color: white;
}

.form-actions button[type="button"]:hover {
    background: #545b62;
}

.form-actions button[type="submit"] {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.form-actions button[type="submit"]:hover {
    transform: translateY(-2px);
}

/* Success Message */
.success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
    z-index: 1001;
    font-weight: 500;
    display: none;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Empty Message */
.empty-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-size: 1.1em;
}

.empty-message p {
    margin: 0;
}

/* Responsive Design */
@media (max-width: 480px) {
    body {
        padding: 0;
        align-items: flex-start;
    }
    
    .container {
        padding: 10px;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .login-box {
        padding: 20px;
        margin: 10px 0;
        border-radius: 8px;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    }
    
    .login-box h1 {
        font-size: 1.6em;
        margin-bottom: 8px;
    }
    
    .login-box p {
        font-size: 0.95em;
        margin-bottom: 20px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-group input {
        padding: 14px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 6px;
    }
    
    button {
        padding: 14px 12px;
        font-size: 16px;
        border-radius: 6px;
        min-height: 48px; /* Better touch target */
    }
    
    #dashboardContainer {
        border-radius: 0;
        min-height: 100vh;
    }
    
    header {
        padding: 12px 15px;
        flex-direction: column;
        gap: 8px;
        text-align: center;
        border-radius: 0;
    }
    
    header h1 {
        font-size: 1.4em;
    }
    
    .user-info {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    .logout-btn {
        width: 100%;
        padding: 10px 16px;
        min-height: 44px;
    }
    
    main {
        padding: 15px;
    }
    
    .services-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .service-card {
        padding: 15px;
        border-radius: 8px;
    }
    
    .service-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .service-name {
        font-size: 1.2em;
    }
    
    .service-website {
        font-size: 0.85em;
    }
    
    .service-provider {
        padding: 6px 10px;
        margin-bottom: 12px;
    }
    
    .provider-label, .provider-name {
        font-size: 0.8em;
    }
    
    .credential-group {
        margin-bottom: 12px;
    }
    
    .credential-group label {
        font-size: 0.85em;
        margin-bottom: 4px;
    }
    
    .credential-input {
        gap: 6px;
        flex-wrap: wrap;
    }
    
    .credential-input input {
        flex: 1;
        min-width: 200px;
        padding: 10px;
        font-size: 14px;
    }
    
    .copy-btn {
        padding: 10px 12px;
        font-size: 11px;
        min-height: 40px;
        min-width: 60px;
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    .container {
        padding: 15px;
    }
    
    .login-box {
        padding: 30px 25px;
        max-width: 480px;
    }
    
    .login-box h1 {
        font-size: 1.8em;
    }
    
    .form-group input {
        padding: 12px;
        font-size: 16px;
    }
    
    button {
        padding: 12px;
        min-height: 48px;
    }
    
    header {
        padding: 15px 20px;
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    header h1 {
        font-size: 1.6em;
    }
    
    .user-info {
        gap: 12px;
    }
    
    .logout-btn {
        padding: 10px 16px;
        min-height: 44px;
    }
    
    main {
        padding: 20px;
    }
    
    .services-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }
    
    .service-card {
        padding: 20px;
    }
    
    .service-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .credential-input {
        gap: 8px;
    }
    
    .credential-input input {
        padding: 10px 12px;
    }
    
    .copy-btn {
        padding: 10px 12px;
        font-size: 12px;
        min-height: 42px;
    }
}

@media (max-width: 320px) {
    .login-box h1 {
        font-size: 1.4em;
    }
    
    .login-box p {
        font-size: 0.9em;
    }
    
    .service-name {
        font-size: 1.1em;
    }
    
    .credential-input {
        flex-direction: column;
        align-items: stretch;
    }
    
    .credential-input input {
        min-width: auto;
        margin-bottom: 6px;
    }
    
    .copy-btn {
        width: 100%;
        margin-bottom: 4px;
    }
    
    .copy-btn:last-child {
        margin-bottom: 0;
    }
    
    .service-actions {
        margin-top: 12px;
        padding-top: 12px;
        flex-direction: column;
        gap: 6px;
    }
    
    .edit-btn, .delete-btn {
        width: 100%;
        min-height: 44px;
    }
    
    .modal {
        margin: 10px;
        max-width: calc(100vw - 20px);
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-header h2 {
        font-size: 1.3em;
    }
    
    .service-form {
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button {
        width: 100%;
        min-height: 48px;
    }
    
    .add-service-card {
        min-height: 150px;
    }
    
    .add-icon {
        font-size: 2.5em;
    }
    
    .success-message {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    button:hover {
        transform: none;
    }
    
    .service-card:hover {
        transform: none;
    }
    
    button:active {
        transform: scale(0.98);
    }
    
    .copy-btn:active {
        transform: scale(0.95);
    }
}