:root {
  --bg: #ffffff;
  --side: #f8f8fa;
  --side-active: #eeeeef;
  --ink: #222226;
  --sub: #8b8c92;
  --muted: #c6c7cc;
  --line: #ececef;
  --soft-line: #f4f4f5;
  --orange: #ff941f;
  --orange-soft: #fff5e9;
  --green: #42b755;
  --green-soft: #eef9f0;
  --red: #e74747;
  --red-soft: #fff0f0;
  --blue: #4f83d8;
  --blue-soft: #f5f9ff;
  --radius: 8px;
  --sidebar: 280px;
  --ease: cubic-bezier(.2,.8,.2,1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { border: 0; background: transparent; cursor: pointer; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

.loading {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.94);
  transition: opacity .22s var(--ease);
}
.loading.hidden { opacity: 0; pointer-events: none; }
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  animation: pulse .9s ease-in-out infinite alternate;
}
@keyframes pulse { from { transform: scale(.75); opacity: .45; } to { transform: scale(1); opacity: 1; } }

.auth-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
}
.auth-box {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
}
.auth-brand {
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
}
.auth-box h1 {
  margin: 18px 0 0;
  font-size: 30px;
  line-height: 1.25;
  font-weight: 900;
}
.auth-box p {
  margin: 0;
  color: var(--sub);
  font-weight: 750;
}
.auth-note {
  font-size: 13px;
}

.layout { min-height: 100dvh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: var(--side);
  border-right: 1px solid var(--line);
  padding: 40px 16px 28px;
  display: flex;
  flex-direction: column;
}
.brand {
  padding: 0 16px 34px;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}
.nav { display: grid; gap: 8px; }
.nav-button {
  width: 100%;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-radius: var(--radius);
  color: var(--sub);
  font-size: 18px;
  font-weight: 800;
  text-align: left;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.nav-button svg { width: 24px; height: 24px; stroke-width: 2.1; }
.help-mark {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}
.nav-button:hover { background: #f1f1f2; color: var(--ink); }
.nav-button.active { background: var(--side-active); color: var(--ink); }
.sidebar-foot {
  margin-top: auto;
  padding: 18px 18px 0;
  border-top: 1px solid var(--line);
  color: var(--sub);
  font-size: 14px;
  font-weight: 650;
  word-break: break-word;
}

.text-button {
  margin-top: 10px;
  padding: 0;
  color: var(--sub);
  font-size: 13px;
  font-weight: 850;
}
.text-button:hover { color: var(--ink); }

.mobile-top {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
}
.mobile-brand { font-size: 22px; font-weight: 900; }

.main {
  min-height: 100dvh;
  margin-left: var(--sidebar);
  padding: 48px 28px 80px;
}
.content {
  width: min(760px, 100%);
  margin: 0 auto;
}
.view { display: none; }
.view.active { display: block; animation: fade .2s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.page-title {
  margin: 0 0 28px;
  font-size: 29px;
  line-height: 1.2;
  font-weight: 900;
}
.section-label {
  margin: 0 0 30px;
  font-size: 17px;
  font-weight: 900;
}

.setup-notice {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #d7e4fb;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: #2f5f9f;
  font-weight: 800;
}
.setup-notice.warning {
  border-color: #ffe4bd;
  background: #fffaf2;
  color: #9a5b15;
}

.expiry-group { border-bottom: 1px solid var(--soft-line); }
.group-head {
  width: 100%;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0;
  text-align: left;
  font-size: 18px;
  font-weight: 900;
}
.group-head.orange { color: var(--orange); }
.group-head.green { color: var(--green); }
.group-head.gray { color: var(--sub); }
.group-count { margin-left: auto; color: var(--sub); font-weight: 800; }
.chevron {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: var(--sub);
  transition: transform .18s var(--ease);
}
.group-head[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.group-body { padding: 0 0 16px; }
.group-body[hidden] { display: none; }

.home-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 14px 0 14px 12px;
  border-left: 4px solid var(--orange);
}
.home-item.expired { border-left-color: var(--red); }
.home-item.soon { border-left-color: var(--green); }
.home-item.future { border-left-color: var(--muted); }
.home-item-name {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}
.mini-label {
  flex: 0 0 auto;
  color: var(--orange);
  font-size: 14px;
  font-weight: 900;
}
.home-item.expired .mini-label { color: var(--red); }
.home-item.soon .mini-label { color: var(--green); }
.product-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 900;
}
.item-meta {
  margin-top: 2px;
  color: var(--sub);
  font-size: 15px;
  font-weight: 650;
}
.item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.plain-empty {
  padding: 4px 0 16px;
  color: var(--sub);
  font-weight: 700;
}
.quiet-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 110px;
  margin-top: 72px;
  color: #c9c9ce;
  font-weight: 700;
}
.quiet-footer::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 18px rgba(79,131,216,.35);
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease), transform .08s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; border-color: #000; }
.btn-ghost { color: var(--sub); }
.btn-ghost:hover { background: #f8f8f8; color: var(--ink); }
.btn-danger { color: var(--red); border-color: #ffd7d7; background: #fffafa; }
.btn-danger:hover { background: var(--red-soft); }
.btn-delete { color: var(--sub); background: #fff; }
.btn-delete:hover { color: var(--red); border-color: #ffd7d7; background: #fffafa; }
.btn-sm { min-height: 38px; padding: 0 16px; }
.btn-block { width: 100%; }
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 22px;
}
.panel + .panel { margin-top: 18px; }
.panel-title {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 900;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label {
  color: var(--ink);
  font-weight: 900;
}
.required { color: var(--red); margin-left: 2px; }
.optional { color: var(--sub); font-weight: 700; }
.field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.field input:focus {
  border-color: #aeb0b7;
  box-shadow: 0 0 0 4px rgba(34,34,38,.05);
}
.hint {
  color: var(--sub);
  font-size: 13px;
  font-weight: 650;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}
.form-actions .edit-delete { margin-left: auto; }
.form-actions.stackable { flex-wrap: wrap; }

.items-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 36px 0 16px;
}
.items-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
}
.item-list { display: grid; }
.list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid var(--soft-line);
}
.list-item.sold { opacity: .62; }
.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}
.status.today { color: var(--orange); background: var(--orange-soft); }
.status.expired { color: var(--red); background: var(--red-soft); }
.status.soon { color: var(--green); background: var(--green-soft); }
.status.future { color: var(--sub); background: #f4f4f5; }
.status.sold { color: var(--sub); background: #f1f1f2; }

.resource-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}
.resource {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--sub);
  font-weight: 800;
}
.resource strong { color: var(--ink); }

