:root{
  --bg:#eef1f6;
  --card:#ffffff;
  --line:#d8dde7;
  --text:#1b2333;
  --sub:#7b8395;
  --navy:#12213f;
  --soft:#e8ebf2;
  --shadow:0 10px 30px rgba(17,24,39,.08);
  --red:#c0392b;
  --yellow:#e7a400;
  --green:#1f8f5f;
  --blue:#2266cc;
}

*{
  box-sizing:border-box;
}

html,body{
  margin:0;
  padding:0;
  min-height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Hiragino Sans","Noto Sans JP",sans-serif;
}

body{
  min-height:100vh;
}

.hidden{
  display:none !important;
}

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

button{
  border:none;
  cursor:pointer;
}

.auth-screen{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:20px;
}

.auth-card{
  width:100%;
  max-width:430px;
  background:#fff;
  border-radius:28px;
  box-shadow:var(--shadow);
  padding:24px;
}

.auth-card h1{
  margin:0 0 8px;
  font-size:30px;
  line-height:1.2;
}

.auth-sub{
  margin:0 0 18px;
  color:var(--sub);
}

.auth-card label,
.card label{
  display:block;
  margin:12px 0 8px;
  font-weight:800;
}

.auth-card input,
.card input,
.card textarea,
.card select{
  width:100%;
  min-height:54px;
  padding:14px 16px;
  border:2px solid var(--line);
  border-radius:18px;
  background:#fff;
}

.auth-message{
  min-height:24px;
  margin:12px 0;
  color:var(--sub);
}

.auth-buttons{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

.auth-buttons button,
#logoutBtn,
#agreeBtn,
#exportCsvBtn,
#exportPdfBtn,
#saveDetailBtn,
#startRouteBtn,
#stopRouteBtn,
.admin-edit-btn,
.admin-delete-btn{
  min-height:56px;
  border-radius:18px;
  padding:14px 16px;
  font-weight:800;
}

.auth-buttons button,
#logoutBtn,
#agreeBtn,
#exportCsvBtn,
#exportPdfBtn,
#saveDetailBtn,
#startRouteBtn{
  background:var(--navy);
  color:#fff;
}

#stopRouteBtn{
  background:var(--soft);
  color:var(--text);
}

.admin-edit-btn{
  background:var(--soft);
  color:var(--text);
}

.admin-delete-btn{
  background:var(--red);
  color:#fff;
}

#appShell{
  min-height:100vh;
  padding-bottom:96px;
}

.topbar{
  position:sticky;
  top:0;
  z-index:100;
  background:rgba(255,255,255,.95);
  backdrop-filter:blur(12px);
  border-bottom:1px solid var(--line);
  padding:16px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
}

.topbar-left h1{
  margin:0;
  font-size:26px;
}

.topbar-user-info{
  margin-top:4px;
  color:var(--sub);
  font-size:14px;
}

.page{
  display:none;
  max-width:940px;
  margin:0 auto;
  padding:16px;
}

.page.active{
  display:block;
}

.page h2{
  margin:0 0 14px;
  font-size:28px;
}

.card{
  background:var(--card);
  border-radius:24px;
  box-shadow:var(--shadow);
  padding:18px;
  margin-bottom:16px;
}

.card h3{
  margin-top:0;
  margin-bottom:8px;
}

.sub-text{
  margin:0 0 14px;
  color:var(--sub);
  line-height:1.6;
}

.info-box{
  background:#f6f8fb;
  border:2px solid var(--line);
  border-radius:18px;
  padding:14px;
  margin-bottom:16px;
  line-height:1.7;
}

.quick-action-wrap{
  display:flex;
  justify-content:center;
  margin:18px 0 10px;
}

.circle-record-btn{
  width:140px;
  height:140px;
  border-radius:999px;
  background:var(--navy);
  color:#fff;
  font-size:28px;
  font-weight:900;
  box-shadow:0 16px 30px rgba(18,33,63,.22);
}

.route-control-wrap{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  margin-top:16px;
}

.map-filter-box{
  margin-bottom:16px;
}

.map-filter-grid{
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:12px;
}

.map-filter-box select{
  width:100%;
  min-height:52px;
  padding:12px 14px;
  border:2px solid var(--line);
  border-radius:16px;
  background:#fff;
}

.map-filter-box input[type="checkbox"]{
  width:22px;
  height:22px;
}

.map-toolbar{
  display:flex;
  gap:10px;
  margin-bottom:12px;
}

.map-action-btn{
  min-height:52px;
  padding:12px 16px;
  border-radius:16px;
  background:var(--navy);
  color:#fff;
  font-weight:800;
}

#map{
  width:100%;
  min-height:460px;
  border-radius:20px;
  overflow:hidden;
  border:2px solid var(--line);
  box-shadow:var(--shadow);
  background:#dbe5f5;
}

