:root {
    --orange-700: #c54f14;
    --orange-600: #e66a1f;
    --orange-500: #ff812f;
    --orange-100: #fff0e6;
    --ink: #24180f;
    --muted: #7b6f67;
    --line: #ead8ca;
    --paper: #fffaf6;
    --white: #ffffff;
    --green: #12805c;
    --red: #c9362b;
    --shadow: 0 16px 42px rgba(100, 48, 15, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: linear-gradient(135deg, #fff7ef 0%, #ffffff 48%, #fff1e5 100%);
    font-family: Tahoma, Arial, sans-serif;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    padding: 24px 18px;
    color: var(--white);
    background: linear-gradient(180deg, var(--orange-700), #8f3611);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 8px;
    color: var(--orange-700);
    background: var(--white);
    font-weight: 800;
    font-size: 24px;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 4px;
    opacity: 0.8;
}

nav {
    display: grid;
    gap: 8px;
    margin-top: 24px;
}

nav a {
    padding: 12px 14px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.86);
}

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

.main {
    margin-left: 260px;
    padding: 28px;
}

.topbar,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow);
}

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

.topbar h1,
.panel h2 {
    margin: 0;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--muted);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
}

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

.stat strong {
    display: block;
    margin-top: 8px;
    color: var(--orange-700);
    font-size: 34px;
}

.panel {
    padding: 22px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 0;
    border-radius: 8px;
    color: var(--white);
    background: var(--orange-600);
    font: inherit;
    cursor: pointer;
}

.btn:hover,
button:hover {
    background: var(--orange-700);
}

.btn.secondary {
    color: var(--orange-700);
    background: var(--orange-100);
}

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

.btn.small,
button.small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 14px;
}

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

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

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

th {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    background: var(--paper);
}

tr:last-child td {
    border-bottom: 0;
}

.badge {
    display: inline-flex;
    min-width: 44px;
    justify-content: center;
    padding: 5px 9px;
    border-radius: 999px;
    color: var(--green);
    background: #e9f8f1;
    font-weight: 700;
}

.status {
    display: inline-flex;
    min-width: 88px;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 700;
}

.status.open {
    color: var(--orange-700);
    background: var(--orange-100);
}

.status.closed {
    color: var(--green);
    background: #e9f8f1;
}

.status.cancelled {
    color: var(--red);
    background: #fdecea;
}

.stat .stat-text {
    font-size: 24px;
}

.empty {
    padding: 32px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    text-align: center;
    background: var(--paper);
}

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

.field {
    display: grid;
    gap: 7px;
}

.field.full {
    grid-column: 1 / -1;
}

label {
    color: var(--muted);
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    color: var(--ink);
    font: inherit;
}

.check-field {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    color: var(--ink);
}

.check-field input {
    width: auto;
    min-height: auto;
}

textarea {
    min-height: 92px;
    resize: vertical;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.notice {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    color: var(--orange-700);
    background: var(--orange-100);
}

.panel-subhead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 24px 0 12px;
}

.panel-subhead h2 {
    margin: 0;
}

.job-parts-table th:first-child,
.job-parts-table td:first-child {
    min-width: 220px;
}

.job-parts-table th:nth-child(2),
.job-parts-table td:nth-child(2) {
    min-width: 420px;
}

.job-parts-table th:nth-child(3),
.job-parts-table td:nth-child(3) {
    width: 140px;
}

.job-parts-table th:last-child,
.job-parts-table td:last-child {
    width: 96px;
}

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

.detail-grid div {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
}

.detail-grid .full {
    grid-column: 1 / -1;
}

.detail-grid span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.detail-grid strong {
    font-weight: 700;
}

.close-form {
    margin-bottom: 16px;
}

.signature-box {
    width: 100%;
    min-height: 220px;
    border: 1px dashed var(--orange-600);
    border-radius: 8px;
    background: var(--white);
    overflow: hidden;
    touch-action: none;
}

.signature-box canvas {
    display: block;
    width: 100%;
    height: 220px;
    cursor: crosshair;
}

.signature-preview {
    display: grid;
    gap: 8px;
    max-width: 420px;
    margin-bottom: 14px;
}

.signature-preview span {
    color: var(--muted);
    font-weight: 700;
}

.signature-preview img {
    width: 100%;
    max-height: 180px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
}

.site-photo-preview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.site-photo-preview a {
    display: grid;
    gap: 8px;
}

.site-photo-preview span {
    color: var(--muted);
    font-weight: 700;
}

.site-photo-preview img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
}

.login-page {
    display: grid;
    place-items: center;
    padding: 18px;
}

.login-shell {
    width: min(100%, 420px);
}

.login-card {
    display: grid;
    gap: 16px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
}

.login-brand {
    padding-bottom: 16px;
    color: var(--ink);
    border-bottom-color: var(--line);
}

@media (max-width: 860px) {
    .sidebar {
        position: static;
        width: auto;
    }

    .main {
        margin-left: 0;
        padding: 18px;
    }

    .topbar,
    .panel-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .grid,
    .form-grid,
    .detail-grid,
    .site-photo-preview {
        grid-template-columns: 1fr;
    }

    .detail-grid .full {
        grid-column: auto;
    }
}
