:root {
    --bg: #f1f5f9;
    --nav: #0f172a;
    --nav2: #1e293b;
    --text: #0f172a;
    --muted: #64748b;
    --purple: #7c3aed;
    --border: #dbe3ee;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* Main application layout */

.app {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    width: 250px;
    height: 100vh;
    overflow-y: auto;
    padding: 28px 18px;
    display: flex;
    flex-direction: column;
    color: white;
    background: linear-gradient(
        180deg,
        var(--nav),
        var(--nav2)
    );
}

.main {
    grid-column: 2;
    min-width: 0;
    width: 100%;
    max-width: 1500px;
    padding: 28px;
}

/* Branding and navigation */

.brand {
    margin-bottom: 30px;
    font-size: 24px;
    font-weight: 900;
}

.brand span {
    color: #c4b5fd;
}

.brand.big {
    font-size: 30px;
}

nav {
    display: grid;
    gap: 6px;
}

nav a {
    padding: 13px 14px;
    border-radius: 10px;
    color: #dbeafe;
    text-decoration: none;
}

nav a:hover {
    background: #334155;
}

.userbox {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid #334155;
    display: grid;
    gap: 5px;
}

.userbox small {
    color: #94a3b8;
}

.userbox a {
    margin-top: 6px;
    color: #c4b5fd;
    text-decoration: none;
}

/* Page headings */

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.top h1 {
    margin: 0;
    font-size: 32px;
}

.muted {
    color: var(--muted);
}

.tiny {
    font-size: 12px;
}

/* Buttons */

.btn {
    display: inline-block;
    padding: 11px 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

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

.full {
    width: 100%;
    margin-top: 8px;
}

/* Dashboard statistics */

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 18px;
}

.stat,
.card {
    border: 1px solid var(--border);
    border-radius: 15px;
    background: white;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.04);
}

.stat {
    padding: 20px;
}

.stat small {
    color: var(--muted);
}

.stat strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
}

/* Cards */

.card {
    padding: 20px;
    margin-bottom: 18px;
}

.cardhead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.cardhead h2 {
    margin: 0 0 12px;
}

/* Tables */

.tablewrap {
    width: 100%;
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 13px;
}

.clickable {
    cursor: pointer;
}

.clickable:hover {
    background: #f8fafc;
}

/* Status badges */

.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    background: #e2e8f0;
    font-size: 12px;
    font-weight: 800;
}

.badge.new {
    background: #ede9fe;
    color: #6d28d9;
}

.badge.attempting {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge.completed {
    background: #dcfce7;
    color: #15803d;
}

/* Forms */

.search {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.search input {
    flex: 1;
}

.form label {
    display: block;
    margin: 10px 0 6px;
    font-size: 13px;
    font-weight: 800;
}

.form input,
.form select,
.form textarea,
.search input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: white;
    font: inherit;
}

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

.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
}

.row {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.hidden-block {
    display: none;
}

/* Job details */

.detailgrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

dl {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 9px 15px;
    margin: 0;
}

dt {
    color: var(--muted);
    font-weight: 800;
}

dd {
    margin: 0;
}

.address {
    font-size: 18px;
    line-height: 1.6;
}

/* Attempt history */

.attempt {
    margin-top: 12px;
    padding: 12px 14px;
    border-left: 4px solid var(--purple);
    border-radius: 8px;
    background: #faf5ff;
}

.attempt > div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.attempt span,
.attempt small {
    color: var(--muted);
}

.empty {
    padding: 25px;
    color: var(--muted);
    text-align: center;
}

/* Messages */

.flash {
    margin-bottom: 14px;
    padding: 12px;
    border-radius: 9px;
    background: #fee2e2;
    color: #991b1b;
}

/* Login page */

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #0f172a, #312e81);
}

