/* =========================================
   坂本工業 耐圧気密試験 記録フォーム PWA
   ========================================= */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-primary: #1a3a5c;
  --c-primary-dark: #0f2541;
  --c-accent: #c8521a;
  --c-bg: #f4f5f7;
  --c-panel: #ffffff;
  --c-border: #d8dde3;
  --c-border-strong: #8f9aa8;
  --c-text: #1c2530;
  --c-text-sub: #5a6776;
  --c-required: #c8521a;
  --c-success: #1e7e4d;
  --c-error: #b3261e;
  --shadow-sm: 0 1px 2px rgba(15,37,65,0.06);
  --shadow-md: 0 4px 16px rgba(15,37,65,0.08);
  --r-sm: 4px;
  --r-md: 6px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* ===== Header ===== */
.app-header {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-dark) 100%);
  color: #fff;
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-md);
}
.header-inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.logo-block {
  display: flex;
  align-items: center;
  gap: 12px;
}
.reload-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  font-size: 20px;
  font-weight: 300;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.3s;
}
.reload-btn:active {
  background: rgba(255, 255, 255, 0.25);
}
.reload-btn.spinning {
  transform: rotate(360deg);
}
.logo-mark {
  width: 40px;
  height: 40px;
  background: var(--c-accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 20px;
  border-radius: var(--r-sm);
  letter-spacing: 0;
}
.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.company {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.subtitle {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 2px;
  letter-spacing: 0.08em;
}

/* ===== Main ===== */
.app-main {
  padding: 24px 16px 80px;
}
.container {
  max-width: 880px;
  margin: 0 auto;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  padding-bottom: 14px;
  border-bottom: 3px double var(--c-primary);
}
.page-desc {
  color: var(--c-text-sub);
  font-size: 13px;
  margin-bottom: 24px;
}

/* ===== Form Section ===== */
.form-section {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--c-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.section-title .num {
  font-family: "Courier New", monospace;
  background: var(--c-primary);
  color: #fff;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 2px;
  letter-spacing: 0.05em;
}
.section-desc {
  font-size: 12px;
  color: var(--c-text-sub);
  margin-bottom: 14px;
}

/* ===== Fields ===== */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field-row .field { flex: 1; }
.field .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-sub);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.03em;
}
.field .label em.req {
  background: var(--c-required);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 600;
}
.field input, .field select {
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--c-text);
  width: 100%;
  -webkit-appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(26,58,92,0.15);
}
.field .help {
  font-size: 11px;
  color: var(--c-text-sub);
}
.field-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.field-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

/* ===== Photo Upload ===== */
.photo-upload {
  margin-bottom: 16px;
}
.photo-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--c-primary);
  color: #fff;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.photo-add-btn:hover, .photo-add-btn:active {
  background: var(--c-primary-dark);
}
.photo-add-btn .plus {
  font-size: 20px;
  line-height: 1;
}

.photo-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.photo-item {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 14px;
  padding: 12px;
  background: #fafbfc;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
}
.photo-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #e8ebee;
  border-radius: var(--r-sm);
  overflow: hidden;
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.photo-index {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: var(--c-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 2px;
  font-family: "Courier New", monospace;
}
.photo-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.photo-fields .field-row {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ===== Submit ===== */
.submit-btn {
  width: 100%;
  padding: 16px;
  background: var(--c-accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  margin-top: 16px;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.submit-btn:hover:not(:disabled) {
  background: #a13e0c;
}
.submit-btn:disabled {
  background: #9aa6b2;
  cursor: not-allowed;
}
.submit-btn .btn-loading { display: none; }
.submit-btn.loading .btn-text { display: none; }
.submit-btn.loading .btn-loading { display: inline; }

.result-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--r-sm);
  font-size: 14px;
  display: none;
}
.result-box.success {
  display: block;
  background: #e8f5ee;
  border: 1px solid var(--c-success);
  color: var(--c-success);
}
.result-box.error {
  display: block;
  background: #fcebea;
  border: 1px solid var(--c-error);
  color: var(--c-error);
}
.result-box a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
}

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  padding: 20px;
  font-size: 11px;
  color: var(--c-text-sub);
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
  .page-title { font-size: 18px; }
  .form-section { padding: 14px; }
  .field-row { grid-template-columns: 1fr; }
  .photo-item { grid-template-columns: 110px 1fr; gap: 10px; }
  .photo-fields .field-row { grid-template-columns: 1fr; }
  .submit-btn { font-size: 15px; padding: 14px; }
}
