:root {
    --bg: #f4f8f7;
    --surface: #ffffff;
    --ink: #14202e;
    --muted: #64748b;
    --line: #dbe7e5;
    --primary: #42d8b7;
    --primary-strong: #109b81;
    --primary-dark: #132238;
    --accent: #9be21f;
    --danger: #b42318;
    --shadow: 0 16px 36px rgba(20, 32, 46, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at top right, rgba(66, 216, 183, 0.12), transparent 28rem),
        var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px 1fr;
    transition: grid-template-columns 0.18s ease;
}

.app-shell > main {
    min-width: 0;
}

.app-shell.sidebar-collapsed {
    grid-template-columns: 0 1fr;
}

.app-shell.sidebar-collapsed .sidebar {
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
}

.sidebar {
    background: linear-gradient(180deg, #101b2b 0%, #142238 58%, #0f1b2c 100%);
    color: #eef4fb;
    padding: 22px;
    min-width: 0;
    transition: padding 0.18s ease;
    box-shadow: 8px 0 30px rgba(15, 23, 42, 0.12);
}

.brand-text {
    color: #69e0c6;
    display: inline-block;
    font-size: 25px;
    font-weight: 800;
    letter-spacing: 0.01em;
    line-height: 1;
    max-width: 160px;
    overflow: hidden;
    text-shadow: 0 10px 24px rgba(66, 216, 183, 0.22);
    white-space: nowrap;
}

.brand-row,
.topbar-left,
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.brand-row {
    justify-content: space-between;
    margin-bottom: 20px;
}

.menu-toggle {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font-size: 13px;
    height: 38px;
    line-height: 1;
    min-width: 58px;
    padding: 0 10px;
}

.sidebar-toggle {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.nav-link {
    display: block;
    padding: 11px 12px;
    border-radius: 8px;
    color: #dbe7f3;
    margin-bottom: 4px;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav-link:hover {
    background: rgba(66, 216, 183, 0.12);
    color: #fff;
    transform: translateX(2px);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(66, 216, 183, 0.22), rgba(155, 226, 31, 0.12));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--primary);
}

.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 8px 20px rgba(20, 32, 46, 0.04);
}

.content {
    padding: 24px;
    max-width: 100%;
    overflow-x: clip;
}

.grid {
    display: grid;
    gap: 16px;
}

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

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

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.stat {
    font-size: 28px;
    font-weight: 700;
    margin-top: 8px;
}

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

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    min-width: 0;
}

.toolbar h1 {
    margin: 0;
}

.button {
    border: 0;
    border-radius: 6px;
    background: var(--primary-strong);
    color: #fff;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.button:hover {
    background: #0b816c;
    box-shadow: 0 10px 20px rgba(16, 155, 129, 0.22);
    transform: translateY(-1px);
}

.button.secondary {
    background: #e7f2f0;
    color: var(--ink);
}

.button.secondary:hover {
    background: #d7ebe7;
    box-shadow: 0 10px 20px rgba(20, 32, 46, 0.08);
}

.button.danger {
    background: var(--danger);
}

.compact-button {
    display: inline-block;
    padding: 7px 10px;
    white-space: nowrap;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--line);
}

