@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===== Design Tokens ===== */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --primary-text: #ffffff;

  --success: #10b981;
  --success-light: #d1fae5;
  --success-text: #065f46;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --danger-text: #991b1b;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --warning-text: #92400e;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --info-text: #1e40af;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-active-bg: #6366f1;
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --sidebar-width: 240px;

  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.2s ease;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }

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

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-brand__logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
}

.sidebar-brand__icon {
  width: 2rem; height: 2rem;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-brand__name {
  font-size: 1.0625rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.sidebar-nav__label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 0.75rem 0.5rem 0.375rem;
  margin-top: 0.5rem;
}

.sidebar-nav__link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5625rem 0.75rem;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.sidebar-nav__link:hover {
  background: var(--sidebar-hover-bg);
  color: #ffffff;
}

.sidebar-nav__link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}

.sidebar-nav__icon {
  width: 1.125rem; height: 1.125rem;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-nav__badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.25rem;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
}

.sidebar-user {
  padding: 0.875rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

.sidebar-user__avatar {
  width: 2rem; height: 2rem;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user__info { flex: 1; min-width: 0; }
.sidebar-user__name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user__role { font-size: 0.75rem; color: var(--sidebar-text); }

.sidebar-user__logout {
  flex-shrink: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--sidebar-text);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
  font-size: 0.8125rem;
}
.sidebar-user__logout:hover { color: #fff; }

/* ===== Main Content ===== */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Topbar ===== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 3.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.topbar__actions { display: flex; align-items: center; gap: 0.5rem; }

/* ===== Page Content ===== */
.main {
  flex: 1;
  padding: 2rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
  transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow); }

.card-header {
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card-body { padding: 1.5rem; }

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  background: var(--surface-hover);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Clickable card */
.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition);
}
.card-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: inherit;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1.125rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: var(--font);
  line-height: 1.5;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  box-shadow: 0 4px 12px rgb(99 102 241 / .35);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: #cbd5e1;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover {
  background: #059669;
  border-color: #059669;
  color: #fff;
  box-shadow: 0 4px 12px rgb(16 185 129 / .35);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
  box-shadow: 0 4px 12px rgb(239 68 68 / .35);
}

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

.btn-info {
  background: var(--info);
  color: #fff;
  border-color: var(--info);
}
.btn-info:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.btn-outline-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline-secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger-light);
  color: var(--danger-text);
}

.btn-outline-success {
  background: transparent;
  color: var(--success);
  border-color: var(--success);
}
.btn-outline-success:hover {
  background: var(--success-light);
  color: var(--success-text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--border-light);
  color: var(--text);
}

.btn-sm { padding: 0.3125rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.6875rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; }
.w-100 { width: 100%; }

.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

label { font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); }

/* 日付+時刻の分割入力ペア */
.dt-pair {
  display: flex;
  gap: 0.5rem;
}
.dt-pair input[type="date"] { flex: 1 1 0; min-width: 0; }
.dt-pair input[type="time"] { flex: 0 0 auto; width: 7.5rem; }

.form-control, .form-select, input[type="text"], input[type="email"],
input[type="password"], input[type="number"], input[type="date"],
input[type="datetime-local"], input[type="time"], input[type="search"],
select, textarea {
  width: 100%;
  padding: 0.5625rem 0.875rem;
  font-size: 0.9375rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  line-height: 1.5;
}

.form-control:focus, .form-select:focus, input[type="text"]:focus,
input[type="email"]:focus, input[type="password"]:focus, input[type="number"]:focus,
input[type="date"]:focus, input[type="datetime-local"]:focus, input[type="search"]:focus,
select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(99 102 241 / .12);
}

.form-select, select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  background-size: 1.125rem;
  padding-right: 2.25rem;
}

textarea { resize: vertical; min-height: 6rem; }

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
small { font-size: 0.8125rem; color: var(--text-muted); }

