:root {
  --bg: #f2f2f7;
  --card: #fff;
  --ink: #000;
  --muted: #8e8e93;
  --line: rgba(60, 60, 67, .12);
  --blue: #007aff;
  --blue-soft: #e8f1ff;
  --green: #34c759;
  --warn: #ff9f0a;
  --red: #ff3b30;
  --shadow: none;
  --nav-h: 50px;
  --radius: 10px;
}

* { box-sizing: border-box; }
html {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--ink);
  background: #d1d1d6;
  -webkit-font-smoothing: antialiased;
}
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
[hidden] { display: none !important; }

.app-shell {
  max-width: 390px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

.topbar {
  min-height: 52px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 6px 16px 4px;
  background: rgba(242, 242, 247, .86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.page-heading {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  min-height: 40px;
}
.topbar-actions { display: flex; align-items: center; gap: 4px; padding-bottom: 6px; }
.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--blue);
  display: grid;
  place-items: center;
  box-shadow: none;
}
.icon-btn.text-btn {
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
}

.view { padding: 10px 16px 28px; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 8px 0 22px;
}
.kpi {
  border: 0;
  border-radius: var(--radius);
  min-height: 88px;
  padding: 12px 7px;
  color: var(--ink);
  background: var(--card);
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.kpi.green, .kpi.slate, .kpi.blue { background: var(--card); color: var(--ink); }
.kpi-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.kpi-label svg { display: none; }
.kpi strong {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.kpi small { font-size: 12px; font-weight: 500; margin-left: 2px; color: var(--muted); }

.section { margin: 6px 0 22px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 4px 10px;
}
.section-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.section-head button,
.text-link {
  border: 0;
  background: none;
  color: var(--blue);
  font-size: 15px;
  padding: 0;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.app-item {
  border: 0;
  border-radius: 16px;
  background: var(--card);
  padding: 16px 8px 14px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}
.app-icon {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 30px;
}
.app-icon svg { width: 22px; height: 22px; }
.app-item > span:last-child { font-size: 16px; font-weight: 650; color: #1c1c1e; }
.tint-blue { background: #c7e0ff; color: #007aff; }
.tint-orange { background: #ffd9a8; color: #ff9500; }
.tint-purple { background: #e2c8ff; color: #af52de; }
.tint-pink { background: #ffc2d6; color: #ff2d55; }
.tint-teal { background: #b4f0e4; color: #00c7be; }
.tint-gray { background: #d8d8de; color: #48484a; }
.tint-yellow { background: #ffe69a; color: #b88600; }

.event-list { display: flex; flex-direction: column; gap: 10px; }
.date-hero { margin: 2px 0 12px; }
.date-hero strong { display: block; font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.date-hero span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.report-shortcut,
.report-date-picker {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
}
.report-shortcut { display: grid; gap: 14px; }
.report-shortcut strong { display: block; font-size: 17px; }
.report-shortcut span { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.report-shortcut input,
.report-date-picker input,
.report-date-picker select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9f9fb;
  padding: 11px 12px;
  font-size: 16px;
}
.report-shortcut .primary-button { margin: 0; }
.report-date-picker { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.report-date-picker label { white-space: nowrap; color: var(--muted); font-size: 14px; }
.daily-row { display: flex; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.daily-row:last-child { border-bottom: 0; }
.daily-row div { display: grid; gap: 4px; }
.daily-row span { color: var(--muted); font-size: 12px; }
.daily-row b { font-size: 14px; text-align: right; }
.event {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  align-items: start;
}
.event-rail {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.event-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  margin-left: 2px;
}
.event-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
}
.event-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}
.event-head strong {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}
.event-links {
  color: var(--blue);
  font-size: 13px;
  white-space: nowrap;
  padding-top: 1px;
}
.event-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}
.who { display: inline-flex; align-items: center; gap: 4px; }
.who svg { width: 14px; height: 14px; }
.badge { font-size: 13px; }
.badge.warn { color: var(--warn); }
.badge.ok { color: var(--green); }
.card-cta {
  width: 100%;
  margin-top: 12px;
  border: 0;
  border-radius: 12px;
  height: 44px;
  background: var(--blue);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  padding: 12px 4px 14px;
  text-align: center;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.stat-n {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.04em;
  word-break: break-all;
}
.stat-n.blue { color: var(--blue); }
.stat-n.warn { color: var(--warn); }
.stat-n.muted { color: #c7c7cc; }
.stat-l { font-size: 11px; color: var(--muted); margin-top: 4px; }

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  padding: 8px 0 4px;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.week-cell { position: relative; padding: 6px 0 12px; color: var(--muted); }
.week-cell .w-lab { display: block; font-size: 11px; }
.week-cell .w-date {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-top: 6px;
  border-radius: 50%;
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
}
.week-cell.today .w-lab { color: var(--blue); }
.week-cell.today .w-date { background: var(--blue); color: #fff; }
.w-dot {
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--muted);
}

.list-meta {
  color: var(--muted);
  font-size: 13px;
  padding: 4px 4px 10px;
}

.panel,
.form-card,
.card,
.profile-card,
.center-card,
.notice,
.record {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: none;
}
.panel { padding: 0 16px; margin: 12px 0; }
.stock-row,
.person-row,
.cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  min-height: 44px;
  border-bottom: .5px solid var(--line);
  background: none;
  width: 100%;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  text-align: left;
  color: inherit;
}
.stock-row:last-child,
.person-row:last-child,
.cell:last-child { border-bottom: 0; }
.stock-name, .cell-title { font-size: 17px; font-weight: 400; }
.stock-spec, .cell-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stock-value { font-size: 17px; font-weight: 600; }
.stock-value small { font-size: 12px; font-weight: 400; color: var(--muted); }
.cell-arrow { color: #c7c7cc; font-size: 20px; }

.notice {
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 12px;
}
.notice strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }

.profile-card { padding: 16px; margin-bottom: 16px; }
.profile-top { display: flex; align-items: center; gap: 12px; }
.avatar-xl {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #e5e5ea;
  color: #8e8e93;
  display: grid;
  place-items: center;
}
.profile-top strong { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.profile-top .sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.role-tag { display: inline-block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.month-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  text-align: center;
  padding: 16px 0 4px;
}
.month-stats strong { display: block; font-size: 20px; font-weight: 700; }
.month-stats span { font-size: 12px; color: var(--muted); }

.center-card { padding: 14px 12px 16px; margin-bottom: 16px; }
.center-card h3 {
  margin: 0 4px 14px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
}

.entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
}
.back {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  font-size: 28px;
  line-height: 1;
  color: var(--blue);
  padding: 0 6px 0 0;
}
.entry-header h1 { font-size: 17px; margin: 0; font-weight: 600; }
.entry-header p { font-size: 13px; color: var(--muted); margin: 2px 0 0; }

.form-card, .card { padding: 6px 16px 14px; margin-bottom: 16px; }
.form-card h3, .card h3 {
  font-size: 13px;
  margin: 12px 0 8px;
  font-weight: 400;
  color: var(--muted);
}
.quantity-row {
  padding: 10px 0;
  border-top: .5px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.quantity-row:first-of-type { border-top: 0; }
.quantity-row .q-label { flex: 1; }
.quantity-row .q-label strong { font-size: 17px; font-weight: 400; }
.quantity-row .q-label small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.num-fields { display: flex; gap: 8px; }
.num-field { display: flex; align-items: center; gap: 5px; }
.num-field input {
  width: 52px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  text-align: center;
  outline: none;
  background: var(--bg);
  font-size: 17px;
  font-weight: 600;
}
.num-field input:focus { box-shadow: 0 0 0 2px var(--blue); }
.num-field span { color: var(--muted); font-size: 13px; }
.form-help, .subtle, .time-note { font-size: 13px; color: var(--muted); line-height: 1.5; }
.result-strip {
  background: var(--blue-soft);
  color: var(--blue);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin: 8px 0 6px;
}
.primary-button {
  width: 100%;
  border: 0;
  background: var(--blue);
  color: #fff;
  border-radius: 12px;
  padding: 14px 20px;
  font-weight: 600;
  font-size: 17px;
  margin-top: 8px;
}
.secondary-button {
  width: 100%;
  border: 0;
  background: var(--bg);
  color: var(--blue);
  border-radius: 12px;
  padding: 12px;
  font-weight: 600;
  font-size: 17px;
}
.field-label { font-size: 13px; font-weight: 400; color: var(--muted); margin: 12px 0 8px; display: block; }
.select-field, .text-field {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--bg);
  outline: none;
  font-size: 17px;
}
.select-field:focus, .text-field:focus { box-shadow: 0 0 0 2px var(--blue); }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--ink);
  margin: 12px 0;
}
.checkbox-row input { accent-color: var(--blue); }
.payment-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0; }
.payment-options label { cursor: pointer; }
.payment-options input { position: absolute; opacity: 0; }
.payment-options span { display: block; text-align: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font-size: 14px; font-weight: 700; }
.payment-options input:checked + span { border-color: var(--blue); background: #eaf4ff; color: var(--blue); }
.payment-options input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.payment-badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 100px; }
.payment-badge.paid { color: #21764d; background: #e8f5eb; }
.payment-badge.unpaid { color: #a35c2a; background: #fff1df; }

.segment {
  display: flex;
  background: rgba(118, 118, 128, .12);
  border-radius: 9px;
  padding: 2px;
  gap: 0;
  margin: 0 0 14px;
}
.segment button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 7px 2px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
}
.segment button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}

.record {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
}
.record-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 16px;
}
.record-icon.out { background: #fff3d6; color: var(--warn); }
.record-main { flex: 1; min-width: 0; }
.record-head { display: flex; justify-content: space-between; gap: 8px; }
.record-head strong { font-size: 15px; }
.record-head time { font-size: 13px; color: var(--muted); white-space: nowrap; }
.record-detail { font-size: 13px; margin-top: 4px; }
.record-foot { font-size: 12px; color: var(--muted); margin-top: 4px; }
.empty { text-align: center; padding: 36px 20px; color: var(--muted); font-size: 15px; }

.simple-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.simple-table th {
  color: var(--muted);
  font-weight: 400;
  text-align: right;
  border-bottom: .5px solid var(--line);
  padding: 10px 4px;
}
.simple-table th:first-child, .simple-table td:first-child { text-align: left; }
.simple-table td {
  padding: 11px 4px;
  text-align: right;
  border-bottom: .5px solid var(--line);
  font-weight: 500;
}
.simple-table tr:last-child td { border-bottom: 0; }
.positive { color: var(--green); }
.negative { color: var(--red); }

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e5e5ea;
  color: #3a3a3c;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.person-row strong { margin-left: auto; font-size: 15px; font-weight: 400; color: var(--muted); }
.person-row small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.menu-item {
  width: 100%;
  background: #fff;
  border: 0;
  border-radius: 0;
  padding: 12px 0;
  display: flex;
  align-items: center;
  text-align: left;
  gap: 12px;
  color: var(--ink);
}
.menu-item .menu-text { font-size: 17px; font-weight: 400; }
.menu-item small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.menu-item .arrow { margin-left: auto; color: #c7c7cc; }

.fab { display: none !important; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(390px, 100%);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background: rgba(249, 249, 249, .92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-radius: 0;
  border-top: .5px solid rgba(0, 0, 0, .18);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 6px 10px 0;
  box-shadow: none;
}
.nav-item {
  min-width: 64px;
  border: 0;
  background: none;
  color: #8e8e93;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 1px;
  font-size: 10px;
  font-weight: 500;
}
.nav-item.active { color: var(--blue); }

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal {
  background: #fff;
  width: min(390px, 100%);
  border-radius: 14px 14px 0 0;
  padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: none;
}
.modal h2 { font-size: 17px; margin: 0 0 6px; font-weight: 600; }
.modal p { font-size: 13px; line-height: 1.5; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions button { flex: 1; }
.modal-actions .primary-button { margin: 0; }
.modal-row {
  display: flex;
  justify-content: space-between;
  border-bottom: .5px solid var(--line);
  padding: 11px 0;
  font-size: 15px;
  gap: 12px;
}
.modal-row strong { font-size: 15px; text-align: right; font-weight: 400; }
.modal-close {
  float: right;
  border: 0;
  background: none;
  font-size: 22px;
  color: var(--muted);
}

#toast {
  position: fixed;
  z-index: 100;
  bottom: calc(var(--nav-h) + 24px);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(28, 28, 30, .92);
  color: #fff;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  white-space: nowrap;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.login-screen { padding: 48px 16px 24px; }
.login-screen h1 { font-size: 34px; margin: 0 0 8px; letter-spacing: -0.04em; }
.login-screen p { color: var(--muted); margin: 0 0 24px; font-size: 15px; line-height: 1.45; }
.login-hint { font-size: 13px; color: var(--muted); margin-top: 16px; line-height: 1.5; }
.notice.phase { align-items: flex-start; }
.notice.phase span { background: #fff1df; color: #a35c2a; }
.dispute-card { padding: 4px 16px 16px; margin-bottom: 12px; }
.dispute-card .primary-button { margin: 12px 0 4px; }
#toast { white-space: normal; max-width: min(340px, calc(100vw - 32px)); text-align: center; }
