:root {
  --bg: #f6f7fb;
  --text: #222;
  --muted: #666;
  --line: #d9dce7;
  --primary: #1f4db8;
  --primary-dark: #15398c;
  --danger: #b42318;
  --ok: #0f7b39;
  --warn-bg: #fff7ed;
  --warn-line: #fdba74;
  --white: #fff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  width: min(100%, 1100px);
  margin: 0 auto;
  padding: 0 16px;
}

.site-header, .site-footer {
  background: #0f172a;
  color: #fff;
}

.site-header .wrap, .site-footer .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 16px;
  flex-wrap: wrap;
}

.site-header h1 {
  margin: 0;
  font-size: 1.2rem;
}

.site-header h1 a,
.site-footer,
.top-nav a,
.top-nav span { color: #fff; }

.top-nav {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.footer-links a {
  color: #fff;
}

.main-area {
  padding: 32px 16px 48px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.card + .card { margin-top: 16px; }
.card.inset { background: #fafcff; }
.narrow { max-width: 540px; }
.login-layout {
  max-width: 820px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 32px;
  align-items: center;
}

.login-card {
  display: grid;
  gap: 16px;
  width: 100%;
}

.login-card h2 {
  margin: 0;
}

.login-visual {
  display: flex;
  justify-content: center;
  align-items: center;
}

.login-visual img {
  width: min(200px, 100%);
  height: auto;
  display: block;
}

@media (max-width: 760px) {
  .login-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}



.form-grid {
  display: grid;
  gap: 16px;
}

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

.align-end { align-items: end; }
.full-span { grid-column: 1 / -1; }

label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #c7ccd8;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
}

textarea { resize: vertical; }

button, .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

button:hover, .button-link:hover { background: var(--primary-dark); text-decoration: none; }
button.secondary { background: #334155; }
.secondary-link { background: #334155; }

.links, .button-row {
  margin-top: 16px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.flash-group {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.flash {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
}
.flash.success { background: #ecfdf3; color: var(--ok); border-color: #b7ebc6; }
.flash.error { background: #fff1f2; color: var(--danger); border-color: #fecdd3; }

.muted { color: var(--muted); }
.error-text { color: var(--danger); font-weight: 700; }
.nav-user { color: #cbd5e1; }
.small { font-size: 0.9rem; }

.hero-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: #fbfcff;
}

.stat-label {
  color: #475569;
  font-weight: 700;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
}

.profile-list {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 12px;
  margin: 18px 0 24px;
}
.profile-list.compact { margin-bottom: 8px; }
.profile-list dt {
  font-weight: 700;
  color: #334155;
}
.profile-list dd { margin: 0; }

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

.entry-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  color: inherit;
  background: #fff;
}

.entry-main {
  display: grid;
  gap: 6px;
}

.entry-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: end;
}

.entry-feedback {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.entry-feedback-item {
  color: #334155;
  font-size: 0.94rem;
  line-height: 1.45;
  word-break: break-word;
}

.pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.88rem;
  font-weight: 700;
}

.pill.warn {
  background: var(--warn-bg);
  color: #9a3412;
}

.alert-row {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.gallery-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.gallery-card img {
  display: block;
  width: 100%;
  height: 320px;
  object-fit: contain;
  background: #f8fafc;
  padding: 10px;
}

.gallery-meta {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.map-box {
  width: 100%;
  height: 420px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
}

@media (max-width: 760px) {
  .profile-list,
  .form-grid.two-col,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .entry-row {
    flex-direction: column;
    align-items: start;
  }

  .entry-meta {
    justify-content: start;
  }
}

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

.search-row {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin: 16px 0 18px;
}

.search-grow {
  flex: 1 1 360px;
}

.search-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  color: #334155;
  background: #f8fafc;
}

.data-table tbody tr:hover {
  background: #fafcff;
}

@media (max-width: 760px) {
  .stats-grid-3 {
    grid-template-columns: 1fr;
  }

  .search-row {
    align-items: stretch;
  }
}

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

.text-small {
  font-size: 0.95rem;
  line-height: 1.3;
  word-break: break-all;
}

.compact-row {
  gap: 8px;
  flex-wrap: wrap;
}

.map-box-form {
  min-height: 340px;
  margin-top: 12px;
}

.maintenance-banner {
  background: #7c2d12;
  color: #fff;
  padding: 12px 0;
}

.maintenance-banner .wrap {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

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

.admin-user-grid {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.admin-user-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  background: #fbfcff;
}

.admin-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.admin-meta-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}

.admin-meta-box .label {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.admin-meta-box .value {
  font-weight: 700;
  word-break: break-word;
}

.admin-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.admin-search {
  margin-top: 18px;
}

.maintenance-card {
  margin: 48px auto 0;
}

.small-button {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #8f1b13;
}

.admin-actions,
.admin-delete-row {
  margin-top: 0;
}

.ocr-assist-panel {
  margin-top: 4px;
}

.ocr-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.ocr-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(240px, 1fr);
  gap: 18px;
  align-items: start;
}

.ocr-canvas-wrap {
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
  padding: 12px;
}

.ocr-canvas {
  display: block;
  width: 100%;
  border-radius: 12px;
  background: #ffffff;
  cursor: crosshair;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.2);
}

.ocr-sidebar {
  display: grid;
  gap: 12px;
}

.policy-card {
  max-width: 920px;
  margin: 0 auto;
}

.policy-header {
  margin-bottom: 24px;
}

.policy-kicker {
  margin: 0 0 8px;
  color: #475569;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.policy-lead {
  margin: 0;
  color: #334155;
  line-height: 1.8;
}

.policy-sections {
  display: grid;
  gap: 22px;
}

.policy-sections section {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.policy-sections section:first-child {
  padding-top: 0;
  border-top: 0;
}

.policy-sections h3 {
  margin: 0 0 12px;
}

.policy-sections p {
  margin: 0 0 12px;
  line-height: 1.8;
}

.policy-list {
  margin: 0 0 12px;
  padding-left: 1.2rem;
  line-height: 1.8;
}

.policy-contact {
  font-style: normal;
  line-height: 1.9;
}

.license-note {
  color: #334155;
}

.license-table th,
.license-table td {
  white-space: normal;
  vertical-align: top;
  line-height: 1.7;
}

.license-table td:last-child a {
  word-break: break-all;
}

.ocr-status,
.ocr-result-preview {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.ocr-status {
  padding: 12px 14px;
  color: #334155;
  background: #eff6ff;
}

.ocr-status.is-error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.ocr-status.is-success {
  background: #ecfdf5;
  color: #166534;
  border-color: #bbf7d0;
}

.ocr-status.is-busy {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

.ocr-result-preview {
  min-height: 120px;
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .stats-grid-4,
  .admin-meta-grid,
  .admin-checkbox-grid,
  .ocr-layout {
    grid-template-columns: 1fr;
  }
}
