:root {
    --rose-primary: #C2185B;
    --rose-secondary: #FCE7F3;
    --rose-background: #FFF3F7;
    --rose-card: #FFFFFF;
    --rose-text: #182033;
    --rose-success: #087F5B;
    --rose-error: #DC2626;
    --ui-border: #eedee6;
    --ui-muted: #586174;
    --ui-shadow: 0 8px 24px #5913340b;
}
.pwa-shell, .liff-shell {
    color: var(--rose-text);
    font: 16px/1.55 system-ui, "Noto Sans Thai", Tahoma, sans-serif;
    overflow-wrap: anywhere;
}
body.pwa-shell {
    background: var(--rose-background);
    max-width: 45rem;
    margin: auto;
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(84px + env(safe-area-inset-bottom));
}
.pwa-shell > header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}
.pwa-shell > header h1 { margin: 0; font-size: 1.25rem; color: var(--rose-primary); }
.pwa-shell > header p { grid-column: 2; margin: 0; color: var(--ui-muted); font-size: .87rem; }
.brand-logo { grid-row: span 2; width: 48px; height: 48px; object-fit: contain; border-radius: 16px; }
.pwa-shell > footer { display: flex; align-items: center; gap: 12px; margin-top: 24px; }
.pwa-shell a { color: var(--rose-primary); }
.pwa-shell > .pwa-shop-header { grid-template-columns: auto minmax(0, 1fr) auto; }
.pwa-shell .pwa-chat-link {
    grid-area: 1 / 3 / span 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 10px;
    border: 1px solid #d4af72;
    border-radius: 12px;
    background: #fff7fa;
    color: #831b4c;
    font-size: .875rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.pwa-shell [hidden], .workspace [hidden] { display: none !important; }
.pwa-shell .web-login {background:var(--rose-card);border:1px solid var(--ui-border);border-radius:18px;padding:20px;margin:26px auto;max-width:405px;box-shadow:var(--ui-shadow);}
.pwa-shell .web-login h2 {color:var(--rose-text);margin:0 0 16px;}
.pwa-shell .web-login-button {display:block;min-height:44px;padding:10px;border-radius:10px;background:var(--rose-primary);color:#fff;font-weight:700;text-align:center;text-decoration:none;}
.pwa-shell .web-shop-rich-grid {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;}
.pwa-shell .web-shop-rich-grid a {display:flex;align-items:center;justify-content:center;flex-direction:column;min-height:82px;gap:7px;padding:8px 4px;background:var(--rose-card);color:var(--rose-primary);border:1px solid var(--ui-border);border-radius:14px;text-decoration:none;text-align:center;font-size:.84rem;font-weight:700;line-height:1.35;overflow-wrap:anywhere;}
.pwa-shell .web-shop-rich-grid svg {width:22px;height:22px;flex:none;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round;}
.pwa-shell .minity-chat-tabs {grid-template-columns:repeat(2,minmax(0,1fr));margin:12px 0;}
.pwa-shell .minity-chat-tabs a {min-height:48px;}
.pwa-shell .minity-chat-tabs a[aria-current="page"] {background:var(--rose-primary);color:white;}
.pwa-shell .minity-chat label {display:block;margin:10px 0;}
.pwa-shell .minity-chat textarea {display:block;width:100%;font:inherit;padding:10px;border:1px solid var(--ui-border);border-radius:10px;}
.pwa-shell .minity-chat button {margin:4px 6px 4px 0;}
.pwa-shell .minity-chat li {white-space:pre-wrap;overflow-wrap:anywhere;}
.web-shop-overview,.web-shop-summary {display:grid;gap:12px;min-width:0;}
.pwa-shell .web-shop-destination {display:block;padding:10px;background:var(--rose-secondary);border-radius:12px;font-weight:700;text-align:center;text-decoration:none;}
.web-shop-received {display:grid;gap:8px;padding:20px;border-radius:18px;color:white;background:linear-gradient(115deg,#770d37,#ba1159);}
.web-shop-received strong {font-size:clamp(1.8rem,8vw,3rem);line-height:1.2;}
.web-shop-received p {font-size:.875rem;}
.web-shop-balance {display:grid;gap:8px;padding:12px;background:var(--rose-card);border:1px solid var(--ui-border);border-radius:16px;}
.web-shop-balance progress {width:100%;accent-color:var(--rose-primary);}
.web-shop-stats {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;}
.web-shop-stats-three {grid-template-columns:repeat(3,minmax(0,1fr));text-align:center;}
.web-shop-stats > div {display:grid;gap:4px;padding:10px;background:var(--rose-card);border:1px solid var(--ui-border);border-radius:14px;font-size:.875rem;}
.web-shop-stats strong {color:var(--rose-primary);font-size:1.1rem;}
.web-shop-stats .web-shop-complete strong {color:var(--rose-success);}
.web-shop-stats .web-shop-unpaid strong {color:var(--rose-error);}
.web-groups,.web-group-list,.web-group-controls,.web-group-history,.web-group-dialog form {display:grid;gap:12px;min-width:0;}
.web-group-heading {display:flex;align-items:center;gap:12px;}
.web-group-heading img {width:44px;height:44px;border-radius:12px;}
.web-group-heading h2,.web-group-item strong,.web-group-history p:first-child {color:var(--rose-primary);}
.web-groups .web-shop-stats-three > div {gap:0;}
.web-groups .web-shop-stats-three strong {font-size:1.5rem;line-height:1.3;}
.web-group-controls,.web-group-card {background:var(--rose-card);border:1px solid var(--ui-border);border-radius:16px;}
.web-group-controls {padding:12px;}
.web-group-controls>.web-shop-stats {gap:10px;}
.web-group-controls label,.web-group-dialog label {display:grid;gap:4px;min-width:0;}
.web-group-controls input,.web-group-controls select,.web-group-dialog input,.web-group-dialog select {width:100%;min-width:0;box-sizing:border-box;}
.web-groups .web-group-item {display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;padding:13px;
    text-align:left;background:var(--rose-card);color:var(--rose-text);border:0;border-bottom:1px solid var(--ui-border);border-radius:15px;}
.web-group-item > span:first-child {display:grid;gap:2px;min-width:0;}
.web-group-item small {color:var(--ui-muted);font-weight:500;}
.web-group-item small[data-tone=success] {color:var(--rose-success);}
.web-group-item small[data-tone=error] {color:var(--rose-error);}
.web-group-arrow {color:var(--rose-primary);background:var(--rose-secondary);padding:8px 10px;border-radius:10px;flex:none;}
.web-group-actions {display:flex;flex-wrap:wrap;gap:8px;padding:8px 12px;}
.web-group-history {padding:8px 12px 12px;}
.web-group-dialog {width:min(32rem,calc(100% - 32px));max-height:85vh;border:1px solid var(--ui-border);border-radius:16px;padding:16px;color:var(--rose-text);}
.web-group-dialog::backdrop {background:#24091466;}
.web-group-dialog img {display:block;width:100%;height:auto;margin-bottom:12px;}
.workspace { min-width: 0; }
#nav-content.workspace { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.workspace-inline { padding-bottom: 0; }
#nav-content.workspace { display: block; }
.workspace > section {
    display: grid;
    gap: 16px;
    background: transparent;
    border: 0;
    padding: 0;
    min-width: 0;
}
.workspace h2 { margin: 0; font-size: 1.375rem; font-weight: 800; }
.workspace h3 { margin: 0; font-size: 1rem; }
.workspace p { margin: 0; }
.workspace [role=alert]:empty { display: none; }
.workspace [role=alert] { color: var(--rose-error); margin-bottom: 12px; }
.workspace button, .workspace .nav-link, .pwa-shell button {
    font: inherit;
    font-weight: 700;
    min-height: 44px;
    box-sizing: border-box;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 8px 12px;
    background: var(--rose-secondary);
    color: var(--rose-primary);
    cursor: pointer;
}
.workspace button:disabled { opacity: .6; }
.workspace :focus-visible, .pwa-shell :focus-visible { outline: 2px solid var(--rose-primary); outline-offset: 2px; }
.workspace label { display: grid; font-weight: 650; gap: 4px; }
.workspace input, .workspace select {
    min-width: 0;
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    color: var(--rose-text);
    background: var(--rose-card);
    padding: 8px 12px;
    font: inherit;
}
.workspace-panel, .workspace-search, .workspace-filters, .workspace > section > section {
    display: grid;
    gap: 12px;
    background: var(--rose-card);
    border: 1px solid var(--ui-border);
    border-radius: 20px;
    padding: 16px;
    box-shadow: var(--ui-shadow);
    min-width: 0;
}
.pwa-shell:has(.web-groups) > .pwa-shop-header {display:none;}
.pwa-shell .workspace > section > .web-groups {background:transparent;border:0;box-shadow:none;padding:0;}
.workspace-search > div:empty { display: none; }
.workspace-hero {
    display: grid;
    gap: 8px;
    border-radius: 20px;
    padding: 20px;
    color: white;
    background: linear-gradient(125deg,#791039,var(--rose-primary));
    box-shadow: 0 10px 28px #83184329;
}
.workspace-hero strong { font-size: clamp(2rem, 9vw, 3.25rem); font-variant-numeric: tabular-nums; line-height: 1.12; }
.workspace-hero p { font-size: .82rem; color: #fff4f9; }
.workspace-kpis, .workspace-periods { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.workspace button.workspace-kpi {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
    min-height: 90px;
    border-radius: 16px;
    border-color: var(--ui-border);
    background: var(--rose-card);
    color: var(--ui-muted);
    font-size: .81rem;
    box-shadow: var(--ui-shadow);
}
.workspace-kpi strong { display: block; font-size: clamp(1rem, 4.75vw, 1.4rem); color: var(--rose-text); }
.workspace .v2-received strong { color: var(--rose-success); }
.workspace .v2-review strong { color: #824313; }
.workspace .v2-overdue strong { color: #ac1927; }
.workspace button[aria-pressed=true] { border-color: var(--rose-primary); background: var(--rose-secondary); }
.workspace-periods { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 4px; }
.workspace-periods button { padding-inline: 4px; font-size: .78rem; }
.workspace-period { display: grid; gap: 8px; }
.workspace-period details, .workspace-line {
    padding: 8px 0;
    border-bottom: 1px solid var(--ui-border);
}
.workspace-period summary { cursor: pointer; min-height: 44px; }
.workspace-period meter { display: block; width: 100%; height: 14px; accent-color: var(--rose-primary); }
.workspace-period meter::-webkit-meter-optimum-value { background: var(--rose-primary); }
.workspace-month-chart { display: grid; gap: 8px; margin-block: 8px; }
.workspace-chart-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--ui-muted); font-size: .75rem; }
.workspace-chart-legend span { display: inline-flex; align-items: center; gap: 4px; }
.workspace-chart-legend span::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--series-color); }
.workspace-month-chart [data-series=received] { --series-color: var(--rose-success); }
.workspace-month-chart [data-series=recordedDue] { --series-color: var(--rose-primary); }
.workspace-month-chart ol { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.workspace-month-chart li {
    display: grid;
    grid-template-columns: 55px minmax(0,1fr);
    align-items: center;
    gap: 8px;
    margin: 0;
    border-bottom: 1px solid var(--ui-border);
    padding-block: 8px;
    font-size: .81rem;
}
.workspace-month-chart li > div > div { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; }
.workspace-month-chart strong { min-width: 66px; text-align: right; font-variant-numeric: tabular-nums; }
.workspace-month-chart meter { accent-color: var(--series-color); }
.workspace-month-chart meter::-webkit-meter-optimum-value { background: var(--series-color); }
.workspace-month-chart meter::-moz-meter-bar { background: var(--series-color); }
.workspace-line { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; align-items: baseline; }
.workspace-line span { color: var(--ui-muted); }
.workspace-line strong { text-align: right; font-variant-numeric: tabular-nums; }
.workspace button.workspace-result {
    display: grid;
    text-align: left;
    width: 100%;
    margin: 4px 0;
    padding: 12px;
    border-radius: 16px;
    border-color: var(--ui-border);
    background: var(--rose-card);
    color: var(--rose-text);
}
.workspace-result small { color: var(--ui-muted); font-weight: 500; }
.workspace-nav {
    position: fixed;
    z-index: 3;
    inset: auto 0 0;
    margin: auto;
    max-width: 45rem;
    display: grid;
    grid-template-columns: repeat(5,minmax(0,1fr));
    gap: 4px;
    background: var(--rose-card);
    border-top: 1px solid var(--ui-border);
    box-shadow: 0 -6px 22px #5913340b;
    padding: 8px max(8px,env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));
}
.workspace-nav button { display: grid; justify-items: center; gap: 4px; padding: 4px; background: white; font-size: .73rem; }
.workspace-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.liff-shell { padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.liff-shell section { border-color: var(--ui-border); box-shadow: var(--ui-shadow); }
.liff-shell #nav-heading, .liff-shell #group-page-heading { padding: 12px 0; }
.liff-shell #nav-heading h1, .liff-shell #group-page-heading h1 { font-size: 1.5rem; line-height: 1.25; }
.liff-shell .shop-nav-link, .liff-shell .group-item, .liff-shell .group-history-card {
    border: 1px solid var(--ui-border);
    border-radius: 16px;
    background: var(--rose-card);
    box-shadow: var(--ui-shadow);
}
.liff-shell .shop-nav-link { padding: 12px; }
.liff-shell .payment-summary {
    border-radius: 20px;
    padding: 16px;
    color: white;
    background: linear-gradient(125deg,#791039,var(--rose-primary));
}
.liff-shell .payment-list { gap: 8px; }
.liff-shell .payment-row { padding: 12px; border: 1px solid var(--ui-border); border-radius: 16px; }
.liff-shell :is(#member-form,#signup,#member-management) h2 { color: var(--rose-primary); }
.liff-shell :is(#member-form,#signup) section { min-width: 0; }

/* Modern Rose · Champagne Gold accents, shared by the shop in LIFF and PWA. */
.workspace .workspace-hero {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    border: 1px solid #edce8f;
    background: radial-gradient(ellipse at 83% 0%, #ed8dbb7a, transparent 52%),
                linear-gradient(135deg, #74153e, var(--rose-primary) 53%, #8f1749);
    box-shadow: 0 9px 23px #8e255034, inset 0 1px 0 #ffffff33;
}
.workspace-hero::before, .workspace-hero::after {
    content: "";
    position: absolute;
    z-index: -1;
    pointer-events: none;
    width: 229px;
    height: 100px;
    top: auto;
    right: -45px;
    bottom: -33px;
    transform: rotate(-36deg);
    border-radius: 50%;
}
.workspace-hero::before {
    background: linear-gradient(0deg, transparent 16%, #ad7138 18%, #e1b86d 22%,
                                #ffedbf 25%, #f6dca1 28%, #b97b41 34%, transparent 41%);
}
.workspace-hero::after {
    right: -64px;
    bottom: -58px;
    border-top: 1px solid #ffe7b0;
}
.workspace .workspace-hero strong { color: #fffbf5; }
.workspace .workspace-search,
.workspace .workspace-filters,
.workspace .workspace-panel {
    border-color: #ead7bb;
    background: linear-gradient(150deg, #fff, #fff6f8);
}
.workspace button.workspace-kpi,
.workspace button.workspace-result {
    border-color: #ead7bb;
    background: linear-gradient(150deg, #fff, #fff5f8);
}
.workspace .workspace-nav {
    border-top-color: #eecb83;
    background: linear-gradient(164deg, #8f2050, #631234 74%);
    box-shadow: 0 -3px 19px #620a3a38, inset 0 1px 0 #ffe4b75e;
}
.workspace .workspace-nav button {
    color: #fff0f7;
    background: transparent;
    border-color: transparent;
}
.workspace .workspace-nav svg { color: #f6cf89; }
.workspace .workspace-nav button[aria-pressed=true] {
    color: #481728;
    border-color: #ffe9bb;
    background: linear-gradient(143deg, #fff2ca, #e2b86f 75%, #f4d99c);
    box-shadow: inset 0 1px 0 #fff6d8, 0 2px 8px #1c051a41;
}
.workspace .workspace-nav button[aria-pressed=true] svg { color: #681843; }
.workspace .workspace-actions {
    background: linear-gradient(135deg, #fff, #fff2f7);
}
.workspace .workspace-actions button {
    color: #8b1845;
    border-color: #e5c89b;
    background: linear-gradient(135deg, #fff3f6, #fce3ee);
}

.bulk-setup { color: #182033; padding-bottom: 12px; }
.bulk-setup h2 { color: #861347; }
.bulk-setup [hidden] { display: none !important; }
.bulk-setup button, .bulk-entry { min-height: 44px; border-radius: 10px; }
.bulk-entry { margin: 12px 0; }
.bulk-entry small { font-size: .84rem; }
.bulk-card { background: #fff; border: 1px solid #eed6e1; border-radius: 16px; margin-block: 12px; padding: 14px; min-width: 0; }
.bulk-group-heading { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; overflow-wrap: anywhere; }
.bulk-setup .bulk-group-heading input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: #087f5b; }
.bulk-line-name { margin: 2px 0 12px; color: #52576a; overflow-wrap: anywhere; }
.bulk-fields { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.bulk-field, .bulk-time-field { border: 1px solid; border-radius: 12px; padding: 8px; display: grid; align-content: start; gap: 5px; min-width: 0; margin: 0; }
.bulk-fields [data-state="ready"] { border-color: #88bca8; background: #effaf4; }
.bulk-fields [data-state="missing"] { border-color: #dba971; background: #fff5e7; }
.bulk-field input, .bulk-field select, .bulk-time input { width: 100%; min-width: 0; min-height: 44px; font-size: 16px; box-sizing: border-box; }
.bulk-time-field { grid-column: 1 / -1; }
.bulk-time-slots { display: flex; flex-wrap: wrap; gap: 8px; }
.bulk-time { display: flex; align-items: center; gap: 5px; }
.bulk-time input { width: 90px; font-variant-numeric: tabular-nums; }
.bulk-time button { min-width: 44px; white-space: nowrap; }
.bulk-times button, .bulk-actions button, .bulk-common > button { margin: 3px 0; }
.bulk-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bulk-common summary { cursor: pointer; padding-block: 8px; font-weight: 700; }
.bulk-setup .bulk-save { width: 100%; background: #c2185b; color: #fff; font-weight: 700; }
.bulk-setup .bulk-save:disabled { opacity: .55; }
.bulk-card small { display: block; margin-top: 7px; }
.bulk-error { color: #9f1725; margin-bottom: 0; }
.bulk-error:empty { display: none; }
@media (max-width: 360px) { .bulk-fields { grid-template-columns: minmax(0,1fr); } }
.shop-save-feedback{position:fixed;z-index:12;top:calc(env(safe-area-inset-top,0px) + 8px);right:max(12px,calc((100vw - 620px)/2));max-width:min(480px,calc(100vw - 24px));padding:10px 14px;border:1px solid #E5AFCB;border-radius:12px;background:#fff3f7;color:#831843;font-size:.9rem;box-shadow:0 4px 16px #83184321;pointer-events:none}
.shop-save-feedback[data-tone=success]{background:#ecfdf5;color:#087f5b;border-color:#86efac}
.shop-save-feedback[data-tone=error]{background:#fff1f2;color:#991b1b;border-color:#fca5a5}
.web-customer-photo{display:grid;gap:8px;padding:12px;border-radius:12px;background:#eff5fd;color:#176aa6}
.web-customer-photo img{max-height:180px;object-fit:contain;width:100%}
.web-customer-photo p{margin:0;font-size:.85rem}
.web-customer-save-success{padding:14px;border-radius:12px;background:#ecfdf5;color:#087f5b}
