:root {
  --paper: #f3ecdf;
  --ink: #1b2330;
  --muted: #5c6b7a;
  --line: #e3d7c6;
  --card: #fffdf8;
  --good: #0e7c45;
  --bad: #9f1239;
  --shadow: 0 10px 30px rgba(60, 42, 20, 0.08);
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", "Nirmala UI", "Mukta", sans-serif;
  background-color: var(--paper);
  background-image: linear-gradient(rgba(227, 215, 198, 0.7) 1px, transparent 1px);
  background-size: 100% 32px;
}

button, input, textarea, select { font: inherit; color: inherit; }

a { color: inherit; }
a.who { color: inherit; text-decoration: none; border-bottom: 1px solid rgba(255, 248, 236, 0.45); }

.app {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 14px 14px calc(22px + var(--safe-bottom));
}

.signboard {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: stretch;
  background: var(--ink);
  color: #fff8ec;
  border-radius: 28px;
  padding: 18px 16px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.sign-kicker {
  margin: 0 0 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  opacity: 0.72;
}

.sign-copy { flex: 1; min-width: 0; }

.brand-logo,
.slip-logo,
.top-logo {
  object-fit: cover;
  background: #000;
}

.brand-logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px rgba(255, 248, 236, 0.22);
}

.slip-logo {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  display: block;
  margin: 0 auto 10px;
}

.top-logo { display: none; }

