/* ===========================
   Reset & Base
   =========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Noto Sans JP', sans-serif;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}
textarea { resize: vertical; }

/* ===========================
   Layout
   =========================== */
.page { min-height: 100vh; }
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===========================
   Login
   =========================== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a3a5c 0%, #2563a8 50%, #1a3a5c 100%);
  padding: 20px;
}
.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo i {
  font-size: 48px;
  color: #2563a8;
}
.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a3a5c;
  margin-top: 8px;
}
.login-subtitle {
  color: #6b7280;
  font-size: 0.85rem;
  margin-top: 4px;
}
.demo-accounts {
  background: #f0f4ff;
  border: 1px solid #c7d7f8;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
}
.demo-title {
  font-weight: 600;
  color: #2563a8;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.demo-table {
  width: 100%;
  font-size: 0.82rem;
  border-collapse: collapse;
}
.demo-table th {
  text-align: left;
  color: #6b7280;
  padding: 2px 6px;
  font-weight: 500;
}
.demo-table td {
  padding: 3px 6px;
}
.login-form .form-group {
  margin-bottom: 16px;
}
.login-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}
.login-form input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}
.login-form input:focus {
  outline: none;
  border-color: #2563a8;
  box-shadow: 0 0 0 3px rgba(37,99,168,0.15);
}
.password-wrapper {
  position: relative;
}
.password-wrapper input {
  padding-right: 44px;
}
.btn-toggle-pw {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #6b7280;
}
.btn-login {
  margin-top: 8px;
  height: 48px;
  font-size: 1rem;
}

/* ===========================
   Sidebar
   =========================== */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: #1a3a5c;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-divider span,
.sidebar.collapsed .sidebar-nav li a span,
.sidebar.collapsed .user-detail,
.sidebar.collapsed .btn-logout span {
  display: none;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header i.fa-users-gear {
  font-size: 22px;
  color: #60a5fa;
  flex-shrink: 0;
}
.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}
.btn-sidebar-toggle {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  font-size: 1rem;
}
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: #cbd5e1;
  transition: background 0.15s, color 0.15s;
  border-radius: 0;
  font-size: 0.92rem;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: rgba(96,165,250,0.15);
  color: #60a5fa;
}
.sidebar-nav li a i {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.nav-divider {
  padding: 8px 16px 4px;
}
.nav-divider span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 600;
}
.admin-only { /* shown/hidden via JS */ }
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.user-avatar i {
  font-size: 28px;
  color: #60a5fa;
}
.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2e8f0;
}
.user-role {
  font-size: 0.72rem;
  color: #94a3b8;
}
.btn-logout {
  width: 100%;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  transition: background 0.15s;
}
.btn-logout:hover { background: rgba(239,68,68,0.25); }

/* ===========================
   Main Content
   =========================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.btn-mobile-menu {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #6b7280;
}
.breadcrumb {
  flex: 1;
  font-size: 0.9rem;
  color: #6b7280;
  font-weight: 500;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.current-user-badge {
  font-size: 0.8rem;
  background: #eff6ff;
  color: #2563a8;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}
.content-page {
  padding: 24px;
  flex: 1;
}

/* ===========================
   Page Header
   =========================== */
.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1a3a5c;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===========================
   Buttons
   =========================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: #2563a8; color: #fff; border-color: #2563a8; }
