:root {
    --primary: #1e3a5f;
    --primary-dark: #142943;
    --accent: #f4762a;
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --text-muted: #6c7a89;
    --success: #2e9e5b;
    --danger: #d94848;
    --warning: #e0a422;
}

* { box-sizing: border-box; }

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    background: var(--bg);
    font-family: 'Segoe UI', Roboto, -apple-system, sans-serif;
    margin: 0;
    color: #263141;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}
body.app-body {
    padding-top: 66px;
    padding-bottom: 70px;
}

.topbar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    min-height: 60px;
    padding-top: 8px;
    padding-bottom: 8px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.18);
}
.topbar .dropdown-toggle::after { display: none; }
.topbar-title-wrap {
    flex-direction: column;
    line-height: 10px;
    overflow: hidden;
}
.topbar-title {
    display: block;
    font-size: 19px;
    white-space: nowrap;
    /* overflow: hidden; */
    text-overflow: ellipsis;
    max-width: 230px;
}
.topbar-subtitle {
    display: block;
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    color: rgba(255,255,255,0.7);
    white-space: nowrap;
}

.app-content {
    max-width: 720px;
    margin: 0 auto;
    padding-bottom: 20px;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: #fff;
    border-top: 1px solid #e3e7ec;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    z-index: 1000;
    max-width: 720px;
    margin: 0 auto;
}
.bottom-nav-item {
    flex: 1;
    text-align: center;
    padding: 8px 4px 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.68rem;
}
.bottom-nav-item i { display: block; font-size: 1.15rem; margin-bottom: 2px; }
.bottom-nav-item.active { color: var(--accent); font-weight: 600; }

/* Cards */
.card { border: none; border-radius: 14px; box-shadow: 0 2px 10px rgba(20,41,67,0.06); }

.stat-card {
    position: relative;
    border-radius: 16px;
    padding: 16px 16px 14px;
    background: var(--primary);
    box-shadow: 0 4px 14px rgba(30,58,95,0.25);
    overflow: hidden;
    color: #fff;
}
.stat-card .stat-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.18);
    color: #fff;
    font-size: 0.95rem;
    margin-bottom: 10px;
}
.stat-card h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.3px;
}
.stat-card p {
    margin: 2px 0 0;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: rgba(255,255,255,0.85);
}
.stat-card.orange { background: var(--accent); box-shadow: 0 4px 14px rgba(244,118,42,0.3); }
.stat-card.green { background: var(--success); box-shadow: 0 4px 14px rgba(46,158,91,0.3); }
.stat-card.red { background: var(--danger); box-shadow: 0 4px 14px rgba(217,72,72,0.3); }
.stat-card.neutral { background: #96a1ae; box-shadow: 0 4px 14px rgba(150,161,174,0.25); }

.section-title {
    font-weight: 700;
    color: var(--primary-dark);
    margin: 18px 0 10px;
    padding: 0 12px;
}

.list-tile {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px 14px;
    margin: 0 12px 10px;
    box-shadow: 0 1px 5px rgba(20,41,67,0.06);
    transition: box-shadow 0.15s ease;
}
.list-tile:active { box-shadow: 0 1px 3px rgba(20,41,67,0.1); }

.badge-status-pending { background: var(--warning); }
.badge-status-in_progress { background: #3b82c4; }
.badge-status-completed { background: var(--success); }
.badge-status-cancelled { background: var(--danger); }

.stage-tracker {
    display: flex;
    align-items: flex-start;
    background: #fff;
    border-radius: 14px;
    padding: 16px 10px 12px;
    box-shadow: 0 1px 5px rgba(20,41,67,0.06);
}
.stage-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 auto;
    width: 76px;
}
.stage-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef1f4;
    color: #9aa4b2;
    font-size: 0.95rem;
    border: 2px solid #eef1f4;
    transition: all 0.2s ease;
}
.stage-step.active .stage-icon {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(30,58,95,0.15);
}
.stage-step.done .stage-icon {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.stage-label {
    margin-top: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    color: #9aa4b2;
    text-align: center;
}
.stage-step.active .stage-label { color: var(--primary); }
.stage-step.done .stage-label { color: var(--success); }
.stage-line {
    flex: 1 1 auto;
    height: 3px;
    background: #eef1f4;
    margin-top: 19px;
    border-radius: 2px;
}
.stage-line.done { background: var(--success); }

/* Dashboard quick action tiles */
.quick-tile {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 14px 0;
    margin: 0;
    box-shadow: 0 1px 5px rgba(20,41,67,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
}
.quick-tile-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
}
.quick-tile-icon.navy { background: var(--primary); }
.quick-tile-icon.orange { background: var(--accent); }
.quick-tile-icon.blue { background: #3b82c4; }
.quick-tile-icon.teal { background: #17a398; }
.quick-tile-icon.purple { background: #8b5fbf; }

/* Recent jobs row icon */
.job-row-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(30,58,95,0.08);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Credit customer avatar */
.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(217,72,72,0.12);
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Global search */
.search-bar { position: relative; }
.search-bar .input-group-text, .search-bar .form-control {
    border: 1px solid #dde3ea;
    background: #fff;
}
.search-bar .form-control:focus { box-shadow: none; border-color: var(--primary); }
.search-results-panel {
    position: relative;
    margin-top: 6px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(20,41,67,0.12);
    max-height: 360px;
    overflow-y: auto;
    z-index: 500;
}
.search-result-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f0f2f5;
}
.search-result-row:last-child { border-bottom: none; }
.search-result-row:hover { background: #f7f9fb; }
.search-result-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.search-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #d8611a; color: #fff; }

.fab {
    position: fixed;
    bottom: 78px;
    right: calc(50% - 340px);
    background: var(--accent);
    color: #fff;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    font-size: 1.3rem;
    z-index: 999;
    text-decoration: none;
}
@media (max-width: 780px) { .fab { right: 20px; } }

.login-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--primary), var(--primary-dark));
    padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    overflow-y: auto;
}
.login-card {
    background: #fff;
    border-radius: 20px;
    padding: clamp(24px, 6vw, 34px) clamp(20px, 6vw, 28px);
    max-width: 380px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.login-logo-badge {
    width: clamp(56px, 16vw, 68px);
    height: clamp(56px, 16vw, 68px);
    margin: 0 auto;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(30,58,95,0.35);
}
.login-logo-badge i { font-size: clamp(1.3rem, 5vw, 1.7rem); color: #fff; }
.login-title {
    font-size: clamp(1.05rem, 4.5vw, 1.2rem);
    line-height: 1.25;
    word-break: break-word;
}
.login-input-group .input-group-text {
    background: #f4f6f9;
    border: 1px solid #dde3ea;
    color: var(--text-muted);
    min-width: 46px;
    justify-content: center;
}
.login-input-group .form-control {
    border: 1px solid #dde3ea;
    border-left: none;
    font-size: 16px;
    padding-top: 10px;
    padding-bottom: 10px;
}
.login-input-group .form-control:focus {
    box-shadow: none;
    border-color: var(--primary);
}
.login-input-group .input-group-text:first-child { border-right: none; }
.login-eye-toggle {
    cursor: pointer;
    border-left: none;
    min-width: 46px;
}
.login-eye-toggle:hover { color: var(--primary); }

@media (max-width: 360px) {
    .login-card { padding: 22px 18px; border-radius: 16px; }
}
@media (max-height: 640px) {
    .login-wrap { justify-content: flex-start; padding-top: max(28px, env(safe-area-inset-top)); }
}