:root {
  color-scheme: light;
  --ink: #1a1a1c;
  --ink-soft: #626264;
  --ink-muted: #757578;
  --primary: #1a69b2;
  --page: #f3f5f7;
  --surface: #fff;
  --line: #d9d9dc;
  --line-soft: #e8e8eb;
  --danger: #d50000;
  --focus: #ffd43b;
  --shadow-card: 0 2px 8px rgb(0 0 0 / 6%);
  --shadow-raised: 0 8px 24px rgb(0 0 0 / 10%);
  font-family: Inter, -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); -webkit-text-size-adjust: 100%; }
body { min-width: 320px; margin: 0; overflow-x: hidden; background: var(--page); color: var(--ink); font-size: 16px; line-height: 1.6; }
button, input, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.app-shell { width: 100%; max-width: 760px; min-height: 100dvh; margin: 0 auto; background: var(--page); }

.app-header { position: sticky; z-index: 20; top: 0; padding: calc(18px + env(safe-area-inset-top)) 16px 14px; background: var(--page); }
.header-main { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
h1 { margin: 0; color: var(--ink); font-size: 1.75rem; font-weight: 800; line-height: 1.25; letter-spacing: 0.015em; }
.updated { display: flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.updated-dot { width: 8px; height: 8px; border-radius: 50%; background: #197b50; box-shadow: 0 0 0 3px #e5f4ed; }

.search-wrap { position: relative; margin-top: 18px; }
#shipment-search { width: 100%; height: 48px; padding: 0 42px 0 14px; border: 1px solid #949497; border-radius: 6px; outline: none; background: var(--surface); color: var(--ink); font-size: 1rem; transition: border-color 140ms ease, box-shadow 140ms ease; }
#shipment-search::placeholder { color: #737376; }
#shipment-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(26 105 178 / 18%); }
.clear-search { position: absolute; top: 50%; right: 8px; width: 32px; height: 32px; padding: 0; transform: translateY(-50%); border: 0; border-radius: 6px; background: transparent; color: #555558; font-size: 1.4rem; line-height: 1; cursor: pointer; }

.owner-filters { display: flex; gap: 5px; margin: 14px -16px -2px; padding: 2px 16px 4px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.owner-filters::-webkit-scrollbar { display: none; }
.owner-chip { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 5px; min-height: 34px; padding: 5px 9px; border: 1px solid #d7d9dc; border-radius: 6px; background: var(--surface); color: #333336; font-size: 0.8rem; font-weight: 700; white-space: nowrap; box-shadow: 0 1px 2px rgb(0 0 0 / 5%); cursor: pointer; }
.owner-chip:hover { background: #f0f0f2; }
.owner-chip.is-active { border-color: var(--primary); background: var(--primary); color: #fff; }
.owner-chip.is-active .owner-dot { background: currentcolor; }
.owner-chip:focus-visible, .shipment-card:focus-visible, .text-button:focus-visible, .detail-close:focus-visible, .detail-link:focus-visible, .clear-search:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.owner-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--owner-color); }
.owner-hashimoto { --owner-color: #c69342; }
.owner-ochi { --owner-color: #3f7ea6; }
.owner-kobayashi { --owner-color: #508164; }
.owner-kono { --owner-color: #d1782c; }
.owner-osaka { --owner-color: #ca574c; }

.content { padding: 20px 16px calc(48px + env(safe-area-inset-bottom)); }
.result-summary { display: flex; min-height: 30px; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; color: var(--ink-soft); }
.result-summary:has(#result-count[hidden]) { display: none; }
.result-summary p { margin: 0; font-size: 0.82rem; font-weight: 700; }
.text-button { padding: 3px 0; border: 0; background: transparent; color: var(--primary); font-size: 0.82rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.shipment-groups { display: grid; gap: 32px; }
.date-group { min-width: 0; }
.date-heading { display: flex; align-items: baseline; gap: 9px; margin: 0 0 12px; }
.date-label { margin: 0; color: var(--ink); font-size: 1.15rem; font-weight: 800; line-height: 1.4; }
.date-label.is-today { color: var(--primary); }
.date-full { color: var(--ink-soft); font-size: 0.84rem; font-weight: 600; }
.date-count { margin-left: auto; color: var(--ink-muted); font-size: 0.78rem; font-weight: 700; }
.card-list { display: grid; gap: 12px; }

.shipment-card { --owner-color: #757578; display: block; width: 100%; min-width: 0; padding: 12px 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-align: left; box-shadow: var(--shadow-card); cursor: pointer; transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease; }
.shipment-card:hover { border-color: #aaaab0; box-shadow: var(--shadow-raised); transform: translateY(-1px); }
.shipment-card:active { transform: translateY(0); }
.card-topline { display: flex; min-width: 0; align-items: center; gap: 9px; }
.ticket-no { flex: 0 1 auto; overflow: hidden; color: #4b4b4e; font-size: 0.76rem; font-weight: 700; letter-spacing: 0.035em; text-overflow: ellipsis; white-space: nowrap; }
.status-tag { flex: 0 0 auto; padding: 3px 8px; border-radius: 6px; font-size: 0.7rem; font-weight: 800; line-height: 1.4; }
.status-paper-hold { background: #f1e9e5; color: #794a35; }
.status-paper-order { background: #fce8e9; color: #a91d2d; }
.status-design { background: #f0eafa; color: #654096; }
.status-plate { background: #f9e9f1; color: #973765; }
.status-printing { background: #fff0c2; color: #765000; }
.status-processing { background: #ffead7; color: #8b4500; }
.status-shipping { background: #e1effb; color: #005b99; }
.status-stock { background: #e3f3ea; color: #166a42; }
.status-complete { background: #ececee; color: #545458; }
.status-outsourced { background: #eee; color: #3f3f42; }
.urgent-mark { display: grid; flex: 0 0 auto; width: 24px; height: 24px; margin-left: auto; place-items: center; border-radius: 50%; background: var(--danger); color: #fff; font-size: 0.82rem; font-weight: 900; line-height: 1; box-shadow: 0 0 0 3px #fce7e7; }

.card-titleline { display: grid; min-width: 0; gap: 2px; margin: 8px 0 10px; }
.product { min-width: 0; overflow: hidden; color: var(--ink); font-size: 1.05rem; font-weight: 800; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.customer { min-width: 0; overflow: hidden; color: var(--ink-soft); font-size: 0.84rem; font-weight: 600; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.9fr) minmax(0, 0.65fr); padding-top: 10px; border-top: 1px solid var(--line-soft); }
.meta-item { min-width: 0; padding: 0 12px; border-left: 1px solid var(--line-soft); }
.meta-item:first-child { padding-left: 0; border-left: 0; }
.meta-item:last-child { padding-right: 0; }
.meta-label { display: block; margin-bottom: 2px; color: var(--ink-muted); font-size: 0.67rem; font-weight: 700; }
.meta-value { display: block; overflow: hidden; color: #333336; font-size: 0.78rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.owner-value { display: inline-flex; align-items: center; gap: 6px; }

.empty-state { margin: 32px 0; padding: 36px 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: center; box-shadow: var(--shadow-card); }
.empty-state h2 { margin: 0; font-size: 1rem; }
.empty-state p { margin: 7px 0 0; color: var(--ink-soft); font-size: 0.86rem; }

.detail-layer { position: fixed; z-index: 50; inset: 0; display: grid; visibility: hidden; align-items: end; opacity: 0; transition: visibility 180ms ease, opacity 180ms ease; }
.detail-layer.is-open { visibility: visible; opacity: 1; }
.detail-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: rgb(0 0 0 / 52%); cursor: pointer; }
.detail-panel { position: relative; z-index: 1; width: 100%; max-height: 94dvh; padding: 18px 20px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; border-radius: 20px 20px 0 0; outline: none; background: #fff; box-shadow: 0 -12px 40px rgb(0 0 0 / 18%); backface-visibility: hidden; transform: translateY(18px); transition: transform 190ms ease; }
.detail-layer.is-open .detail-panel { transform: translateY(0); }
.detail-handle { width: 38px; height: 4px; margin: 0 auto 18px; border-radius: 999px; background: #d5d5d8; }
.detail-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-close { display: none; width: 32px; height: 32px; padding: 0; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--ink-soft); font-size: 1.35rem; line-height: 1; cursor: pointer; }
.detail-warning { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 5px; margin-left: auto; padding: 2px 3px 2px 7px; border: 1px solid #edb8b8; border-radius: 6px; background: #fff5f5; color: #a11919; font-size: 0.68rem; font-weight: 750; line-height: 1.4; }
.detail-warning-mark { display: grid; flex: 0 0 auto; width: 18px; height: 18px; place-items: center; border-radius: 50%; background: var(--danger); color: #fff; font-size: 0.68rem; font-weight: 900; line-height: 1; }
.detail-header { margin-top: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.detail-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 9px; }
.detail-date { color: var(--ink-soft); font-size: 0.83rem; font-weight: 750; }
.detail-customer { margin: 0 0 4px; color: var(--ink-soft); font-size: 0.95rem; font-weight: 650; }
.detail-header h2 { margin: 0; color: var(--ink); font-size: 1.35rem; line-height: 1.45; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; margin: 18px 0 20px; }
.detail-field { min-width: 0; }
.detail-field dt { margin-bottom: 1px; color: var(--ink-muted); font-size: 0.76rem; font-weight: 700; }
.detail-field dd { margin: 0; overflow-wrap: anywhere; color: #333336; font-size: 0.94rem; font-weight: 750; }
.detail-link { display: flex; width: 100%; min-height: 44px; align-items: center; justify-content: center; border: 1px solid var(--primary); border-radius: 6px; color: var(--primary); font-size: 0.92rem; font-weight: 800; text-decoration: none; }
.detail-note { margin: 6px 0 0; color: var(--ink-muted); font-size: 0.72rem; text-align: center; }

.noscript { margin: 20px; padding: 16px; border-radius: 8px; background: #fff; }
body.detail-open { overflow: hidden; }

@media (min-width: 640px) {
  .app-shell { margin: 24px auto; min-height: calc(100dvh - 48px); overflow: clip; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-raised); }
  .app-header { padding-right: 24px; padding-left: 24px; }
  .owner-filters { margin-right: -24px; margin-left: -24px; padding-right: 24px; padding-left: 24px; }
  .content { padding: 24px 24px 48px; }
  .detail-layer { place-items: center; padding: 28px; }
  .detail-panel { max-width: 520px; max-height: min(760px, 90dvh); border-radius: 16px; }
  .detail-close { display: grid; }
}

@media (max-width: 359px) {
  .card-meta { grid-template-columns: 1fr 1fr; gap: 12px 0; }
  .meta-item:last-child { grid-column: 1 / -1; padding-left: 0; border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
