/* ===== Reset ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  background: #f5f6fa;
  color: #1f2937;
  line-height: 1.6;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Topbar ===== */
.topbar {
  background: #1f2937;
  color: #fff;
  border-bottom: 3px solid #2563eb;
}
body.ws-personal .topbar { border-bottom-color: #7c3aed; }
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand {
  color: #fff;
  font-weight: bold;
  font-size: 1.1rem;
  text-decoration: none;
}
.nav { display: flex; gap: 1rem; flex: 1; }
.nav a { color: #d1d5db; }
.nav a:hover { color: #fff; text-decoration: none; }
.admin-link { color: #fbbf24 !important; }
.topbar-right { display: flex; align-items: center; gap: 0.8rem; }
.user-chip {
  background: rgba(255,255,255,0.1);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
}
.btn-link {
  background: none;
  border: none;
  color: #d1d5db;
  cursor: pointer;
  font: inherit;
}
.btn-link:hover { color: #fff; }
.inline { display: inline; }

/* WS switcher */
.ws-switcher { display: flex; gap: 0.3rem; }
.ws-pill {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(255,255,255,0.1);
  color: #d1d5db;
  text-decoration: none;
}
.ws-pill.active.ws-metasc { background: #2563eb; color: #fff; }
.ws-pill.active.ws-personal { background: #7c3aed; color: #fff; }
.ws-pill.ws-metasc { color: #93c5fd; }
.ws-pill.ws-personal { color: #c4b5fd; }

/* ===== Main ===== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}
h1 { margin-top: 0; }
.muted { color: #6b7280; }

/* ===== Flash ===== */
.flashes { margin-bottom: 1rem; }
.flash {
  padding: 0.7rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}
.flash-info { background: #dbeafe; color: #1e40af; }
.flash-success { background: #d1fae5; color: #065f46; }
.flash-error { background: #fee2e2; color: #991b1b; }
.flash-warning { background: #fef3c7; color: #92400e; }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #1f2937;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-success { background: #059669; color: #fff; border-color: #059669; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.btn-block { display: block; width: 100%; }

/* ===== Forms ===== */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form label { display: block; }
.form label > span {
  display: block;
  font-size: 0.85rem;
  color: #4b5563;
  margin-bottom: 0.3rem;
  font-weight: 500;
}
.form input[type=text],
.form input[type=email],
.form input[type=password],
.form input[type=datetime-local],
.form input[type=date],
.form select,
.form textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font: inherit;
  background: #fff;
  font-size: 16px; /* iOS zoom 抑止 */
}
.form textarea { min-height: 6em; resize: vertical; }
.form .form-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ===== Cards ===== */
.auth-card {
  max-width: 400px;
  margin: 3rem auto;
  background: #fff;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: #fff;
  padding: 1.2rem;
  border-radius: 10px;
  border-top: 4px solid #2563eb;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.stat-card.ws-personal { border-top-color: #7c3aed; }
.stat-card h3 { margin-top: 0; }
.stat-card ul { list-style: none; padding: 0; }
.stat-card ul li { padding: 0.3rem 0; border-bottom: 1px dotted #e5e7eb; }
.stat-card ul li strong { float: right; font-size: 1.2rem; }
.stat-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* ===== Tables ===== */
.data-table {
  width: 100%;
  background: #fff;
  border-collapse: collapse;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.data-table th, .data-table td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}
.data-table th { background: #f9fafb; font-size: 0.85rem; color: #4b5563; }
.data-table tr:hover { background: #f9fafb; }

/* ===== Big button (mobile staff) ===== */
.big-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  background: #2563eb;
  color: #fff;
  border-radius: 12px;
  font-size: 1.2rem;
  font-weight: 600;
  margin: 1.5rem 0;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}
.big-button:hover { background: #1d4ed8; color: #fff; text-decoration: none; }
.big-button-icon { font-size: 1.5rem; }

/* ===== Material list ===== */
.material-list { list-style: none; padding: 0; }
.material-list li { background: #fff; margin-bottom: 0.5rem; border-radius: 8px; overflow: hidden; }
.material-list a { display: block; padding: 0.8rem 1rem; color: inherit; text-decoration: none; }
.material-list a:hover { background: #f9fafb; }
.material-meta { font-size: 0.8rem; color: #6b7280; margin-bottom: 0.3rem; }
.material-body { color: #1f2937; }

/* ===== Material form ===== */
.hint-cards { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.hint-card {
  background: #fef3c7;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  border-left: 4px solid #f59e0b;
  font-size: 0.95rem;
}
.checkbox-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.8rem;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}
.checkbox-group input[type=checkbox] { margin: 0; }
.radio-group { display: flex; flex-direction: column; gap: 0.4rem; }
.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.8rem;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
}
.radio-group input[type=radio]:checked + span { font-weight: 600; }

/* ===== Risk Badge ===== */
.risk-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.risk-green { background: #d1fae5; color: #065f46; }
.risk-yellow { background: #fef3c7; color: #92400e; }
.risk-red { background: #fee2e2; color: #991b1b; }

.risk-panel {
  background: #fff;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.risk-panel ul { padding-left: 1.2rem; margin: 0.5rem 0; }
.risk-panel .hit-block { color: #991b1b; }
.risk-panel .hit-warn { color: #92400e; }

/* ===== Draft Review ===== */
.draft-review-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1rem;
}
@media (max-width: 768px) {
  .draft-review-layout { grid-template-columns: 1fr; }
}
.draft-edit-pane { background: #fff; padding: 1.5rem; border-radius: 10px; }
.draft-side-pane { display: flex; flex-direction: column; gap: 1rem; }
.draft-meta {
  background: #fff;
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
}
.draft-meta dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.7rem; margin: 0; }
.draft-meta dt { color: #6b7280; }
.draft-action-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* ===== AI Generate ===== */
.candidate-card {
  background: #fff;
  padding: 1.2rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border-left: 4px solid #2563eb;
}
.candidate-card.risk-red { border-left-color: #dc2626; }
.candidate-card.risk-yellow { border-left-color: #f59e0b; }
.candidate-card.risk-green { border-left-color: #059669; }
.candidate-body { white-space: pre-wrap; font-size: 0.95rem; padding: 0.8rem; background: #f9fafb; border-radius: 6px; margin: 0.5rem 0; }
.candidate-actions { display: flex; gap: 0.5rem; }

/* ===== Calendar ===== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: #e5e7eb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}
.calendar-cell {
  background: #fff;
  min-height: 80px;
  padding: 0.4rem;
  font-size: 0.85rem;
}
.calendar-cell.today { background: #fef3c7; }
.calendar-cell.weekend { background: #f9fafb; }
.calendar-cell .day-num { font-weight: 600; color: #4b5563; }
.calendar-cell .day-items { display: flex; flex-direction: column; gap: 2px; margin-top: 0.3rem; }
.calendar-cell .day-item {
  background: #2563eb;
  color: #fff;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.75rem;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calendar-cell .day-item.ws-personal { background: #7c3aed; }
.calendar-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 600;
  padding: 0.5rem 0;
}
.calendar-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

/* ===== Error page ===== */
.error-page { text-align: center; padding: 3rem 1rem; }
.error-page h1 { font-size: 4rem; margin: 0; color: #4b5563; }

/* ===== Mobile ===== */
@media (max-width: 640px) {
  .main { padding: 1rem 0.7rem; }
  .topbar-inner { padding: 0.5rem 0.7rem; gap: 0.5rem; }
  .nav { flex: 1 0 100%; order: 99; font-size: 0.9rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .big-button { font-size: 1.1rem; padding: 1.2rem; }
  .data-table { font-size: 0.85rem; }
  .data-table th, .data-table td { padding: 0.5rem 0.6rem; }
}
