:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --secondary: #475569;
    --secondary-hover: #334155;
    --dark: #0f172a;
    --light-bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --border-focus: #3b82f6;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--light-bg);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* NAVBAR */
.app-navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--dark);
    font-size: 1.25rem;
    font-weight: 700;
}

.logo-icon {
    font-size: 1.4rem;
}

.logo-text strong {
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    min-height: 44px;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

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

.btn-secondary:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-outline-primary {
    background-color: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background-color: var(--primary-light);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.05rem;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    min-height: 36px;
}

.btn-block {
    width: 100%;
}

.btn-text-action {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.btn-text-action:hover {
    background-color: var(--primary-light);
}

/* FORM ELEMENTS */
.form-group {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 5px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.92rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: #ffffff;
    color: var(--text-main);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    min-height: 44px;
}

.form-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-select {
    cursor: pointer;
    appearance: auto;
}

.form-row {
    display: flex;
    gap: 12px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-uppercase { text-transform: uppercase; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }

/* BADGES */
.badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-blue { background-color: #dbeafe; color: #1e40af; }
.badge-gray { background-color: #e2e8f0; color: #334155; }

/* MODAL */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: 16px;
}

.modal-card {
    background: #ffffff;
    width: 100%;
    max-width: 540px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalPop 0.2s ease-out;
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--dark);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 20px;
    max-height: 75vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f8fafc;
}

/* FOOTER */
.app-footer {
    text-align: center;
    padding: 24px 16px 85px 16px; /* Extra bottom padding for sticky nav */
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
    background: #ffffff;
}

/* ANDROID APP-LIKE TOP APPBAR ACTIONS */
.appbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.appbar-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.appbar-pill.pill-unlocked {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.appbar-pill.pill-locked {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}

.appbar-pill.pill-locked:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.status-pulse-dot {
    width: 7px;
    height: 7px;
    background-color: #22c55e;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.appbar-btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fee2e2;
    color: #dc2626;
    text-decoration: none;
    transition: background 0.15s ease;
}

.appbar-btn-logout:hover {
    background: #fecaca;
}

/* STICKY ANDROID BOTTOM NAVIGATION BAR */
.android-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 990;
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.05);
    padding-bottom: env(safe-area-inset-bottom, 0);
    -webkit-user-select: none;
    user-select: none;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #64748b;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 0;
    transition: color 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:active {
    transform: scale(0.92);
}

.bottom-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 28px;
    border-radius: 14px;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    color: #64748b;
    margin-bottom: 2px;
}

.bottom-nav-icon svg {
    transition: all 0.2s ease;
    stroke: currentColor;
}

.bottom-nav-label {
    font-size: 11px;
    letter-spacing: -0.2px;
    margin-top: 1px;
    color: #64748b;
    transition: color 0.2s ease, font-weight 0.2s ease;
}

/* PROMINENT ACTIVE STATE HIGHLIGHT (MATERIAL 3 PILL) */
.bottom-nav-item.active {
    color: #1d4ed8 !important;
}

.bottom-nav-item.active .bottom-nav-icon {
    background: #dbeafe !important;
    color: #1d4ed8 !important;
    box-shadow: 0 1px 4px rgba(29, 78, 216, 0.2) !important;
}

.bottom-nav-item.active .bottom-nav-icon svg {
    stroke: #1d4ed8 !important;
    stroke-width: 2.6 !important;
    transform: scale(1.08);
}

.bottom-nav-item.active .bottom-nav-label {
    color: #1d4ed8 !important;
    font-weight: 800 !important;
}

/* ANDROID BOTTOM SHEET DRAWER */
.bottom-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1050;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.bottom-sheet-card {
    width: 100%;
    max-width: 520px;
    background: #ffffff;
    border-radius: 20px 20px 0 0;
    padding: 12px 18px 24px 18px;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
    animation: sheetSlideUp 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 85vh;
    overflow-y: auto;
}

@keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

.bottom-sheet-grabber {
    width: 36px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 4px auto 14px auto;
}

.bottom-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.sheet-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.bottom-sheet-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.sheet-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
}

.sheet-tile:active, .sheet-tile:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: scale(0.98);
}

.sheet-tile-icon {
    font-size: 22px;
    margin-bottom: 6px;
}

.sheet-tile-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.sheet-tile-desc {
    font-size: 11px;
    color: #64748b;
    margin-top: 3px;
}

.sheet-tile-danger {
    background: #fef2f2;
    border-color: #fecaca;
}

.sheet-tile-danger .sheet-tile-title {
    color: #dc2626;
}

/* Ensure mobile pages have space before bottom nav */
@media (max-width: 768px) {
    body {
        padding-bottom: 65px;
    }
}
