/* Shopwise web UI — builds on the report design system (render/static/report.css):
   same tokens, type and .sheet. Mobile first: one column, large touch targets. */

body {
    padding: 0 0 72px
}

.sheet.app {
    margin-top: 12px
}

.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0)
}

/* ---- top bar ---- */
.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    max-width: 860px;
    margin: 0 auto;
    padding: 12px 16px 0
}

.brand {
    font-weight: 900;
    letter-spacing: .08em;
    color: var(--brand);
    text-decoration: none
}

.local-badge {
    font-size: 11px;
    color: var(--ink-2);
    flex: 1 1 200px
}

/* "How to use" (A67): next to the Language select, on every app page */
.helplink {
    font-size: 13px;
    color: var(--brand);
    white-space: nowrap
}

/* account / admin / log out (A92) */
.usernav {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px
}

.usernav a,
.usernav .linkbtn {
    color: var(--brand);
    white-space: nowrap
}

.usernav form {
    display: inline;
    margin: 0
}

.linkbtn {
    font: inherit;
    border: 0;
    background: none;
    padding: 0;
    text-decoration: underline;
    cursor: pointer
}

/* login and account pages (A92) */
.kv {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 16px;
    margin: 12px 0 24px
}

.kv dt {
    color: var(--ink-2)
}

.kv dd {
    margin: 0;
    overflow-wrap: anywhere
}

.auth-box {
    max-width: 520px
}

.auth-box .actions {
    margin-top: 20px
}

.admin-figures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 16px 0;
    padding: 0;
    list-style: none
}

.admin-figures li {
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--paper)
}

.admin-figures .k {
    display: block;
    font-size: 13px;
    color: var(--ink-2)
}

.admin-figures .v {
    display: block;
    font-size: 24px;
    font-weight: 700;
    margin-top: 4px
}

.help-first {
    margin-top: 6px
}

.help-first a {
    color: var(--brand);
    font-weight: 700
}

.langsw {
    display: flex;
    align-items: center
}

.langsw .lang-select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 4px 0 10px;
    min-height: 36px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: var(--paper);
    color: var(--ink-2)
}

.langsw .globe {
    flex: none
}

.langsw select {
    font: inherit;
    font-size: 13px;
    border: 0;
    background: transparent;
    color: var(--ink);
    padding: 6px 4px;
    min-height: 34px;
    cursor: pointer
}

.langsw button {
    font: inherit;
    font-size: 13px;
    margin-left: 4px
}

/* ---- text bits ---- */
.crumbs {
    font-size: 13px;
    color: var(--ink-2);
    margin: 0 0 6px
}

.crumbs a,
.store-card,
.report-list a {
    color: var(--brand)
}

/* every text link in the app uses the design system's link colour (no browser blue) */
.app a:not(.btn) {
    color: var(--brand)
}

.meta-line,
.hint {
    font-size: 13px;
    color: var(--ink-2)
}

.hint {
    display: block;
    margin: 4px 0 0
}

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--warn-bg);
    color: var(--warn);
    vertical-align: 3px
}

.flash {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px
}

.flash.ok,
p.ok {
    background: var(--pos-bg);
    color: var(--pos)
}

p.ok {
    padding: 8px 12px;
    border-radius: 8px
}

.flash.err {
    background: var(--alert-bg);
    color: var(--alert)
}

/* read-only notice (A102): what happened, in plain words; not an error */
.flash.notice {
    background: var(--warn-bg);
    color: var(--ink)
}

.flash.notice a {
    color: inherit
}

.trial-line {
    margin: 0 0 8px
}

.err {
    display: block;
    color: var(--alert);
    font-size: 13px;
    margin-top: 3px
}

.warn {
    color: var(--warn);
    font-size: 13px
}

/* ---- buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 16px;
    border: 1px solid var(--rule);
    border-radius: 10px;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer
}

.btn.primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff
}

.btn.link {
    border-color: transparent;
    background: none;
    color: var(--brand);
    font-weight: 500
}

.btn[disabled] {
    opacity: .45;
    cursor: not-allowed
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 18px 0
}


form.inline {
    display: inline
}

/* ---- store list ---- */
.store-list,
.report-list,
.sources,
.issues {
    list-style: none;
    padding: 0;
    margin: 0
}

