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

:root {
    --primary: #6c5ce7;
    --primary-light: #a29bfe;
    --primary-dark: #5a4bd1;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e17055;
    --bg: #f8f9fa;
    --card-bg: #ffffff;
    --text: #2d3436;
    --text-light: #636e72;
    --border: #dfe6e9;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    direction: rtl;
}

.top-bar {
    background: var(--primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(108,92,231,0.3);
}

.top-bar h1 {
    font-size: 1.2rem;
    font-weight: 700;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
    color: inherit;
    border-radius: 8px;
    transition: background 0.2s;
}
#top-nfc-btn {
    font-size: 1.5rem;
    padding: 6px 10px;
    min-width: 44px;
    min-height: 44px;
}
#top-nfc-btn.nfc-active {
    background: var(--success);
    border-radius: 8px;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 100;
}

.nav-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    font-size: 0.7rem;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.2s;
}

.nav-btn .nav-icon {
    font-size: 1.4rem;
}

.nav-btn.active {
    color: var(--primary);
    font-weight: 700;
}

.page {
    display: none;
    padding: 16px;
    padding-bottom: 80px;
    min-height: calc(100vh - 60px);
}

.page.active {
    display: block;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    position: -webkit-sticky;
    position: sticky;
    top: var(--topbar-h, 56px);
    z-index: 90;
    background: var(--bg);
    padding: 8px 0;
    margin-top: -8px;
}

.search-bar input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    background: white;
    direction: rtl;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

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

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

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

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

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

.btn-warning {
    background: var(--warning);
    color: #4a3b00;
}

.btn-block {
    width: 100%;
    display: block;
}

.card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    transition: transform 0.2s;
}

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

.avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.avatar-placeholder {
    background: var(--primary-light);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.card-info {
    flex: 1;
}

.card-info h4 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.card-info p {
    font-size: 0.85rem;
    color: var(--text-light);
}

.card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* Check-in */
.checkin-container {
    max-width: 500px;
    margin: 0 auto;
}

.checkin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    position: -webkit-sticky;
    position: sticky;
    top: var(--topbar-h, 56px);
    z-index: 90;
    background: var(--bg);
    padding: 8px 0;
    margin-top: -8px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.checkin-tab-content {
    display: none;
}

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

.qr-reader-box {
    background: #1a1a2e;
    border-radius: 16px;
    padding: 60px 20px;
    text-align: center;
    color: white;
}

.qr-reader-box p {
    margin-bottom: 16px;
    color: #b2bec3;
}

.qr-video {
    width: 100%;
    border-radius: 16px;
    display: none;
}

.nfc-container {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.nfc-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.nfc-container p {
    margin-bottom: 16px;
    color: var(--text-light);
}

.status-msg {
    font-weight: 600;
    margin-top: 10px;
}

.manual-checkin input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    margin-bottom: 12px;
    direction: rtl;
}

.checkin-result {
    margin-top: 20px;
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    white-space: pre-line;
    animation: slideUp 0.3s ease;
}

.checkin-result.success {
    background: #d4edda;
    color: #155724;
}

.checkin-result.error {
    background: #f8d7da;
    color: #721c24;
}

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

/* Payments */
.payment-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: white;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

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

/* Reports */
.reports-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.report-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.report-card h3 {
    margin-bottom: 16px;
    font-size: 1.05rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.stat {
    text-align: center;
    padding: 12px;
    background: var(--bg);
    border-radius: 12px;
}

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

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

.period-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.report-details {
    font-size: 0.9rem;
}

.report-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.recent-list {
    max-height: 300px;
    overflow-y: auto;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

/* Settings */
.settings-container {
    max-width: 500px;
    margin: 0 auto;
}

.settings-container h2 {
    margin-bottom: 20px;
}

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

.setting-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
}

.setting-group input[type="text"],
.setting-group input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    direction: rtl;
}

.setting-group h3 {
    margin-bottom: 12px;
}

.setting-group .btn {
    margin-bottom: 8px;
}

.days-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.days-selector label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: normal;
    font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    align-items: stretch;
    justify-content: center;
    z-index: 200;
    display: none;
}

.modal-overlay.visible {
    display: flex;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

.modal-body {
    padding: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    direction: rtl;
}

.form-group select {
    appearance: none;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23636e72' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat left 12px center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.9rem;
    z-index: 300;
    animation: slideUp 0.3s ease;
    white-space: nowrap;
}

/* QR Code display */
.qr-display {
    text-align: center;
    padding: 20px;
}

.qr-display canvas {
    border-radius: 12px;
    margin: 10px 0;
}

@media (min-width: 768px) {
    .page {
        max-width: 700px;
        margin: 0 auto;
    }
}
