:root {
  color-scheme: light;
  --color-bg: #f3f7f1;
  --color-panel: #ffffff;
  --color-text: #16251d;
  --color-muted: #52645a;
  --color-border: #b9c9bf;
  --color-primary: #176b45;
  --color-primary-dark: #0e5233;
  --color-primary-soft: #e3f4e9;
  --color-warning-bg: #fff6d8;
  --color-warning-border: #e5b84d;
  --color-error: #a32121;
  --color-error-bg: #fff0f0;
  --color-success: #0e613b;
  --color-success-bg: #e6f7ed;
  --shadow: 0 3px 12px rgba(22, 37, 29, 0.1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  width: 100%;
  min-width: 320px;
  max-width: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--color-bg);
  color: var(--color-text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font: inherit;
}

.container {
  width: 100%;
  max-width: 760px;
  padding-inline: 12px;
  margin-inline: auto;
}

.app-header {
  width: 100%;
  padding: 22px 0 20px;
  overflow: hidden;
  background: var(--color-primary);
  color: #ffffff;
}

.app-label,
.header-description,
h1,
h2,
p {
  margin-top: 0;
}

.app-label {
  margin-bottom: 2px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(1.9rem, 8vw, 2.5rem);
  line-height: 1.25;
}

.header-description {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.main-content {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 18px 0 36px;
}

.panel {
  min-width: 0;
  padding: 18px 14px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-panel);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading > div {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.section-number {
  display: grid;
  width: 31px;
  height: 31px;
  margin-bottom: 0;
  border-radius: 50%;
  background: var(--color-primary);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 800;
  place-items: center;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
  line-height: 1.3;
}

.section-title-text {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.3;
}

.section-description {
  margin-bottom: 14px;
  color: var(--color-muted);
  font-size: 1rem;
}

.privacy-note,
.message,
.empty-state {
  padding: 11px 12px;
  border-radius: 9px;
}

.privacy-note {
  margin-bottom: 16px;
  border: 1px solid var(--color-warning-border);
  background: var(--color-warning-bg);
  font-size: 1rem;
}

.message {
  margin-bottom: 14px;
  font-size: 1rem;
  font-weight: 700;
}

.message-error {
  border: 1px solid #e5adad;
  background: var(--color-error-bg);
  color: var(--color-error);
}

.message-success {
  border: 1px solid #a8d2b7;
  background: var(--color-success-bg);
  color: var(--color-success);
}

.form-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.form-field {
  display: grid;
  gap: 7px;
  min-width: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.form-field small {
  color: var(--color-muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.required {
  display: inline-block;
  margin-left: 3px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--color-error);
  color: #ffffff;
  font-size: 0.8rem;
  line-height: 1.4;
  vertical-align: 2px;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-height: 56px;
  padding: 13px;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--color-text);
  font-size: 1.08rem;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid #f0b429;
  outline-offset: 2px;
}

.form-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.button {
  width: 100%;
  max-width: 100%;
  min-height: 58px;
  padding: 14px 16px;
  border: 2px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 800;
}

.button-primary {
  background: var(--color-primary);
  color: #ffffff;
}

.button-primary:hover,
.button-primary:active {
  background: var(--color-primary-dark);
}

.button-secondary {
  border-color: var(--color-primary);
  background: #ffffff;
  color: var(--color-primary-dark);
}

.button-danger {
  border-color: #b74040;
  background: #ffffff;
  color: var(--color-error);
}

.button-danger-solid {
  background: var(--color-error);
  color: #ffffff;
}

.button-small {
  min-height: 44px;
  padding: 8px 12px;
}

.form-actions .button-primary {
  min-height: 64px;
  font-size: 1.2rem;
}

.edit-mode-label {
  margin-bottom: 0;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--color-warning-bg);
  color: #6d5100;
  font-size: 0.95rem;
  font-weight: 800;
}

.record-count {
  margin-bottom: 0;
  color: var(--color-primary-dark);
  font-size: 1.05rem;
  font-weight: 800;
}

.summary-list {
  display: grid;
  gap: 12px;
}

.summary-card {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: #ffffff;
}

.records-table-scroll {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: #ffffff;
}

.records-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 1rem;
  white-space: nowrap;
}

.records-table th,
.records-table td {
  padding: 11px 10px;
  border-bottom: 1px solid #e1e9e4;
  text-align: left;
  vertical-align: middle;
}

.records-table th {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-weight: 800;
}

.records-table tr:last-child td {
  border-bottom: 0;
}

.record-table-actions {
  display: flex;
  gap: 6px;
}

.record-table-button {
  width: auto;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 7px 10px;
  font-size: 0.95rem;
}

.records-table-empty {
  color: var(--color-muted);
  text-align: center;
  white-space: normal;
}

.data-management-actions {
  display: grid;
  gap: 10px;
}

.data-management-panel {
  padding-block: 12px;
}

.data-management-details {
  min-width: 0;
}

.data-management-summary {
  display: block;
  cursor: pointer;
  list-style: none;
}

.data-management-summary::-webkit-details-marker {
  display: none;
}

.data-management-heading {
  margin-bottom: 0;
}

.data-management-heading > span:first-child {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.data-management-toggle-text {
  flex: 0 0 auto;
  padding: 5px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--color-primary-dark);
  font-size: 0.95rem;
  font-weight: 800;
}

.toggle-text-open {
  display: none;
}

.data-management-details[open] .toggle-text-closed {
  display: none;
}

.data-management-details[open] .toggle-text-open {
  display: inline;
}

.data-management-content {
  padding-top: 12px;
}

.data-management-actions .button {
  min-height: 48px;
  padding: 10px 12px;
  font-size: 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  margin: -1px;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--color-primary-soft);
}

.summary-toggle-button {
  width: 100%;
  margin-top: 12px;
}

.field-summary-filter {
  margin-bottom: 12px;
}

.summary-crop {
  margin-bottom: 0;
  font-weight: 800;
}

.summary-values {
  flex-shrink: 0;
  margin-bottom: 0;
  text-align: right;
}

.summary-values strong {
  color: var(--color-primary-dark);
  font-size: 1.12rem;
}

.empty-state {
  margin-bottom: 0;
  border: 1px dashed var(--color-border);
  background: #f9fbf9;
  color: var(--color-muted);
  text-align: center;
}

.confirm-dialog {
  width: min(calc(100% - 32px), 440px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(22, 37, 29, 0.3);
}

.confirm-dialog::backdrop {
  background: rgba(12, 24, 18, 0.55);
}

.confirm-dialog-content {
  padding: 20px;
}

.confirm-dialog-content h2 {
  margin-bottom: 8px;
}

.confirm-dialog-content p {
  margin-bottom: 18px;
  color: var(--color-muted);
}

.confirm-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

[hidden] {
  display: none !important;
}

@media (min-width: 620px) {
  .panel {
    padding: 22px;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-field-full {
    grid-column: 1 / -1;
  }

  .form-actions {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .data-management-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
