/* Kaya product maintenance: compact Stock Cards-inspired list and modal workspace. */
body.admin-stock-page {
    --stock-green: #8ebf42;
    --stock-green-dark: #6f9f2a;
    --stock-border: #d0d7de;
    --stock-ink: #0f172a;
    --stock-muted: #64748b;
    background: #f8fafc;
    color: var(--stock-ink);
    font-family: "Segoe UI", Arial, sans-serif;
}
body.admin-stock-page .admin-header,
body.admin-stock-page .admin-main { width: min(1420px, calc(100% - 32px)); }
body.admin-stock-page .admin-header { padding: 13px 0; }
body.admin-stock-page .admin-main { padding-bottom: 24px; }
body.admin-stock-page .brand { color: var(--stock-ink); }
body.admin-stock-page .admin-header-logout { background: white; border: 1px solid var(--stock-border); color: var(--stock-ink); }
body.admin-stock-page h1, body.admin-stock-page h2, body.admin-stock-page h3 { letter-spacing: normal; }
.admin-stock-page .primary-button { background: var(--stock-green); color: #fff; }
.admin-stock-page .primary-button:hover { background: var(--stock-green-dark); color: #fff; }
.admin-stock-page .secondary-button { background: white; border: 1px solid var(--stock-border); color: #334155; }
.admin-stock-page .secondary-button:hover { background: #f1f5f9; }
.admin-stock-page .primary-button, .admin-stock-page .secondary-button, .admin-stock-page .danger-button { border-radius: 6px; min-height: 38px; padding: 7px 14px; font-size: .88rem; font-weight: 600; }
.admin-stock-page :is(button, input, select, textarea, a):focus-visible { outline: 2px solid var(--stock-green-dark); outline-offset: 2px; }
.admin-stock-heading { margin: 6px 0 10px; padding: 13px 17px; display: flex; gap: 14px; align-items: center; justify-content: space-between; border-radius: 9px; background: var(--stock-green); color: white; }
.admin-stock-heading h1 { margin: 0; font-size: clamp(1.2rem, 2.3vw, 1.5rem); font-weight: 700; }
.admin-stock-heading .primary-button { background: white; color: #35521d; border: 1px solid rgba(255,255,255,.8); }
.admin-stock-heading .primary-button:hover { background: #eff7e5; color: #35521d; }
.admin-stock-filters { display: grid; grid-template-columns: minmax(0, 1fr) 160px auto; align-items: end; gap: 10px; margin: 0 0 10px; padding: 12px; border: 1px solid var(--stock-border); border-radius: 8px; background: #fff; }
.admin-stock-filters label { display: grid; gap: 4px; min-width: 0; margin: 0; font-size: .79rem; font-weight: 600; color: #475569; }
.admin-stock-filters :is(input[type="search"], select) { width: 100%; height: 38px; min-width: 0; padding: 6px 10px; border: 1px solid #bbc6d0; border-radius: 5px; background: #fff; color: var(--stock-ink); font: inherit; font-size: .9rem; }
.admin-stock-count { display: flex; align-items: baseline; justify-content: center; min-height: 38px; gap: 7px; padding: 6px 10px; white-space: nowrap; border: 1px solid var(--stock-border); border-radius: 5px; font-size: .82rem; color: var(--stock-muted); }
.admin-stock-count strong { font-size: 1.15rem; color: var(--stock-ink); }
.admin-stock-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; align-items: start; }
.admin-stock-list-card { min-width: 0; border: 1px solid var(--stock-border); border-radius: 8px; background: #fff; overflow: hidden; }
.admin-stock-table-scroll { max-height: min(73dvh, 840px); overflow: auto; }
.admin-stock-products { border-collapse: collapse; width: 100%; table-layout: fixed; color: var(--stock-ink); font-size: .9rem; }
.admin-stock-products th { position: sticky; top: 0; z-index: 1; background: #eaf3dc; border-bottom: 1px solid var(--stock-border); padding: 12px 11px; text-align: left; font-size: .78rem; font-weight: 700; color: #334155; }
.admin-stock-products td { border-bottom: 1px solid #e6eaf0; padding: 7px 11px; vertical-align: middle; }
.admin-stock-products tr:nth-child(even) { background: #f7faef; }
.admin-stock-products tr.admin-stock-row { cursor: pointer; }
.admin-stock-products tr.admin-stock-row:hover, .admin-stock-products tr.admin-stock-row:focus-visible { background: #eaf3dc; outline: 2px solid var(--stock-green-dark); outline-offset: -2px; }
.admin-stock-products th:nth-child(1) { width: 75px; }
.admin-stock-products th:nth-child(3) { width: 116px; text-align: right; }
.admin-stock-products th:nth-child(4) { width: 100px; }
.admin-stock-products th:nth-child(5) { width: 72px; text-align: center; }
.admin-stock-image img, .admin-stock-empty-photo { width: 54px; height: 54px; border: 1px solid #e2e8f0; border-radius: 5px; object-fit: contain; background: #fff; }
.admin-stock-empty-photo { display: grid; place-items: center; color: var(--stock-muted); font-size: .75rem; }
.admin-stock-name a { display: block; font-weight: 650; text-decoration: none; color: var(--stock-ink); overflow-wrap: anywhere; }
.admin-stock-name a:hover { text-decoration: underline; }
.admin-stock-name small { display: block; margin-top: 3px; color: var(--stock-muted); font-size: .77rem; }
.admin-stock-price { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.admin-stock-status { display: inline-flex; padding: 3px 8px; border-radius: 4px; background: #f1f5f9; color: #475569; font-size: .74rem; font-weight: 650; }
.admin-stock-status.is-visible { background: #eaf3dc; color: #42651e; }
.admin-stock-photo-count { text-align: center; font-variant-numeric: tabular-nums; color: #475569; }
.admin-stock-empty { padding: 30px 15px; color: var(--stock-muted); text-align: center; }
body.admin-stock-page:has(.admin-stock-dialog[open]) { overflow: hidden; }
.admin-stock-dialog { width: min(820px, calc(100% - 22px)); max-width: 100%; max-height: min(92dvh, 950px); overflow: hidden; padding: 0; margin: auto; background: white; color: var(--stock-ink); border: 1px solid var(--stock-border); border-radius: 10px; box-shadow: 0 18px 65px rgba(15,23,42,.27); }
.admin-stock-dialog::backdrop { background: rgba(15,23,42,.62); }
.admin-stock-dialog:not([open]) { display: none; }
.admin-stock-dialog-shell { display: flex; flex-direction: column; max-height: min(calc(92dvh - 2px), 948px); min-height: 0; }
.admin-stock-dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 13px 18px; background: var(--stock-green); color: white; flex: 0 0 auto; }
.admin-stock-dialog-header h2 { font-size: 1.12rem; font-weight: 700; margin: 0; }
.admin-stock-dialog-header :is(button,a) { flex: 0 0 auto; min-height: 35px; padding: 6px 12px; background: #fff; border: 1px solid #e1ebd5; border-radius: 5px; font: 600 .82rem "Segoe UI", Arial, sans-serif; color: #35521d; cursor: pointer; text-decoration: none; }
.admin-stock-dialog-header :is(button,a):hover { background: #f1f7e6; }
.admin-stock-dialog-body { min-height: 0; overflow: auto; padding: 17px 18px; overscroll-behavior: contain; }
.admin-stock-confirm-dialog { width: min(440px, calc(100% - 22px)); }
.admin-stock-confirm-actions { display: flex; justify-content: flex-end; }
.admin-stock-confirm-dialog p { margin: 0 0 20px; }
.admin-stock-confirm-dialog .danger-button { background: #b42318; color: white; }
.admin-stock-editor .admin-form { gap: 12px; }
.admin-stock-edit-id { color: var(--stock-muted); font-size: .8rem; font-weight: 700; }
.admin-stock-editor .form-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.admin-stock-editor .form-grid > .price-visibility-row { grid-column: 1 / -1; }
.admin-stock-dialog-body label { font-weight: 600; color: #475569; gap: 4px; }
.admin-stock-dialog-body :is(input[type="text"],input[type="file"],textarea) { padding: 8px 10px; border: 1px solid #bbc6d0; border-radius: 5px; font-size: .88rem; }
.admin-stock-dialog-body textarea { min-height: 74px; resize: vertical; }
.admin-stock-dialog-body .checkbox-label { font-weight: 600; }
.admin-stock-editor .admin-disclosure { padding: 8px 0; border-top: 1px solid #e6eaf0; }
.admin-stock-editor .admin-disclosure summary { cursor: pointer; font-weight: 650; color: #334155; }
.admin-stock-editor .disclosure-grid { margin-top: 12px; }
.admin-stock-editor .current-images-block { border-top: 1px solid #e6eaf0; padding-top: 12px; }
.admin-stock-editor .current-images-title { color: #334155; font-size: .9rem; }
.admin-stock-editor .current-images-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); gap: 12px; overflow: visible; }
.admin-stock-editor .current-image-item { flex: none; min-width: 0; width: 100%; }
.admin-stock-editor .current-image-photo { position: relative; }
.admin-stock-page .admin-stock-editor .photo-preview-trigger img { width: 100%; height: 115px; object-fit: contain; border-radius: 6px; border: 1px solid #e2e8f0; background: #fff; }
.admin-stock-editor .photo-variation-fields { margin-top: 6px; display: grid; gap: 6px; }
.admin-stock-editor .photo-variation-fields label { font-size: .72rem; }
.admin-stock-editor .photo-variation-fields input { width: 100%; }
.admin-stock-editor .edit-button-row { padding: 10px 0; }
.admin-stock-editor .photo-upload-panel { border-top: 1px solid #e6eaf0; padding-top: 13px; margin-top: 8px; }
.admin-stock-editor .photo-upload-heading h3 { margin: 0 0 10px; font-size: .95rem; }
.admin-stock-editor .photo-upload-form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.admin-stock-editor .photo-upload-form label { flex: 1 1 230px; }
.admin-stock-editor .delete-edit-form { justify-content: flex-start; margin-top: 14px; padding-top: 12px; }
.admin-stock-editor .delete-product-button { height: 38px; width: fit-content; max-width: 100%; flex: 0 0 auto; align-self: flex-start; }
.admin-stock-page .admin-stock-editor .main-photo-toggle, .admin-stock-page .admin-stock-editor .delete-photo-button { z-index: 1; }
.admin-stock-page .admin-stock-editor .crop-photo-button { z-index: 1; }
.admin-stock-merge > p { margin: 0 0 12px; }
.admin-stock-merge .merge-target-grid { grid-template-columns: repeat(auto-fill, minmax(185px,1fr)); gap: 9px; }
.admin-stock-merge .merge-target-button { min-height: 76px; grid-template-columns: 55px minmax(0,1fr); gap: 9px; border-radius: 6px; padding: 7px; }
.admin-stock-merge .merge-target-button img { width: 55px; height: 55px; border-radius: 5px; }
.admin-stock-merge .merge-target-button small { display: block; color: var(--stock-muted); }
.admin-stock-photo-dialog { width: min(950px,calc(100% - 22px)); }
.admin-stock-photo-dialog .admin-stock-dialog-body { display: grid; place-items: center; }
.admin-stock-photo-dialog img { max-width: 100%; max-height: 75dvh; object-fit: contain; }
@media (max-width: 680px) {
    .admin-stock-editor .delete-product-button { width: 100%; }
}
@media (max-width: 740px) {
    .admin-stock-page .admin-header, .admin-stock-page .admin-main { width: min(100% - 18px, 740px); }
    .admin-stock-heading { padding: 11px 12px; }
    .admin-stock-filters { grid-template-columns: minmax(0,1fr) 110px auto; gap: 9px; }
    .admin-stock-filters .admin-stock-count { justify-content: center; }
    .admin-stock-workspace { grid-template-columns: minmax(0,1fr); }
    .admin-stock-table-scroll { max-height: none; }
    .admin-stock-products th:nth-child(1) { width: 68px; }
    .admin-stock-products th:nth-child(3) { width: 90px; }
    .admin-stock-products th:nth-child(4) { width: 83px; }
    .admin-stock-products th:nth-child(5), .admin-stock-products td:nth-child(5) { display: none; }
}
@media (max-width: 510px) {
    .admin-stock-heading .primary-button { min-height: 36px; padding: 6px 8px; font-size: .79rem; }
    .admin-stock-filters { grid-template-columns: minmax(0,1fr) 95px auto; }
    .admin-stock-filters .admin-stock-count { font-size: .75rem; }
    .admin-stock-products thead { display: none; }
    .admin-stock-products, .admin-stock-products tbody { display: block; width: 100%; }
    .admin-stock-products tr.admin-stock-row { display: grid; grid-template-columns: 62px minmax(0,1fr) auto; grid-template-rows: auto auto; gap: 2px 9px; align-items: center; padding: 9px; border-bottom: 1px solid var(--stock-border); }
    .admin-stock-products td { padding: 0; border: 0; min-width: 0; }
    .admin-stock-products td:nth-child(1) { grid-row: 1 / 3; grid-column: 1; }
    .admin-stock-products td:nth-child(2) { grid-row: 1 / 3; grid-column: 2; }
    .admin-stock-products td:nth-child(3) { grid-row: 1; grid-column: 3; font-size: .83rem; }
    .admin-stock-products td:nth-child(4) { grid-row: 2; grid-column: 3; text-align: right; }
    .admin-stock-products .admin-stock-status { font-size: .68rem; }
    .admin-stock-dialog-shell { max-height: calc(95dvh - 2px); }
    .admin-stock-dialog { max-height: 95dvh; }
    .admin-stock-dialog-header { padding: 11px 12px; }
    .admin-stock-dialog-body { padding: 12px; }
    .admin-stock-editor .form-grid { grid-template-columns: 1fr; }
    .admin-stock-editor .form-grid > .price-visibility-row { grid-column: 1; }
    .admin-stock-page .admin-stock-editor .price-visibility-row { grid-template-columns: minmax(0,1fr) auto; }
    .admin-stock-editor .current-images-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
/* Author-level display rule ensures filters hide rows even in phone grid mode. */
.admin-stock-products .admin-stock-row[hidden] { display: none !important; }

/* All admin workspaces share the same header and Close action. */
.admin-stock-top-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-stock-page .admin-card { background: white; border: 1px solid var(--stock-border); border-radius: 10px; box-shadow: none; }
.admin-stock-heading .secondary-button { color: #35521d; border-color: rgba(255,255,255,.8); }
.admin-stock-page-panel { border: 1px solid var(--stock-border); border-radius: 10px; overflow: hidden; background: white; }
.admin-share-dialog { width: min(680px,calc(100% - 22px)); }
.admin-share-dialog .game-share-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.admin-share-dialog .game-share-grid > div { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid var(--stock-border); border-radius: 6px; background: #f7faef; }
.admin-share-dialog strong { flex: 1; overflow-wrap: anywhere; font-size: .9rem; }
.admin-share-dialog .game-copy-icon { flex: 0 0 44px; width: 44px; height: 44px; padding: 10px; display: grid; place-items: center; }
.admin-share-dialog svg { display: block; }
#game-link-status { margin: 12px 0 0; }
.admin-history-dialog { width: min(1000px,calc(100% - 22px)); }
.admin-history-dialog .admin-stock-dialog-header h2 { min-width: 0; overflow-wrap: anywhere; }
.admin-history-dialog h3 { margin: 22px 0 8px; font-size: 1rem; font-weight: 700; }
.visit-log-filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 0 0 12px; }
.visit-log-filter label { display: grid; gap: 4px; min-width: 0; font-size: .85rem; }
.visit-log-filter input[type="date"] { min-width: 0; max-width: 100%; min-height: 38px; padding: 6px 10px; border: 1px solid var(--stock-border); border-radius: 5px; background: white; color: var(--stock-ink); }
.visit-log-filter label.visit-log-home { display: flex; align-items: center; gap: 8px; min-height: 38px; flex: 0 0 auto; cursor: pointer; }
.visit-log-home input { width: 18px; height: 18px; margin: 0; flex: none; }
.visit-log-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin: 12px 0; }
.visit-log-metrics > div { display: grid; gap: 4px; padding: 12px; border-radius: 6px; background: #eaf3dc; }
.visit-log-metrics strong { font-size: 1.2rem; }
.visit-log-metrics span { font-size: .8rem; color: #475569; }
.visit-log-scroll { overflow-x: auto; max-width: 100%; }
.visit-log-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.visit-log-table :is(th,td) { padding: 9px 8px; border-bottom: 1px solid var(--stock-border); text-align: left; vertical-align: top; }
.visit-log-table th { background: #eaf3dc; white-space: nowrap; }
.visit-log-table tr:nth-child(even) { background: #f7faef; }
.visit-log-table td { overflow-wrap: anywhere; }
.visit-log-table .visit-log-drill-row { cursor: pointer; }
.visit-log-table .visit-log-drill-row:is(:hover,:focus-within) { background: #eaf3dc; }
.visit-log-drill-button { display: block; max-width: 100%; min-height: 38px; padding: 0; border: 0; background: transparent; color: var(--stock-green-dark); font: inherit; font-weight: 600; text-align: left; text-decoration: underline; overflow-wrap: anywhere; cursor: pointer; }
.visit-log-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.visit-log-pagination > div { display: flex; gap: 8px; }
.visit-log-pagination button:disabled { opacity: .45; cursor: default; }
@media (max-width: 600px) {
    .admin-stock-heading { flex-wrap: wrap; gap: 10px; }
    .admin-stock-top-actions { width: 100%; }
    .admin-stock-top-actions > button { flex: 1 1 auto; padding: 6px 8px; font-size: .78rem; }
    .admin-stock-filters { gap: 6px; padding: 8px; }
    .admin-stock-count { padding: 6px; gap: 4px; }
    .admin-stock-filters :is(input[type="search"], select) { padding: 6px; font-size: .8rem; }
    .visit-log-filter label { flex: 1 1 110px; }
    .visit-log-metrics { gap: 6px; }
    .visit-log-metrics > div { padding: 8px; }
    .visit-log-metrics strong { font-size: .95rem; }
    .visit-log-table { font-size: .78rem; }
    .visit-log-table :is(th,td) { padding: 8px 5px; }
}
