:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #ca8a04;
  --warning-light: #fef9c3;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --sidebar-width: 220px;
  --header-height: 56px;
}

* { 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-800);
  background: var(--gray-50);
  line-height: 1.5;
}

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

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-800);
  color: #fff;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  padding: 16px;
  background: var(--gray-700);
  border-bottom: 1px solid var(--gray-600);
}

.sidebar-header h1 {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

.sidebar-header p {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--gray-300);
  font-size: 13px;
  transition: background 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--gray-700);
  color: #fff;
  text-decoration: none;
}

.sidebar-nav a .icon { font-size: 16px; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--gray-700);
  font-size: 12px;
  color: var(--gray-400);
}

.sidebar-footer .staff-name { color: #fff; font-weight: 600; }

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
}

.content {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
}

/* ─── Cards ─── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-100);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.stat-card .number {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .label {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }

.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }

/* ─── Forms ─── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--gray-800);
  background: #fff;
  transition: border-color 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
}

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  font-size: 12px;
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* ─── Badges / Tags ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ─── Tabs ─── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-btn:hover { color: var(--gray-700); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Search bar ─── */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ─── Status helpers ─── */
.status-open { color: var(--danger); font-weight: 600; }
.status-pending { color: var(--warning); font-weight: 600; }
.status-done { color: var(--success); font-weight: 600; }

/* ─── Alert ─── */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #86efac; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 90%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gray-400); }
.modal-close:hover { color: var(--gray-700); }

/* ─── Login ─── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 360px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.3;
}

.login-logo p {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ─── Customer header ─── */
.customer-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.customer-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
}

.customer-header-info h2 { font-size: 18px; font-weight: 700; }
.customer-header-info .furigana { font-size: 12px; color: var(--gray-500); }
.customer-header-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--gray-600); }

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}
.empty-state .icon { font-size: 40px; margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: relative; }
  .main { margin-left: 0; }
  .layout { flex-direction: column; }
  .form-row { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* ─── Utilities ─── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--gray-500); }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.hidden { display: none; }

/* ─── Multi-select Tag Input ─── */
.ms-wrap {
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background: #fff;
  cursor: text;
  transition: border-color 0.15s;
}
.ms-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.ms-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px 2px;
  min-height: 36px;
}
.ms-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
}
.ms-tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: 0.7;
}
.ms-tag-remove:hover { opacity: 1; }
.ms-input-row {
  display: flex;
  align-items: center;
  padding: 2px 8px 6px;
  gap: 4px;
}
.ms-input {
  border: none;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  flex: 1;
  min-width: 120px;
  background: transparent;
}
.ms-dropdown {
  position: absolute;
  z-index: 300;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  max-height: 220px;
  overflow-y: auto;
  min-width: 220px;
}
.ms-dropdown-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ms-dropdown-item:hover, .ms-dropdown-item.selected { background: var(--primary-light); }
.ms-dropdown-item.selected { color: var(--primary); font-weight: 600; }
.ms-container { position: relative; }
