/*
 * 檔案名稱：assets/css/admin.css
 * 修改日期：2026/08/14 00:26（UTC+8）
 * 檔案用途：TEMS Central Core 管理後台共用樣式。
 * 修改說明：v0.3.3 保留共用後台水平對齊，新增登入頁最底部版本資訊樣式。
 */

:root {
    color-scheme: light;
    font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    background: #f4f3f0;
    color: #242321;
    --sidebar-width: 250px;
    --sidebar-collapsed: 76px;
    --admin-header-height: 82px;
    --line: #dedbd5;
    --muted: #746f67;
    --surface: #ffffff;
    --surface-soft: #f8f6f2;
    --primary: #2e2925;
    --danger: #a53d38;
    --success: #34704a;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background: #f4f3f0;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.admin-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    transition: grid-template-columns 180ms ease;
}

.admin-layout.sidebar-collapsed {
    grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--line);
    background: #ffffff;
}

.sidebar-brand {
    height: var(--admin-header-height);
    min-height: var(--admin-header-height);
    max-height: var(--admin-header-height);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.brand-mark {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--primary);
    color: #ffffff;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0.05em;
}

.brand-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
    white-space: nowrap;
}

.brand-copy strong {
    font-size: 14px;
}

.brand-copy span {
    color: var(--muted);
    font-size: 12px;
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    margin-bottom: 4px;
    padding: 0 12px;
    border-radius: 10px;
    color: #4b4844;
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}

.nav-item:hover,
.nav-item:focus-visible {
    background: #f3f0eb;
}

.nav-item.active {
    background: #eae4dc;
    color: #241e1a;
}

.nav-icon {
    flex: 0 0 28px;
    width: 28px;
    text-align: center;
    font-size: 18px;
}

.sidebar-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.sidebar-footer a {
    color: #514940;
}

.sidebar-collapsed .brand-copy,
.sidebar-collapsed .nav-item > span:last-child,
.sidebar-collapsed .sidebar-footer {
    opacity: 0;
    pointer-events: none;
}

.admin-main {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--admin-header-height);
    min-height: var(--admin-header-height);
    max-height: var(--admin-header-height);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(244, 243, 240, 0.94);
    backdrop-filter: blur(12px);
}

.sidebar-toggle {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    cursor: pointer;
}

.topbar-title {
    min-width: 0;
}

.topbar h1 {
    margin: 0 0 3px;
    font-size: clamp(22px, 2.6vw, 30px);
    line-height: 1.05;
}

.topbar-title span {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.2;
}

.content-shell {
    width: min(1500px, 100%);
    padding: 24px;
}

.page-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 16px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.metric-card,
.panel {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}

.metric-card {
    padding: 20px;
}

.metric-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

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

.panel {
    margin-top: 16px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}

.panel-header h2 {
    margin: 0;
    font-size: 17px;
}

.panel-body {
    padding: 20px;
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid #ece9e4;
    text-align: left;
    vertical-align: middle;
    font-size: 14px;
}

th {
    color: #686159;
    font-size: 12px;
    letter-spacing: 0.03em;
    background: #fbfaf8;
}

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

.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    word-break: break-all;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    background: #efede9;
    color: #554e47;
    font-size: 12px;
    font-weight: 800;
}

.badge.success {
    background: #e9f5ed;
    color: var(--success);
}

.badge.danger {
    background: #fcebea;
    color: var(--danger);
}

.button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 9px;
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
}

.button.primary {
    background: var(--primary);
    color: #ffffff;
}

.button.secondary {
    border-color: var(--line);
    background: #ffffff;
    color: #39342f;
}

.button.danger {
    background: #fff1f0;
    color: var(--danger);
    border-color: #efd0ce;
}

.button:disabled {
    opacity: 0.55;
    cursor: wait;
}

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

.dialog {
    width: min(720px, calc(100% - 28px));
    max-height: calc(100vh - 40px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 28px 80px rgba(32, 26, 20, 0.22);
}

.dialog::backdrop {
    background: rgba(28, 24, 20, 0.48);
}

.dialog-header,
.dialog-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    background: #fbfaf8;
}