.form-error {
  font-size: 0.8125rem;
  color: var(--danger);
  margin-top: 0.25rem;
}

.form-text { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.25rem; display: block; }
.form-text.text-muted { color: var(--text-muted); }

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-check-input { width: 1rem; height: 1rem; accent-color: var(--primary); }
.form-check-label { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0; }

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 1rem; height: 1rem;
  accent-color: var(--primary);
}

/* ===== Alerts / Messages ===== */
.messages { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.alert-success { background: var(--success-light); color: var(--success-text); border-color: #a7f3d0; }
.alert-error   { background: var(--danger-light);  color: var(--danger-text);  border-color: #fca5a5; }
.alert-warning { background: var(--warning-light); color: var(--warning-text); border-color: #fde68a; }
.alert-info    { background: var(--info-light);    color: var(--info-text);    border-color: #93c5fd; }
.alert-danger  { background: var(--danger-light);  color: var(--danger-text);  border-color: #fca5a5; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge.bg-primary, .badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge.bg-success, .badge-success { background: var(--success-light); color: var(--success-text); }
.badge.bg-danger,  .badge-danger  { background: var(--danger-light);  color: var(--danger-text);  }
.badge.bg-warning, .badge-warning { background: var(--warning-light); color: var(--warning-text); }
.badge.bg-info,    .badge-info    { background: var(--info-light);    color: var(--info-text);    }
.badge.bg-secondary, .badge-secondary { background: #f1f5f9; color: #475569; }
.badge.text-dark   { color: var(--warning-text); }
.badge.bg-light    { background: #f1f5f9; color: #475569; }
.badge.text-white  { color: #fff; }
.badge.bg-dark     { background: #1e293b; color: #fff; }

/* ===== Grid / Layout helpers ===== */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0;
}

.col { flex: 1; min-width: 0; }
.col-md-1  { flex: 0 0 calc(8.333% - 0.875rem); }
.col-md-2  { flex: 0 0 calc(16.666% - 0.875rem); }
.col-md-3  { flex: 0 0 calc(25% - 0.75rem); }
.col-md-4  { flex: 0 0 calc(33.333% - 0.75rem); }
.col-md-5  { flex: 0 0 calc(41.666% - 0.875rem); }
.col-md-6  { flex: 0 0 calc(50% - 0.5rem); }
.col-md-7  { flex: 0 0 calc(58.333% - 0.875rem); }
.col-md-8  { flex: 0 0 calc(66.666% - 0.875rem); }
.col-md-9  { flex: 0 0 calc(75% - 0.875rem); }
.col-md-10 { flex: 0 0 calc(83.333% - 0.875rem); }
.col-md-12 { flex: 0 0 100%; }

.g-4 { gap: 1.5rem; }
.g-2 { gap: 0.5rem; }

.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* ===== Dashboard ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.dashboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dashboard-list li + li { border-top: 1px solid var(--border-light); }

.dashboard-item {
  position: relative;
  padding: 0.875rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: background var(--transition);
  cursor: pointer;
}
.dashboard-item:hover { background: var(--surface-hover); }

/* ストレッチリンク: メインリンクの ::after でブロック全体をクリッカブルに */
.dashboard-item-link::after {
  content: '';
  position: absolute;
  inset: 0;
}

.dashboard-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.dashboard-item-header a {
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}
.dashboard-item-header a:hover { color: var(--primary); }

.dashboard-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dashboard-item-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.dashboard-item-unread {
  border-left: 3px solid var(--primary);
  padding-left: calc(1.5rem - 3px);
}

.dashboard-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ===== Schedule Calendar ===== */
.cal-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.cal-nav-btn {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}
.cal-nav-btn:hover { background: var(--bg); color: var(--text); }

.cal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  text-align: center;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
}

.cal-weekday-label {
  padding: 0.5rem 0;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.cal-weekday-label--sun { color: #ef4444; }
.cal-weekday-label--sat { color: #3b82f6; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-day {
  min-height: 110px;
  padding: 0.375rem;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition);
  overflow: hidden;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day:nth-last-child(-n+7) { border-bottom: none; }
.cal-day:hover { background: var(--bg); }

.cal-day--other { background: #fafbfc; }
.cal-day--other:hover { background: #f4f6f8; }
.cal-day--other .cal-day-num { color: var(--text-muted); opacity: 0.6; }

.cal-day--sun .cal-day-num:not(.cal-day-num--today) { color: #ef4444; }
.cal-day--sat .cal-day-num:not(.cal-day-num--today) { color: #3b82f6; }

.cal-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 50%;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.cal-day-num--today {
  background: var(--primary);
  color: #fff !important;
  font-weight: 700;
}

.cal-pills {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-pill {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
  line-height: 1.45;
  cursor: pointer;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity var(--transition);
}
.cal-pill:hover { opacity: 0.82; }

.cal-pill-time {
  flex-shrink: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.cal-pill-title {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.cal-pill--more {
  background: var(--bg) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border);
  cursor: default;
  font-size: 0.68rem;
  justify-content: center;
}

@media (max-width: 600px) {
  .cal-day { min-height: 72px; }
  .cal-pill-time { display: none; }
}

/* ── ビュー切り替えスイッチ ── */
.cal-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cal-view-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cal-view-btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}
.cal-view-btn:last-child { border-right: none; }
.cal-view-btn:hover { background: var(--bg); color: var(--text); }
.cal-view-btn--active { background: var(--primary); color: #fff; }
.cal-view-btn--active:hover { background: var(--primary-dark); color: #fff; }

/* ── 週・日ビュー共通 ── */
.cal-time-header {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.cal-time-gutter-head {
  width: 52px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-light);
}

.cal-time-col-head {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.25rem;
  cursor: pointer;
  border-right: 1px solid var(--border-light);
  transition: background var(--transition);
  gap: 0.25rem;
}
.cal-time-col-head:last-child { border-right: none; }
.cal-time-col-head:hover { background: var(--bg); }
.cal-time-col-head--single { cursor: default; flex: 1; }
.cal-time-col-head--single:hover { background: transparent; }
.cal-time-col-head--today { background: var(--primary-light); }
.cal-time-col-head--sun .cal-col-dow { color: #ef4444; }
.cal-time-col-head--sat .cal-col-dow { color: #3b82f6; }

.cal-col-dow {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}
.cal-col-date {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
}
.cal-col-date--today {
  background: var(--primary);
  color: #fff !important;
  font-weight: 700;
}

/* ── 時間グリッド本体 ── */
.cal-time-scroll {
  overflow-y: auto;
  max-height: calc(100vh - 220px);
  min-height: 400px;
}

.cal-time-inner {
  display: flex;
  position: relative;
}

.cal-time-gutter {
  width: 52px;
  flex-shrink: 0;
  position: relative;
  border-right: 1px solid var(--border-light);
}

.cal-time-label {
  position: absolute;
  right: 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
  transform: translateY(-50%);
  white-space: nowrap;
  user-select: none;
}

.cal-time-cols {
  flex: 1;
  display: flex;
}

.cal-time-col {
  flex: 1;
  position: relative;
  border-right: 1px solid var(--border-light);
  cursor: crosshair;
  transition: background var(--transition);
  user-select: none;
}
.cal-time-col:last-child { border-right: none; }
.cal-time-col:hover { background: rgba(99,102,241,0.02); }
.cal-time-col--today { background: rgba(99,102,241,0.03); }

.cal-time-hline {
  position: absolute;
  left: 0; right: 0;
  border-top: 1px solid var(--border-light);
  pointer-events: none;
}
.cal-time-hline--first { border-top-color: transparent; }

/* 現在時刻ライン */
.cal-now-line {
  position: absolute;
  left: 0; right: 0;
  border-top: 2px solid #ef4444;
  pointer-events: none;
  z-index: 2;
}
.cal-now-dot {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
}

/* 時間グリッドのイベントブロック */
.cal-te {
  position: absolute;
  left: 2px; right: 2px;
  border-radius: 4px;
  padding: 3px 6px;
  overflow: hidden;
  cursor: pointer;
  color: #fff;
  z-index: 1;
  transition: opacity var(--transition), filter var(--transition);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.cal-te:hover { filter: brightness(0.9); }

.cal-te-title {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-te-time {
  font-size: 0.68rem;
  opacity: 0.85;
  white-space: nowrap;
}
.cal-te--event {
  border-left: 3px solid rgba(255,255,255,0.6);
}
.cal-te-tag {
  font-size: 0.6rem;
  font-weight: 700;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  padding: 0 3px;
  flex-shrink: 0;
}
.cal-pill--event {
  border-left: 3px solid rgba(255,255,255,0.5);
}
.cal-pill-tag {
  font-size: 0.6rem;
  font-weight: 700;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  padding: 0 2px;
  flex-shrink: 0;
  margin-right: 2px;
}

/* ドラッグ選択 */
.cal-drag-sel {
  position: absolute;
  left: 2px; right: 2px;
  background: rgba(59, 130, 246, 0.25);
  border: 2px solid #3b82f6;
  border-radius: 4px;
  pointer-events: none;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  padding: 2px 4px;
}
.cal-drag-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #1d4ed8;
  white-space: nowrap;
}

/* 予定追加モーダル */
.cal-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.cal-modal {
  background: var(--surface);
  border-radius: var(--radius-lg, 10px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 420px;
  animation: cal-modal-in 0.15s ease;
}
@keyframes cal-modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.cal-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.cal-modal-title {
  font-weight: 600;
  font-size: 1rem;
}
.cal-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
  line-height: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
}
.cal-modal-close:hover { color: var(--text); background: var(--bg); }
.cal-modal-body {
  padding: 1rem 1.25rem;
}
.cal-modal-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  display: block;
}
.cal-modal-footer {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid var(--border);
}
.cal-detail-time {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.cal-detail-time::before {
  content: '';
  display: inline-block;
  width: 14px; height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  flex-shrink: 0;
}
.cal-detail-content {
  font-size: 0.9rem;
  color: var(--text);
  white-space: pre-wrap;
  margin: 0;
}
.cal-conflict-box {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  padding: 0.75rem 1rem;
}
.cal-conflict-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 0.5rem;
  color: #92400e;
}
.cal-conflict-subtitle {
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0.5rem 0 0.25rem;
  color: #92400e;
}
.cal-conflict-list {
  margin: 0 0 0.5rem;
  padding-left: 1.25rem;
  font-size: 0.85rem;
  color: #78350f;
}
.cal-conflict-list li { margin-bottom: 0.15rem; }
.cal-conflict-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ヘッダーのレスポンシブ対応 */
@media (max-width: 680px) {
  .cal-header { flex-wrap: wrap; gap: 0.5rem; }
  .cal-title { order: -1; flex: 1 0 100%; font-size: 1rem; }
  .cal-controls { margin-left: auto; }
}

/* ===== Stats cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.stat-card__label { font-size: 0.8125rem; color: var(--text-muted); font-weight: 500; }
.stat-card__value { font-size: 1.875rem; font-weight: 700; color: var(--text); letter-spacing: -0.03em; }
.stat-card__sub   { font-size: 0.8125rem; color: var(--text-muted); }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; }
.table-responsive { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead tr { border-bottom: 2px solid var(--border); }
thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border-light); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover); }
tbody td { padding: 0.875rem 1rem; color: var(--text); vertical-align: middle; }

.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table-striped tbody tr:nth-child(even) { background: var(--surface-hover); }
.table-sm thead th, .table-sm tbody td { padding: 0.5rem 0.75rem; }
.align-middle { vertical-align: middle; }
.ps-3 { padding-left: 1rem; }

/* ===== List Group ===== */
.list-group {
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.list-group-item {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
  font-size: 0.9rem;
}

.list-group-item:last-child { border-bottom: none; }

.list-group-item.d-flex {
  display: flex;
  align-items: center;
}

/* ===== Event / item cards ===== */
.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.event-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.event-card__title { font-size: 1rem; font-weight: 600; color: var(--text); }
.event-card__meta  { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; }
.event-card__desc  { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.5; }
.event-card__foot  { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }

/* ===== Notification ===== */
.notification-bell__container { display: inline-flex; align-items: center; }

.notification-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: background var(--transition);
}
.notification-bell:hover { background: var(--border-light); }

.notification-bell__badge {
  position: absolute;
  top: 0; right: 0;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.2rem;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.125rem;
  transform: translate(30%, -30%);
}

/* ===== Wizard ===== */
.event-wizard-steps { margin-bottom: 2rem; }
.event-wizard-steps__list {
  display: flex;
  gap: 0;
  list-style: none;
  background: var(--border-light);
  border-radius: var(--radius-full);
  padding: 0.25rem;
}

.event-wizard-steps__button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

.event-wizard-steps__button:disabled { cursor: default; opacity: 0.5; }
.event-wizard-steps__button:hover:not(:disabled) { color: var(--text); }

.event-wizard-steps__number {
  width: 1.375rem; height: 1.375rem;
  border-radius: var(--radius-full);
  background: var(--border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  display: inline-flex; align-items: center; justify-content: center;
}

.event-wizard-steps li.active .event-wizard-steps__button {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.event-wizard-steps li.active .event-wizard-steps__number {
  background: var(--primary);
  color: #fff;
}
.event-wizard-steps li.completed .event-wizard-steps__button {
  color: var(--success-text);
}
.event-wizard-steps li.completed .event-wizard-steps__number {
  background: var(--success);
  color: #fff;
}

/* ===== Drawer (mobile header fallback) ===== */
.header-drawer {
  position: fixed; inset: 0;
  display: flex; justify-content: flex-start;
  pointer-events: none; opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 200;
}
.header-drawer--open { pointer-events: auto; opacity: 1; }

.header-drawer__content {
  width: 260px; background: var(--sidebar-bg);
  height: 100%; box-shadow: var(--shadow-lg);
  transform: translateX(-100%); transition: transform 0.3s ease;
  padding: 1.5rem; display: flex; flex-direction: column; gap: 1.5rem;
}
.header-drawer--open .header-drawer__content { transform: translateX(0); }

.header-drawer__header { display: flex; justify-content: space-between; align-items: center; }
.header-drawer__title  { font-size: 1.125rem; font-weight: 700; color: #fff; }
.header-drawer__close  { border: none; background: transparent; font-size: 1.5rem; cursor: pointer; color: var(--sidebar-text); line-height: 1; }
.header-drawer__close:hover { color: #fff; }

.header-drawer__nav { list-style: none; display: flex; flex-direction: column; gap: 0.25rem; }
.header-drawer__nav a { color: var(--sidebar-text); text-decoration: none; font-weight: 500; display: block; padding: 0.5rem 0.75rem; border-radius: var(--radius); }
.header-drawer__nav a:hover { background: var(--sidebar-hover-bg); color: #fff; }
.header-drawer__backdrop { flex: 1; background: rgba(0,0,0,0.5); }

/* ===== header (noscript / old fallback) ===== */
.header {
  background: var(--sidebar-bg);
  color: #fff;
  padding: 0 1.5rem;
  height: 3.75rem;
  display: flex; align-items: center;
}
.header-content { display: flex; align-items: center; gap: 1rem; width: 100%; }
.logo a, .header-brand__link { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.125rem; }
.nav-list { display: flex; list-style: none; gap: 1.5rem; flex: 1; margin-left: 2rem; }
.nav-list a { color: var(--sidebar-text); text-decoration: none; font-size: 0.875rem; font-weight: 500; transition: color var(--transition); }
.nav-list a:hover { color: #fff; }
.user-menu { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.user-name { font-size: 0.875rem; font-weight: 500; }

.header-menu-button { width: 2.25rem; height: 2.25rem; border: none; background: transparent; display: inline-flex; flex-direction: column; justify-content: center; gap: 0.3rem; cursor: pointer; }
.header-menu-button__line { display: block; width: 1.5rem; height: 2px; background: rgba(255,255,255,0.7); border-radius: 2px; transition: transform 0.2s, opacity 0.2s; }
.header-menu-button.is-open .header-menu-button__line:nth-child(1) { transform: translateY(0.45rem) rotate(45deg); }
.header-menu-button.is-open .header-menu-button__line:nth-child(2) { opacity: 0; }
.header-menu-button.is-open .header-menu-button__line:nth-child(3) { transform: translateY(-0.45rem) rotate(-45deg); }

/* ===== Footer ===== */
.footer { padding: 1.25rem 2rem; border-top: 1px solid var(--border); background: var(--surface); }
.footer p { font-size: 0.8125rem; color: var(--text-muted); }

/* ===== Utility ===== */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-sm      { font-size: 0.875rem; }
.text-xs      { font-size: 0.75rem; }
.fw-semibold  { font-weight: 600; }
.fw-bold      { font-weight: 700; }
.small        { font-size: 0.8125rem; color: var(--text-muted); }

.d-flex       { display: flex; }
.flex-column  { flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.align-items-start  { align-items: flex-start; }
.align-center { align-items: center; }
.gap-1        { gap: 0.25rem; }
.gap-2        { gap: 0.5rem; }
.gap-3        { gap: 0.75rem; }
.gap-4        { gap: 1rem; }
.h-100        { height: 100%; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }
.me-2 { margin-right: 0.5rem; }

.p-0 { padding: 0 !important; }
.p-3 { padding: 1rem; }

.divider { height: 1px; background: var(--border); margin: 1.25rem 0; }
.border-success { border-color: var(--success) !important; }
.border-info    { border-color: var(--info) !important; }
.bg-success     { background: var(--success) !important; }
.bg-info        { background: var(--info) !important; }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state__icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state__title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state__desc  { font-size: 0.875rem; }

.avatar {
  width: 2.25rem; height: 2.25rem;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8125rem;
  flex-shrink: 0;
}

.tag {
  display: inline-flex; align-items: center;
  padding: 0.1875rem 0.5rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--border-light);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* input-group */
.input-group {
  display: flex;
  gap: 0;
}
.input-group .form-control {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  flex: 1;
}
.input-group .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* form-select-sm */
.form-select-sm {
  padding: 0.25rem 2rem 0.25rem 0.5rem;
  font-size: 0.8125rem;
  width: auto;
}

/* form-control-sm */
.form-control-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
}

/* hr */
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
  min-width: 2rem; text-align: center;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

/* ===== Auth pages ===== */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 2rem;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
}

.auth-card__header {
  padding: 2.5rem 2.5rem 1.5rem;
  text-align: center;
}

.auth-card__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem; height: 3rem;
  background: var(--primary);
  border-radius: var(--radius-md);
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

.auth-card__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 0.375rem;
}

.auth-card__subtitle { font-size: 0.9rem; color: var(--text-muted); }

.auth-card__body { padding: 0 2.5rem 2.5rem; }
.auth-card__footer { padding: 1.25rem 2.5rem; border-top: 1px solid var(--border-light); text-align: center; font-size: 0.875rem; background: var(--surface-hover); }
.auth-card__footer a { font-weight: 600; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { display: none; }
  .main-wrapper { margin-left: 0; }
  .main { padding: 1.25rem; }
  .col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-md-9 { flex: 0 0 100%; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .auth-layout { padding: 1rem; }
  .auth-card__header, .auth-card__body { padding-left: 1.5rem; padding-right: 1.5rem; }
}
