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

:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --secondary: #64748b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --code-bg: #0f172a;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* Header */
.header {
    background: var(--bg-card);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header h1 svg {
    width: 24px;
    height: 24px;
    color: var(--primary-light);
}

.add-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.add-btn:hover {
    background: var(--primary-dark);
}

/* Main Content */
.main-content {
    padding: 1rem;
    max-width: 500px;
    margin: 0 auto;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    color: var(--secondary);
    margin-bottom: 1rem;
}

.empty-state h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.hidden {
    display: none !important;
}

/* Accounts List */
.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.account-item {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.account-item:hover {
    background: var(--bg-hover);
}

.account-item.active {
    border-color: var(--primary-light);
    background: var(--bg-hover);
}

.account-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    flex-shrink: 0;
}

.account-info {
    overflow: hidden;
}

.account-issuer {
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.account-name {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

/* Code Display */
.code-display {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
}

.code-display .account-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.code-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.current-code {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Consolas', monospace;
    letter-spacing: 0.1em;
    color: var(--text-primary);
}

.code-timer {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: conic-gradient(
        var(--primary-light) var(--progress, 100%),
        var(--bg-dark) var(--progress, 100%)
    );
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    position: relative;
}

.code-timer::before {
    content: '';
    position: absolute;
    width: 42px;
    height: 42px;
    background: var(--bg-card);
    border-radius: 50%;
}

.code-timer span {
    position: relative;
    z-index: 1;
}

.code-timer.warning {
    background: conic-gradient(
        var(--danger) var(--progress, 100%),
        var(--bg-dark) var(--progress, 100%)
    );
}

.code-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.code-btn {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.code-btn:hover {
    background: var(--border-color);
}

.code-btn.danger {
    color: var(--danger);
}

.code-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 1rem;
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem;
}

/* Add Account Options */
.add-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.add-option {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    padding: 1.25rem;
    border-radius: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
}

.add-option:hover {
    border-color: var(--primary-light);
    background: var(--bg-hover);
}

.add-option svg {
    width: 32px;
    height: 32px;
    color: var(--primary-light);
    flex-shrink: 0;
}

.add-option-text h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.add-option-text p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Scanner */
.scanner-container {
    width: 100%;
    aspect-ratio: 1;
    background: #000;
    border-radius: 0.75rem;
    overflow: hidden;
    position: relative;
}

.scanner-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scanner-frame {
    width: 200px;
    height: 200px;
    border: 2px solid var(--primary-light);
    border-radius: 1rem;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.scanner-actions {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

/* Form */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-light);
}

.form-group input::placeholder {
    color: var(--secondary);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.875rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: #dc2626;
}

/* Delete Confirm */
.delete-confirm-content {
    text-align: center;
}

.delete-confirm-content svg {
    width: 48px;
    height: 48px;
    color: var(--danger);
    margin-bottom: 1rem;
}

.delete-confirm-content p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.delete-confirm-actions {
    display: flex;
    gap: 0.75rem;
}

.delete-confirm-actions .btn {
    flex: 1;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0.875rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Install Banner */
.install-banner {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.install-banner p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.install-banner .btn {
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 480px) {
    .current-code {
        font-size: 2rem;
    }

    .code-wrapper {
        flex-direction: column;
    }
}

/* Safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