.dialog-header {
    border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
    margin: 0;
    font-size: 18px;
}

.dialog-body {
    max-height: calc(100vh - 210px);
    overflow-y: auto;
    padding: 20px;
}

.dialog-footer {
    border-top: 1px solid var(--line);
}

.close-button {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 22px;
}

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

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

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

.field > span {
    min-height: 21px;
    font-size: 13px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cfcac3;
    border-radius: 9px;
    padding: 10px 12px;
    background: #ffffff;
    color: #282522;
    outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
    border-color: #6a5b4e;
    box-shadow: 0 0 0 3px rgba(106, 91, 78, 0.12);
}


/* v0.2.2：API Client 狀態與 Scope 呈現 */
.status-cell {
    white-space: nowrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 7px;
    min-height: 30px;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.status-pill.is-active {
    border-color: #bcdcc8;
    background: #f1faf4;
    color: #23643a;
}

.status-pill.is-inactive {
    border-color: #edc7c4;
    background: #fff4f3;
    color: #a13932;
}

.status-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: currentColor;
}

.muted-inline {
    color: #81766d;
    font-size: 12px;
    white-space: nowrap;
}

.scope-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}

.field-help {
    display: block;
    margin-top: 5px;
    color: #81766d;
    font-size: 12px;
    line-height: 1.55;
}

.button.compact {
    min-height: 34px;
    padding: 0 10px;
    font-size: 12px;
}

.scope-option-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    line-height: 1.35;
}

.scope-option-text strong {
    font-size: 13px;
}

.scope-option-code {
    color: #7a6f66;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    word-break: break-all;
}

.scope-chip-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 170px;
}

.scope-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    max-width: 100%;
    font-size: 12px;
    line-height: 1.35;
    white-space: nowrap;
}

.scope-chip-code {
    color: #7a6f66;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 10px;
}

.scope-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
}

.scope-option {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
}

.scope-option input {
    width: 18px;
    min-height: 18px;
}


/* v0.3.0：API Client 設定、Scope 圖示兩列與精簡列表 */
.panel-subtitle {
    margin: 6px 0 0;
    color: #81766d;
    font-size: 12px;
    line-height: 1.5;
}

.client-dialog {
    width: min(920px, calc(100% - 28px));
}

.dialog-subtitle {
    margin: 5px 0 0;
    color: #81766d;
    font-size: 12px;
}

.scope-workspace,
.credential-summary {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.scope-list-three {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 12px;
    margin-top: 12px;
}

.scope-list-three .scope-option {
    min-height: 58px;
    padding: 9px 10px;
    border: 1px solid #e4e0da;
    border-radius: 10px;
    background: #fcfbf9;
}

.scope-list-three .scope-option:hover {
    border-color: #cfc7bd;
    background: #ffffff;
}

.scope-option-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f0ede8;
    color: #5c5148;
}

.client-table {
    table-layout: fixed;
    min-width: 940px;
}

.client-table th,
.client-table td {
    vertical-align: middle;
    white-space: nowrap;
}

.client-table th:nth-child(1),
.client-table td:nth-child(1) {
    width: 20%;
}

.client-table th:nth-child(2),
.client-table td:nth-child(2) {
    width: 21%;
}

.client-table th:nth-child(3),
.client-table td:nth-child(3) {
    width: 12%;
}

.client-table th:nth-child(4),
.client-table td:nth-child(4) {
    width: 21%;
}

.client-table th:nth-child(5),
.client-table td:nth-child(5) {
    width: 13%;
}

.client-table th:nth-child(6),
.client-table td:nth-child(6) {
    width: 13%;
}

.client-row-clickable {
    cursor: pointer;
    outline: none;
    transition: background 120ms ease;
}

.client-row-clickable:hover,
.client-row-clickable:focus-visible {
    background: #faf8f5;
}

