:root {
    color-scheme: light;
    font-family: "Segoe UI", Arial, sans-serif;
    color: #17212b;
    background: #f4f7fa;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    --muted: #647484;
    --line: #e1e8ee;
    --accent: #197b70;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(ellipse at 82% 8%, rgba(207, 235, 228, 0.58), transparent 34rem),
        #f4f7fa;
}

.topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1000;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(20px, 6vw, 88px);
    border-bottom: 1px solid rgba(221, 230, 236, 0.9);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
}

.topbar .function-tabs {
    width: 70%;
    justify-content: flex-start;
}

.topbar-actions {
    display: flex;
    flex: 0 0 30%;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #263744;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.back-button span {
    color: var(--accent);
    font-size: 18px;
    line-height: 1;
}

.back-button:hover {
    transform: translateX(-2px);
    border-color: var(--accent);
    color: var(--accent);
}

.back-button:focus-visible {
    outline: 3px solid rgba(25, 123, 112, 0.25);
    outline-offset: 2px;
}

.topbar-label {
    white-space: nowrap;
    color: #6c7c88;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.page {
    width: min(1440px, calc(100% - 48px));
    margin: 0 auto;
    padding: calc(clamp(34px, 6vh, 58px) + 76px) 0 72px;
}

.intro {
    margin-bottom: 34px;
}

.eyebrow,
.workspace-kicker {
    margin: 0 0 12px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
}

h1 {
    margin: 0;
    color: #17212b;
    font-size: clamp(32px, 5vw, 46px);
    letter-spacing: -0.045em;
    line-height: 1.12;
}

.intro-copy {
    margin: 13px 0 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.6;
}

h2 {
    margin: 0;
    color: #20303b;
    font-size: clamp(21px, 3vw, 26px);
    letter-spacing: -0.025em;
}

.function-tabs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 0;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f6f8f9;
}

.function-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
}

.tab-count {
    min-width: 24px;
    padding: 3px 7px;
    border-radius: 999px;
    background: #edf2f4;
    color: #687984;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.function-tab.is-active {
    background: #fff;
    color: var(--accent);
    box-shadow: 0 1px 3px rgba(33, 57, 70, 0.12);
}

.function-tab.is-active::after {
    content: none;
}

.function-tab.is-active .tab-count {
    background: #e5f2ef;
    color: var(--accent);
}

.function-tab:focus-visible,
.refresh-button:focus-visible,
.search-field input:focus-visible {
    outline: 3px solid rgba(25, 123, 112, 0.25);
    outline-offset: 2px;
}

.trace-panel {
    padding: clamp(20px, 3vw, 34px);
    border: 1px solid #e4ebef;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 18px 50px rgba(33, 57, 70, 0.06);
}

.panel-heading,
.records-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.panel-kicker {
    margin: 0 0 7px;
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
}

.shop-location-field {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid #d8eae5;
    border-radius: 9px;
    background: #f0f8f5;
    color: #266e65;
    font-size: 12px;
    font-weight: 700;
}

.shop-location-field select {
    max-width: 240px;
    padding: 5px 8px;
    border: 1px solid #c8ded7;
    border-radius: 6px;
    background: #fff;
    color: #194f49;
    font: inherit;
}

.shop-location-field select:disabled {
    cursor: wait;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 12px;
}

.search-field {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: center;
    gap: 10px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
}

.search-field:focus-within {
    border-color: var(--accent);
}

.search-field svg {
    width: 18px;
    flex: 0 0 auto;
    fill: none;
    stroke: #80909b;
    stroke-linecap: round;
    stroke-width: 1.8;
}

.search-field input {
    width: 100%;
    min-height: 44px;
    border: 0;
    outline: 0;
    background: transparent;
    color: #263744;
    font: inherit;
    font-size: 14px;
}

.refresh-button {
    display: inline-flex;
    min-height: 44px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 15px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: #31444f;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.page-size-field {
    display: inline-flex;
    min-height: 44px;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: #536570;
    font-size: 13px;
    font-weight: 600;
}

.page-size-field select {
    min-height: 30px;
    max-width: 190px;
    padding: 0 5px;
    border: 0;
    background: transparent;
    color: #263744;
    font: inherit;
    cursor: pointer;
}

.page-size-field select:focus-visible {
    outline: 3px solid rgba(25, 123, 112, 0.25);
    outline-offset: 2px;
}

.refresh-button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.refresh-button span {
    color: var(--accent);
    font-size: 19px;
    line-height: 1;
}

.refresh-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.request-status {
    min-height: 20px;
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 12px;
}

.request-status.is-error {
    color: #b42318;
}

.request-status.is-success {
    color: #18794e;
}