.record-list{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.record-item{
  background:#fff;
  border:2px solid var(--line);
  border-radius:20px;
  padding:14px;
  transition:transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.record-item.clickable{
  cursor:pointer;
}

.record-item.clickable:hover{
  transform:translateY(-1px);
  box-shadow:var(--shadow);
  border-color:#b9c4d8;
}

.record-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:8px;
}

.record-title{
  font-size:18px;
  font-weight:900;
}

.record-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:72px;
  min-height:32px;
  padding:6px 10px;
  border-radius:999px;
  color:#fff;
  font-size:13px;
  font-weight:800;
}

.badge-dead{ background:var(--red); }
.badge-injured{ background:var(--yellow); color:#222; }
.badge-alive{ background:var(--green); }
.badge-unknown{ background:var(--blue); }

.record-sub{
  color:var(--sub);
  font-size:13px;
  margin-bottom:6px;
  line-height:1.5;
}

.record-memo{
  margin-top:8px;
  padding:10px 12px;
  background:#f6f8fb;
  border-radius:14px;
  border:1px solid var(--line);
  line-height:1.6;
  font-size:14px;
}

.record-admin-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:12px;
}

.button-stack{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.photo-preview{
  display:block;
  width:100%;
  max-width:280px;
  margin-top:12px;
  border-radius:18px;
  border:2px solid var(--line);
}

.modal{
  position:fixed;
  inset:0;
  z-index:3000;
  background:rgba(10,18,34,.45);
  display:grid;
  place-items:center;
  padding:20px;
}

.modal-card{
  width:min(100%,480px);
  background:#fff;
  border-radius:24px;
  padding:22px;
  box-shadow:var(--shadow);
}

.modal-card h2{
  margin-top:0;
}

.modal-text{
  color:var(--sub);
  line-height:1.7;
}

.check-row{
  display:flex;
  align-items:center;
  gap:10px;
  margin:18px 0;
}

.check-row input{
  width:24px;
  height:24px;
}

.bottom-nav{
  position:fixed;
  left:0;
  right:0;
  bottom:0;
  z-index:200;
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:10px;
  padding:12px;
  background:rgba(255,255,255,.96);
  backdrop-filter:blur(10px);
  border-top:1px solid var(--line);
}

.bottom-nav .tab{
  min-height:58px;
  border-radius:18px;
  padding:10px 8px;
  background:var(--soft);
  color:var(--text);
  font-weight:800;
}

.bottom-nav .tab.active{
  background:var(--navy);
  color:#fff;
}

@media (max-width:720px){
  .auth-buttons{
    grid-template-columns:1fr;
  }

  .topbar{
    flex-direction:column;
    align-items:stretch;
  }

  .topbar-left h1{
    font-size:24px;
  }

  .page{
    padding:12px;
  }

  .page h2{
    font-size:24px;
  }

  .circle-record-btn{
    width:124px;
    height:124px;
    font-size:24px;
  }

  .route-control-wrap{
    grid-template-columns:1fr;
  }

  .map-filter-grid{
    grid-template-columns:1fr;
  }

  #map{
    min-height:360px;
  }

  .record-head{
    flex-direction:column;
    align-items:flex-start;
  }

  .bottom-nav{
    gap:8px;
    padding:10px;
  }

  .bottom-nav .tab{
    min-height:54px;
    font-size:14px;
  }
}

.record-photo{
  display:block;
  width:100%;
  max-width:240px;
  margin-top:10px;
  border-radius:14px;
  border:2px solid var(--line);
}

.section-tabs{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  margin-bottom:14px;
}

.section-tab{
  min-height:60px;
  padding:14px 16px;
  border-radius:20px;
  font-weight:800;
  background:var(--soft);
  color:var(--text);
}

.section-tab.active{
  background:var(--navy);
  color:#fff;
}

.record-subpage{
  display:none;
}

.record-subpage.active{
  display:block;
}

@media (max-width:720px){
  .section-tabs{
    grid-template-columns:1fr;
  }
}

#analysisChart{
  image-rendering: -webkit-optimize-contrast;
}

#map{
  width:100%;
  min-height:460px;
  height:60vh;
  background:#dfe6ee;
  border-radius:20px;
  border:2px solid #d8dde7;
  overflow:hidden;
}

@media (max-width:720px){
  #map{
    min-height:340px;
    height:52vh;
  }
}

/* ===== スマホ地図UI最適化 ===== */
@media (max-width: 720px){

  .topbar{
    padding: 18px 16px 10px;
  }

  #logoutBtn{
    width: auto !important;
    min-width: 120px;
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 16px;
  }

  .map-filter-box{
    padding: 16px !important;
    border-radius: 22px;
  }

  .map-filter-grid{
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .map-filter-box label{
    font-size: 15px;
    font-weight: 700;
  }

  .map-filter-box select{
    min-height: 52px;
    font-size: 17px;
    border-radius: 18px;
  }

  .check-row{
    margin-top: 10px;
    font-size: 16px;
    gap: 10px;
  }

  #map{
    min-height: 48vh !important;
    height: 48vh !important;
    margin-bottom: 90px;
    border-radius: 22px;
  }

  .map-toolbar{
    margin-bottom: 12px;
  }

  .map-action-btn{
    min-height: 50px;
    padding: 12px 18px;
    font-size: 16px;
    border-radius: 16px;
  }

  .sub-text{
    font-size: 15px;
    margin-bottom: 10px;
  }

  .bottom-nav{
    padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
  }
}

