:root {
  --blue: #1a73e8;
  --blue-dark: #1557b0;
  --blue-soft: #e8f0fe;
  --red: #ea4335;
  --red-soft: #fce8e6;
  --yellow: #f9ab00;
  --yellow-soft: #fef7e0;
  --green: #188038;
  --green-soft: #e6f4ea;
  --ink: #202124;
  --muted: #5f6368;
  --line: #dadce0;
  --line-soft: #eef0f2;
  --canvas: #f8fafd;
  --surface: #ffffff;
  --danger: #b3261e;
  --shadow-sm: 0 1px 2px rgba(60,64,67,.08), 0 1px 3px 1px rgba(60,64,67,.06);
  --shadow-md: 0 8px 24px rgba(60,64,67,.12);
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
[hidden] { display: none !important; }
.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; }
.eyebrow { margin: 0 0 5px; color: var(--blue); font-size: .72rem; font-weight: 800; letter-spacing: .15em; }
.quiet { margin: 0; color: var(--muted); font-size: .88rem; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 14% 18%, rgba(66,133,244,.10), transparent 24%),
    radial-gradient(circle at 86% 14%, rgba(234,67,53,.08), transparent 22%),
    radial-gradient(circle at 80% 88%, rgba(52,168,83,.08), transparent 24%),
    var(--canvas);
}
.login-card { width: min(100%, 440px); padding: 46px; border: 1px solid var(--line); border-radius: 24px; background: white; box-shadow: var(--shadow-md); }
.login-card h1 { margin: 0; font-size: clamp(1.65rem, 6vw, 2.1rem); font-weight: 700; letter-spacing: -.035em; }
.login-copy { margin: 10px 0 30px; color: var(--muted); }
.login-card label, dialog label { display: grid; gap: 8px; margin-bottom: 18px; color: #3c4043; font-size: .9rem; font-weight: 700; }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; outline: none; transition: border-color .16s ease, box-shadow .16s ease; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,115,232,.14); }
.brand-mark { width: 48px; height: 48px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 24px; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: var(--shadow-sm); }
.brand-mark span { display: block; border-radius: 5px; background: #4285f4; }
.brand-mark span:nth-child(2) { background: var(--red); }
.brand-mark span:nth-child(3) { background: #fbbc04; }
.brand-mark span:nth-child(4) { background: #34a853; }
.brand-mark.small { width: 40px; height: 40px; margin: 0; padding: 5px; border-radius: 12px; }

.primary-button, .ghost-button, .text-button, .icon-button, .save-record { min-height: 42px; border-radius: 21px; border: 0; font-weight: 750; transition: background .16s ease, box-shadow .16s ease, transform .16s ease; }
.primary-button { padding: 0 24px; color: white; background: var(--blue); box-shadow: 0 1px 2px rgba(26,115,232,.3); }
.primary-button:hover { background: var(--blue-dark); box-shadow: 0 2px 6px rgba(26,115,232,.28); }
.full { width: 100%; margin-top: 4px; }
.ghost-button { padding: 0 16px; color: var(--blue); background: white; border: 1px solid var(--line); }
.ghost-button:hover { background: #f7fafe; border-color: #c6d7f2; }
.text-button { min-height: 36px; padding: 0; color: var(--blue); background: transparent; }
.icon-button { min-width: 48px; padding: 0 12px; color: var(--blue); background: var(--blue-soft); }
.form-error { min-height: 20px; margin: -8px 0 8px; color: var(--danger); font-size: .86rem; }

.app-header { min-height: 76px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; padding: 12px max(20px, calc((100vw - 1280px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup h1 { margin: 0; font-size: 1.04rem; font-weight: 700; letter-spacing: -.01em; }
.brand-lockup .eyebrow { font-size: .6rem; }
.tabs { display: flex; gap: 2px; padding: 4px; border-radius: 24px; background: #f1f3f4; }
.tab, .segment { border: 0; border-radius: 20px; color: var(--muted); background: transparent; font-weight: 750; }
.tab { min-height: 38px; padding: 0 20px; }
.tab.is-active { color: #174ea6; background: var(--blue-soft); }
.segment.is-active { color: #174ea6; background: white; box-shadow: var(--shadow-sm); }
.app-header > .ghost-button { justify-self: end; }

main { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0 64px; }
.connection-notice { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 28px; padding: 12px 16px; border: 1px solid #c6dafc; border-radius: 14px; background: #f4f8ff; color: #174ea6; font-size: .85rem; }
.connection-notice div { display: flex; gap: 9px; flex-wrap: wrap; }
.connection-notice a { color: var(--blue); font-weight: 800; white-space: nowrap; }
.connection-notice .connection-actions { flex-wrap: nowrap; align-items: center; }
.connection-notice .connection-actions .ghost-button { min-height: 34px; padding: 0 12px; font-size: .78rem; }
.view { display: none; }
.view.is-active { display: block; animation: reveal .24s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } }
.page-heading { min-height: 68px; display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 24px; }
.page-heading h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.15rem); font-weight: 700; letter-spacing: -.04em; }
.heading-actions { display: flex; gap: 8px; }
.dashboard-heading-actions { display: grid; justify-items: end; gap: 8px; }
.trend-switch { display: inline-flex; gap: 3px; padding: 4px; border-radius: 22px; background: #f1f3f4; }
.trend-tab { min-height: 36px; padding: 0 15px; border: 0; border-radius: 18px; color: var(--muted); background: transparent; font-size: .82rem; font-weight: 750; }
.trend-tab.is-active { color: #174ea6; background: white; box-shadow: var(--shadow-sm); }

.search-panel { position: relative; max-width: 900px; margin: 0 auto 30px; padding: 24px; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: white; box-shadow: var(--shadow-md); }
.search-panel::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, #4285f4 0 25%, #ea4335 25% 50%, #fbbc04 50% 75%, #34a853 75%); }
.segmented { display: inline-flex; gap: 3px; margin-bottom: 16px; padding: 4px; border-radius: 22px; background: #f1f3f4; }
.segment { min-height: 36px; padding: 0 17px; }
.search-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.search-form input { min-height: 58px; padding: 0 22px; border-radius: 29px; font-size: 1.05rem; box-shadow: 0 1px 4px rgba(60,64,67,.15); }
.search-form .primary-button { min-height: 58px; border-radius: 29px; }
.search-hint { margin: 11px 18px 0; color: var(--muted); font-size: .82rem; }
.bulk-search { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.bulk-search summary { width: fit-content; color: var(--blue); font-size: .9rem; font-weight: 750; cursor: pointer; }
.bulk-search summary span { margin-left: 7px; padding: 3px 8px; border-radius: 12px; color: #174ea6; background: var(--blue-soft); font-size: .72rem; }
.bulk-search form { margin-top: 18px; }
.bulk-search label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.bulk-search textarea { display: block; min-height: 110px; padding: 14px 16px; resize: vertical; line-height: 1.55; }
.bulk-search-footer { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 10px; }
.bulk-search-footer .search-hint { margin: 0 auto 0 0; }
.bulk-search-footer span { flex: none; color: var(--muted); font-size: .82rem; font-weight: 700; }
.bulk-search-error { color: var(--danger); }
.bulk-search-error { margin: 10px 0 0; font-size: .84rem; }
.bulk-results-summary { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: baseline; padding: 13px 18px; border: 1px solid #c6dafc; border-radius: 12px; color: #174ea6; background: #eef4ff; font-size: .88rem; }
.bulk-results-summary span { color: var(--muted); overflow-wrap: anywhere; }
.bulk-load-more { justify-self: center; min-width: 260px; }
.empty-state { min-height: 300px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 10px 0 3px; color: var(--ink); font-size: 1.1rem; }
.empty-state p { margin: 0; }
.empty-symbol { width: 54px; height: 54px; display: grid; place-items: center; margin: auto; border-radius: 50%; color: var(--blue); background: var(--blue-soft); font-size: 1.9rem; }

.results { display: grid; gap: 16px; }
.member-card { display: grid; grid-template-columns: 190px minmax(270px, 1fr) minmax(340px, .9fr); align-items: stretch; overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: var(--shadow-sm); }
.member-primary, .member-meta { padding: 26px; }
.member-primary { border-right: 1px solid var(--line-soft); background: linear-gradient(145deg, #fff, #f7faff); }
.member-number { margin: 8px 0 0; color: #174ea6; font-size: 1.52rem; font-weight: 800; letter-spacing: .02em; }
.card-quick-open { margin-top: 16px; }
.meta-grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; margin: 0; }
.meta-grid dt { color: var(--muted); font-size: .82rem; }
.meta-grid dd { margin: 0; font-weight: 700; }
.district-badge, .status-badge { display: inline-flex; padding: 5px 10px; border-radius: 99px; font-size: .84rem; font-weight: 700; }
.district-badge { color: #137333; background: var(--green-soft); }
.status-badge { color: #b06000; background: var(--yellow-soft); }
.record-controls { display: grid; grid-template-columns: 1fr 1fr; border-left: 1px solid var(--line-soft); background: #f8fafd; }
.quick-control { min-width: 0; display: flex; flex-direction: column; padding: 22px 18px; }
.quick-control + .quick-control { border-left: 1px solid var(--line); }
.quick-control label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .78rem; font-weight: 750; }
.quick-control select { min-height: 46px; font-size: .86rem; font-weight: 700; }
.save-record { width: 100%; margin-top: 9px; padding: 0 12px; color: var(--blue); background: white; border: 1px solid #a8c7fa; font-size: .82rem; }
.save-record:hover { background: var(--blue-soft); }
.shelf-tag { display: inline-flex; align-items: center; gap: 7px; margin-top: 10px; color: var(--muted); font-size: .75rem; }
.shelf-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { position: relative; min-height: 132px; overflow: hidden; padding: 21px; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: var(--shadow-sm); }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--blue); }
.kpi:nth-child(2)::before { background: var(--red); }
.kpi:nth-child(3)::before { background: var(--green); }
.kpi strong { display: block; margin: 18px 0 6px; font-size: 2rem; line-height: 1; font-weight: 750; }
.kpi span { color: var(--muted); font-size: .84rem; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.data-card { padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: var(--shadow-sm); }
.chart-card-wide { min-height: 360px; }
.card-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 20px; }
.card-heading h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.card-heading span { color: var(--muted); font-size: .78rem; text-align: right; }
.card-kicker { margin: 0 0 5px; font-size: .67rem; font-weight: 800; letter-spacing: .14em; }
.card-kicker.blue { color: var(--blue); }
.card-kicker.red { color: var(--red); }
.card-kicker.yellow { color: #b06000; }
.card-kicker.green { color: var(--green); }
.bar-list { display: grid; gap: 12px; }
.scroll-chart { max-height: 410px; overflow: auto; padding-right: 7px; scrollbar-width: thin; scrollbar-color: #bdc1c6 transparent; }
.chart-filter { display:grid; gap:5px; margin:-6px 0 16px; color:var(--muted); font-size:.73rem; font-weight:700; }
.chart-filter select { min-height:39px; padding:7px 11px; font-size:.84rem; }
.bar-row { display: grid; grid-template-columns: minmax(135px, .7fr) 2fr 46px; gap: 10px; align-items: center; font-size: .82rem; }
.bar-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bar-track { height: 9px; overflow: hidden; border-radius: 99px; background: #edf2fa; }
.bar-fill { height: 100%; min-width: 2px; border-radius: inherit; background: var(--blue); }
#addressChart .bar-fill { background: var(--red); }
#districtChart .bar-fill { background: var(--yellow); }
#shelfChart .bar-fill { background: var(--green); }
.bar-value { text-align: right; color: var(--ink); font-weight: 800; }
.trend-table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line-soft); border-radius: 12px; background: white; }
.trend-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; }
.trend-table th, .trend-table td { min-width: 64px; padding: 10px 9px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); text-align: center; white-space: nowrap; font-size: .78rem; }
.trend-table thead th { position: sticky; top: 0; z-index: 2; color: var(--muted); background: #f8fafd; font-weight: 750; }
.trend-table th:first-child { position: sticky; left: 0; z-index: 3; width: 150px; max-width: 180px; overflow: hidden; text-align: left; text-overflow: ellipsis; background: white; }
.trend-table thead th:first-child { z-index: 4; background: #f8fafd; }
.trend-table tr:last-child th, .trend-table tr:last-child td { border-bottom: 0; }
.trend-table th:last-child, .trend-table td:last-child { border-right: 0; }
.trend-table td { color: #174ea6; font-weight: 750; }
.trend-table td.is-zero { color: #bdc1c6; font-weight: 500; }
.trend-table td.trend-total { color: var(--ink); background: #f8fafd; }
.movement-card { margin-top: 18px; }
.movement-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line-soft); font-size: .85rem; }
.movement-row:first-child { border-top: 0; }
.movement-route { color: var(--ink); font-weight: 700; }
.movement-date { color: var(--muted); font-size: .78rem; }

.manage-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; align-items: start; }
.table-toolbar { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.table-toolbar input { max-width: 360px; min-height: 40px; }
.table-toolbar span { margin-left: auto; color: var(--muted); font-size: .8rem; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); text-align: left; font-size: .82rem; }
th { color: var(--muted); background: #f8fafd; font-weight: 750; }
tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 7px; justify-content: flex-end; }
.mini-button { min-height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 15px; color: var(--blue); background: white; font-size: .75rem; font-weight: 750; }
.mini-button.danger { color: var(--danger); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }
.pagination span { color: var(--muted); font-size: .8rem; }
.shelf-list { display: grid; gap: 8px; }
.shelf-group { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; }
.shelf-group summary { display: flex; justify-content: space-between; align-items: center; min-height: 44px; padding: 9px 12px; color: var(--ink); font-size: .85rem; font-weight: 800; cursor: pointer; }
.shelf-group summary small { color: var(--muted); font-size: .72rem; font-weight: 600; }
.shelf-group-items { display: grid; gap: 7px; padding: 0 8px 8px; }
.shelf-group:not([open]) .shelf-group-items { display: none; }
.shelf-item { display: flex; justify-content: space-between; align-items: center; min-height: 43px; padding: 8px 10px 8px 13px; border-radius: 10px; background: #f8fafd; font-size: .85rem; }
.shelf-item button { border: 0; color: var(--danger); background: transparent; font-size: .76rem; }

dialog { width: min(92vw, 480px); padding: 0; border: 0; border-radius: 22px; box-shadow: 0 24px 72px rgba(60,64,67,.3); }
dialog::backdrop { background: rgba(32,33,36,.48); backdrop-filter: blur(3px); }
dialog form { padding: 25px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.dialog-heading h3 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 25px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 12px 18px; border-radius: 8px; color: white; background: #323232; box-shadow: var(--shadow-md); transition: .2s ease; font-size: .88rem; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 1080px) {
  .member-card { grid-template-columns: 175px 1fr; }
  .record-controls { grid-column: 1 / -1; border-top: 1px solid var(--line); border-left: 0; }
}
@media (max-width: 900px) {
  .app-header { grid-template-columns: 1fr auto; }
  .tabs { order: 3; grid-column: 1 / -1; justify-content: center; }
  .app-header > .ghost-button { grid-column: 2; grid-row: 1; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .manage-grid { grid-template-columns: 1fr; }
  .shelves-card { order: -1; }
}
@media (max-width: 620px) {
  .login-card { padding: 34px 24px; }
  .app-header { padding: 12px 16px; gap: 12px; }
  .brand-lockup .eyebrow { display: none; }
  .brand-lockup h1 { font-size: .92rem; }
  .tabs { width: 100%; overflow-x: auto; justify-content: flex-start; }
  .tab { padding: 0 15px; flex: 1 0 auto; }
  main { width: min(100% - 28px, 1280px); padding-top: 18px; }
  .connection-notice, .page-heading { align-items: flex-start; flex-direction: column; }
  .dashboard-heading-actions { width: 100%; justify-items: start; }
  .trend-switch { width: 100%; overflow-x: auto; }
  .trend-tab { flex: 1 0 auto; }
  .connection-notice { gap: 9px; }
  .search-panel { padding: 20px 16px; }
  .search-form { grid-template-columns: 1fr; }
  .search-form .primary-button { min-height: 50px; }
  .bulk-search-footer { flex-wrap: wrap; }
  .bulk-search-footer .search-hint { width: 100%; }
  .member-card { grid-template-columns: 1fr; }
  .member-primary { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .record-controls { grid-column: auto; grid-template-columns: 1fr; }
  .quick-control + .quick-control { border-top: 1px solid var(--line); border-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi { min-height: 112px; padding: 17px; }
  .kpi strong { margin-top: 13px; font-size: 1.65rem; }
  .bar-row { grid-template-columns: minmax(100px, .8fr) 1fr 36px; }
  .movement-row { grid-template-columns: 1fr auto; }
  .movement-date { grid-column: 1 / -1; }
  .heading-actions { width: 100%; }
  .heading-actions button { flex: 1; }
}