.signboard h1 {
  margin: 0;
  font-size: clamp(22px, 5.4vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.sign-year {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 248, 236, 0.14);
  font-weight: 700;
}

.sign-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.today-stamp {
  width: 74px;
  min-height: 74px;
  border-radius: 18px;
  background: #fff8ec;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.today-stamp strong { font-size: 32px; }
.today-stamp span { font-size: 13px; font-weight: 800; letter-spacing: 0.04em; }

.who {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.8;
}

.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tile {
  min-height: 168px;
  border-radius: 28px;
  background: var(--tile, #1f5fbf);
  color: white;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 10px;
  box-shadow: var(--shadow);
}

.tile svg { width: 64px; height: 64px; }
.tile-en { font-size: 22px; font-weight: 800; line-height: 1.1; }
.tile-hi { font-size: 16px; font-weight: 700; opacity: 0.92; }
.tile:active { transform: scale(0.98); }

.topbar {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.topbar-title { text-align: center; display: flex; align-items: center; justify-content: center; gap: 10px; }
.topbar-title strong { display: block; font-size: 26px; line-height: 1.1; }
.topbar-title span { color: var(--muted); font-weight: 700; }

.icon-btn {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--ink);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.icon-btn svg { width: 34px; height: 34px; }
.signboard .icon-btn { background: #fff8ec; color: var(--ink); }

.sheet { display: flex; flex-direction: column; gap: 12px; }

.banner {
  border-radius: 18px;
  padding: 14px 16px;
  font-size: 18px;
  font-weight: 800;
}

.banner.ok { background: #e5f6ec; color: #0e7c45; }
.banner.bad { background: #fde8ee; color: var(--bad); }
.banner.info { background: #fff4d8; color: #7a4b00; }
.banner ul { margin: 0; padding-left: 18px; }

.stack, .card, .person, .slip, .line, .bar-row, .note {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.stack, .card { padding: 14px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field span, .label { font-size: 18px; font-weight: 800; }
.field small, .label small { color: var(--muted); font-weight: 700; font-size: 14px; }
.label { margin: 4px 0 8px; }

input[type="text"], input[type="password"], input[type="tel"], input[type="date"], input[type="month"], input[type="number"], input[type="file"], input[type="search"], textarea, select {
  width: 100%;
  min-height: 58px;
  border-radius: 16px;
  border: 2px solid #d9cbb8;
  background: #fff;
  padding: 12px 14px;
  font-size: 18px;
}

textarea { min-height: 90px; resize: vertical; }

.big-btn, button.big-btn {
  width: 100%;
  min-height: 64px;
  border: 0;
  border-radius: 18px;
  background: var(--good);
  color: white;
  font-size: 22px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
}

.big-btn.dark { background: var(--ink); }
.big-btn.warn { background: var(--bad); }
.big-btn svg { width: 28px; height: 28px; }
.big-btn:disabled { opacity: 0.6; }

.chip-grid, .chip-row, .choice-grid, .stat-grid, .count-grid {
  display: grid;
  gap: 8px;
}

.chip-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 12px; }
.chip-row { grid-template-columns: repeat(4, 1fr); margin-bottom: 12px; }
.choice-grid { grid-template-columns: repeat(3, 1fr); margin-bottom: 12px; }
.choice-grid.two { grid-template-columns: 1fr 1fr; }
.stat-grid { grid-template-columns: 1fr 1fr; }
.count-grid { grid-template-columns: repeat(4, 1fr); }

button.chip { width: 100%; cursor: pointer; }
.chip, .choice {
  position: relative;
  min-height: 64px;
  border-radius: 16px;
  border: 2px solid #d9cbb8;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-weight: 800;
  text-align: center;
  padding: 8px 4px;
}

.chip span, .choice span { font-size: 18px; }
.choice small { color: var(--muted); font-size: 13px; }
.choice svg { width: 28px; height: 28px; }
.chip.wide span { font-size: 14px; }
.chip input, .choice input, .month input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.chip:has(input:checked), .choice:has(input:checked) {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.choice:has(input:checked) small { color: rgba(255,255,255,0.8); }

.month-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.month {
  position: relative;
  min-height: 84px;
  border-radius: 18px;
  border: 2px solid #d9cbb8;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.month small { font-weight: 700; color: var(--muted); }
.month input { cursor: pointer; }

.month:has(input:checked) {
  background: var(--good);
  color: white;
  border-color: var(--good);
}

.month:has(input:checked) small { color: rgba(255,255,255,0.85); }

.month.paid {
  background: #e7f6ee;
  color: var(--good);
  border-color: #b7e4c7;
}

.person {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  text-decoration: none;
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  flex: 0 0 auto;
}

.person-body { display: flex; flex-direction: column; min-width: 0; }
.person-body strong { font-size: 20px; }
.person-body em, .person-body small { font-style: normal; color: var(--muted); font-weight: 700; }
.person-body strong, .person-body em, .person-body small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dots { display: flex; gap: 3px; margin-top: 6px; }
.dots i {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: #e3d7c6;
  display: block;
}
.dots i.on { background: var(--good); }

.hero {
  background: var(--ink);
  color: white;
  border-radius: 24px;
  padding: 16px;
}

.hero span { display: block; opacity: 0.75; font-weight: 700; }
.hero strong { display: block; font-size: clamp(36px, 10vw, 52px); letter-spacing: -0.04em; line-height: 1.05; }
.hero.good { background: var(--good); }
.hero.bad { background: var(--bad); }

.stat {
  background: var(--card);
  border-radius: 20px;
  padding: 14px;
  border: 1px solid var(--line);
}
.stat span { display: block; color: var(--muted); font-weight: 800; }
.stat strong { display: block; font-size: 26px; margin-top: 4px; }
.stat small { color: var(--muted); font-weight: 700; }

.line, .bar-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 14px;
  font-weight: 800;
}

.bar-row .bar {
  flex: 1;
  height: 14px;
  background: #efe4d4;
  border-radius: 99px;
  overflow: hidden;
}
.bar-row .bar i { display: block; height: 100%; background: #1f5fbf; border-radius: 99px; }

.search {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
}
.search button {
  border: 0;
  border-radius: 16px;
  background: var(--ink);
  color: white;
}
.search button svg { width: 32px; height: 32px; }

.scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.scroller .chip { min-width: 72px; text-decoration: none; }
.scroller a.chip.on { background: var(--ink); color: white; border-color: var(--ink); }

.paybar {
  position: sticky;
  bottom: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  background: var(--ink);
  color: white;
  border-radius: 22px;
  padding: 10px 10px 10px 16px;
}
.paybar span { display: block; opacity: 0.7; font-size: 13px; font-weight: 700; }
.paybar strong { font-size: 28px; }
.paybar button {
  width: auto;
  min-width: 150px;
  min-height: 58px;
}

.slip { padding: 18px 16px; }
.slip h2, .slip p { margin: 0; text-align: center; }
.slip h2 { font-size: 28px; }
.slip .muted { color: var(--muted); font-weight: 700; }
.rule { border: 0; border-top: 2px dashed #d9cbb8; margin: 12px 0; }
.slip-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--ink);
  color: white;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 28px;
  font-weight: 800;
}
.sign-line { margin-top: 28px; text-align: right; color: var(--muted); font-weight: 700; }

.more summary {
  min-height: 56px;
  display: flex;
  align-items: center;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.more[open] summary { margin-bottom: 8px; }

.empty { text-align: center; padding: 18px 8px 8px; }
.empty-icon svg { width: 72px; height: 72px; }
.empty p { font-size: 18px; font-weight: 800; }

.note { padding: 12px 14px; font-weight: 700; }

.count {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  text-align: center;
  padding: 8px 4px;
  text-decoration: none;
}
.count b { display: block; font-size: 22px; }
.count span { color: var(--muted); font-weight: 800; }

.row-actions { display: flex; gap: 8px; }
.tiny {
  border: 0;
  background: #fde8ee;
  color: var(--bad);
  border-radius: 12px;
  min-height: 44px;
  padding: 0 12px;
  font-weight: 800;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.login-card { width: min(460px, 100%); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tabs a {
  min-height: 64px;
  border-radius: 16px;
  background: white;
  border: 2px solid #d9cbb8;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}
.tabs a.on { background: var(--ink); color: white; border-color: var(--ink); }

:focus-visible { outline: 3px solid #1f5fbf; outline-offset: 2px; }

[hidden] { display: none !important; }

@media (min-width: 768px) {
  .app { width: min(980px, calc(100% - 28px)); padding: 22px 10px 36px; }
  .signboard { padding: 22px; border-radius: 32px; align-items: center; }
  .brand-logo { width: 92px; height: 92px; border-radius: 22px; }
  .signboard h1 { font-size: 40px; }
  .tile-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .tile { min-height: 188px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .month-grid { grid-template-columns: repeat(4, 1fr); }
  .chip-grid { grid-template-columns: repeat(6, 1fr); }
  .count-grid { grid-template-columns: repeat(5, 1fr); }
  .top-logo { display: block; width: 46px; height: 46px; border-radius: 12px; }
  .scroller { flex-wrap: wrap; overflow: visible; }
  .login-card { width: min(560px, 100%); }
}

@media (min-width: 1100px) {
  .app { width: min(1160px, calc(100% - 48px)); }
  .tile-grid { grid-template-columns: repeat(4, 1fr); gap: 18px; }
  .tile { min-height: 196px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .month-grid { grid-template-columns: repeat(6, 1fr); }
  .chip-grid { grid-template-columns: repeat(8, 1fr); }
  .count-grid { grid-template-columns: repeat(8, 1fr); }
  .sheet {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
  }
  .sheet > :not(.person):not(.line):not(.big-btn) { grid-column: 1 / -1; }
  .sheet > .stack,
  .sheet > details.card {
    max-width: 780px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }
  .slip { max-width: 440px; width: 100%; margin-left: auto; margin-right: auto; }
}

@media (max-width: 380px) {
  .tile { min-height: 142px; }
  .tile svg { width: 52px; height: 52px; }
  .tile-en { font-size: 18px; }
  .chip-grid, .count-grid { grid-template-columns: repeat(3, 1fr); }
  .paybar { flex-direction: column; align-items: stretch; }
  .paybar button { width: 100%; }
}

@media print {
  body { background: white; }
  .no-print { display: none !important; }
  .app { max-width: none; width: auto; padding: 0; }
  .sheet { display: block; }
  .slip { max-width: none; box-shadow: none; }
  .card, .line, .bar-row { box-shadow: none; }
}