.client-cell-stack {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.client-cell-stack strong,
.client-cell-stack span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-cell-stack span,
.client-type-badge small {
    color: #81766d;
    font-size: 11px;
}

.client-type-badge {
    display: inline-grid;
    gap: 2px;
    padding: 5px 8px;
    border: 1px solid #dfdbd5;
    border-radius: 8px;
    background: #fbfaf8;
    line-height: 1.25;
}

.site-unbound {
    display: inline-flex;
    width: fit-content;
    padding: 4px 8px;
    border-radius: 999px;
    background: #f2f0ed;
    color: #8a8179 !important;
    font-weight: 700;
}

.scope-icon-strip {
    display: grid;
    grid-template-columns: repeat(5, 29px);
    grid-auto-rows: 29px;
    align-items: center;
    justify-content: start;
    gap: 4px;
    width: 161px;
}

.scope-icon-token {
    position: relative;
    width: 29px;
    height: 29px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    outline: none;
    transition: transform 120ms ease, background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.scope-icon-token svg {
    width: 16px;
    height: 16px;
}

.scope-icon-token.is-granted {
    border-color: #c9d9cd;
    background: #edf6ef;
    color: #2d6840;
}

.scope-icon-token.is-muted {
    border-color: #e4e1dd;
    background: #f5f4f2;
    color: #b5afa8;
}

.scope-icon-token:hover,
.scope-icon-token:focus-visible {
    z-index: 20;
    transform: translateY(-1px);
    border-color: #8b7b6c;
}

.scope-icon-token::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    z-index: 100;
    width: max-content;
    max-width: 280px;
    padding: 7px 9px;
    border-radius: 7px;
    background: #2f2a26;
    color: #ffffff;
    font-size: 11px;
    line-height: 1.35;
    white-space: normal;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 4px);
    transition: opacity 120ms ease, transform 120ms ease;
}

.scope-icon-token:hover::after,
.scope-icon-token:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 0);
}

.client-time-stack strong {
    font-size: 13px;
}

.client-status-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
}

.credential-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.credential-summary-item {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #e4e0da;
    border-radius: 9px;
    background: #fcfbf9;
}

.credential-summary-item span {
    color: #81766d;
    font-size: 11px;
}

.credential-summary-item strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 12px;
}

.credential-summary-wide {
    grid-column: span 2;
}

@media (max-width: 1100px) {
    .scope-list-three {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.secret-box {
    padding: 14px;
    border: 1px solid #dacfbf;
    border-radius: 10px;
    background: #fffaf1;
}

.secret-box textarea {
    margin-top: 10px;
    min-height: 180px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

.toast-stack {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1000;
    display: grid;
    gap: 10px;
    width: min(380px, calc(100% - 36px));
}

.toast {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 12px 32px rgba(35, 30, 25, 0.12);
    font-size: 14px;
}

.toast.success {
    border-color: #bfdcc8;
    background: #eef8f1;
    color: #285e3a;
}

.toast.error {
    border-color: #edc6c3;
    background: #fff1f0;
    color: #8d2e2b;
}

.toast.inline {
    margin-bottom: 16px;
    box-shadow: none;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: #f4f1ec;
}

.login-card {
    width: min(480px, 100%);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 22px 64px rgba(36, 30, 24, 0.12);
}

.login-brand {
    padding: 28px;
    background: #fbf7f0;
    border-bottom: 1px solid var(--line);
}

.login-brand h1 {
    margin: 0 0 6px;
    font-size: 28px;
}

.login-brand p {
    margin: 0;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 16px;
    padding: 26px 28px 28px;
}

.login-version {
    padding: 12px 20px 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
}

.password-row,
.captcha-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.icon-button {
    min-width: 44px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #ffffff;
    cursor: pointer;
}

.captcha-image {
    width: 140px;
    height: 42px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #faf8f4;
    cursor: pointer;
}

@media (max-width: 1080px) {
    .card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .admin-layout,
    .admin-layout.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        z-index: 60;
        width: min(290px, 88vw);
        transform: translateX(-102%);
        transition: transform 180ms ease;
        box-shadow: 18px 0 48px rgba(0, 0, 0, 0.16);
    }

    .admin-layout.mobile-sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-collapsed .brand-copy,
    .sidebar-collapsed .nav-item > span:last-child,
    .sidebar-collapsed .sidebar-footer {
        opacity: 1;
        pointer-events: auto;
    }

    .content-shell,
    .topbar {
        padding-left: 14px;
        padding-right: 14px;
    }

    .card-grid,
    .field-grid {
        grid-template-columns: 1fr;
    }

    .scope-list-three {
        grid-template-columns: 1fr;
    }

    .scope-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .scope-heading .button {
        width: 100%;
    }

    .page-actions {
        justify-content: stretch;
    }

    .page-actions .button {
        flex: 1 1 auto;
    }
}

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

    .password-row,
    .captcha-row {
        grid-template-columns: 1fr;
    }

    .captcha-image {
        width: 100%;
    }
}


/* v0.2.0：會員／備份／更新工作區 */
.panel-subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.compact-panel-body {
    padding-top: 14px;
    padding-bottom: 14px;
}

.search-row,
.button-row,
.update-form {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 10px;
}

.search-row .grow {
    flex: 1 1 320px;
}

.subdued-code {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

.toast.inline.danger {
    border-color: #efd0ce;
    background: #fff1f0;
    color: var(--danger);
}

@media (max-width: 720px) {
    .search-row,
    .button-row,
    .update-form {
        align-items: stretch;
    }

    .search-row .button,
    .button-row .button,
    .update-form .button {
        width: 100%;
    }
}

/* v0.2.1：更新前自動完整備份／下載／還原 */
.button.compact {
    min-height: 34px;
    padding: 0 10px;
    font-size: 12px;
}

.backup-policy-box,
.backup-warning {
    display: grid;
    gap: 6px;
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid #dccda9;
    border-radius: 10px;
    background: #fffaf0;
    color: #51452c;
    line-height: 1.65;
}

.backup-policy-box strong {
    color: #312a1e;
}

.backup-sensitive-note {
    margin-top: 14px;
}

.backup-created-actions,
.update-backup-actions {
    justify-content: flex-start;
}

.backup-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 210px;
}

.backup-filename {
    max-width: 380px;
    overflow-wrap: anywhere;
}

.backup-dialog .dialog-body {
    display: grid;
    gap: 16px;
}

.backup-dialog .backup-warning {
    margin: 0;
    border-color: #e7c9c4;
    background: #fff5f3;
    color: #74362f;
}

.update-flow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 18px;
}