.create-help {
    margin: -2px 0 16px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.create-fieldset {
    min-width: 0;
    margin: 0 0 22px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 11px;
}

.create-fieldset legend {
    padding: 0 7px;
    color: #263744;
    font-size: 14px;
    font-weight: 700;
}

.create-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.create-field {
    display: grid;
    min-width: 0;
    gap: 6px;
    color: #536570;
    font-size: 12px;
    font-weight: 650;
}

.create-field input,
.create-field select,
.create-field textarea,
.create-details-table input {
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid #d8e1e7;
    border-radius: 7px;
    background: #fff;
    color: #17212b;
    font: inherit;
    font-size: 13px;
}

.create-field textarea {
    resize: vertical;
}

.create-field input:focus-visible,
.create-field select:focus-visible,
.create-field textarea:focus-visible,
.create-details-table input:focus-visible {
    outline: 3px solid rgba(25, 123, 112, 0.2);
    outline-offset: 1px;
}

.create-field input:disabled,
.create-field select:disabled,
.item-scan-field input:disabled {
    background: #f0f3f5;
    color: #697984;
    cursor: not-allowed;
}

.create-field--wide {
    grid-column: 1 / -1;
}

.item-scan-field {
    margin-bottom: 14px;
}

.item-scan-field input {
    min-height: 42px;
    font-size: 15px;
}

.create-details-table {
    min-width: 740px;
}

.create-details-table th,
.create-details-table td {
    padding: 8px;
}

.create-details-table input {
    min-height: 38px;
}

.create-details-table input[type="number"] {
    text-align: right;
}

.secondary-button,
.primary-button {
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.secondary-button {
    background: #fff;
    color: #40535f;
}

.secondary-button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.primary-button {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.primary-button:hover:not(:disabled) {
    background: #12665d;
}

.secondary-button:disabled,
.primary-button:disabled {
    cursor: wait;
    opacity: 0.6;
}

.create-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 30px;
}

.summary-card {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 4px 12px;
    padding: 17px 19px;
    border: 1px solid #e7edf1;
    border-radius: 11px;
    background: #fbfcfd;
}

.summary-label {
    color: #536570;
    font-size: 13px;
    font-weight: 650;
}

.summary-card strong {
    grid-column: 2;
    grid-row: 1 / span 2;
    color: #20303b;
    font-size: 27px;
    font-weight: 700;
}

.summary-caption {
    color: #8997a1;
    font-size: 11px;
}

.records-section + .records-section {
    margin-top: 32px;
}

.records-section[hidden] {
    display: none;
}

.records-section[role="tabpanel"]:focus-visible {
    outline: 3px solid rgba(25, 123, 112, 0.2);
    outline-offset: 4px;
}

.records-heading {
    margin-bottom: 11px;
}

.records-heading h3 {
    margin: 0;
    color: #263744;
    font-size: 16px;
}

.record-count {
    color: #84929c;
    font-size: 12px;
}

.table-scroll {
    overflow: auto;
    border: 1px solid #e5ebef;
    border-radius: 10px;
}

.records-table {
    width: 100%;
    min-width: 1000px;
    border-collapse: collapse;
    background: #fff;
    text-align: left;
}

.records-table th,
.records-table td {
    padding: 12px 13px;
    border-bottom: 1px solid #edf1f4;
    color: #41525e;
    font-size: 12px;
    line-height: 1.45;
    white-space: nowrap;
}

.records-table th:nth-child(9),
.records-table td:nth-child(9) {
    width: 240px;
    max-width: 240px;
    white-space: normal;
    overflow-wrap: anywhere;
}

.records-table th {
    background: #f7f9fa;
    color: #687984;
    font-size: 11px;
    font-weight: 700;
}

.records-table tbody tr:last-child td {
    border-bottom: 0;
}

.records-table tbody tr:hover td {
    background: #f8fbfa;
}

.records-table td:first-child {
    color: #236e65;
    font-weight: 700;
}

.document-preview-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: #236e65;
    font: inherit;
    font-weight: 700;
    text-align: left;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 3px;
    cursor: pointer;
}

.document-preview-button:hover,
.document-preview-button:focus-visible {
    color: #145c53;
    text-decoration-color: currentColor;
}

.document-preview-button:focus-visible {
    outline: 2px solid rgba(25, 123, 112, 0.35);
    outline-offset: 3px;
}

.records-table .empty-cell {
    padding: 28px 16px;
    color: #82909a;
    text-align: center;
    white-space: normal;
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 2px 0;
    color: #84929c;
    font-size: 12px;
}

.page-buttons {
    display: flex;
    gap: 8px;
}

.page-buttons button {
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: #31444f;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.page-buttons button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.page-buttons button:disabled {
    cursor: default;
    opacity: 0.45;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

@media (max-width: 680px) {
    .topbar {
        height: 112px;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 4px 0;
        padding: 8px 16px;
    }

    .topbar .function-tabs {
        width: 100%;
        order: 2;
        justify-content: flex-start;
    }

    .topbar-actions {
        flex: 0 0 100%;
        order: 1;
        gap: 10px;
    }

    .topbar-label {
        font-size: 11px;
    }

    .page {
        width: calc(100% - 32px);
        padding-top: 154px;
    }

    .panel-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .page-size-field {
        justify-content: space-between;
    }

    .summary-grid {
        gap: 9px;
    }

    .create-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .create-fieldset {
        padding: 14px;
    }

    .summary-card {
        padding: 14px 12px;
    }

    .summary-card strong {
        font-size: 23px;
    }

    .create-actions {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
