:root {
  --bg: #f4f7fb;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f172a;
  --primary-2: #1e293b;
  --accent: #2563eb;
  --success: #16a34a;
  --danger: #e11d48;
  --warning: #d97706;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f8fbff 0%, #f2f6fb 100%);
  color: var(--text);
}
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
#app { min-height: 100vh; }
.hidden { display: none !important; }

.login-shell {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.25), transparent 28%),
    radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.24), transparent 24%),
    linear-gradient(135deg, #020617, #0f172a 55%, #111827);
}

.login-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  backdrop-filter: blur(2px);
}

.login-layout {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 36px 24px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 32px;
  align-items: center;
}

.hero-panel h1 {
  margin: 18px 0 0;
  max-width: 760px;
  font-size: clamp(2.4rem, 5vw, 4.4rem);
  line-height: 1.02;
  color: white;
}

.hero-panel p {
  max-width: 760px;
  color: #cbd5e1;
  font-size: 1.05rem;
  line-height: 1.8;
  margin-top: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 34px;
}

.feature-card {
  border-radius: var(--radius-xl);
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: white;
}

.feature-card h3 { margin: 14px 0 8px; font-size: 1.05rem; }
.feature-card p { margin: 0; color: #cbd5e1; font-size: 0.94rem; line-height: 1.6; }

.icon-bubble {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  font-size: 1.35rem;
}

.card {
  border-radius: var(--radius-xl);
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-card {
  max-width: 560px;
  width: 100%;
  justify-self: center;
  padding: 28px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 14px;
}
.section-title .icon-bubble {
  background: var(--primary);
  color: white;
}
.section-title h2,
.panel-head h2,
.form-card h2,
.topbar h1 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1.1;
}
.section-title p,
.panel-head p,
.form-card p,
.topbar p,
.muted,
.subtle {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.demo-box,
.error-box,
.empty-box,
.notice-box,
.privacy-box {
  border-radius: var(--radius-lg);
  padding: 15px 18px;
  font-size: 0.95rem;
}
.demo-box {
  margin-top: 24px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}
.demo-box strong { color: #14532d; }
.error-box { border: 1px solid #fecdd3; background: #fff1f2; color: #be123c; }
.notice-box { border: 1px solid #bfdbfe; background: #eff6ff; color: #1d4ed8; }
.empty-box { border: 1px dashed var(--line); background: #f8fafc; color: var(--muted); }
.privacy-box {
  margin-top: 24px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
}
.privacy-box strong { display:block; margin-bottom:6px; color:#0f172a; }

.form-grid { display: grid; gap: 18px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

label.field {
  display: grid;
  gap: 8px;
}
label.field span {
  font-size: 0.92rem;
  font-weight: 600;
  color: #334155;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 18px;
  padding: 13px 15px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.input:focus,
.textarea:focus,
.select:focus {
  border-color: #cbd5e1;
  box-shadow: 0 0 0 5px rgba(226, 232, 240, 0.7);
}
.textarea { min-height: 110px; resize: vertical; }

.password-wrap { position: relative; }
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 12px;
  padding: 8px 10px;
}
.password-toggle:hover { background: #f1f5f9; color: var(--text); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: 18px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-2); }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--line); }
.btn-secondary:hover { background: #f8fafc; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #be123c; }
.btn-soft { background: #eff6ff; color: #1d4ed8; }
.btn-soft:hover { background: #dbeafe; }

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 20px 18px 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  margin-bottom: 22px;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}
.portal-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  font-size: 1.35rem;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: none;
  border-radius: 18px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 700;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 8px;
  border-radius: 22px;
  background: #e2e8f0;
}
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #334155;
}
.user-text { min-width: 0; }
.user-text strong,
.user-text span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-text span { color: var(--muted); font-size: 0.85rem; }

.layout-stack { display: grid; gap: 18px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.stat-card { padding: 20px; }
.stat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.stat-value {
  margin-top: 10px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.main-grid {
  display: grid;
  grid-template-columns: 1.7fr 0.78fr;
  gap: 18px;
}
.panel,
.form-card,
.intern-card,
.user-card,
.dept-card {
  padding: 20px;
}
.panel-head,
.panel-actions,
.card-top,
.calendar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.calendar-head {
  margin-bottom: 18px;
  align-items: center;
}
.month-switch {
  display: flex;
  align-items: center;
  gap: 10px;
}
.month-label {
  min-width: 210px;
  text-align: center;
  background: #e2e8f0;
  color: #334155;
  border-radius: 18px;
  padding: 12px 16px;
  font-weight: 700;
}
.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.weekday-row { margin-bottom: 10px; }
.weekday-row div {
  text-align: center;
  padding: 10px 6px;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.day-card {
  min-height: 220px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 24px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.day-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.08);
}
.day-card.other-month { background: #f8fafc; color: #94a3b8; }
.day-card.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.18);
}
.day-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.day-number,
.assignment-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  font-weight: 800;
}
.day-number {
  width: 36px;
  height: 36px;
  background: #f1f5f9;
  color: #334155;
}
.day-card.selected .day-number {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}
.day-card.today:not(.selected) .day-number {
  background: var(--primary);
  color: white;
}
.assignment-count {
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  font-size: 0.78rem;
  background: #f1f5f9;
  color: var(--muted);
}
.day-card.selected .assignment-count {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}
.day-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  align-content: start;
  flex: 1;
}
.assignment-chip,
.range-badge,
.role-badge,
.status-badge,
.count-badge,
.soft-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}
.assignment-chip {
  border: 1px solid transparent;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
  align-items: flex-start;
}
.day-card.selected .assignment-chip {
  background: rgba(255, 255, 255, 0.12) !important;
  color: white !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}
.more-chip {
  font-size: 0.8rem;
  color: inherit;
  opacity: 0.75;
  padding: 6px 2px 0;
  font-weight: 700;
}

.detail-list,
.user-list,
.dept-list,
.intern-grid {
  display: grid;
  gap: 14px;
}
.detail-list { margin-top: 16px; }
.detail-card {
  border-radius: 22px;
  border: 1px solid var(--line);
  background: #f8fafc;
  padding: 16px;
}
.detail-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.detail-top h3,
.user-card h3,
.intern-card h3,
.dept-card h3 {
  margin: 0;
  font-size: 1.05rem;
}
.meta-list {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 0.93rem;
  line-height: 1.55;
}

.search-wrap {
  position: relative;
  width: min(420px, 100%);
}
.search-wrap::before {
  content: "🔎";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.55;
}
.search-wrap .input { padding-left: 42px; }

.intern-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}
.intern-card,
.user-card,
.dept-card {
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #f8fafc;
}
.card-top {
  align-items: center;
}
.card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.range-badge,
.count-badge,
.soft-badge {
  background: #e2e8f0;
  color: #334155;
}
.role-admin { background: #ede9fe; color: #6d28d9; }
.role-user { background: white; color: #334155; border: 1px solid var(--line); }
.status-badge { background: #dcfce7; color: #15803d; }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.preview-item,
.schedule-item,
.assignment-row {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: white;
}
.preview-item {
  padding: 12px 14px;
}
.preview-item small,
.schedule-item small,
.assignment-row small,
.dept-meta small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.preview-item strong,
.schedule-item strong,
.assignment-row strong { display: block; }

.assignment-panel {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 24px;
  padding: 18px;
}
.assignment-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.assignment-rows {
  display: grid;
  gap: 12px;
}
.assignment-row {
  padding: 12px;
}
.assignment-row label,
.assignment-row > div {
  display: block;
}
.assignment-row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.assignment-row-title strong {
  font-size: 0.95rem;
}
.assignment-row-title span {
  color: var(--muted);
  font-size: 0.84rem;
}

.dept-layout,
.user-admin-layout {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
}
.dept-card,
.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.dept-left,
.user-left { min-width: 0; }
.dept-meta,
.user-left span {
  color: var(--muted);
  font-size: 0.9rem;
}
.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 6px;
  vertical-align: -2px;
}

.footer-note {
  margin-top: 18px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.7;
}
.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  background: var(--primary);
  color: white;
  padding: 14px 16px;
  border-radius: 18px;
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.24);
  z-index: 40;
  font-weight: 700;
}

@media (max-width: 1200px) {
  .login-layout,
  .main-grid,
  .dept-layout,
  .user-admin-layout,
  .intern-grid {
    grid-template-columns: 1fr;
  }
  .topbar,
  .calendar-head,
  .panel-actions,
  .card-top {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar-right { justify-content: stretch; }
  .stats-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .feature-grid,
  .form-grid.two,
  .form-grid.three,
  .form-grid.four,
  .preview-grid {
    grid-template-columns: 1fr;
  }
  .weekday-row,
  .calendar-grid {
    gap: 8px;
  }
  .day-card {
    min-height: 180px;
    padding: 12px;
  }
}

@media (max-width: 720px) {
  .app-shell { padding: 14px 12px 28px; }
  .login-layout { padding: 22px 16px; }
  .login-card,
  .panel,
  .form-card,
  .stat-card,
  .intern-card,
  .user-card,
  .dept-card { padding: 16px; }
  .month-label { min-width: 0; width: 100%; }
  .calendar-grid,
  .weekday-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .weekday-row div:nth-child(n+3) { display: none; }
}
