:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --dark: #1f2937;
    --light: #f3f4f6;
    --border: #e5e7eb;
    --text: #374151;
    --text-muted: #6b7280;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --radius: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--light);
    color: var(--text);
    line-height: 1.6;
}

/* Navigation */
.navbar {
    background: var(--dark);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    color: var(--white);
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.navbar-brand span {
    color: var(--primary);
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 0.25rem;
}

.nav-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
    color: var(--white);
    background: rgba(255,255,255,0.1);
}

.navbar-user {
    color: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.navbar-user a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
}

.navbar-user a:hover {
    color: var(--white);
}

/* Hamburger toggle — hidden on desktop */
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    flex-direction: column;
    gap: 5px;
}

.navbar-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--white);
    border-radius: 2px;
}

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--dark);
}

.breadcrumb {
    display: flex;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.4;
}

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

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

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

.btn-success:hover {
    background: #15803d;
}

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

.btn-danger:hover {
    background: #b91c1c;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

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

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

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

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

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

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select.form-control {
    cursor: pointer;
    background: var(--white);
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--light);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
}

tr:hover {
    background: rgba(0,0,0,0.02);
}

td.actions {
    white-space: nowrap;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f3f4f6; color: #4b5563; }

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stat-card-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-top: 0.25rem;
}