.store-card {
    display: grid;
    gap: 2px;
    padding: 14px 16px;
    margin: 0 0 10px;
    border: 1px solid var(--rule);
    border-radius: 12px;
    text-decoration: none
}

.store-card .name {
    font-weight: 700;
    color: var(--ink);
    font-size: 17px
}

.store-card .meta,
.report-list .meta {
    font-size: 13px;
    color: var(--ink-2)
}

.report-list li {
    display: grid;
    gap: 2px;
    padding: 10px 0;
    border-bottom: 1px solid var(--rule-2)
}

/* ---- forms ---- */
.form fieldset,
.month-card,
.field-card {
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 12px 14px 14px;
    margin: 0 0 14px;
    min-width: 0
}

legend {
    font-weight: 700;
    padding: 0 6px
}

.form label,
.month-card label {
    display: block;
    margin: 10px 0 0;
    font-size: 14px;
    color: var(--ink-2)
}

/* sales by time of day in a month card (A88): one heading, one note, then the slots */
.month-card .slot-group {
    margin-top: 14px;
    padding-top: 8px;
    border-top: 1px dashed var(--rule)
}

.month-card .group-h {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-2)
}

/* a field's note sits between its label and its input (A88) */
.month-card .field-note {
    display: block;
    margin: 2px 0 0;
    font-size: 12.5px;
    line-height: 1.5
}

input:not([type=checkbox]):not([type=radio]):not([type=file]),
select {
    display: block;
    width: 100%;
    min-height: 44px;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid #cfd6d4;
    border-radius: 8px;
    font: inherit;
    font-size: 16px;
    /* ≥16px: no zoom on iOS focus */
    color: var(--ink);
    background: var(--paper)
}

input[aria-invalid=true] {
    border-color: var(--alert);
    background: var(--alert-bg)
}

input[type=file] {
    display: block;
    margin: 6px 0 10px;
    font-size: 14px;
    max-width: 100%
}

label.check {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    color: var(--ink);
    font-size: 15px
}

label.check input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex: none
}

label.check.sub {
    padding-left: 28px
}

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

.preview {
    margin: 4px 0 8px
}

.chips {
    list-style: none;
    padding: 0;
    margin: 6px 0 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px
}

.chips li {
    font-size: 13px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--pos-bg);
    color: var(--pos)
}

.chips.off li {
    background: var(--rule-2);
    color: var(--ink-3)
}

.paths {
    display: grid;
    gap: 14px;
    grid-template-columns: 1fr;
    margin-top: 10px
}

.path {
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 12px 14px
}

.path h3 {
    margin: 0 0 4px;
    font-size: 15px
}

.inline-form {
    display: grid;
    gap: 0 12px;
    align-items: end
}

/* ---- entry: one card per month; all months = a picker on phones, a grid on desktop ---- */
.month-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 14px
}

.month-picker .hint {
    flex: 1 0 100%;
    margin: 0
}

/* any other month (A95): a month picker next to the chips */
.other-month {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    margin: -4px 0 16px;
    font-size: 13px
}

.other-month label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--ink-2)
}

.other-month input {
    font: inherit;
    font-size: 15px;
    min-height: 40px;
    padding: 4px 8px;
    border: 1px solid var(--rule);
    border-radius: 8px;
    background: var(--paper);
    color: var(--ink)
}

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 4px 12px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    color: var(--brand);
    text-decoration: none
}

.chip.new {
    border-color: var(--brand);
    font-weight: 700
}

.entry.grid-mode {
    display: none  /* phones: pick a month instead of a 15 × 7 column */
}

label.del {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    margin-top: 4px;
    font-size: 12px;
    color: var(--ink-2)
}

label.del input {
    width: 16px;
    height: 16px
}

