/* ── リセット & ベース ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:        #1A2340;
  --blue:        #1C3D8F;
  --blue-mid:    #2A52B5;
  --blue-light:  #E8EFFE;
  --bg:          #F4F7FB;
  --white:       #FFFFFF;
  --text:        #1A2340;
  --text-mid:    #5A6A8A;
  --border:      #D8E0EE;
  --amber:       #F59E0B;
  --amber-bg:    #FEF3C7;
  --green:       #10B981;
  --green-bg:    #D1FAE5;
  --red:         #EF4444;
  --red-bg:      #FEE2E2;
  --shadow:      0 1px 3px rgba(26,35,64,.08), 0 1px 2px rgba(26,35,64,.04);
  --shadow-md:   0 4px 6px rgba(26,35,64,.07), 0 2px 4px rgba(26,35,64,.06);
  --r:           8px;
  --r-sm:        4px;
}

body {
  font-family: -apple-system, 'Hiragino Sans', 'Meiryo', 'Yu Gothic UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ── サイドバー ──────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: 220px; height: 100vh;
  background: var(--navy);
  display: flex; flex-direction: column;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0,0,0,.15);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.sidebar-logo { font-size: 22px; flex-shrink: 0; }

.sidebar-title {
  color: #fff;
  font-size: 13px; font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.4;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 10px 10px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 10px; font-weight: 700;
  color: rgba(255,255,255,.3);
  text-transform: uppercase; letter-spacing: .1em;
  padding: 0 10px; margin-bottom: 6px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.65);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500;
  transition: all .15s;
}

.nav-link svg       { flex-shrink: 0; opacity: .75; }
.nav-link:hover     { color: #fff; background: rgba(255,255,255,.1); }
.nav-link:hover svg { opacity: 1; }
.nav-link.active    { color: #fff; background: var(--blue); }
.nav-link.active svg{ opacity: 1; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.9);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  margin-bottom: 8px;
}

.sidebar-username {
  color: rgba(255,255,255,.7);
  font-size: 12px; font-weight: 500;
  margin-bottom: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.btn-logout {
  display: block; width: 100%;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.7);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  cursor: pointer; font-size: 12px;
  transition: all .15s;
  font-family: inherit; text-align: center;
}

.btn-logout:hover { background: rgba(255,255,255,.18); color: #fff; }

/* ── メインコンテンツ ─────────────────────────────────────────── */
.main-content {
  margin-left: 220px;
  padding: 28px 28px 48px;
  min-height: 100vh;
}

/* ── ログイン ─────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  background: var(--white);
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-logo  { font-size: 48px; margin-bottom: 12px; }
.login-title { font-size: 20px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.login-sub   { color: var(--text-mid); font-size: 13px; margin-bottom: 32px; }
.login-card .form-group { text-align: left; }

/* ── ページヘッダー ───────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-top: 4px;
}

.page-title     { font-size: 22px; font-weight: 700; color: var(--navy); }
.page-date      { color: var(--text-mid); font-size: 13px; }
.result-count   { color: var(--text-mid); font-size: 13px; }

/* ── 統計カード ───────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--r);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border-top: 3px solid transparent;
}

.stat-card--amber { border-top-color: var(--amber); }
.stat-card--red   { border-top-color: var(--red);   }
.stat-card--green { border-top-color: var(--green);  }
.stat-card--blue  { border-top-color: var(--blue);   }

.stat-value {
  font-size: 32px; font-weight: 700;
  color: var(--navy); line-height: 1;
  margin-bottom: 6px;
}

.stat-unit  { font-size: 16px; font-weight: 500; margin-left: 2px; }
.stat-label { font-size: 13px; color: var(--text-mid); font-weight: 500; }
.stat-sub   { font-size: 11px; color: var(--text-mid); margin-top: 2px; }

/* ── セクション ───────────────────────────────────────────────── */
.section { margin-bottom: 28px; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}

.section-title       { font-size: 15px; font-weight: 600; color: var(--navy); margin-bottom: 12px; }
.section-title.alert { color: var(--red); }