.btn-primary:hover { background: #1e4f8c; border-color: #1e4f8c; }
.btn-secondary { background: #fff; color: #374151; border-color: #d1d5db; }
.btn-secondary:hover { background: #f9fafb; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: #d97706; color: #fff; border-color: #d97706; }
.btn-warning:hover { background: #b45309; }
.btn-success { background: #059669; color: #fff; border-color: #059669; }
.btn-success:hover { background: #047857; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-xs { padding: 3px 8px; font-size: 0.75rem; }

/* ===========================
   Cards & Panels
   =========================== */
.card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8faff;
  flex-wrap: wrap;
  gap: 8px;
}
.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #1a3a5c;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-header-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.card-body { padding: 20px; }

.panel {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e5e7eb;
}
.panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #1a3a5c;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===========================
   Dashboard
   =========================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #fff;
}
.stat-icon.blue { background: #2563a8; }
.stat-icon.green { background: #059669; }
.stat-icon.orange { background: #d97706; }
.stat-icon.purple { background: #7c3aed; }
.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1a3a5c;
  line-height: 1;
}
.stat-label {
  font-size: 0.78rem;
  color: #6b7280;
  margin-top: 4px;
}
.dashboard-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 768px) {
  .dashboard-panels { grid-template-columns: 1fr; }
}

/* ===========================
   Search Panel
   =========================== */
.search-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.search-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.search-row:last-child { margin-bottom: 0; }
.search-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 160px;
}
.search-field label {
  font-size: 0.8rem;
  color: #6b7280;
  font-weight: 500;
}
.search-field input,
.search-field select {
  padding: 7px 10px;
  border: 1.5px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.88rem;
}
.search-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

/* ===========================
   List Meta
   =========================== */
.list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: #6b7280;
}
.sort-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sort-controls select {
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.82rem;
}

/* ===========================
   Table
   =========================== */
.table-wrapper {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  overflow-x: auto;
  margin-bottom: 16px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.data-table thead {
  background: #f8faff;
}
.data-table th {
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8faff; }
.data-table tbody tr.inactive { opacity: 0.5; }
.action-btns {
  display: flex;
  gap: 4px;
  white-space: nowrap;
}

/* ===========================
   Badges & Status
   =========================== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-general { background: #dbeafe; color: #1e40af; }
.badge-viewer { background: #f3f4f6; color: #6b7280; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.badge-new { background: #dbeafe; color: #1e40af; }
.badge-contact { background: #ede9fe; color: #5b21b6; }
.badge-individual { background: #fce7f3; color: #9d174d; }
.badge-corporate { background: #dbeafe; color: #1e40af; }

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 600;
}
.status-新規 { background: #dbeafe; color: #1e40af; }
.status-商談中 { background: #ede9fe; color: #5b21b6; }
.status-受注 { background: #d1fae5; color: #065f46; }
.status-失注 { background: #fee2e2; color: #991b1b; }
.status-休眠 { background: #f3f4f6; color: #6b7280; }
.status-順調 { background: #ccfbf1; color: #065f46; }

.contact-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.76rem;
  font-weight: 600;
}
.ct-電話 { background: #dbeafe; color: #1e40af; }
.ct-メール { background: #fce7f3; color: #9d174d; }
.ct-訪問 { background: #d1fae5; color: #065f46; }
.ct-来店 { background: #ccfbf1; color: #0f766e; }
.ct-問い合わせ { background: #fef3c7; color: #92400e; }
.ct-商談 { background: #ede9fe; color: #5b21b6; }
.ct-クレーム { background: #fee2e2; color: #991b1b; }
.ct-その他 { background: #f3f4f6; color: #6b7280; }

/* ===========================
   Pagination
   =========================== */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 0;
}
.pagination button {
  min-width: 36px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  color: #374151;
  transition: all 0.15s;
}
.pagination button:hover { background: #f0f4ff; border-color: #2563a8; color: #2563a8; }
.pagination button.active { background: #2563a8; border-color: #2563a8; color: #fff; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .pages-info { font-size: 0.8rem; color: #6b7280; margin: 0 8px; }

/* ===========================
   Detail Layout
   =========================== */
.detail-layout { }
.detail-main { }

.detail-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px 24px;
}
.detail-field { }
.detail-field .field-label {
  font-size: 0.76rem;
  color: #6b7280;
  font-weight: 500;
  margin-bottom: 2px;
}
.detail-field .field-value {
  font-size: 0.9rem;
  color: #1a3a5c;
  font-weight: 500;
}
.detail-field.full { grid-column: 1 / -1; }

/* ===========================
   History List
   =========================== */
.history-item {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.1s;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: #f8faff; }
.history-timeline {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 40px;
  flex-shrink: 0;
}
.history-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e0e7ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: #4338ca;
  flex-shrink: 0;
}
.history-line {
  width: 2px;
  flex: 1;
  background: #e5e7eb;
  margin-top: 6px;
}
.history-content { flex: 1; min-width: 0; }
.history-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.history-datetime {
  font-size: 0.78rem;
  color: #6b7280;
}
.history-staff {
  font-size: 0.78rem;
  color: #6b7280;
}
.history-subject {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a3a5c;
  margin-bottom: 4px;
  cursor: pointer;
}
.history-subject:hover { color: #2563a8; text-decoration: underline; }
.history-detail-preview {
  font-size: 0.84rem;
  color: #6b7280;
  white-space: pre-wrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.history-actions { margin-top: 8px; display: flex; gap: 4px; }
.history-next-action {
  font-size: 0.75rem;
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 4px;
  display: inline-block;
}

/* ===========================
   Forms
   =========================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
}
.form-group.required label::after {
  content: ' *';
  color: #dc2626;
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
  background: #fff;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2563a8;
  box-shadow: 0 0 0 3px rgba(37,99,168,0.1);
}
.form-group input.error,
.form-group select.error,
.form-group textarea.error {
  border-color: #dc2626;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px 20px;
}
.form-group-full { grid-column: 1 / -1; }
.form-section {
  margin-bottom: 20px;
}
.form-section h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: #2563a8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid #dbeafe;
}
.char-count {
  font-size: 0.72rem;
  color: #9ca3af;
  text-align: right;
}
.input-sm {
  padding: 5px 10px;
  border: 1.5px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.82rem;
}

/* ===========================
   Modal
   =========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  position: relative;
}
.modal-lg { max-width: 760px; }
.modal-sm { max-width: 380px; }
.modal-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8faff;
  position: sticky;
  top: 0;
  z-index: 1;
}
.modal-header h3 {
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  color: #1a3a5c;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #6b7280;
  padding: 4px;
}
.modal-close:hover { color: #374151; }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

/* ===========================
   Alerts
   =========================== */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.86rem;
  margin-bottom: 12px;
}
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ===========================
   Toast
   =========================== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 8px;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: slideIn 0.3s ease;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-info { background: #2563a8; }
.toast-warning { background: #d97706; }
@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===========================
   CSV Import
   =========================== */
.import-guide {
  background: #f0f4ff;
  border: 1px solid #c7d7f8;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.import-guide h4 {
  color: #1e40af;
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.import-guide ul {
  list-style: disc;
  padding-left: 20px;
  font-size: 0.84rem;
  color: #374151;
}
.import-guide ul li { margin-bottom: 4px; }

/* ===========================
   Master Tabs
   =========================== */
.master-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid #e5e7eb;
}
.tab-btn {
  padding: 9px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.88rem;
  color: #6b7280;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-weight: 500;
  transition: all 0.15s;
}
.tab-btn.active {
  color: #2563a8;
  border-bottom-color: #2563a8;
  font-weight: 700;
}

/* ===========================
   Tags
   =========================== */
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag {
  display: inline-block;
  padding: 2px 8px;
  background: #e0e7ff;
  color: #4338ca;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
}

/* ===========================
   Empty State
   =========================== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #6b7280;
}
.empty-state i {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
  color: #d1d5db;
}
.empty-state p { font-size: 0.9rem; }

/* ===========================
   Loading
   =========================== */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: #2563a8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -240px;
    z-index: 100;
    transition: left 0.25s;
  }
  .sidebar.open { left: 0; }
  .btn-mobile-menu { display: block; }
  .content-page { padding: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header-actions { width: 100%; }
  .search-row { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-overlay { padding: 8px; }
  .modal { max-height: 96vh; }
}

/* ===========================
   History Detail Modal
   =========================== */
.history-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
  margin-bottom: 16px;
}
.history-detail-grid .hd-field { }
.hd-field .hd-label {
  font-size: 0.76rem;
  color: #6b7280;
  margin-bottom: 2px;
}
.hd-field .hd-value {
  font-size: 0.9rem;
  color: #1a3a5c;
  font-weight: 500;
}
.history-detail-body {
  background: #f8faff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 14px;
  font-size: 0.9rem;
  white-space: pre-wrap;
  line-height: 1.7;
  max-height: 300px;
  overflow-y: auto;
}

/* ===========================
   Misc
   =========================== */
.text-muted { color: #6b7280; font-size: 0.82rem; }
.text-danger { color: #dc2626; }
.text-success { color: #059669; }
.nowrap { white-space: nowrap; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
  display: inline-block;
}
hr.divider {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 16px 0;
}
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 0.1s;
}
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: #f8faff; }
.recent-item-name { font-size: 0.88rem; font-weight: 600; color: #1a3a5c; }
.recent-item-meta { font-size: 0.76rem; color: #6b7280; }

/* ===========================
   Company Link (顧客一覧)
   =========================== */
.company-link {
  color: #2563a8;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  transition: color 0.15s;
}
.company-link:hover { color: #1a3a5c; text-decoration: underline; }

/* ===========================
   Contacts Grid（担当者一覧）
   =========================== */
.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  padding: 16px;
}

/* 担当者カード */
.contact-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.contact-card:hover {
  box-shadow: 0 4px 16px rgba(37,99,168,0.10);
  border-color: #93c5fd;
}
.contact-card-primary {
  border-color: #2563a8;
  background: #f0f7ff;
}

.contact-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid #f3f4f6;
}
.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #dbeafe;
  color: #2563a8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.contact-card-primary .contact-avatar {
  background: #2563a8;
  color: #fff;
}
.contact-name-block { flex: 1; min-width: 0; }
.contact-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1a3a5c;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.76rem;
  color: #6b7280;
  margin-bottom: 4px;
}
.contact-title-badge {
  background: #e0e7ff;
  color: #4338ca;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 500;
}
.badge-primary-contact {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #2563a8;
  color: #fff;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}
.contact-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  margin-top: 2px;
}

.contact-card-body {
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.contact-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.83rem;
  color: #2563a8;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-link i { font-size: 0.8em; color: #6b7280; flex-shrink: 0; }
.contact-link:hover { text-decoration: underline; }
.contact-notes {
  font-size: 0.78rem;
  color: #6b7280;
  display: flex;
  align-items: flex-start;
  gap: 5px;
}
.contact-notes i { margin-top: 2px; flex-shrink: 0; }

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .contacts-grid { grid-template-columns: 1fr; padding: 10px; }
}