.month-card .msgs:empty {
    display: none
}

.month-card .msgs {
    margin-top: 8px
}

.month-card .msgs p {
    margin: 4px 0
}

/* ---- import review ---- */
.field-card.low {
    border-color: var(--warn);
    background: linear-gradient(var(--warn-bg), var(--warn-bg)) top / 100% 4px no-repeat
}

/* inline pill next to the field name (not the report's .conf panel) */
.field-card .conf-pill {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    background: #eef3f1;
    font-weight: 500;
    font-size: 12px;
    line-height: 1.6;
    color: var(--ink-2);
    white-space: nowrap;
    vertical-align: middle;
    cursor: help
}

/* reading certainty (A76): the word carries the meaning, the colour only supports it */
.field-card .conf-pill.high {
    color: var(--pos)
}

.field-card .conf-pill.medium,
.field-card .conf-pill.low {
    background: var(--warn-bg);
    color: #8a5a00
}

/* the short explanation under "leave unconfirmed" / "exclude" (A76) */
.choice-note {
    display: block;
    margin-left: 1.6em;
    font-size: 12.5px
}

.flag {
    font-size: 12px;
    color: var(--warn);
    font-weight: 700
}

.sources li {
    font-size: 14px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--rule-2)
}

.monthly {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0
}

.monthly span {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    padding: 2px 8px;
    background: var(--rule-2);
    border-radius: 6px
}

.monthly small {
    color: var(--ink-3);
    margin-right: 4px
}

/* optional extended data in store settings (A87) */
.extra-data {
    border-top: 1px dashed var(--rule);
    margin-top: 10px;
    padding-top: 10px
}

.extra-data .sub-h {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-2)
}

.extra-data .hint {
    padding-left: 28px
}

/* time slots (A88): asked only while sales by time of day is ticked */
.extra-data:has(input[name="tod"]:not(:checked)) .slots:not(.items-list),
.extra-data:has(input[name="products"]:not(:checked)) .items-list {
    display: none
}

.item-row label {
    margin-top: 6px
}

/* time slots (A88): name, from, to — one row each; stacked name over times on phones */
.extra-data .slots {
    margin: 6px 0 10px 28px;
    padding: 8px 12px 10px;
    border: 1px solid var(--rule);
    border-radius: 10px
}

.extra-data .slots .hint {
    padding-left: 0
}

.slot-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 0 10px;
    align-items: start
}

.slot-row label {
    margin-top: 6px
}

@media (max-width: 520px) {
    .extra-data .slots {
        margin-left: 0
    }

    .slot-row {
        grid-template-columns: 1fr 1fr;
        padding-bottom: 6px;
        border-bottom: 1px dashed var(--rule-2)
    }

    .slot-row .slot-name {
        grid-column: 1 / -1
    }
}

/* a total among a field's lines (A85): the owner's question, inside the field card */
.split-q {
    display: grid;
    gap: 8px;
    margin: 10px 0;
    padding: 10px 12px;
    border-left: 3px solid var(--warn);
    background: var(--warn-bg);
    border-radius: 6px
}

.split-q p {
    margin: 0
}

.choices {
    display: grid;
    gap: 6px;
    margin-top: 6px
}

.choices label {
    font-size: 14px;
    color: var(--ink);
    margin: 0
}

/* ---- review / history tables ---- */
.changes {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px
}

.changes th,
.changes td {
    text-align: left;
    padding: 6px 4px;
    border-bottom: 1px solid var(--rule-2)
}

.changes td.num {
    text-align: right;
    font-variant-numeric: tabular-nums
}

.changes small {
    color: var(--ink-3)
}

.changes tr.cleared td {
    color: var(--alert)
}

.issues li {
    padding: 6px 0;
    font-size: 14px
}

.issues li.err {
    display: list-item
}

