* {
    box-sizing: border-box
}

html {
    height: 100%
}

body {
    margin: 0;
    min-height: 100%;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: #f6f6f4;
    color: #171717;
    -webkit-font-smoothing: antialiased
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns:auto 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: #fff;
    color: #111;
    border-bottom: 1px solid #e7e5e4;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .08)
}

h1 {
    font-size: 20px;
    margin: 0;
    line-height: 1.15
}

.eyebrow {
    font-size: 11px;
    color: #8a6d19;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 1px
}

.top-title {
    min-width: 0
}

.icon-button {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 12px;
    background: #f1f1ef;
    color: #111;
    font-size: 25px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer
}

.status-pill {
    padding: 6px 9px;
    border-radius: 999px;
    font-size: 12px;
    background: #e7e5e4;
    color: #444;
    white-space: nowrap
}

.status-pill.online {
    background: #dcfce7;
    color: #166534
}

.status-pill.offline {
    background: #fee2e2;
    color: #991b1b
}

.layout {
    display: grid;
    grid-template-columns:380px 1fr;
    gap: 12px;
    padding: 12px
}

.panel {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .07);
    padding: 12px;
    min-height: calc(100vh - 78px)
}

.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px
}

.input {
    width: 100%;
    border: 1px solid #d8d6d2;
    border-radius: 10px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
    color: #171717
}

.input:focus {
    outline: 2px solid #d4af37;
    border-color: #d4af37
}

.button {
    border: 0;
    border-radius: 11px;
    padding: 11px 14px;
    background: #d4af37;
    color: #111;
    font-weight: 750;
    cursor: pointer;
    white-space: nowrap;
    font: inherit
}

.button.secondary {
    background: #eceae7
}

.button.danger {
    background: #fee2e2;
    color: #991b1b
}

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

.order-list {
    border-top: 1px solid #e7e5e4
}

.order-row {
    position: relative;
    padding: 8px 40px 8px 8px;
    border-bottom: 1px solid #e7e5e4;
    cursor: pointer;
    min-height: 64px
}

.order-row:nth-child(even) {
    background: #fafaf9
}

.order-row:hover, .order-row.active {
    background: #fffbea
}

.order-title {
    font-weight: 850;
    font-size: 14px;
    line-height: 1.25
}

.order-subject {
    font-size: 13px;
    color: #292524;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.order-address {
    font-size: 12.5px;
    color: #57534e;
    margin-top: 2px
}

.status-icon {
    position: absolute;
    right: 9px;
    top: 9px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 900;
    background: #e7e5e4;
    color: #44403c
}

.status-icon.pending {
    background: #dbeafe;
    color: #1d4ed8
}

.status-icon.synced {
    background: #dcfce7;
    color: #166534
}

.status-icon.completed {
    background: #fef3c7;
    color: #92400e
}

.status-watermark {
    position: absolute;
    right: 8px;
    bottom: -4px;
    font-size: 42px;
    line-height: 1;
    opacity: .045;
    font-weight: 900;
    pointer-events: none
}

.detail-panel {
    padding: 0;
    background: transparent;
    box-shadow: none
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: #78716c;
    background: #fff;
    border-radius: 16px
}

.detail-header {
    display: none
}

.detail-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, .07);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid #eee
}

.hero-card h2 {
    font-size: 28px;
    margin: 0 0 8px;
    font-weight: 900;
    line-height: 1.05
}

.hero-subject {
    font-size: 16px;
    font-weight: 750;
    line-height: 1.32;
    margin-bottom: 14px
}

.info-line {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 16px;
    line-height: 1.35;
    margin-top: 7px
}

.info-icon {
    width: 24px;
    flex: 0 0 24px;
    text-align: center;
    color: #1d4ed8
}

.form-grid {
    display: grid;
    grid-template-columns:repeat(3, 1fr);
    gap: 12px
}

.field {
    margin-bottom: 0
}

.label {
    font-size: 13px;
    font-weight: 800;
    margin: 0 0 6px;
    color: #292524
}

.toggle-line {
    display: grid;
    grid-template-columns:auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 10px 11px;
    background: #fff;
    border: 1px solid #d8d6d2;
    border-radius: 10px;
    min-height: 46px
}

.toggle-line input {
    width: 22px;
    height: 22px
}

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

.section-title {
    font-size: 20px;
    margin: 0;
    font-weight: 850
}

.work-row {
    border: 1px solid #e3e0dc;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 12px;
    background: #fff
}

.work-head {
    display: grid;
    grid-template-columns:1fr auto;
    gap: 8px;
    align-items: start;
    margin-bottom: 8px
}

.work-date {
    max-width: 170px
}

.work-description {
    resize: vertical;
    min-height: 64px;
    margin-bottom: 8px;
    font-weight: 650
}

.worker-row {
    display: grid;
    grid-template-columns:1fr 92px 42px;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center
}

.remove-worker {
    padding: 8px 0
}

.sig-grid {
    display: grid;
    grid-template-columns:1fr 1fr;
    gap: 12px
}