.update-flow span {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #ffffff;
    font-size: 12px;
    font-weight: 800;
}

.update-flow b {
    color: var(--muted);
}

@media (max-width: 720px) {
    .backup-row-actions {
        min-width: 160px;
    }

    .backup-row-actions .button {
        flex: 1 1 100%;
    }

    .backup-created-actions,
    .update-backup-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .backup-created-actions .button,
    .update-backup-actions .button {
        width: 100%;
    }

    .update-flow {
        align-items: stretch;
        flex-direction: column;
    }

    .update-flow b {
        display: none;
    }
}

/* v0.2.3：稽核紀錄查詢 */
.audit-search-row {
    align-items: end;
}

.audit-result-filter {
    min-width: 150px;
}

.audit-request-id {
    overflow-wrap: anywhere;
}

.audit-metadata {
    min-width: 260px;
    max-width: 520px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.55;
    white-space: normal;
    overflow-wrap: anywhere;
}

@media (max-width: 900px) {
    .audit-search-row {
        align-items: stretch;
    }

    .audit-result-filter {
        min-width: 0;
    }
}


/* v0.3.0：Orders 管理工作區 */
.filter-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(180px, 260px) auto;
    align-items: end;
    gap: 12px;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.clickable-row {
    cursor: pointer;
    transition: background 120ms ease;
}

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

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

.detail-card {
    display: grid;
    gap: 5px;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fcfbf9;
}

.detail-card > span {
    color: #81766d;
    font-size: 12px;
}

.detail-card > strong {
    font-size: 15px;
}

.detail-card > small {
    overflow-wrap: anywhere;
    color: #81766d;
    font-size: 11px;
    line-height: 1.45;
}

.amount-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.amount-summary-grid > div {
    display: grid;
    gap: 5px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fcfbf9;
}

.amount-summary-grid span {
    color: #81766d;
    font-size: 12px;
}

.amount-summary-grid strong {
    font-size: 18px;
}

.amount-summary-grid .total {
    background: #f4efe8;
}