.table-scroll {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.inventory-results {
    margin-bottom: 22px;
}

.inventory-table-scroll {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.inventory-table-scroll .table {
    border: 0;
    min-width: 980px;
}

.inventory-pagination {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-top: 12px;
    padding: 12px;
}

.pagination-summary {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.pagination-buttons {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.pagination-button,
.pagination-ellipsis {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    display: inline-flex;
    font-size: 13px;
    font-weight: 800;
    justify-content: center;
    min-height: 34px;
    min-width: 34px;
    padding: 7px 10px;
}

.pagination-button {
    background: #fff;
    color: var(--ink);
}

.pagination-button:hover {
    border-color: rgba(16, 155, 129, 0.42);
    color: var(--primary-strong);
}

.pagination-button.active {
    background: var(--primary-strong);
    border-color: var(--primary-strong);
    color: #fff;
}

.pagination-button.disabled,
.pagination-ellipsis {
    background: #f4f7f7;
    color: var(--muted);
    cursor: default;
}

.table th,
.table td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

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

.nowrap {
    white-space: nowrap;
}

.row-actions {
    align-items: center;
    display: flex;
    gap: 8px;
    min-width: max-content;
}

.admin-materials-scroll {
    border: 1px solid var(--line);
    border-radius: 8px;
    max-width: 100%;
}

.work-order-materials-card {
    margin-top: 16px;
    overflow: visible;
}

.work-order-materials-card h2 {
    margin-top: 0;
}

.admin-material-add-grid {
    align-items: end;
    grid-template-columns: minmax(280px, 2fr) minmax(130px, 0.8fr) minmax(130px, 0.8fr) minmax(150px, 0.9fr);
}

.admin-material-add-grid .admin-measured-material-field {
    grid-column: span 1;
}

.admin-materials-table {
    border: 0;
    min-width: 1240px;
    table-layout: fixed;
}

.admin-materials-table th:nth-child(1),
.admin-materials-table td:nth-child(1) {
    width: 320px;
}

.admin-materials-table th:nth-child(2),
.admin-materials-table td:nth-child(2) {
    width: 330px;
}

.admin-materials-table th:nth-child(3),
.admin-materials-table td:nth-child(3) {
    width: 130px;
}

.admin-materials-table th:nth-child(4),
.admin-materials-table td:nth-child(4) {
    width: 90px;
}

.admin-materials-table th:nth-child(5),
.admin-materials-table td:nth-child(5) {
    text-align: right;
    width: 135px;
}

.admin-materials-table th:nth-child(6),
.admin-materials-table td:nth-child(6) {
    text-align: right;
    width: 135px;
}

.admin-materials-table th:nth-child(7),
.admin-materials-table td:nth-child(7) {
    width: 190px;
}

.admin-material-product-cell,
.admin-material-product-cell input,
.admin-material-help {
    max-width: 100%;
    min-width: 0;
}

.admin-material-help {
    display: block;
    overflow-wrap: anywhere;
}

.admin-material-quantity {
    min-width: 0;
    width: 100%;
}

.admin-material-measure-cell {
    display: grid;
    gap: 8px;
}

.admin-material-measure-summary {
    display: block;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.admin-material-measure-edit {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(88px, 1fr));
}

.admin-material-measure-edit[hidden] {
    display: none;
}

.admin-material-measure-edit input,
.admin-materials-table input {
    min-width: 0;
    width: 100%;
}

.admin-material-total {
    color: var(--primary-strong);
    font-weight: 800;
}

.admin-materials-table .location-results {
    width: min(520px, calc(100vw - 48px));
}

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 700;
    background: #e8faf5;
    color: var(--primary-strong);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.work-order-filters {
    margin-bottom: 16px;
}

.work-order-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.work-orders-toolbar .button {
    flex: 0 0 auto;
}

.work-orders-table {
    min-width: 1360px;
}

.work-orders-results {
    transition: opacity 0.15s ease;
}

.work-orders-results.is-loading {
    opacity: 0.55;
    pointer-events: none;
}

.field label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px;
    font: inherit;
}

.autocomplete-field {
    position: relative;
}

.location-results {
    background: #fff;
    border: 1px solid #d5dde8;
    border-radius: 6px;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.12);
    margin-top: 6px;
    max-height: 320px;
    overflow-y: auto;
    position: absolute;
    width: min(680px, calc(100vw - 48px));
    z-index: 20;
}

.location-result {
    background: transparent;
    border: 0;
    border-bottom: 1px solid #edf1f7;
    color: #172033;
    cursor: pointer;
    display: block;
    padding: 10px 12px;
    text-align: left;
    width: 100%;
}

.location-result:hover,
.location-result:focus {
    background: #f3f6fb;
    outline: none;
}

.location-result strong,
.location-result span {
    display: block;
}

.location-result span {
    color: #64748b;
    font-size: 13px;
    margin-top: 4px;
}

.location-result.empty {
    cursor: default;
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover {
    background: #eefbf7;
}

.dashboard-hero {
    align-items: center;
    background: linear-gradient(135deg, #132238 0%, #16324a 62%, #0f8b78 100%);
    border-radius: 10px;
    box-shadow: var(--shadow);
    color: #fff;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 18px;
    padding: 24px;
}

.dashboard-hero h1 {
    font-size: 28px;
    margin: 4px 0;
}

.dashboard-hero p {
    color: #d8f1ec;
    margin: 0;
}

.eyebrow {
    color: #9be21f;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dashboard-stats .stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
    color: var(--ink);
    display: block;
    min-height: 142px;
    padding: 18px;
    position: relative;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.dashboard-stats .stat-card::after {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 999px;
    content: "";
    height: 36px;
    opacity: 0.18;
    position: absolute;
    right: 16px;
    top: 16px;
    width: 36px;
}

.dashboard-stats .stat-card:hover {
    border-color: rgba(16, 155, 129, 0.45);
    box-shadow: 0 18px 42px rgba(16, 155, 129, 0.16);
    transform: translateY(-3px);
}

.stat-label {
    color: var(--muted);
    display: block;
    font-size: 13px;
    font-weight: 800;
}

.stat-link {
    color: var(--primary-strong);
    display: block;
    font-size: 13px;
    font-weight: 800;
    margin-top: 12px;
}

.dashboard-table .table {
    box-shadow: var(--shadow);
}

.mobile-shell {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--surface);
}

.mobile-header {
    position: sticky;
    top: 0;
    background: #132238;
    color: #fff;
    padding: 16px;
    z-index: 5;
}

.mobile-content {
    padding: 16px;
}

.job-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 12px;
}

.action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mobile-action-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.mobile-primary-action {
    align-items: center;
    display: inline-flex;
    font-size: 16px;
    font-weight: 800;
    justify-content: center;
    min-height: 48px;
    text-align: center;
}

.mobile-section {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.mobile-section summary {
    cursor: pointer;
    font-weight: 800;
    list-style: none;
    padding: 15px 44px 15px 14px;
    position: relative;
}

.mobile-section summary::-webkit-details-marker {
    display: none;
}

.mobile-section summary::after {
    color: var(--primary-strong);
    content: "+";
    font-size: 24px;
    line-height: 1;
    position: absolute;
    right: 16px;
    top: 12px;
}

.mobile-section[open] summary {
    border-bottom: 1px solid var(--line);
}

.mobile-section[open] summary::after {
    content: "-";
}

.mobile-section-body {
    padding: 14px;
}

.mobile-photo-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 14px;
}

.mobile-photo-grid a {
    background: #f5f7fb;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: block;
    overflow: hidden;
}

.mobile-photo-grid img {
    aspect-ratio: 1 / 1;
    display: block;
    height: auto;
    object-fit: cover;
    width: 100%;
}

.location-detail-list {
    display: grid;
    gap: 8px;
}

.location-detail-row {
    align-items: start;
    background: #f8fbfa;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(120px, 42%) 1fr;
    padding: 10px;
}

.location-detail-row span:first-child {
    color: var(--muted);
    font-weight: 800;
}

.location-detail-row span:last-child {
    color: var(--ink);
    font-weight: 700;
    overflow-wrap: anywhere;
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        bottom: 0;
        left: 0;
        max-width: 280px;
        overflow-y: auto;
        padding: 14px;
        position: fixed;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.18s ease;
        width: 82vw;
        z-index: 40;
    }

    .app-shell.sidebar-collapsed .sidebar {
        overflow-y: auto;
        padding-left: 14px;
        padding-right: 14px;
        transform: translateX(0);
    }

    .nav-link {
        display: block;
    }

    .grid-4,
    .grid-2,
    .form-grid,
    .admin-material-add-grid,
    .work-order-filter-grid {
        grid-template-columns: 1fr;
    }

    .admin-material-measure-edit {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 0 16px;
    }

    .content {
        padding: 16px;
    }

    .inventory-pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .pagination-buttons {
        justify-content: flex-start;
    }

    .brand-text {
        font-size: 24px;
        max-width: 150px;
    }

    .dashboard-hero {
        align-items: stretch;
        flex-direction: column;
        padding: 18px;
    }

    .dashboard-hero h1 {
        font-size: 22px;
    }
}