@media (min-width: 720px) {
    .row {
        grid-template-columns: 1fr 1fr
    }

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

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


/* Desktop: all months as one table — headers and inputs share the same columns. */
@media (min-width: 900px) {
    .sheet.app {
        max-width: 1180px
    }

    .entry.grid-mode {
        display: block
    }

    .month-picker .hint {
        display: none
    }

    .grid-wrap {
        overflow-x: auto
    }

    .entry-grid {
        border-collapse: collapse;
        font-size: 13px
    }

    .entry-grid th {
        text-align: left;
        font-weight: 500;
        color: var(--ink-2);
        padding: 4px 6px;
        vertical-align: bottom
    }

    .entry-grid thead th {
        position: sticky;
        top: 0;
        background: var(--paper);
        border-bottom: 1px solid var(--rule)
    }

    .entry-grid tbody th {
        font-weight: 700;
        color: var(--ink);
        white-space: nowrap;
        vertical-align: top;
        padding-top: 14px
    }

    .entry-grid td {
        padding: 4px 3px;
        vertical-align: top;
        border-bottom: 1px solid var(--rule-2)
    }

    .entry-grid input:not([type=checkbox]) {
        width: 12ch;  /* "2,410,000" and 9+ digits with separators */
        min-width: 12ch;
        margin: 0;
        text-align: right;
        font-variant-numeric: tabular-nums;
        font-size: 15px;
        padding: 6px 8px
    }
}

/* ---- review: data-safety blocks ---- */
.gap-box,
.overwrite-box {
    border: 2px solid var(--warn);
    background: var(--warn-bg);
    border-radius: 12px;
    padding: 12px 14px;
    margin: 14px 0
}

.overwrite-box h2 {
    margin-top: 0
}

.confirm-form {
    display: grid;
    gap: 10px;
    justify-items: start
}

label.ack {
    font-weight: 700
}

/* ---- change history: one card per save event ---- */
.events {
    list-style: none;
    padding: 0;
    margin: 0
}

.event {
    border: 1px solid var(--rule);
    border-radius: 12px;
    margin: 0 0 10px
}

.event summary {
    display: grid;
    gap: 2px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none
}

.event summary::-webkit-details-marker {
    display: none
}

.event summary::after {
    content: "▾";
    justify-self: end;
    margin-top: -22px;
    color: var(--ink-3)
}

.event details[open] summary::after {
    content: "▴"
}

.event .when {
    font-size: 12px;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums
}

.event .what {
    font-weight: 700
}

.event .meta {
    font-size: 13px;
    color: var(--ink-2)
}

.event-changes {
    list-style: none;
    margin: 0;
    padding: 0 14px 12px
}

.event-changes li {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0 10px;
    padding: 6px 0;
    border-top: 1px solid var(--rule-2);
    font-size: 13px
}

.event-changes .v {
    grid-column: 1 / -1;
    text-align: right
}

@media (min-width: 720px) {
    .event-changes li {
        grid-template-columns: 80px 1fr auto
    }

    .event-changes .v {
        grid-column: auto
    }
}

/* ---- file picker (string-pack text instead of the browser's native control) ---- */
.file-pick {
    display: grid;
    gap: 6px;
    justify-items: start;
    margin: 6px 0 10px
}

.file-label {
    font-size: 14px;
    color: var(--ink-2)
}

.sr-file {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden
}

.btn.file {
    position: relative
}

.btn.file:focus-within {
    outline: 2px solid var(--brand);
    outline-offset: 2px
}

.file-name {
    font-size: 13px;
    color: var(--ink-2);
    word-break: break-all
}

/* ---- setup: advanced settings ---- */
details.advanced {
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 10px 14px;
    margin: 0 0 14px
}

details.advanced summary {
    font-weight: 700;
    cursor: pointer;
    min-height: 32px
}

.with-unit {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 240px  /* the same width for the fixed share and the hourly wage */
}

.with-unit .unit {
    font-size: 15px;
    color: var(--ink-2)
}

.changes td:first-child,
.changes th {
    white-space: nowrap
}

.changes td small {
    display: block
}

.with-unit.wide {
    max-width: none
}

.with-unit input {
    flex: 1 1 auto;
    min-width: 0
}

.with-unit .unit {
    flex: none;
    white-space: nowrap
}

.entry-grid th small.unit {
    display: block;
    font-weight: 400;
    color: var(--ink-3)
}

/* ---- store settings (A47) ---- */
.bench-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 14px
}