/* ── カード ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.form-card   { padding: 32px; }
.filter-card { padding: 16px 20px; margin-bottom: 16px; }

/* ── テーブル ─────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-mid);
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}

.data-table tr:last-child td       { border-bottom: none; }
.data-table tbody tr:hover td      { background: #f9fafb; }
.data-table tr.row-alert td        { background: #fff7f7; }
.data-table tr.row-alert:hover td  { background: #ffecec; }
.data-table tr.row-claimed td      { background: #f0fdf4; }
.data-table tr.row-claimed:hover td { background: #dcfce7; }

/* ── バッジ ───────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}

.badge-amber { background: var(--amber-bg); color: #92400e; }
.badge-green { background: var(--green-bg); color: #065f46; }
.badge-red   { background: var(--red-bg);   color: #991b1b; }
.badge-blue  { background: var(--blue-light); color: var(--blue); }

.dept-badge {
  display: inline-block;
  padding: 2px 7px;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 3px;
  font-size: 11.5px;
}

/* ── フォーム ─────────────────────────────────────────────────── */
.form-group          { margin-bottom: 20px; }
.form-group--inline  { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}

.form-label.required::after { content: ' *'; color: var(--red); }

.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 14px; color: var(--text);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  outline: none; font-family: inherit;
}

.form-input:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(42,82,181,.12);
}

.form-select { cursor: pointer; }

.form-actions {
  display: flex; gap: 12px;
  margin-top: 28px; padding-top: 24px;
  border-top: 1px solid var(--border);
}

.filter-row {
  display: flex; align-items: flex-end;
  gap: 16px; flex-wrap: wrap;
}

.filter-row .form-group--inline { min-width: 160px; }

/* ── 写真アップロード ─────────────────────────────────────────── */
.photo-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  border: 2px dashed var(--border);
  border-radius: var(--r);
  padding: 40px 20px;
  cursor: pointer; color: var(--text-mid);
  font-size: 13px;
  transition: all .15s;
}

.photo-placeholder:hover { border-color: var(--blue-mid); color: var(--blue); }
.photo-icon  { font-size: 32px; }
.photo-hint  { font-size: 11px; opacity: .7; }

.photo-preview-img {
  max-width: 100%; max-height: 240px;
  border-radius: var(--r);
  display: block; margin-bottom: 8px;
}

/* ── ボタン ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 18px;
  border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  font-family: inherit; white-space: nowrap;
  line-height: 1.4;
}

.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-mid); border-color: var(--blue-mid); }

.btn-outline { background: transparent; color: var(--blue); border-color: var(--blue); }
.btn-outline:hover { background: var(--blue-light); }

.btn-ghost { background: transparent; color: var(--text-mid); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm    { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 11px; font-size: 14.5px; }

/* ── アラート ─────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 13px; margin-bottom: 16px;
}

.alert-error   { background: var(--red-bg);   color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--green-bg); color: #065f46; border: 1px solid #6ee7b7; }

/* ── 空・ローディング ─────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-mid); font-size: 14px;
}

.loading {
  text-align: center; padding: 60px;
  color: var(--text-mid); font-size: 14px;
}

/* ── 操作ボタングループ ───────────────────────────────────────── */
.action-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── 写真サムネイル ───────────────────────────────────────────── */
.thumb {
  width: 48px; height: 48px;
  object-fit: cover;
  border-radius: var(--r-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: opacity .15s;
  display: block;
}
.thumb:hover { opacity: .75; }

.thumb-empty {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  color: var(--text-mid);
  font-size: 20px;
  cursor: pointer;
}

/* ── 詳細モーダル ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26,35,64,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  padding: 24px;
}
.modal-card {
  background: var(--white);
  border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(26,35,64,.18);
  max-width: 480px; width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 28px 28px 20px;
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  background: transparent; border: none;
  font-size: 18px; cursor: pointer;
  color: var(--text-mid); padding: 4px 8px;
  border-radius: var(--r-sm);
  line-height: 1;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-photo {
  width: 100%; max-height: 280px;
  object-fit: contain;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  display: block;
}
.modal-no-photo {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  text-align: center;
  padding: 40px;
  color: var(--text-mid);
  margin-bottom: 20px;
  font-size: 13px;
}
.modal-title {
  font-size: 15px; font-weight: 600;
  color: var(--text); margin-bottom: 14px;
}
.modal-table {
  width: 100%; border-collapse: collapse;
  margin-bottom: 18px;
}
.modal-table th, .modal-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.modal-table th {
  color: var(--text-mid); font-weight: 500;
  width: 80px; white-space: nowrap;
}
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  flex-wrap: wrap;
}

/* ── モーダル ログ ─────────────────────────────────────────────── */
.modal-log-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-bottom: 16px;
}
.modal-log-title {
  font-size: 12px; font-weight: 600;
  color: var(--text-mid); text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: 8px;
}
.modal-logs {
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.modal-log-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 4px 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.modal-log-item:last-child { border-bottom: none; }
.modal-log-action {
  color: var(--blue); font-weight: 600;
  white-space: nowrap; padding-top: 1px;
}
.modal-log-body { color: var(--text); }
.modal-log-meta { color: var(--text-mid); font-size: 11px; }
.modal-log-empty {
  color: var(--text-mid); font-size: 12px;
  padding: 6px 0;
}
.modal-comment-form {
  display: flex; gap: 8px; align-items: center;
}
.modal-comment-form .form-input {
  flex: 1; padding: 6px 10px; font-size: 13px;
}

/* ── ユーザー検索オートコンプリート ──────────────────────────────── */
.ac-wrap { position: relative; }

.ac-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  box-shadow: 0 4px 12px rgba(26,35,64,.1);
  z-index: 200;
  max-height: 260px;
  overflow-y: auto;
}