.login-card {
    width: min(440px, 92vw);
    padding: 30px;
    border-radius: 18px;
    background: white;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.login-card h1 {
    margin-bottom: 5px;
}

.login-card label {
    display: block;
    margin: 12px 0 6px;
    font-weight: 800;
}

.login-card input {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
}

/* Camera and uploaded photos */

.camera-box {
    padding: 14px;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
}

.camera-box input[type="file"] {
    padding: 8px 0;
    border: 0;
    background: transparent;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(
        auto-fill,
        minmax(120px, 1fr)
    );
    gap: 10px;
    margin-top: 12px;
}

.photo-grid img {
    display: block;
    width: 100%;
    height: 110px;
    border: 1px solid #dbe3ee;
    border-radius: 10px;
    object-fit: cover;
}

/* Server dashboard */

.server-job-grid {
    display: grid;
    grid-template-columns: repeat(
        auto-fit,
        minmax(340px, 1fr)
    );
    gap: 16px;
}

.server-job {
    margin: 0;
}

.server-job h2 {
    margin: 5px 0 0;
}

.jobnum {
    color: #6d28d9;
}

.address-small {
    font-size: 17px;
    line-height: 1.5;
}

.field-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 16px;
}

/* Attempt form */

.eyebrow {
    margin-bottom: 5px;
    color: #7c3aed;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.12em;
}

.section-title {
    margin: 20px 0 8px;
    color: #334155;
    font-size: 14px;
    font-weight: 900;
}

.conditional-panel {
    display: none;
    margin-top: 14px;
    padding: 14px;
    border: 1px solid #e9d5ff;
    border-radius: 13px;
    background: #faf5ff;
}

.gps-card {
    padding: 14px;
    border: 1px solid #dbe3ee;
    border-radius: 13px;
    background: #f8fafc;
}

.gps-pill {
    display: inline-block;
    align-self: center;
    padding: 8px 11px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    font-size: 12px;
    font-weight: 800;
}

.gps-pill.good {
    background: #dcfce7;
    color: #166534;
}

.gps-pill.warn {
    background: #fef3c7;
    color: #92400e;
}

.gps-pill.bad {
    background: #fee2e2;
    color: #991b1b;
}

.camera-prominent {
    padding: 18px;
}

.camera-prominent input[type="file"] {
    position: absolute;
    left: -9999px;
}

.camera-button {
    display: inline-block;
    margin: 0 0 8px;
    padding: 14px 18px;
    border-radius: 11px;
    background: #111827;
    color: white;
    font-size: 16px;
    font-weight: 900;
    cursor: pointer;
}

.quick-notes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chip {
    padding: 8px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: white;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.submit-bar {
    position: sticky;
    bottom: 0;
    margin: 22px -20px -20px;
    padding: 14px 20px;
    border-top: 1px solid #e2e8f0;
    border-radius: 0 0 15px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(6px);
}

.big-submit {
    padding: 14px 20px;
    font-size: 16px;
}

.field-form textarea {
    min-height: 120px;
}

/* Completion panels */

.moved-panel {
    border-color: #fed7aa;
    background: #fff7ed;
}

.completion-card {
    border: 1px solid #bbf7d0;
}

.next-doc {
    margin-top: 16px;
    padding: 14px;
    border-radius: 10px;
    font-weight: 700;
}

.next-doc.nonservice {
    background: #fff7ed;
    color: #9a3412;
}

.next-doc.served {
    background: #ecfdf5;
    color: #166534;
}

/* Tablet and mobile layout */

@media (max-width: 800px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        overflow: visible;
        padding: 18px;
    }

    .sidebar nav {
        grid-template-columns: repeat(3, 1fr);
        font-size: 13px;
    }

    .userbox {
        display: none;
    }

    .main {
        grid-column: 1;
        width: 100%;
        padding: 16px;
    }

    .stats {
        grid-template-columns: 1fr 1fr;
    }

    .grid2,
    .detailgrid {
        grid-template-columns: 1fr;
    }

    .top {
        align-items: flex-start;
    }

    .top h1 {
        font-size: 27px;
    }
}

@media (max-width: 600px) {
    .server-job-grid {
        grid-template-columns: 1fr;
    }

    .field-actions .btn {
        width: 100%;
        padding: 14px;
        text-align: center;
    }

    .sidebar nav {
        grid-template-columns: 1fr 1fr;
    }

    .stats {
        grid-template-columns: 1fr 1fr;
    }

    .field-form {
        padding: 16px;
    }

    .section-title {
        margin-top: 17px;
    }

    .camera-button {
        width: 100%;
        padding: 16px;
        text-align: center;
    }

    .submit-bar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .big-submit {
        width: 100%;
        padding: 16px;
    }

    .quick-notes {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .chip {
        border-radius: 10px;
    }
}