:root {
    --bg-main: #0b0f19;
    --bg-card: #151d30;
    --bg-card-hover: #1e293b;
    --border-color: #27354f;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #38bdf8;
    --accent-indigo: #6366f1;
    --accent-green: #22c55e;
    --accent-green-bg: rgba(34, 197, 94, 0.12);
    --accent-amber: #f59e0b;
    --accent-amber-bg: rgba(245, 158, 11, 0.12);
    --accent-rose: #f43f5e;
    --accent-rose-bg: rgba(244, 63, 94, 0.12);
    --nav-height: 64px;
    --header-height: 60px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Header */
.app-header {
    height: var(--header-height);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-blue));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.brand-title h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--accent-green);
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-green);
}

.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:active {
    transform: scale(0.92);
}

/* Main Scrollable Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: calc(var(--nav-height) + 20px);
}

/* Tab Pages */
.tab-page {
    display: none;
    flex-direction: column;
    gap: 18px;
    animation: fadeIn 0.25s ease-out;
}

.tab-page.active {
    display: flex;
}

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

/* Card Sections */
.card-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.count-pill {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-blue);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 12px;
}

.badge-alert {
    background: var(--accent-rose-bg);
    color: var(--accent-rose);
}

/* Item Cards */
.item-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 0.88rem;
    line-height: 1.4;
    transition: all 0.2s;
}

.item-card.completed {
    opacity: 0.6;
    border-color: rgba(34, 197, 94, 0.4);
    background: var(--accent-green-bg);
}

.bold-carpet-date {
    font-weight: 700;
    color: #fbbf24;
}

/* Turnovers Grid & Cards */
.filter-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.search-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    color: var(--text-muted);
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 10px 0;
    width: 100%;
}

.toggle-group {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 3px;
}

.toggle-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.toggle-btn.active {
    background: var(--accent-indigo);
    color: #fff;
}

.turnover-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    gap: 16px;
    margin-top: 4px;
}

.subtab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    padding: 8px 0;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.subtab-btn.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

.turnover-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.turnover-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.unit-badge {
    font-family: 'Outfit', sans-serif;
    font-size: 0.92rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 6px;
    display: inline-block;
}

.unit-badge.go {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.unit-badge.bh {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.status-badge {
    font-size: 0.76rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.done {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.turnover-card.completed-card {
    opacity: 0.75;
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(34, 197, 94, 0.3);
}

.check-btn {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.check-btn:hover {
    background: var(--accent-green);
    color: #0f172a;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

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

.nav-item.active svg {
    stroke: var(--accent-blue);
}

.hidden {
    display: none !important;
}

.loading-spinner {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 20px 0;
}

.emp-tag {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-indigo);
    background: rgba(129, 140, 248, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 6px;
    display: inline-block;
}

.turnover-details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 10px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    background: rgba(15, 23, 42, 0.4);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.05);
}

.detail-item strong {
    color: var(--text-muted);
    font-weight: 500;
}

.days-open-tag {
    color: #fbbf24;
    font-weight: 700;
}

.turnover-notes-box {
    background: rgba(30, 41, 59, 0.7);
    border-left: 3px solid var(--accent-blue);
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 0.83rem;
    color: var(--text-primary);
    display: flex;
    gap: 6px;
    align-items: flex-start;
    line-height: 1.4;
    word-break: break-word;
}

.notes-icon {
    font-size: 0.88rem;
    flex-shrink: 0;
}

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

.edit-notes-btn {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: #38bdf8;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.edit-notes-btn:hover {
    background: #38bdf8;
    color: #0f172a;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-card {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.modal-close-btn:hover {
    color: #f8fafc;
    background: rgba(255,255,255,0.1);
}

.modal-card textarea {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: var(--radius-md);
    padding: 12px;
    font-size: 0.92rem;
    color: #f8fafc;
    outline: none;
    font-family: inherit;
    resize: vertical;
    width: 100%;
    box-sizing: border-box;
}

.modal-card textarea:focus {
    border-color: #6366f1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-secondary {
    background: transparent;
    border: 1px solid #334155;
    color: #94a3b8;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border: none;
    color: #ffffff;
    padding: 8px 18px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
}

/* Hidden Helper */
.hidden {
    display: none !important;
}

/* Full Screen Passcode Login */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0f172a;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.login-screen.hidden {
    display: none !important;
}

.login-card {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 36px 28px;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.login-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.login-logo {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.login-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
}

.login-header p {
    font-size: 0.88rem;
    color: #94a3b8;
    margin: 0;
}

.login-form-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-form-group input {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-size: 1.15rem;
    color: #f8fafc;
    text-align: center;
    letter-spacing: 4px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    width: 100%;
}

.login-form-group input:focus {
    border-color: #6366f1;
}

.login-error {
    font-size: 0.84rem;
    color: #f87171;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
}

.login-btn {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    padding: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    width: 100%;
}

.login-btn:hover {
    opacity: 0.95;
}

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