.guide {
  display: grid;
  gap: 26px;
}
.guide-section {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--soft-line);
}
.guide-section:last-child { border-bottom: 0; padding-bottom: 0; }
.guide-section h2 {
  margin: 0 0 12px;
  font-size: 19px;
  font-weight: 900;
}
.guide-section p {
  margin: 0;
  color: var(--sub);
  font-weight: 700;
}
.guide-steps {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}
.guide-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  align-items: start;
}
.guide-num {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--side-active);
  font-weight: 900;
}
.guide-step strong {
  display: block;
  margin-bottom: 2px;
  font-size: 16px;
}
.guide-step span {
  display: block;
  color: var(--sub);
  font-weight: 700;
}
.guide-note {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: #fafafa;
  color: var(--sub);
  font-weight: 800;
}
.guide-note strong { color: var(--ink); }

.toast-container {
  position: fixed;
  z-index: 80;
  right: 22px;
  top: 22px;
  display: grid;
  gap: 8px;
}
.toast {
  min-width: 240px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 36px rgba(0,0,0,.08);
  font-weight: 800;
  animation: toastIn .2s var(--ease);
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--orange); }
.toast.removing { opacity: 0; transform: translateX(18px); }
@keyframes toastIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: translateX(0); } }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20,20,24,.28);
}
.modal-overlay.hidden { display: none; }
.modal {
  width: min(390px, 100%);
  padding: 26px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,.14);
  text-align: center;
}
.modal h3 { margin: 0 0 8px; font-size: 20px; font-weight: 900; }
.modal p { margin: 0 0 22px; color: var(--sub); font-weight: 700; }
.modal-actions { display: flex; justify-content: center; gap: 10px; }
.is-busy { opacity: .5; pointer-events: none; }

.bottom-tabs { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .mobile-top { display: flex; align-items: center; justify-content: space-between; }
  .main {
    margin-left: 0;
    padding: 28px 20px 96px;
  }
  .content { margin: 0; }
  .page-title { font-size: 27px; margin-bottom: 26px; }
  .bottom-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(14px);
  }
  .bottom-tabs .nav-button {
    height: 58px;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    padding: 0;
    font-size: 12px;
    border-radius: var(--radius);
  }
  .bottom-tabs .nav-button svg { width: 22px; height: 22px; }
  .home-item, .list-item {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .home-item .item-actions, .list-item .item-actions { justify-content: flex-start; }
  .quiet-footer {
    gap: 24px;
    justify-content: flex-start;
    margin-top: 54px;
    font-size: 13px;
  }
}

@media (max-width: 560px) {
  .auth-screen { align-items: start; padding-top: 68px; }
  .auth-box h1 { font-size: 27px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .edit-delete { margin-left: 0; }
  .btn { width: 100%; }
  .item-actions { width: 100%; }
  .item-actions .btn { flex: 1; }
  .toast-container { left: 12px; right: 12px; top: auto; bottom: 92px; }
}