.stat-card-value.success { color: var(--success); }
.stat-card-value.danger { color: var(--danger); }
.stat-card-value.warning { color: var(--warning); }

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* Grid Layouts */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }

    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 0.75rem 1rem;
    }

    .navbar-toggle {
        display: flex;
    }

    .navbar-nav {
        display: none;
        flex-direction: column;
        width: 100%;
        order: 3;
        padding: 0.5rem 0;
        gap: 0;
    }

    .navbar-nav.open {
        display: flex;
    }

    .navbar-nav li {
        width: 100%;
    }

    .nav-link {
        display: block;
        padding: 0.6rem 0.75rem;
        border-radius: 4px;
    }

    .navbar-user {
        display: none;
        width: 100%;
        order: 4;
        padding: 0.5rem 0;
        border-top: 1px solid rgba(255,255,255,0.1);
        justify-content: space-between;
    }

    .navbar-user.open {
        display: flex;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Nav Cards (Dashboard) */
.nav-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.nav-card {
    background: var(--white);
    padding: 1.5rem 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    text-align: center;
    transition: all 0.2s;
}

.nav-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.nav-card-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.nav-card-title {
    font-weight: 600;
    font-size: 0.9rem;
}

/* Financial Summary */
.financial-summary {
    background: linear-gradient(135deg, var(--dark) 0%, #374151 100%);
    color: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.financial-summary h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    opacity: 0.9;
}

.financial-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.financial-row:last-child {
    border-bottom: none;
}

.financial-row.total {
    font-weight: 700;
    font-size: 1.1rem;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 2px solid rgba(255,255,255,0.3);
    border-bottom: none;
}

.financial-row .positive { color: #4ade80; }
.financial-row .negative { color: #f87171; }

/* Action buttons group */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

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

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Money formatting */
.money { 
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.95em;
}

.money-positive { color: var(--success); }
.money-negative { color: var(--danger); }

/* Section spacing */
.section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--dark);
}

/* Client Info */
.client-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem 0;
}

.client-info-item {
    display: flex;
    flex-direction: column;
}

.client-info-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.client-info-value {
    font-weight: 500;
}

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-box {
    display: flex;
    gap: 0.5rem;
}

.search-box input {
    min-width: 250px;
}

/* Product Cards */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.product-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.product-card-image {
    height: 150px;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-card-body {
    padding: 1rem;
}

.product-card-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.product-card-category {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.product-card-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0.5rem 0;
}

.product-card-costs {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.product-card-profit {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.product-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Team Member Cards */
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.team-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.team-card-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.team-card-role {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.team-card-info {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.team-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Calculator */
.calc-section {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.calc-result {
    background: var(--light);
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
}

.calc-result-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.calc-result-total {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    border-top: 2px solid var(--border);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

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

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dark) 0%, #374151 100%);
}

.login-box {
    background: var(--white);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo h1 {
    font-size: 2rem;
    color: var(--dark);
}

.login-logo h1 span {
    color: var(--primary);
}

/* Utility Classes */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.w-100 { width: 100%; }

/* Quote Styles */
.quote-item-row {
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.item-notes-row {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
}

.expiration-warning {
    display: inline;
}

/* ========================================
   Site Survey Styles
   ======================================== */

/* Survey Type Picker (create page) */
.survey-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.survey-type-card {
    cursor: pointer;
}

.survey-type-card input[type="radio"] {
    display: none;
}

.survey-type-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.25rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    transition: all 0.2s;
    min-height: 100px;
}

.survey-type-card input:checked + .survey-type-card-inner {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.survey-type-card-inner:hover {
    border-color: var(--primary);
}

.survey-type-icon {
    font-size: 2rem;
}

.survey-type-label {
    font-weight: 600;
    font-size: 0.95rem;
}

/* Survey Header Card */
.survey-header-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.survey-type-badge {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.survey-client-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.survey-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Survey Area Accordion */
.survey-areas-container {
    padding: 0 !important;
}

.survey-area {
    border-bottom: 1px solid var(--border);
}

.survey-area:last-of-type {
    border-bottom: none;
}

.survey-area-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    min-height: 52px;
}

.survey-area-header:hover {
    background: var(--light);
}

.survey-area-toggle {
    font-size: 0.75rem;
    color: var(--text-muted);
    width: 16px;
    flex-shrink: 0;
}

.survey-area-title {
    font-weight: 600;
    flex: 1;
}

.survey-area-dims {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.survey-area-body {
    padding: 0 1.25rem 1.25rem;
    border-top: 1px dashed var(--border);
}

/* Dimensions row */
.survey-dims-row {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1rem;
}

.survey-dim-field {
    flex: 1;
}

.survey-dim-field label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.survey-dim-field input {
    font-size: 1.1rem;
    padding: 0.6rem 0.75rem;
    min-height: 44px;
}

.survey-dim-sqft {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    padding-bottom: 0.6rem;
    min-width: 70px;
}

/* Photo upload & grid */
.survey-photo-upload {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.survey-camera-btn {
    min-height: 44px;
    min-width: 44px;
    font-size: 0.95rem;
}

.survey-photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.survey-photo-item {
    position: relative;
    width: 90px;
    text-align: center;
}

.survey-photo-thumb {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
}

.survey-photo-pdf {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--light);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--danger);
    cursor: default;
}

.survey-photo-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0.25rem;
}

.survey-photo-delete {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--danger);
    color: var(--white);
    border: 2px solid var(--white);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.survey-area-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
}

/* Add area form */
.survey-add-area {
    padding: 1rem 1.25rem;
    background: var(--light);
}

.survey-add-area-form {
    display: flex;
    gap: 0.5rem;
}

.survey-add-area-form input {
    flex: 1;
    min-height: 44px;
}

.survey-add-area-form button {
    min-height: 44px;
    white-space: nowrap;
}

/* Badge styles */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-primary {
    background: #dbeafe;
    color: #1e40af;
}

/* Mobile responsive for surveys */
@media (max-width: 768px) {
    .survey-type-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .survey-header-info {
        flex-direction: column;
    }

    .survey-actions {
        width: 100%;
    }

    .survey-actions .btn {
        flex: 1;
        min-width: 0;
        text-align: center;
        font-size: 0.85rem;
    }

    .survey-dims-row {
        flex-wrap: wrap;
    }

    .survey-dim-field {
        min-width: 100px;
    }

    .survey-add-area-form {
        flex-direction: column;
    }

    .survey-photo-item {
        width: 80px;
    }

    .survey-photo-thumb {
        width: 80px;
        height: 80px;
    }
}

/* Print styles */
@media print {
    .navbar, .btn, .action-buttons {
        display: none !important;
    }

    .main-content {
        padding: 0;
        max-width: none;
    }
}
