:root {
  color-scheme: light;
  --green: #174f45;
  --green-2: #246f60;
  --green-soft: #e5f2ef;
  --ink: #17211f;
  --muted: #66736f;
  --line: #d4dedb;
  --surface: #ffffff;
  --surface-2: #f2f6f4;
  --blue: #1b6695;
  --red: #b42318;
  --amber: #8a5a00;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--surface-2); color: var(--ink); }
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: calc(60px + env(safe-area-inset-top));
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  color: white;
  background: var(--green);
}

.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; }
.brand-mark span {
  width: 22px; height: 22px; border-radius: 50%; background: white;
  box-shadow: inset -4px -4px 0 #d5e3df, 12px 12px 0 -9px rgba(255,255,255,.5);
}
.header-title { min-width: 0; display: flex; flex-direction: column; }
.header-title strong { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-title span { font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-button {
  width: 40px; height: 40px; border: 0; border-radius: 6px; background: transparent; color: inherit;
  display: grid; place-items: center; font-size: 25px;
}
.icon-button:active { background: rgba(255,255,255,.14); }

.app-main { width: min(100%, 920px); margin: 0 auto; padding: 14px 12px 28px; }
.bottom-nav {
  position: fixed; z-index: 45; left: 0; right: 0; bottom: 0;
  height: calc(62px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: white; border-top: 1px solid var(--line);
}
.bottom-nav button {
  border: 0; background: white; color: var(--muted); font-size: 11px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.bottom-nav button span { font-size: 21px; line-height: 1; }
.bottom-nav button.active { color: var(--green); font-weight: 800; background: var(--green-soft); }

.screen-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 2px 0 14px; }
.screen-head h1 { margin: 0; font-size: 22px; }
.screen-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.stack { display: grid; gap: 10px; }
.section-title { margin: 20px 0 8px; font-size: 16px; }

.button {
  min-height: 42px; border: 1px solid var(--line); border-radius: 6px; padding: 9px 13px;
  background: white; color: var(--ink); font-weight: 700;
}
.button.primary { background: var(--green); border-color: var(--green); color: white; }
.button.secondary { color: var(--green); border-color: #8cb4ad; background: var(--green-soft); }
.button.danger { color: var(--red); border-color: #e2a29c; background: #fff3f1; }
.button.small { min-height: 34px; padding: 6px 9px; font-size: 13px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }

.panel { background: white; border: 1px solid var(--line); border-radius: 7px; padding: 12px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.panel-title h2 { margin: 0; font-size: 16px; }
.panel-title span { color: var(--muted); font-size: 12px; }
.notice { padding: 10px 12px; border-left: 4px solid var(--blue); background: #edf7ff; color: #164d75; font-size: 13px; }
.warning { border-left-color: var(--amber); background: #fff8e6; color: #654600; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); border: 1px dashed #b8c3bc; background: white; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--line); }
.summary-item { background: white; padding: 11px 6px; text-align: center; min-width: 0; }
.summary-item span { display: block; color: var(--muted); font-size: 11px; }
.summary-item strong { display: block; margin-top: 3px; font-size: 18px; overflow-wrap: anywhere; }

.note-list { display: grid; gap: 1px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--line); }
.note-row {
  width: 100%; border: 0; background: white; color: inherit; padding: 12px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; text-align: left; align-items: center;
}
.note-row:active { background: var(--green-soft); }
.note-title { font-weight: 750; overflow-wrap: anywhere; }
.note-detail { margin-top: 3px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.note-value { font-weight: 850; color: var(--green); text-align: right; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 700; }
.tag.warn { background: #fff2d9; color: #7b4d00; }
.tag.bad { background: #fff0ee; color: var(--red); }

.advice-list { display: grid; gap: 8px; }
.advice-card { border: 1px solid var(--line); border-radius: 7px; padding: 11px; background: white; }
.advice-card strong { display: block; margin-bottom: 4px; }
.advice-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid #aebbb3; border-radius: 6px; padding: 10px; background: white; color: var(--ink);
}
.field textarea { min-height: 74px; resize: vertical; }

.dialog {
  position: fixed; z-index: 80; inset: 0; padding: calc(env(safe-area-inset-top) + 10px) 10px calc(env(safe-area-inset-bottom) + 10px);
  background: rgba(5, 16, 12, .36); display: grid; place-items: center;
}
.dialog-shell { width: min(100%, 720px); max-height: 100%; background: white; border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.dialog-header { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); color: white; background: var(--green); }
.dialog-header h2 { margin: 0; font-size: 17px; }
.dialog-content { overflow-y: auto; padding: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding-top: 12px; }

.toast {
  position: fixed; z-index: 100; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(14px); opacity: 0; pointer-events: none;
  background: #10241c; color: white; padding: 10px 14px; border-radius: 999px; font-size: 13px;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 720px) {
  body { padding-bottom: 72px; }
  .app-main { padding: 22px 20px 42px; }
  .bottom-nav { height: 54px; padding: 0; }
  .bottom-nav button { flex-direction: row; gap: 7px; font-size: 13px; }
  .bottom-nav button span { font-size: 17px; }
}

@media (max-width: 390px) {
  .summary-grid { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
}
