/* ===== Variables ===== */
:root {
  --primary:     #1e3a5f;
  --primary-mid: #2c5282;
  --accent:      #3182ce;
  --accent-light:#ebf8ff;
  --success:     #276749;
  --success-bg:  #c6f6d5;
  --warning:     #975a16;
  --warning-bg:  #fefcbf;
  --info:        #2b6cb0;
  --info-bg:     #bee3f8;
  --danger:      #c53030;
  --danger-bg:   #fed7d7;
  --gray-50:     #f7fafc;
  --gray-100:    #edf2f7;
  --gray-200:    #e2e8f0;
  --gray-400:    #a0aec0;
  --gray-500:    #718096;
  --gray-700:    #4a5568;
  --gray-900:    #1a202c;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius:      8px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', sans-serif;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--gray-100);
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.app-wrapper { display: flex; min-height: 100vh; }
.main-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.container { max-width: 1300px; margin: 0 auto; padding: 24px 20px; flex: 1; }

/* ===== Sidebar ===== */
.sidebar {
  width: 210px;
  min-height: 100vh;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  margin-top: auto;
}
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar-user-id   { font-size: 11px; color: rgba(255,255,255,.5); margin-bottom: 6px; }
.sidebar-logout {
  font-size: 11px;
  color: rgba(255,255,255,.5);
  text-decoration: none;
  transition: color .15s;
}
.sidebar-logout:hover { color: #fc8181; text-decoration: none; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.logo-icon { font-size: 22px; }
.sidebar-nav { padding: 12px 8px; flex: 1; }
.nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.4);
  padding: 16px 8px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 6px;
  color: rgba(255,255,255,.75);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  text-decoration: none;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 15px; width: 20px; text-align: center; }

/* ===== Sidebar Accordion ===== */
.nav-group { border: none; margin-bottom: 2px; }
.nav-group summary { list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 6px;
  color: rgba(255,255,255,.75);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all .15s;
}
.nav-group-title:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-group[open] .nav-group-title { color: #fff; background: rgba(255,255,255,.08); }
.nav-group-label { flex: 1; }
.nav-arrow { font-size: 10px; transition: transform .2s; }
.nav-group[open] .nav-arrow { transform: rotate(180deg); }
.nav-sub { padding: 2px 0 4px 32px; }
.nav-sub-item {
  display: block;
  padding: 6px 10px;
  border-radius: 5px;
  color: rgba(255,255,255,.6);
  font-size: 12px;
  transition: all .15s;
  text-decoration: none;
  margin-bottom: 1px;
}
.nav-sub-item:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-sub-item.active { background: var(--accent); color: #fff; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 18px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #2b6cb0; }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300, #cbd5e0); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9b2c2c; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: var(--success-bg); color: var(--success); border-left: 4px solid #48bb78; }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-left: 4px solid #fc8181; }

/* ===== Page Header ===== */
.page-title { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 20px; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header .page-title { margin-bottom: 0; }
.page-actions { display: flex; gap: 8px; }

/* ===== Summary Cards ===== */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.summary-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border-top: 4px solid transparent;
  transition: transform .15s, box-shadow .15s;
  cursor: default;
}
.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.summary-num {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 4px;
}
.summary-label { font-size: 12px; color: var(--gray-500); font-weight: 500; }
.card-success  { border-color: #48bb78; }
.card-success  .summary-num { color: var(--success); }
.card-info     { border-color: #63b3ed; }
.card-info     .summary-num { color: var(--info); }
.card-warning  { border-color: #f6e05e; }
.card-warning  .summary-num { color: var(--warning); }
.card-secondary{ border-color: var(--gray-400); }
.card-secondary .summary-num { color: var(--gray-700); }
.card-total    { border-color: var(--accent); }
.card-total    .summary-num { color: var(--accent); }

/* ===== Search Form ===== */
.search-form {
  background: #fff;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.search-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.input-text, .input-select {
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: var(--gray-900);
  transition: border-color .15s, box-shadow .15s;
}
.input-text:focus, .input-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49,130,206,.15);
}
.search-row .input-text { flex: 1; min-width: 220px; }

/* ===== Result Info ===== */
.result-info {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 10px;
  padding: 0 2px;
}

/* ===== Table ===== */
.table-wrapper {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.customer-table { width: 100%; border-collapse: collapse; }
.customer-table thead { background: var(--gray-50); }
.customer-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.customer-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  vertical-align: middle;
}
.customer-table tr:last-child td { border-bottom: none; }
.clickable-row { cursor: pointer; transition: background .1s; }
.clickable-row:hover { background: var(--accent-light); }
.no-data { text-align: center; color: var(--gray-400); padding: 48px !important; font-size: 14px; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}
.badge-success   { background: var(--success-bg); color: var(--success); }
.badge-warning   { background: var(--warning-bg); color: var(--warning); }
.badge-info      { background: var(--info-bg);    color: var(--info); }
.badge-secondary { background: var(--gray-100);   color: var(--gray-700); }
.badge-danger    { background: var(--danger-bg);  color: var(--danger); }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  gap: 4px;
  margin-top: 20px;
  justify-content: center;
  flex-wrap: wrap;
}
.page-btn {
  padding: 7px 13px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  background: #fff;
  transition: all .15s;
}
.page-btn:hover { background: var(--accent-light); border-color: var(--accent); text-decoration: none; }
.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ===== Detail Page ===== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.detail-section {
  background: #fff;
  padding: 20px 24px;
  border-radius: var(--radius);
  border: 1px solid #dde5ee;
  box-shadow: 0 2px 8px rgba(45, 74, 107, 0.08);
}
.detail-section.full-width { grid-column: 1 / -1; }
.detail-section h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .8px;
  color: #2d4a6b;
  background: #eef4fb;
  border-left: 4px solid #2b6cb0;
  border-bottom: none;
  border-radius: 4px;
  padding: 8px 12px;
  margin: -6px -8px 16px;
}
/* ページ背景をカードとコントラストさせる（白カードが浮き上がって見えるように） */
body {
  background: #e3eaf3;
}
.detail-list {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px 12px;
  align-items: start;
}
.detail-list dt { font-size: 12px; color: var(--gray-500); padding-top: 1px; }
.detail-list dd { font-size: 13px; font-weight: 500; }
.record-text {
  white-space: pre-wrap;
  word-break: break-all;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.7;
  background: var(--gray-50);
  padding: 14px 16px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
}
.summary-text, .note-text { font-size: 13px; line-height: 1.7; }
.detail-meta {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 8px;
  display: flex;
  gap: 20px;
}

/* ===== Forms ===== */
.customer-form {
  background: #fff;
  padding: 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 28px;
  margin-bottom: 28px;
}
.form-section h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-100);
  padding-bottom: 8px;
  margin-bottom: 14px;
}
.form-section.full-width { grid-column: 1 / -1; margin-bottom: 16px; }
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 5px;
}
.form-group .input-text,
.form-group .input-select,
.form-group .input-textarea { width: 100%; }
.input-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  line-height: 1.6;
  transition: border-color .15s, box-shadow .15s;
}
.input-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49,130,206,.15);
}
.required { color: var(--danger); }
.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--gray-400);
  font-size: 12px;
  margin-top: 48px;
}

