:root {
    --primary: #1a56db;
    --primary-dark: #1e429f;
    --secondary: #6b7280;
    --danger: #dc2626;
    --success: #059669;
    --warning: #d97706;
    --bg: #f3f4f6;
    --card: #ffffff;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --nav-height: 64px;
    --header-height: 56px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-bottom: var(--nav-height);
}

h1, h2, h3 {
    font-weight: 600;
    line-height: 1.3;
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 1rem;
    background: var(--primary);
    color: white;
}

.app-header h1 {
    font-size: 1.1rem;
}

.connection-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.2);
}

.connection-status.offline {
    background: var(--danger);
}

.app-main {
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.form-card, .profile-card, .stats-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

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

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

.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-bar select {
    flex: 1;
    min-width: 100px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
}

.list-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-item {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.list-item-title {
    font-weight: 600;
    font-size: 0.9375rem;
}

.list-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-accepted { background: #d1fae5; color: #065f46; }
.badge-not_accepted { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-synced { background: #dbeafe; color: #1e40af; }
.badge-local { background: #e5e7eb; color: #374151; }
.badge-failed { background: #fee2e2; color: #991b1b; }

.profile-field {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.profile-field:last-child {
    border-bottom: none;
}

.profile-field .label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.profile-field .value {
    font-weight: 500;
}

.stats-card {
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.button-group .btn {
    flex: 1;
    min-width: 100px;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: 0.875rem;
}

.message.error { background: #fee2e2; color: #991b1b; }
.message.success { background: #d1fae5; color: #065f46; }
.message.info { background: #dbeafe; color: #1e40af; }
.message.hidden { display: none; }

.hint, .otp-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    height: var(--nav-height);
    background: var(--card);
    border-top: 1px solid var(--border);
    z-index: 100;
    overflow-x: auto;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.625rem;
    cursor: pointer;
    padding: 0.25rem;
    min-width: 56px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 1.25rem;
}

.install-prompt {
    position: fixed;
    bottom: calc(var(--nav-height) + 0.5rem);
    left: 1rem;
    right: 1rem;
    background: var(--card);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 200;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.install-prompt p {
    flex: 1;
    font-size: 0.875rem;
}

.install-prompt.hidden,
.hidden {
    display: none !important;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.otp-code {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--primary);
    font-family: monospace;
}
