:root {
    --accent: #e67e22;
    --accent-hover: #d35400;
    --dark: #1a1a2e;
    --dark-secondary: #16213e;
    --bg: #f5f5f0;
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-muted: #94a3b8;
    --success: #27ae60;
    --danger: #e74c3c;
    --bottom-nav-height: 70px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

* { -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
    overflow-x: hidden;
    max-width: 100vw;
}

.app-wrapper {
    min-height: 100vh;
    padding-bottom: calc(60px + var(--safe-bottom) + 1rem);
    overflow-x: hidden;
    max-width: 100vw;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.app-wrapper.loaded {
    opacity: 1;
}

/* ===== Top Bar ===== */
.app-topbar {
    background: var(--dark);
    color: #fff;
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-topbar h5 {
    margin: 0;
    font-weight: 700;
    font-size: 1.1rem;
}

.app-topbar .back-btn {
    color: #fff;
    font-size: 1.3rem;
    text-decoration: none;
    padding: 0.25rem 0.5rem 0.25rem 0;
}

/* ===== Bottom Nav ===== */
.bottom-nav {
    display: flex;
    background-color: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 0.5rem;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    justify-content: space-around;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    padding-bottom: var(--safe-bottom);
}

.bottom-nav-item {
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.25rem;
    border-radius: 10px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    touch-action: manipulation;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 20%;
    text-align: center;
    font-size: 0.68rem;
    text-decoration: none;
    gap: 3px;
}

.bottom-nav-item i {
    font-size: 1.3rem;
}

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

.nav-add-btn {
    width: 42px;
    height: 42px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.4rem;
    box-shadow: 0 2px 8px rgba(230,126,34,0.35);
}

/* ===== Content Area ===== */
.pwa-content {
    padding: 1rem 1.2rem;
}

/* ===== Search Bar ===== */
.search-bar {
    position: relative;
    margin-bottom: 1.2rem;
}

.search-bar input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.8rem;
    border-radius: 14px;
    border: none;
    background: #fff;
    font-size: 0.95rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.search-bar i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* ===== Service Categories Grid ===== */
.section-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.category-card {
    background: #fff;
    border-radius: 14px;
    padding: 0.8rem 0.4rem;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: transform 0.15s, box-shadow 0.15s;
}

.category-card:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.category-card .cat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #fff3e6;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.4rem;
    font-size: 1.3rem;
}

.category-card span {
    font-size: 0.7rem;
    font-weight: 600;
    display: block;
    line-height: 1.2;
}

/* ===== Quick Action Buttons ===== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.quick-action-btn {
    background: #fff;
    border: none;
    border-radius: 14px;
    padding: 1rem;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    cursor: pointer;
    transition: transform 0.15s;
    text-decoration: none;
    color: var(--text);
}

.quick-action-btn:active {
    transform: scale(0.97);
}

.quick-action-btn .qa-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.quick-action-btn .qa-text {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
}

.qa-orange { background: #fff3e6; color: var(--accent); }
.qa-blue   { background: #e8f0fe; color: #2980b9; }
.qa-green  { background: #e6f9f0; color: var(--success); }
.qa-purple { background: #f3e8ff; color: #8e44ad; }

/* ===== Contractor Cards ===== */
.contractor-card {
    background: #fff;
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 0.7rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    display: flex;
    gap: 0.8rem;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.15s;
}

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

.contractor-card .cc-avatar {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.contractor-card .cc-info {
    flex: 1;
    min-width: 0;
}

.contractor-card .cc-name {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.contractor-card .cc-trade {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.contractor-card .cc-rating {
    font-size: 0.8rem;
    color: #f59e0b;
    margin-top: 3px;
}

.contractor-card .cc-distance {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

/* ===== Profile Header ===== */
.profile-header {
    background: var(--dark);
    color: #fff;
    padding: 2rem 1.2rem 1.5rem;
    border-radius: 0 0 20px 20px;
    text-align: center;
}

.profile-header .ph-avatar {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.8rem;
    font-weight: 800;
    font-size: 2rem;
}

.profile-header .ph-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.profile-header .ph-stars {
    color: #f59e0b;
}

.profile-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.2rem;
}

.profile-actions .btn {
    flex: 1;
    border-radius: 12px;
    padding: 0.7rem;
    font-weight: 600;
    font-size: 0.9rem;
}

/* ===== Job Card ===== */
.job-card {
    background: #fff;
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 0.7rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.job-card .jc-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* ===== Quote Card ===== */
.quote-card {
    background: #fff;
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 0.7rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.quote-card.accepted {
    border: 2px solid var(--success);
}

/* ===== Forms ===== */
.pwa-form label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    display: block;
}

.pwa-form .form-control,
.pwa-form .form-select {
    border-radius: 12px;
    padding: 0.7rem 1rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
}

.pwa-form .form-control:focus,
.pwa-form .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(230,126,34,0.1);
}

.pwa-form textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
}

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

.btn-outline-accent {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.btn-outline-accent:hover {
    background: var(--accent);
    color: #fff;
}

/* ===== Messages ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--bottom-nav-height) - 120px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.8rem;
}

.chat-bubble {
    max-width: 80%;
    margin-bottom: 0.6rem;
    padding: 0.7rem 1rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
}

.chat-bubble.sent {
    background: var(--accent);
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-bubble.received {
    background: #e2e8f0;
    color: var(--text);
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.chat-bubble .chat-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 4px;
}

.chat-input {
    padding: 0.7rem;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 0.5rem;
}

/* ===== Misc ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 0.8rem;
    display: block;
}

.badge-status {
    padding: 0.3em 0.7em;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}

.bg-accent { background: var(--accent); }
.text-accent { color: var(--accent); }
.text-star { color: #f59e0b; }

/* ===== Photo Upload ===== */
.photo-upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 14px;
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.2s;
}

.photo-upload-area:active {
    border-color: var(--accent);
}

.photo-upload-area i {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.photo-preview {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.photo-preview img {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    object-fit: cover;
}

/* ===== Measurement Display ===== */
.measurement-display {
    background: var(--dark);
    color: #fff;
    border-radius: 14px;
    padding: 1.2rem;
    text-align: center;
    margin-bottom: 1rem;
}

.measurement-display .m-value {
    font-size: 2rem;
    font-weight: 800;
}

.measurement-display .m-label {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a2e;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.35s ease;
    opacity: 1;
}

.loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: #e67e22;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}