/* ===== Error Page ===== */
.error-page { text-align: center; padding: 100px 20px; }
.error-page h1 { font-size: 36px; color: var(--danger); margin-bottom: 12px; }
.error-message { font-size: 16px; color: var(--gray-500); margin-bottom: 28px; }

/* ===== Uploads ===== */
.upload-list { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 12px; }
.upload-item { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; padding: 10px; max-width: 160px; }
.upload-thumb { width: 120px; height: 90px; object-fit: cover; border-radius: 4px; }
.upload-link { font-size: 13px; color: var(--primary); word-break: break-all; }
.upload-name { font-size: 11px; color: var(--gray-500); word-break: break-all; text-align: center; }
.upload-form { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.input-file { font-size: 13px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.text-muted { color: var(--gray-400); font-size: 13px; }

/* ===== Drop Zone ===== */
.drop-zone { border: 2px dashed var(--gray-300); border-radius: 10px; padding: 32px 20px; text-align: center; cursor: pointer; transition: border-color .2s, background .2s; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100px; }
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--primary); background: #f0f4ff; }
.drop-zone-label { color: var(--gray-400); font-size: 14px; pointer-events: none; }
.drop-zone-label small { font-size: 12px; }
.drop-zone-input { display: none; }
.drop-zone-preview { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; font-size: 14px; }

/* ===== Gallery ===== */
.gallery-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.gallery-label { font-weight: 600; font-size: 13px; color: var(--gray-700); }
.gallery-hint { font-size: 11px; color: var(--gray-400); }
.gallery-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.gallery-item { position: relative; border-radius: 8px; overflow: hidden; background: var(--gray-100); cursor: grab; box-shadow: 0 1px 4px rgba(0,0,0,.1); transition: box-shadow .2s; }
.gallery-item:active { cursor: grabbing; }
.gallery-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.gallery-item a { display: block; }
.gallery-thumb { width: 100%; height: 120px; object-fit: cover; display: block; }
.cover-badge { position: absolute; top: 6px; left: 6px; background: var(--primary); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px; }
.gallery-item-actions { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px; background: rgba(0,0,0,.03); }
.btn-cover { background: none; border: none; font-size: 16px; cursor: pointer; opacity: .4; transition: opacity .2s, transform .2s; padding: 2px; }
.btn-cover:hover, .btn-cover.is-cover { opacity: 1; transform: scale(1.2); }
.btn-delete-icon { background: none; border: none; color: var(--danger); font-size: 14px; cursor: pointer; font-weight: 700; padding: 2px 4px; opacity: .6; }
.btn-delete-icon:hover { opacity: 1; }

/* ===== List Thumbnail ===== */
.list-thumb { width: 52px; height: 40px; object-fit: cover; border-radius: 4px; display: block; }
.list-thumb-empty { width: 52px; height: 40px; background: var(--gray-100); border-radius: 4px; }

/* ===== Cover Photo ===== */
.cover-photo-wrap { margin-bottom: 20px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-md); background: #000; max-width: 33%; }
.cover-photo { width: 100%; max-height: 200px; object-fit: contain; display: block; }