.sig-title {
    font-size: 16px;
    font-weight: 750;
    margin: 0 0 8px
}

.sig-card {
    border: 1px solid #d6d3d1;
    border-radius: 14px;
    background: #fff;
    overflow: hidden
}

.sig-locked {
    padding: 14px;
    background: #fff;
    display: grid;
    gap: 10px
}

.sig-preview {
    width: 100%;
    height: 110px;
    object-fit: contain;
    border: 1px dashed #d6d3d1;
    border-radius: 10px;
    background: #fff
}

.signature-canvas {
    width: 100%;
    height: 190px;
    display: block;
    touch-action: none;
    background: #fff
}

.sig-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 8px;
    background: #fafaf9;
    border-top: 1px solid #e7e5e4
}

.readonly {
    padding: 11px 12px;
    background: #f5f5f4;
    border-radius: 10px;
    border: 1px solid #e7e5e4;
    min-height: 44px
}

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

.photo-grid img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid #ddd
}

.actions {
    position: sticky;
    bottom: 0;
    z-index: 12;
    display: grid;
    grid-template-columns:1fr;
    gap: 10px;
    margin: 16px -12px -12px;
    padding: 12px;
    background: rgba(255, 255, 255, .95);
    backdrop-filter: blur(8px);
    border-top: 1px solid #e7e5e4
}

.notice {
    padding: 10px 12px;
    border-radius: 12px;
    background: #fef3c7;
    margin: 12px 0 0;
    font-size: 14px
}

.save-state {
    font-size: 13px;
    color: #57534e;
    text-align: right
}

.hidden {
    display: none !important
}

@media (max-width: 900px) {
    .layout {
        display: block;
        padding: 8px
    }

    .panel {
        min-height: auto;
        border-radius: 12px
    }

    .list-panel {
        padding: 8px
    }

    .detail-open .list-panel {
        display: none
    }

    .detail-open .detail-panel {
        display: block
    }

    .detail-panel:has(.empty-state) {
        display: none
    }

    .detail-card {
        border-radius: 14px;
        padding: 14px;
        margin-bottom: 10px
    }

    .hero-card h2 {
        font-size: 26px
    }

    .hero-subject {
        font-size: 15px
    }

    .info-line {
        font-size: 15px
    }

    .form-grid {
        grid-template-columns:1fr
    }

    .sig-grid {
        grid-template-columns:1fr
    }

    .work-head {
        grid-template-columns:1fr
    }

    .worker-row {
        grid-template-columns:1fr 86px 40px
    }

    .topbar {
        padding: 8px 10px
    }

    h1 {
        font-size: 19px
    }

    .status-pill {
        font-size: 12px
    }

    .actions {
        margin: 14px -8px -8px
    }

    .section-head {
        align-items: center
    }

    .section-head .button {
        padding: 10px 12px
    }

    .order-row {
        padding-top: 7px;
        padding-bottom: 7px
    }
}

@media (min-width: 901px) {
    .header-back {
        display: none !important
    }

    .detail-panel {
        background: #fff;
        border-radius: 16px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, .07);
        padding: 12px
    }

    .detail-card {
        box-shadow: none
    }

    .actions {
        position: static;
        margin: 18px 0 0;
        padding: 0;
        background: transparent;
        border-top: 0
    }
}

.created-on {
    margin-top: 12px;
    font-size: 12px;
    color: #78716c;
    text-align: right
}

@media (max-width: 900px) {
    .created-on {
        text-align: left;
        margin-top: 10px
    }

    .detail-open .topbar {
        grid-template-columns:auto 1fr auto
    }

    .header-back {
        font-size: 22px
    }
}

/* v5 smartphone refinements */
.detail-open .list-panel {
    display: none !important
}

.detail-open .layout {
    display: block;
    max-width: 760px;
    margin: 0 auto
}

.header-text-box {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f5f5f4;
    color: #292524;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-line
}

.meta-line {
    margin-top: 12px;
    font-size: 12px;
    color: #78716c;
    line-height: 1.35
}

.created-on {
    display: none
}

.unavailable-line {
    margin-bottom: 10px;
    background: #fafaf9
}

.submit-button {
    width: 100%;
    background: #1d4ed8;
    color: #fff
}

.work-head {
    grid-template-columns:minmax(140px, 180px) 1fr;
    align-items: center
}

.work-head .remove-row {
    justify-self: end;
    background: #fff;
    color: #dc2626;
    padding: 9px 10px
}

.worker-row select.worker-name {
    min-width: 0
}

@media (max-width: 900px) {
    .detail-open .detail-panel {
        display: block !important
    }

    .work-head {
        grid-template-columns:1fr auto
    }

    .work-head .remove-row {
        font-size: 0;
        padding: 11px 12px;
        min-width: 48px
    }

    .work-head .remove-row::after {
        content: '🗑';
        font-size: 18px
    }

    .worker-row {
        grid-template-columns:1fr 84px 40px
    }

    .sig-actions {
        display: grid;
        grid-template-columns:1fr 1fr;
        gap: 8px
    }

    .sig-actions .button:last-child {
        grid-column: 1/-1
    }
}