.ac-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.focused { background: var(--blue-light); }

.ac-item-info { flex: 1; min-width: 0; }
.ac-item-name {
  font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-item-sub {
  font-size: 12px; color: var(--text-mid); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ac-badge-db  { background: var(--green-bg);  color: #065f46; }
.ac-badge-ad  { background: var(--blue-light); color: var(--blue); }

.ac-selected {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--blue-light);
  border: 1px solid var(--blue);
  border-radius: var(--r-sm);
  font-size: 14px;
}
.ac-selected-name { font-weight: 600; color: var(--navy); flex: 1; }
.ac-selected-sub  { font-size: 12px; color: var(--text-mid); }
.ac-clear {
  background: none; border: none; cursor: pointer;
  color: var(--text-mid); font-size: 16px; padding: 0 2px;
  line-height: 1;
}
.ac-clear:hover { color: var(--text); }

.ac-empty {
  padding: 12px 14px;
  font-size: 13px; color: var(--text-mid);
  text-align: center;
}

/* ── 受取者別通知履歴 ────────────────────────────────────────── */
.recipient-link {
  color: var(--blue); cursor: pointer; font-weight: 500;
  text-decoration: underline; text-underline-offset: 2px;
}
.recipient-link:hover { color: var(--blue-mid); }

.notify-history-timeline { display: flex; flex-direction: column; gap: 0; }

.notify-history-entry { padding: 14px 4px; }

.notify-history-meta {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.notify-history-date { font-size: 13px; color: var(--text-mid); font-weight: 500; }

.notify-history-detail {
  display: flex; gap: 16px; font-size: 13px; color: var(--text); margin-bottom: 4px;
}
.notify-history-actor { color: var(--text-mid); }

.notify-history-arrival { font-size: 12px; color: var(--text-mid); margin-bottom: 8px; }

.notify-history-thumb {
  max-width: 200px; max-height: 140px; border-radius: 6px;
  object-fit: cover; border: 1px solid var(--border);
}
.notify-history-nophoto { font-size: 12px; color: var(--text-mid); }

.notify-history-divider { border: none; border-top: 1px solid var(--border); margin: 0; }

/* ── テーブル横スクロール ─────────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── モバイル用要素（デスクトップでは非表示） ───────────────────── */
.mobile-topbar { display: none; }
.hamburger { display: none; }
.sidebar-backdrop { display: none; }

/* ── レスポンシブ（スマホ・タブレット） ─────────────────────────── */
@media (max-width: 768px) {
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px;
    position: fixed; top: 0; left: 0; right: 0; height: 52px;
    background: var(--navy); z-index: 150; padding: 0 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
  }
  .mobile-topbar-title { color: #fff; font-size: 15px; font-weight: 700; }
  .hamburger {
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: #fff; cursor: pointer;
    padding: 6px; margin-left: -6px;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    z-index: 190; opacity: 0; pointer-events: none; transition: opacity .25s ease;
  }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  .main-content {
    margin-left: 0;
    padding: 68px 16px 40px;
  }

  .page-title { font-size: 19px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card  { padding: 16px; }

  /* 詳細・履歴パネルは全幅表示 */
  #detail-panel, #history-panel { width: 100vw !important; }
}