@media (min-width: 760px) {
    .bench-grid { grid-template-columns: 1fr 1fr }
}

.form fieldset.bench-item {
    margin: 10px 0 0;
    padding: 8px 12px 12px
}

.bench-item .row { grid-template-columns: 1fr 1fr }

.bench-item .with-unit { max-width: 150px }

.bench-item .hint .tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--rule-2);
    white-space: nowrap
}

.effects-list { padding-left: 1.2em }

.effects-list li { margin: 4px 0 }

.effects-list .lost { color: var(--alert) }

.currency-q .rate { margin-left: 28px }

.settings-history { margin-top: 28px }

.settings-changes td { word-break: normal; overflow-wrap: anywhere }

.rate-box { margin: 6px 0 0 28px }

.rate-box .rate-h { margin: 8px 0 0; font-size: 14px; font-weight: 700 }

.rate-box .rate { margin-left: 0 }

.rate-box input[name=rate] { max-width: 200px }

.rate-list { list-style: none; padding: 0; margin: 4px 0 0 }

.rate-list li { display: flex; flex-wrap: wrap; gap: 0 10px; padding: 3px 0; border-bottom: 1px solid var(--rule-2) }

.rate-list .f { color: var(--ink-2); min-width: 9em }

.bench-count {
    margin-left: 6px;
    font-size: 12.5px;
    font-weight: 400;
    color: var(--brand)
}

/* ---- deleting (A78) ---- */
section.danger {
    margin-top: 40px;
    padding: 18px 20px;
    border: 1px solid var(--alert);
    border-radius: 12px
}

section.danger h2 {
    color: var(--alert)
}

.btn.danger {
    background: var(--alert);
    border-color: var(--alert);
    color: #fff
}

.btn.danger:disabled {
    opacity: .45;
    cursor: not-allowed
}

.delete-list {
    margin: 8px 0 14px;
    padding-left: 1.3em;
    line-height: 1.9
}

.btn.link.month-del {
    padding: 0;
    min-height: 0;
    font-size: 12px;
    color: var(--alert)
}

.report-list .report-del {
    margin-left: 10px;
    font-size: 13px;
    color: var(--alert)
}

/* the "other" fill button (A90): wraps between phrases, never one character on a line */
.other-fill {
    text-wrap: balance;
    word-break: auto-phrase;
}

/* waiting for a report (A93) */
.job-wait .spinner {
    width: 28px;
    height: 28px;
    margin: 8px 0 12px;
    border: 3px solid var(--rule);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: job-spin 1s linear infinite
}

.job-wait .job-month {
    font-weight: 700;
    margin: 0 0 6px
}

@keyframes job-spin {
    to {
        transform: rotate(360deg)
    }
}

@media (prefers-reduced-motion: reduce) {
    .job-wait .spinner {
        animation: none
    }
}

/* Japanese headings break between phrases, never inside a word (A95): auto-phrase where
   the browser has it (Chrome); elsewhere only at marked phrase boundaries (<wbr>), and a
   very long word (a store name) still wraps rather than overflow */
:lang(ja) h1,
:lang(ja) h2,
:lang(ja) h3 {
    word-break: keep-all;
    word-break: auto-phrase;
    overflow-wrap: anywhere;
    text-wrap: balance
}

/* sentences: phrase breaks where available (Chrome), otherwise the browser's normal ones */
:lang(ja) .auth-box p,
:lang(ja) .flash {
    word-break: auto-phrase;
    text-wrap: pretty
}

/* the app footer: the Terms, the Privacy Policy and the legal disclosure (A99, A110) */
.app-foot {
    max-width: 1080px;
    margin: 0 auto;
    padding: 16px 16px 0;
    font-size: 13px;
    color: var(--ink-2);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px
}

.app-foot a {
    color: inherit
}