@media (max-width: 900px) {
    .detail-grid,
    .amount-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .filter-grid,
    .detail-grid,
    .amount-summary-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions .button {
        flex: 1 1 auto;
    }
}

/* v0.3.0：Orders API 接入狀態 */
.order-readiness-list {
    display: grid;
    gap: 10px;
    padding: 14px 18px 18px;
}

.order-readiness-card {
    display: grid;
    grid-template-columns: minmax(180px, 0.85fr) minmax(360px, 2fr) auto;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fcfbf9;
}

.order-readiness-card.is-ready {
    border-color: #c9d9cd;
    background: #f7fbf8;
}

.order-readiness-identity {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.order-readiness-identity span,
.order-readiness-identity small {
    overflow: hidden;
    color: #81766d;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-readiness-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.readiness-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 27px;
    padding: 0 9px;
    border: 1px solid #dedad4;
    border-radius: 999px;
    background: #f5f4f2;
    color: #756d65;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.readiness-chip.is-pass {
    border-color: #c5dbc9;
    background: #edf7ef;
    color: #2d6840;
}

.readiness-chip.is-missing {
    border-color: #e4ddd3;
    background: #f7f4f0;
    color: #8a7560;
}

.order-readiness-result {
    white-space: nowrap;
}

.order-readiness-result.is-pass {
    color: #2d6840;
}

.order-readiness-result.is-missing {
    color: #8a5f37;
}

.clickable-row:focus-visible {
    outline: 2px solid #8b7b6c;
    outline-offset: -2px;
    background: #faf8f5;
}

@media (max-width: 900px) {
    .order-readiness-card {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .order-readiness-result {
        justify-self: start;
    }

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

    .credential-summary-wide {
        grid-column: span 2;
    }
}

@media (max-width: 640px) {
    .credential-summary-grid {
        grid-template-columns: 1fr;
    }

    .credential-summary-wide {
        grid-column: span 1;
    }
}

/* v0.3.1：API 用戶端列表高度收斂、類型取消框線、權限圖示桌機單列 */
.client-table {
    min-width: 900px;
}

.client-table th,
.client-table td {
    padding-top: 10px;
    padding-bottom: 10px;
}

.client-table th:nth-child(1),
.client-table td:nth-child(1) {
    width: 18%;
}

.client-table th:nth-child(2),
.client-table td:nth-child(2) {
    width: 20%;
}

.client-table th:nth-child(3),
.client-table td:nth-child(3) {
    width: 12%;
}

.client-table th:nth-child(4),
.client-table td:nth-child(4) {
    width: 27%;
}

.client-table th:nth-child(5),
.client-table td:nth-child(5) {
    width: 12%;
}

.client-table th:nth-child(6),
.client-table td:nth-child(6) {
    width: 11%;
}

.client-type-text {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    line-height: 1.35;
    white-space: nowrap;
}

.client-type-text strong {
    font-size: 13px;
}

.client-type-text small {
    color: #81766d;
    font-size: 11px;
}

.scope-icon-strip {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 3px;
    width: auto;
    min-width: 0;
}

.scope-icon-token {
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    border-radius: 7px;
}

.scope-icon-token svg {
    width: 14px;
    height: 14px;
}

.scope-icon-token::after {
    bottom: calc(100% + 6px);
}

.client-cell-stack {
    gap: 2px;
}

.client-time-stack strong {
    font-size: 12px;
}

.client-status-actions .status-pill {
    min-height: 27px;
    padding-left: 9px;
    padding-right: 9px;
    font-size: 12px;
}

/* v0.3.1：訂單 API 接入狀態單列顯示 */
.compact-readiness-panel .panel-header {
    padding-bottom: 14px;
}

.order-readiness-list {
    display: grid;
    gap: 0;
}

.order-readiness-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.25fr) minmax(130px, 0.9fr) minmax(360px, 2.2fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 9px 14px;
    border-top: 1px solid var(--line);
    background: #ffffff;
}

.order-readiness-row.is-ready {
    background: #fbfdfb;
}

.order-readiness-client {
    display: flex;
    align-items: baseline;
    gap: 7px;
    min-width: 0;
}

.order-readiness-client strong,
.order-readiness-client span,
.order-readiness-site {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-readiness-client span,
.order-readiness-site {
    color: #81766d;
    font-size: 11px;
}

.order-readiness-row .order-readiness-checks {
    flex-wrap: nowrap;
    gap: 5px;
    min-width: 0;
}

.order-readiness-row .readiness-chip {
    min-height: 25px;
    padding: 0 8px;
    font-size: 10px;
}

.order-readiness-row .order-readiness-result {
    justify-self: end;
    font-size: 12px;
}

@media (max-width: 1050px) {
    .order-readiness-row {
        grid-template-columns: minmax(180px, 1fr) minmax(120px, 0.8fr) minmax(320px, 1.8fr) auto;
    }
}

@media (max-width: 820px) {
    .order-readiness-row {
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .order-readiness-row .order-readiness-checks {
        flex-wrap: wrap;
    }

    .order-readiness-row .order-readiness-result {
        justify-self: start;
    }
}

/* ============================================================
 * v0.4.0 商品主檔 / 商品逐店派送
 * 修改日期：2026/08/14 08:39（UTC+8）
 * ============================================================ */
.product-page-actions {
    align-items: end;
    justify-content: space-between;
    gap: 16px;
}

.product-filter {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.product-filter .inline-field {
    min-width: min(360px, 70vw);
}

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

.cell-stack,
.muted-stack {
    display: grid;
    gap: 3px;
}

.muted-stack,
.muted-text {
    color: #81766d;
    font-size: 12px;
}

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

.product-field-wide {
    grid-column: span 2;
}

.product-enabled-field {
    align-self: end;
    min-height: 42px;
}

.product-revision-summary {
    display: grid;
    justify-items: end;
    gap: 2px;
}

.product-revision-summary span {
    color: #81766d;
    font-size: 11px;
}

.product-revision-summary strong {
    font-size: 18px;
}

.product-save-footer,
.product-publish-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.product-publish-footer > div {
    display: grid;
    gap: 3px;
    margin-right: auto;
}

.product-publish-footer > div span {
    color: #81766d;
    font-size: 12px;
}

.target-select-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 18px;
}

.target-select-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
}

.target-select-card:hover {
    border-color: #b8aa9f;
    background: #fdfbf9;
}

.target-select-card input {
    margin-top: 4px;
}

.target-select-copy {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.target-select-copy span,
.target-select-copy small {
    color: #81766d;
}

.hash-cell {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.target-editor-form {
    display: grid;
    gap: 16px;
}

.form-note {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #faf8f5;
}

.warning-note {
    border-color: #e1cda7;
    background: #fffaf0;
}

.target-actions-cell {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: nowrap;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.dispatch-filter-grid {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(160px, .8fr) minmax(260px, 1.4fr) auto;
    align-items: end;
    gap: 12px;
}

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

.dispatch-state-applied,
.state-applied {
    background: #e8f6ec;
    color: #28643a;
}

.dispatch-state-failed,
.state-failed {
    background: #fdeaea;
    color: #9a3434;
}

.dispatch-state-conflict,
.state-conflict {
    background: #fff1dd;
    color: #8b5a14;
}

.dispatch-state-leased,
.dispatch-state-retry_wait,
.dispatch-state-pending {
    background: #edf3fa;
    color: #315c82;
}

.text-link {
    color: var(--primary, #5b4636);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.dispatch-table td {
    vertical-align: top;
}

@media (max-width: 1100px) {
    .product-editor-grid,
    .target-select-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .dispatch-filter-actions {
        align-self: end;
    }
}

@media (max-width: 760px) {
    .product-metric-grid,
    .product-editor-grid,
    .target-select-grid,
    .dispatch-filter-grid {
        grid-template-columns: 1fr;
    }

    .product-field-wide {
        grid-column: auto;
    }

    .product-page-actions,
    .product-save-footer,
    .product-publish-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .product-publish-footer > div {
        margin-right: 0;
    }

    .product-filter .inline-field {
        min-width: 100%;
        width: 100%;
    }

    .target-actions-cell,
    .dispatch-filter-actions {
        flex-wrap: wrap;
    }

    .hash-cell {
        max-width: 150px;
    }
}
