:root {
  --navy: #003057;
  --navy-2: #0b4a7d;
  --gold: #b3a369;
  --gold-soft: #f3edda;
  --ink: #16202a;
  --muted: #61707e;
  --line: #dbe3ea;
  --bg: #f4f7fa;
  --card: #fff;
  --danger: #b3261e;
  --ok: #1f7a4d;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.35;
}

.sticky-head {
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: var(--navy);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--gold);
  color: var(--navy);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.15;
}

.brand p {
  margin: 1px 0 0;
  color: #c9d6e2;
  font-size: 11px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--navy);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #c9d6e2;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: var(--gold);
  color: var(--navy);
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 14px 12px 32px;
}

.panel {
  display: grid;
  gap: 12px;
}

[hidden] {
  display: none !important;
}

.card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

h2 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 15px;
}

h3 {
  margin: 0;
  font-size: 14px;
}

.hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.hint a {
  color: var(--navy-2);
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 560px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.person-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.person-picker label {
  flex: 1 1 220px;
}

.person-picker .btn {
  flex: 0 0 auto;
}

label {
  display: grid;
  gap: 4px;
  color: #3b4a57;
  font-size: 12px;
  font-weight: 600;
}

.label-note {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.paste-names {
  display: grid;
  gap: 6px;
  padding: 11px;
  border: 1px solid #e5ebf0;
  border-radius: 12px;
  background: #f8fafc;
}

.paste-names label {
  color: var(--navy);
}

.inline-hint {
  margin: 0;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 2px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #c8d3dd;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  outline: 3px solid rgba(179, 163, 105, 0.35);
}

textarea {
  resize: vertical;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row.wrap {
  flex-wrap: wrap;
}

.stack {
  display: grid;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--navy);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}

.btn.primary:hover {
  background: var(--navy-2);
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 12px;
}

.btn.block {
  width: 100%;
  padding: 14px;
  font-size: 16px;
}

.btn.danger {
  border-color: #f0c7c3;
  background: #fff7f6;
  color: var(--danger);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.member-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
}

.member-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.member-name-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.member-name-label h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-name-label .serial {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.member-head input {
  font-weight: 700;
}

.lines {
  display: grid;
  gap: 6px;
}

.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 44px;
  gap: 6px;
  align-items: center;
}

.line .line-notes {
  grid-column: 1 / -1;
  padding: 8px 10px;
  font-size: 14px;
}

.line select {
  padding: 9px;
  font-size: 14px;
}

.line input[type="number"] {
  padding: 9px 6px;
  text-align: center;
}

.remove-line {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--danger);
  font-size: 18px;
  cursor: pointer;
}

.pill {
  justify-self: start;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e8eef4;
  color: #4a5b6a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pill.new {
  background: var(--gold-soft);
  color: #7a651f;
}

.roster-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.event-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.event-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.event-main p {
  margin: 3px 0 0;
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e7f4ec;
  color: var(--ok);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.closed {
  background: #eef1f4;
  color: #5d6b78;
}

.badge.open {
  background: #e7f4ec;
  color: var(--ok);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat {
  padding: 8px;
  border-radius: 10px;
  background: #f4f7fa;
  text-align: center;
}

.stat b {
  display: block;
  color: var(--navy);
  font-size: 18px;
}

.stat span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.member-group {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
}

.member-group h3 {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
}

.member-group h3 span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px dashed #dde5ec;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}

.checkline:first-of-type {
  border-top: 0;
}

.checkline input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.checkline .item {
  flex: 1;
  min-width: 0;
}

.checkline .item b {
  font-weight: 700;
}

.checkline .returned {
  color: var(--ok);
  font-size: 11px;
  font-weight: 700;
}

.checkline .pending {
  color: #8a5a00;
  font-size: 11px;
  font-weight: 700;
}

.checkline .line-note {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.detail {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 2px solid var(--navy);
  border-radius: var(--radius);
  background: #fff;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.detail-head h2 {
  margin: 0;
}

.toast {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--navy);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(20px);
  transition: 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--danger);
}

.empty {
  padding: 22px 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-head h2 {
  margin: 0;
}

.inv-card {
  display: grid;
  gap: 8px;
}

.inv-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.inv-top h3 {
  font-size: 14px;
}

.inv-top .serial {
  color: var(--muted);
  font-size: 11px;
}

.inv-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
}

.chip {
  padding: 3px 8px;
  border-radius: 999px;
  background: #f0f4f8;
  color: #465564;
  font-weight: 600;
}

.chip.good {
  background: #e7f4ec;
  color: var(--ok);
}

.chip.bad {
  background: #fdecea;
  color: var(--danger);
}

.chip.neutral {
  background: var(--gold-soft);
  color: #766323;
}

@media (max-width: 420px) {
  .line {
    grid-template-columns: minmax(0, 1fr) 56px 44px;
  }
}
