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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #333;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.header-icon {
    margin-bottom: 10px;
}

.logo-img {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    object-fit: cover;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    letter-spacing: -0.5px;
}

header p {
    font-size: 1rem;
    opacity: 0.95;
}

.nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.tab-btn.active {
    background: white;
    color: #1a1a2e;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
    display: block;
}

form,
.tab-content>div:not(.nav-tabs) {
    background: rgba(255, 255, 255, 0.98);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
}

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

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
}

input,
select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s ease;
    font-family: inherit;
}

input:focus,
select:focus {
    outline: none;
    border-color: #1a1a2e;
    box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.1);
}

.select-with-button {
    display: flex;
    gap: 10px;
}

.select-with-button select {
    flex: 1;
}

.btn-icon {
    width: 48px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    transform: scale(1.05);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary:hover,
.btn-primary-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(26, 26, 46, 0.3);
}

.btn-primary-small {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-danger-small {
    background: #fc8181;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-danger-small:hover {
    background: #f56565;
    transform: translateY(-2px);
}

.result {
    margin-top: 20px;
    animation: slideUp 0.4s ease-out;
}

.result.hidden {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.result-header h2 {
    color: #2d3748;
    font-size: 1.3rem;
}

.success-icon {
    font-size: 2rem;
}

.key-display {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 25px;
    border-radius: 15px;
    font-family: 'Courier New', monospace;
    font-size: 1.3rem;
    font-weight: bold;
    text-align: center;
    letter-spacing: 2px;
    color: #1a1a2e;
    margin: 20px 0;
    border: 2px solid #e2e8f0;
    word-break: break-all;
}

.key-info {
    background: #e8f0fe;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    color: #4a5568;
    text-align: center;
    margin-bottom: 20px;
}

.button-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-copy,
.btn-email,
.btn-new {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-copy {
    background: #48bb78;
    color: white;
}

.btn-copy:hover {
    background: #38a169;
    transform: translateY(-2px);
}

.btn-email {
    background: #4299e1;
    color: white;
}

.btn-email:hover {
    background: #3182ce;
    transform: translateY(-2px);
}

.btn-new {
    background: #edf2f7;
    color: #4a5568;
}

.btn-new:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
}

.table-container {
    overflow-x: auto;
    margin-top: 15px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

.data-table thead {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.data-table tbody tr:hover {
    background: #f7fafc;
}

.data-table.compact th,
.data-table.compact td {
    padding: 8px;
    font-size: 13px;
}

.master-detail {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.master-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
}

.detail-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
}

.master-section h3,
.detail-section h3,
.db-stats h3 {
    margin-bottom: 15px;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 10px;
}

.master-section h3::before {
    content: "📱";
    font-size: 1.2rem;
}

.detail-section h3::before {
    content: "🔑";
    font-size: 1.2rem;
}

.detail-table-container {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.detail-table thead {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    z-index: 10;
}

.detail-table th,
.detail-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}

.detail-table tbody tr:hover {
    background: #f7fafc;
}

.detail-table code {
    background: #edf2f7;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    font-weight: bold;
}

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

.stat-card {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: bold;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-large {
    max-width: 700px;
}

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

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.close-modal,
.close-email-modal {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #a0aec0;
}

.close-modal:hover,
.close-email-modal:hover {
    color: #4a5568;
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

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

.btn-delete {
    background: #fc8181;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

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

.btn-edit {
    background: #4299e1;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    margin-right: 5px;
}

.btn-edit:hover {
    background: #3182ce;
}

.email-preview {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.email-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.email-input {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
}

.email-textarea {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    resize: vertical;
    line-height: 1.5;
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #2d3748;
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 14px;
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
}

.toast.hidden {
    display: none;
}

.hidden {
    display: none;
}

footer {
    text-align: center;
    margin-top: 30px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8rem;
}

.footer-content {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(5px);
}

.footer-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    margin-bottom: 10px;
    object-fit: cover;
}

.footer-email {
    margin-top: 8px;
    font-size: 0.75rem;
    opacity: 0.8;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .nav-tabs {
        gap: 5px;
    }

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

    form,
    .tab-content>div:not(.nav-tabs) {
        padding: 20px;
    }

    .key-display {
        font-size: 0.9rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px;
        font-size: 12px;
    }

    h1 {
        font-size: 1.8rem;
    }

    .detail-table {
        font-size: 11px;
    }

    .detail-table th,
    .detail-table td {
        padding: 6px 4px;
    }

    .button-group {
        flex-direction: column;
    }

    .btn-copy,
    .btn-email,
    .btn-new {
        justify-content: center;
    }

    .modal-large {
        max-width: 95%;
    }

    .logo-img {
        width: 60px;
        height: 60px;
    }
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #1a1a2e;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #16213e;
}
