:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --ink: #111827;
    --muted: #667085;
    --line: #e5e7eb;
    --primary: #0f172a;
    --primary-soft: #e8edf7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --success: #047857;
    --success-soft: #d1fae5;
}

* {
    box-sizing: border-box;
}

body.mobile-body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.45;
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

a {
    color: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
    background: rgba(245, 247, 251, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.topbar h1,
.section-header h2,
.panel h2,
.job-card h2,
.auth-card h1 {
    margin: 0;
    letter-spacing: 0;
}

.topbar h1 {
    font-size: 24px;
}

.eyebrow {
    margin: 0 0 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.muted {
    margin: 2px 0 0;
    color: var(--muted);
}

.mobile-main {
    display: grid;
    gap: 18px;
    width: min(760px, 100%);
    margin: 0 auto;
    padding: 18px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.metric-card,
.panel,
.job-card,
.auth-card,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.05);
}

.metric-card {
    padding: 12px;
}

.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.metric-card strong {
    display: block;
    margin-top: 4px;
    font-size: 26px;
}

.metric-card.danger {
    background: var(--danger-soft);
}

.metric-card.success {
    background: var(--success-soft);
}

.section-block,
.stack-form {
    display: grid;
    gap: 12px;
}

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

.sticky-actions {
    position: sticky;
    top: 86px;
    z-index: 10;
    padding: 10px 0;
    background: var(--bg);
}

.job-card,
.panel,
.empty-state {
    padding: 16px;
}

.job-card.featured {
    border-color: #b9c2d7;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.11);
}

.card-row,
.card-actions,
.nav-actions,
.form-grid {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.card-row {
    justify-content: flex-start;
    margin-bottom: 10px;
}

.time {
    margin-left: auto;
    color: var(--muted);
    font-weight: 700;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.badge.danger {
    color: var(--danger);
    background: var(--danger-soft);
}

.badge.warning {
    color: var(--warning);
    background: var(--warning-soft);
}

.badge.success {
    color: var(--success);
    background: var(--success-soft);
}

.badge.neutral {
    color: #344054;
    background: #eef2f7;
}

.equipment {
    color: #344054;
    font-weight: 700;
}

.contact-strip,
.history-row,
.subpanel {
    margin-top: 12px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.contact-strip {
    display: grid;
    gap: 4px;
    color: #344054;
}

.card-actions {
    margin-top: 14px;
}

.card-actions.vertical {
    display: grid;
    align-items: stretch;
}

.primary-button,
.secondary-button,
.ghost-button,
.nav-actions button {
    min-height: 42px;
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

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

.secondary-button,
.nav-actions button {
    color: var(--primary);
    background: var(--primary-soft);
}

.ghost-button {
    color: var(--muted);
    background: transparent;
}

.nav-actions {
    margin-top: 10px;
}

.nav-actions button {
    min-height: 36px;
    padding: 8px 10px;
}

label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    padding: 12px;
    background: white;
    color: var(--ink);
    font: inherit;
}

textarea {
    resize: vertical;
}

.form-grid {
    align-items: stretch;
}

.form-grid label {
    flex: 1 1 180px;
}

.material-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) 90px minmax(0, 1fr) auto;
    gap: 8px;
    margin-top: 8px;
}

[data-camera-video] {
    display: block;
    width: 100%;
    max-height: 300px;
    border-radius: 14px;
    background: #111827;
}

.signature-wrap {
    height: min(58vh, 460px);
    border: 1px solid #d0d5dd;
    border-radius: 16px;
    background: white;
    overflow: hidden;
    touch-action: none;
}

[data-signature-canvas] {
    width: 100%;
    height: 100%;
    display: block;
}

.bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.bottom-nav a {
    padding: 10px 6px;
    border-radius: 12px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
}

.bottom-nav a.active {
    color: white;
    background: var(--primary);
}

.alert {
    width: min(760px, calc(100% - 36px));
    margin: 12px auto 0;
    padding: 12px 14px;
    border-radius: 14px;
    font-weight: 700;
}

.alert-success {
    color: var(--success);
    background: var(--success-soft);
}

.alert-error {
    color: var(--danger);
    background: var(--danger-soft);
}

.empty-state {
    text-align: center;
}

.empty-state.compact {
    padding: 12px;
    color: var(--muted);
}

.auth-body {
    display: grid;
    place-items: center;
    padding: 18px;
}

.auth-card {
    width: min(420px, 100%);
    padding: 24px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 16px;
    border-radius: 15px;
    background: #fff;
    padding: 4px;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

@media (max-width: 620px) {
    .metrics-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .metric-card {
        padding: 10px;
    }

    .metric-card strong {
        font-size: 22px;
    }

    .material-row {
        grid-template-columns: 1fr;
    }
}