.record-admin-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:12px;
}

.admin-edit-btn,
.admin-delete-btn{
  min-height:44px;
  padding:10px 14px;
  border:none;
  border-radius:14px;
  font-weight:800;
}

.admin-edit-btn{
  background:#e8ebf2;
  color:#1b2333;
}

.admin-delete-btn{
  background:#c0392b;
  color:#fff;
}

.record-photo{
  display:block;
  width:100%;
  max-width:240px;
  margin-top:10px;
  border-radius:14px;
  border:2px solid #d8dde7;
}

.export-toolbar{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-bottom:16px;
}

.export-toolbar button,
.export-actions button{
  min-height:44px;
  padding:10px 14px;
  border:none;
  border-radius:14px;
  font-weight:800;
  background:#12213f;
  color:#fff;
}

.chart-wrap{
  position:relative;
  width:100%;
  min-height:360px;
  height:360px;
}

#analysisChart{
  width:100% !important;
  height:100% !important;
}

#exportJapanMap{
  width:100%;
  min-height:420px;
  height:420px;
  border-radius:20px;
  overflow:hidden;
  border:2px solid #d8dde7;
}

.export-actions{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}

@media (max-width:720px){
  .chart-wrap{
    min-height:280px;
    height:280px;
  }

  #exportJapanMap{
    min-height:320px;
    height:320px;
  }
}

.export-toolbar{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-bottom:16px;
}

.export-toolbar button,
.export-actions button{
  min-height:44px;
  padding:10px 14px;
  border:none;
  border-radius:14px;
  font-weight:800;
  background:#12213f;
  color:#fff;
}

.chart-wrap{
  position:relative;
  width:100%;
  min-height:360px;
  height:360px;
}

#analysisChart{
  width:100% !important;
  height:100% !important;
}

#exportJapanMap{
  width:100%;
  min-height:420px;
  height:420px;
  border-radius:20px;
  overflow:hidden;
  border:2px solid #d8dde7;
}

.export-actions{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}

.export-toolbar{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-bottom:4px;
}

.export-toolbar button,
.export-actions button{
  min-height:44px;
  padding:10px 14px;
  border:none;
  border-radius:14px;
  font-weight:800;
  background:#12213f;
  color:#fff;
}

.chart-wrap{
  position:relative;
  width:100%;
  min-height:360px;
  height:360px;
}

#analysisChart{
  width:100% !important;
  height:100% !important;
}

#exportJapanMap{
  width:100%;
  min-height:420px;
  height:420px;
  border-radius:20px;
  overflow:hidden;
  border:2px solid #d8dde7;
  background:#eef1f6;
}

.export-actions{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}

@media (max-width:720px){
  .chart-wrap{
    min-height:280px;
    height:280px;
  }

  #exportJapanMap{
    min-height:320px;
    height:320px;
  }
}

.export-toolbar{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-bottom:4px;
}

.export-toolbar button,
.export-actions button{
  min-height:44px;
  padding:10px 14px;
  border:none;
  border-radius:14px;
  font-weight:800;
  background:#12213f;
  color:#fff;
}

.chart-wrap{
  position:relative;
  width:100%;
  min-height:360px;
  height:360px;
}

#analysisChart{
  width:100% !important;
  height:100% !important;
}

#exportJapanMap{
  width:100%;
  min-height:420px;
  height:420px;
  border-radius:20px;
  overflow:hidden;
  border:2px solid #d8dde7;
  background:#eef1f6;
}

.export-actions{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}

@media (max-width:720px){
  .chart-wrap{
    min-height:280px;
    height:280px;
  }

  #exportJapanMap{
    min-height:320px;
    height:320px;
  }
}

.record-memo{
  margin-top:8px;
  padding:10px 12px;
  background:#f6f8fb;
  border:1px solid #d8dde7;
  border-radius:14px;
  line-height:1.6;
  font-size:14px;
  color:#1b2333;
}
@media print{
  .topbar,
  .bottom-nav,
  .export-toolbar,
  .export-actions,
  #logoutBtn{
    display:none !important;
  }

  body{
    background:#fff !important;
  }

  .page{
    padding:0 !important;
    margin:0 !important;
  }

  .card{
    box-shadow:none !important;
    border:1px solid #ddd !important;
    page-break-inside:avoid;
    margin-bottom:18px !important;
  }

  .chart-wrap{
    height:420px !important;
  }

  #exportJapanMap{
    height:520px !important;
    page-break-before:always;
  }
}

@media print{
  .export-map-card{
    break-before: page;
    page-break-before: always;
  }

  .chart-wrap{
    height:380px !important;
  }

  #exportJapanMap{
    height:620px !important;
    min-height:620px !important;
  }
}
