/* ==========================================================================
   CSS DESIGN SYSTEM & VARIABLES
   ========================================================================== */

:root {
  /* Dark Theme (Default) */
  --bg-app: #090d16;
  --bg-sidebar: #0f1524;
  --bg-card: rgba(20, 27, 45, 0.6);
  --bg-card-hover: rgba(28, 38, 62, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
  --glow-blue: 0 0 15px rgba(59, 130, 246, 0.3);
  
  /* Brand & Priority Colors */
  --color-primary: #3b82f6;      /* Blue */
  --color-primary-grad: linear-gradient(135deg, #3b82f6, #1d4ed8);
  --color-secondary: #64748b;    /* Slate */
  --color-success: #10b981;      /* Emerald */
  --color-warning: #f59e0b;      /* Amber */
  --color-danger: #ef4444;       /* Rose */
  --color-info: #06b6d4;         /* Cyan */
  --color-purple: #8b5cf6;       /* Violet */
  --color-purple-grad: linear-gradient(135deg, #8b5cf6, #6d28d9);
  --color-rose-grad: linear-gradient(135deg, #ef4444, #b91c1c);
  --color-emerald-grad: linear-gradient(135deg, #10b981, #047857);
  
  /* Statuses */
  --status-todo: #f59e0b;
  --status-inprogress: #3b82f6;
  --status-review: #8b5cf6;
  --status-done: #10b981;
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s ease;
}

.light-theme {
  /* Light Theme Variables */
  --bg-app: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: #3b82f6;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
  --glow-blue: 0 0 12px rgba(59, 130, 246, 0.15);
}

/* ==========================================================================
   RESET & GLOBALS
   ========================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

button, input, select, textarea {
  font-family: inherit;
  outline: none;
}

/* ==========================================================================
   CUSTOM SCROLLBARS (theme-aware, subtle & rounded)
   ========================================================================== */
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}
/* WebKit / Chromium */
::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  border: 3px solid transparent;   /* creates padding around the thumb */
  background-clip: padding-box;
  transition: background-color var(--transition-fast);
}
::-webkit-scrollbar-thumb:hover {
  background-color: rgba(148, 163, 184, 0.5);
}
::-webkit-scrollbar-thumb:active {
  background-color: rgba(148, 163, 184, 0.65);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* Light theme: slightly darker thumb for contrast on light backgrounds */
.light-theme, .light-theme * { scrollbar-color: rgba(100, 116, 139, 0.4) transparent; }
.light-theme *::-webkit-scrollbar-thumb { background-color: rgba(100, 116, 139, 0.3); }
.light-theme *::-webkit-scrollbar-thumb:hover { background-color: rgba(100, 116, 139, 0.55); }

/* Blue accent thumb for primary content areas */
.content-body ::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
  background-color: rgba(59, 130, 246, 0.3);
}
.content-body ::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover {
  background-color: rgba(59, 130, 246, 0.55);
}

/* ==========================================================================
   APP CONTAINER & LAYOUT
   ========================================================================== */

.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  overflow: hidden;
  white-space: nowrap;
  transition: width var(--transition-normal), background-color var(--transition-normal), border-right var(--transition-normal);
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

.sidebar-toggle i { width: 18px; height: 18px; }

/* ===== Collapsed sidebar state ===== */
.app-container.sidebar-collapsed .sidebar { width: 76px; }
.app-container.sidebar-collapsed .main-content { margin-left: 76px; }

.app-container.sidebar-collapsed .logo-container,
.app-container.sidebar-collapsed .nav-link span,
.app-container.sidebar-collapsed .profile-info,
.app-container.sidebar-collapsed .profile-avatar { display: none; }

/* Collapsed footer: show a clean, centered logout icon (no cut-off initials) */
.app-container.sidebar-collapsed .btn-logout {
  display: flex !important;
  margin: 0 !important;
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.app-container.sidebar-collapsed .btn-logout:hover { background-color: rgba(255, 255, 255, 0.06); }
.app-container.sidebar-collapsed .btn-logout i { width: 20px; height: 20px; }

.app-container.sidebar-collapsed .sidebar-header {
  justify-content: center;
  padding: 22px 0;
}

.app-container.sidebar-collapsed .sidebar-nav { padding: 24px 12px; }
.app-container.sidebar-collapsed .nav-link { justify-content: center; padding: 12px 0; }
.app-container.sidebar-collapsed .nav-link:hover i { transform: none; }

.app-container.sidebar-collapsed .sidebar-footer { padding: 16px 0; }
.app-container.sidebar-collapsed #sidebar-user-profile { justify-content: center !important; }
.app-container.sidebar-collapsed #sidebar-user-profile > div {
  justify-content: center !important;
  flex: unset !important;
  gap: 0 !important;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon-box {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--color-primary-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow-blue);
}

.logo-icon {
  color: #fff;
  width: 20px;
  height: 20px;
}

.logo-text-box {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-main);
}

.logo-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  min-height: 0;        /* 메뉴가 많아도 푸터(사용자명)를 밀어내지 않도록 */
  overflow-y: auto;     /* 넘치면 메뉴 영역만 스크롤 */
  padding: 24px 16px;
}

.sidebar-nav ul {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-link i {
  width: 18px;
  height: 18px;
  transition: transform var(--transition-fast);
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-link:hover i {
  transform: translateX(2px);
}

.nav-link.active {
  background: var(--color-primary-grad);
  color: #ffffff;
  box-shadow: var(--glow-blue);
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-avatar {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--color-purple-grad);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

.profile-info {
  display: flex;
  flex-direction: column;
}

.profile-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.profile-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Main Content Area Styling */
.main-content {
  flex: 1;
  margin-left: 260px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 30px;
  overflow: hidden;
  transition: margin-left var(--transition-normal);
}

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

#view-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.datetime-widget {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(10px);
}

.datetime-widget i {
  width: 16px;
  height: 16px;
  color: var(--color-primary);
}

/* ===== 완료 태스크: 전체 보기 버튼 + 모달 리스트 ===== */
.kanban-more-btn {
  width: 100%; margin-top: 8px; padding: 10px;
  background: transparent; border: 1px dashed var(--border-color);
  border-radius: 10px; color: var(--text-muted); cursor: pointer;
  font-size: 0.84rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.kanban-more-btn:hover { background: var(--bg-card-hover); color: var(--text-main); border-color: var(--color-primary, #6c8cff); }
.kanban-more-btn i { width: 15px; height: 15px; }
.done-tasks-list { list-style: none; margin: 0; padding: 0; max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.done-task-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 10px;
  background: var(--color-surface, rgba(255,255,255,0.03));
}
.done-task-main { min-width: 0; flex: 1; }
.done-task-title { font-size: 0.9rem; font-weight: 600; color: var(--text-main); margin-bottom: 4px; word-break: break-word; }
.done-task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 0.76rem; color: var(--text-muted); }
.done-task-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ===== 도움말 ? 버튼 + 텔레그램 안내 ===== */
.help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; margin-left: 2px;
  border-radius: 50%; border: 1px solid var(--color-primary, #6c8cff);
  background: transparent; color: var(--color-primary, #6c8cff);
  font-size: 0.72rem; font-weight: 700; line-height: 1; cursor: pointer;
  vertical-align: middle;
}
.help-btn:hover { background: var(--color-primary, #6c8cff); color: #fff; }
.tg-help-intro { font-size: 0.9rem; color: var(--text-main); margin: 0 0 14px; line-height: 1.5; }
.tg-help-steps { margin: 0 0 14px; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; }
.tg-help-steps > li { font-size: 0.9rem; color: var(--text-main); }
.tg-help-steps > li > strong { color: var(--color-primary, #6c8cff); }
.tg-help-steps p { margin: 4px 0 0; font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.tg-help-warn { color: var(--color-danger, #e5484d); }
.tg-help-steps code, .tg-help-note code {
  background: rgba(108,140,255,0.12); color: var(--color-primary, #6c8cff);
  padding: 1px 6px; border-radius: 5px; font-size: 0.82em;
}
.tg-help-note {
  border: 1px solid var(--border-color); border-radius: 10px;
  padding: 12px 14px; background: rgba(0,0,0,0.03); font-size: 0.85rem; color: var(--text-main);
}
.light-theme .tg-help-note { background: rgba(0,0,0,0.02); }
.tg-help-note > div { margin-bottom: 6px; }
.tg-help-note ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; color: var(--text-muted); }

/* ===== 알림 (벨 + 드롭다운) ===== */
.noti-wrap { position: relative; }
.noti-bell {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 40px; height: 40px;
  border-radius: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.noti-bell:hover { background: var(--bg-card-hover); }
.noti-bell i { width: 18px; height: 18px; }
.noti-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--color-danger, #e5484d); color: #fff;
  border-radius: 9px; font-size: 0.68rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--bg-body, #0b0f19);
}
.noti-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; max-height: 440px;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  z-index: 200; display: flex; flex-direction: column; overflow: hidden;
}
.noti-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border-color);
  font-weight: 700; font-size: 0.92rem;
}
.noti-panel-actions { display: flex; gap: 6px; }
.noti-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.noti-empty { padding: 24px 14px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.noti-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 11px 14px; border-bottom: 1px solid var(--border-color);
  cursor: pointer; transition: background var(--transition-fast);
}
.noti-item:hover { background: var(--bg-card-hover); }
.noti-item.unread { background: rgba(108, 140, 255, 0.08); }
.noti-item.unread .noti-msg { font-weight: 600; }
.noti-item.unread::before {
  content: ''; flex-shrink: 0; margin-top: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-primary, #6c8cff);
}
.noti-item.read::before { content: ''; flex-shrink: 0; width: 7px; }
.noti-item-body { flex: 1; min-width: 0; }
.noti-msg { font-size: 0.86rem; color: var(--text-main); line-height: 1.4; word-break: break-word; }
.noti-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; }
.noti-del {
  flex-shrink: 0; background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); width: 22px; height: 22px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
}
.noti-del:hover { background: rgba(255,0,0,0.08); color: var(--color-danger, #e5484d); }

.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
  transition: all var(--transition-fast);
  backdrop-filter: blur(10px);
}

.theme-toggle:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.dark-theme .sun-icon { display: block; }
.dark-theme .moon-icon { display: none; }
.light-theme .sun-icon { display: none; }
.light-theme .moon-icon { display: block; }

/* Content Body */
.content-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.view-section {
  display: none;
  animation: fadeIn var(--transition-normal) forwards;
}

.view-section.active {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
  min-height: 0;
}

/* Settings screen has many stacked cards — let the body scroll so lower cards
   (AI · 텔레그램 · 사용자 및 권한 관리) are always reachable. */
#settings-view .settings-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

#dashboard-view {
  overflow-y: auto;
  padding-right: 6px;
}

#persons-view, #groups-view, #departments-view, #apps-view {
  overflow: hidden;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   GENERIC COMPONENTS & UTILITIES
   ========================================================================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary-grad);
  color: #ffffff;
  box-shadow: var(--glow-blue);
}

.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.45);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.btn-secondary.active {
  background: var(--color-primary-grad);
  border-color: var(--border-focus);
  color: #ffffff;
  box-shadow: var(--glow-blue);
}

.btn-danger {
  background: var(--color-rose-grad);
  color: #ffffff;
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-success {
  background: var(--color-emerald-grad);
  color: #ffffff;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
  gap: 6px;
}

.btn-sm svg,
.btn-sm i {
  width: 14px;
  height: 14px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  padding: 0;
}

.btn-icon i {
  width: 18px;
  height: 18px;
}

/* Translucent Glass Panels */
.glass {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
  transition: border-color var(--transition-normal), background-color var(--transition-normal);
}

.glass:hover {
  background-color: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

/* Activity-log action pills (reuse status color codes) */
.logs-table .badge.count { padding: 4px 9px; border-radius: 6px; font-size: 0.74rem; }
.logs-table .badge.count.received { background-color: rgba(5, 182, 212, 0.15); color: var(--color-info); }
.logs-table .badge.count.assigned { background-color: rgba(139, 92, 246, 0.15); color: var(--color-purple); }
.logs-table .badge.count.in-progress { background-color: rgba(59, 130, 246, 0.15); color: var(--color-primary); }
.logs-table .badge.count.completed { background-color: rgba(16, 185, 129, 0.15); color: var(--color-success); }
.logs-table .badge.count.hold { background-color: rgba(239, 68, 68, 0.15); color: var(--color-danger); }
.logs-table td { vertical-align: middle; }

.badge.priority-high { background-color: rgba(239, 68, 68, 0.15); color: var(--color-danger); }
.badge.priority-medium { background-color: rgba(245, 158, 11, 0.15); color: var(--color-warning); }
.badge.priority-low { background-color: rgba(59, 130, 246, 0.15); color: var(--color-primary); }

.badge.status-pending { background-color: rgba(245, 158, 11, 0.15); color: var(--color-warning); }
.badge.status-approved { background-color: rgba(5, 182, 212, 0.15); color: var(--color-info); }
.badge.status-inprogress { background-color: rgba(59, 130, 246, 0.15); color: var(--color-primary); }
.badge.status-review { background-color: rgba(139, 92, 246, 0.15); color: var(--color-purple); }
.badge.status-done { background-color: rgba(16, 185, 129, 0.15); color: var(--color-success); }
.badge.status-rejected { background-color: rgba(239, 68, 68, 0.15); color: var(--color-danger); }

/* ===== Maintenance ledger (유지보수대장) ===== */
.maintenance-table { table-layout: fixed; }
/* Keep every maintenance row on a single, compact line; long text truncates with ellipsis.
   Use .data-table.maintenance-table for higher specificity than the generic .data-table td padding. */
.data-table.maintenance-table td {
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 9px 12px;
}
.data-table.maintenance-table th { padding: 11px 12px; }

/* Sortable headers (클릭하여 오름/내림 정렬) */
.maintenance-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 20px !important;
  transition: color var(--transition-fast);
}
.maintenance-table th.sortable:hover { color: var(--text-main); }
.maintenance-table th.sortable::after {
  content: '⇅';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  opacity: 0.35;
}
.maintenance-table th.sortable.sort-active { color: var(--color-primary); }
.maintenance-table th.sortable.sort-active::after { opacity: 1; color: var(--color-primary); }
.maintenance-table th.sortable[data-dir="asc"]::after { content: '↑'; }
.maintenance-table th.sortable[data-dir="desc"]::after { content: '↓'; }

.maint-datetime {
  font-family: 'Outfit', monospace;
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.maint-content-cell {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.maint-type-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  background-color: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}
.maint-type-tag.type-new { background-color: rgba(59, 130, 246, 0.15); color: var(--color-primary); }
.maint-type-tag.type-improvement { background-color: rgba(16, 185, 129, 0.15); color: var(--color-success); }
.maint-type-tag.type-error { background-color: rgba(239, 68, 68, 0.15); color: var(--color-danger); }
.maint-type-tag.type-etc { background-color: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

.ai-category-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  background-color: rgba(59, 130, 246, 0.12);
  color: var(--color-primary);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

/* 유지보수 대분류(시스템) 태그 */
.maint-system-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  background-color: rgba(139, 92, 246, 0.12);
  color: var(--color-purple);
  border: 1px solid rgba(139, 92, 246, 0.28);
}

.text-muted-cell { color: var(--text-muted); }

/* ===== Table pagination ===== */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 4px 4px;
  margin-top: 8px;
}

.pagination-left {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.page-size-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

#maint-page-size {
  background-color: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text-main);
  font-size: 0.82rem;
  cursor: pointer;
}

.light-theme #maint-page-size { background-color: #f8fafc; }

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  background-color: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.page-btn:hover:not(:disabled):not(.active) {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--border-focus);
}

.page-btn.active {
  background: var(--color-primary-grad);
  color: #fff;
  border-color: transparent;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-ellipsis {
  color: var(--text-muted);
  padding: 0 2px;
}

/* ===== AI summary dot in list ===== */
.ai-summary-dot {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--color-primary);
  vertical-align: middle;
  margin-right: 4px;
}

/* ===== Rich text editor ===== */
.rich-editor-wrap {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  background-color: rgba(0, 0, 0, 0.15);
}
.light-theme .rich-editor-wrap { background-color: #f8fafc; }

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.02);
}

.rich-toolbar button {
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.rich-toolbar button:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border-color: var(--border-color);
}

.rich-editor {
  min-height: 90px;
  max-height: 260px;
  overflow-y: auto;
  padding: 12px 14px;
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.6;
  outline: none;
}
.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}
.rich-editor:focus { box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.25); }
.rich-editor ul, .rich-editor ol { padding-left: 22px; margin: 4px 0; }
.rich-editor a { color: var(--color-primary); text-decoration: underline; }

/* Pasted content (Excel/Word/메일) often carries hard-coded black text
   (color: rgb(0,0,0) / #000000 / black / windowtext), which is invisible on the
   dark editor background. Force such black text to the theme color in dark mode.
   Other colors (red/blue highlights) are left untouched. */
.dark-theme .rich-editor [style*="rgb(0, 0, 0)"],
.dark-theme .rich-editor [style*="rgb(0,0,0)"],
.dark-theme .rich-editor [style*="color:#000000"],
.dark-theme .rich-editor [style*="color: #000000"],
.dark-theme .rich-editor [style*="color:black"],
.dark-theme .rich-editor [style*="color: black"],
.dark-theme .rich-editor [style*="windowtext"],
.dark-theme .rich-editor font[color="#000000"],
.dark-theme .rich-editor font[color="#000"],
.dark-theme .rich-editor font[color="black"] {
  color: var(--text-main) !important;
}

/* ===== Requester management ===== */
.requester-list { display: flex; flex-direction: column; gap: 6px; }
.requester-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.02);
}
.requester-info { display: flex; align-items: center; gap: 10px; }
.requester-name { font-weight: 600; color: var(--text-main); }
.requester-dept {
  font-size: 0.78rem;
  color: var(--text-muted);
  background-color: rgba(148, 163, 184, 0.15);
  padding: 2px 8px;
  border-radius: 6px;
}

/* ===== Permission checklist & user management ===== */
.perm-checklist {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background-color: rgba(0, 0, 0, 0.12);
}
.light-theme .perm-checklist { background-color: #f8fafc; }

.perm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
}
.perm-item input { width: 16px; height: 16px; cursor: pointer; }

.menu-perm-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background-color: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
  margin: 1px 0;
}

/* ===== Toast notifications (styled alert) ===== */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 48px));
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--bg-card, #131c31);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--color-primary);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  color: var(--text-main);
  font-size: 0.88rem;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.28s ease;
}
.toast.toast-in { transform: translateX(0); opacity: 1; }
.toast.toast-out { transform: translateX(120%); opacity: 0; }

.toast .toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast .toast-msg { flex: 1; line-height: 1.45; word-break: break-word; }
.toast .toast-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 2px; display: flex; flex-shrink: 0;
}
.toast .toast-close i { width: 15px; height: 15px; }
.toast .toast-close:hover { color: var(--text-main); }

.toast-success { border-left-color: var(--color-success); }
.toast-success .toast-icon { color: var(--color-success); }
.toast-error { border-left-color: var(--color-danger); }
.toast-error .toast-icon { color: var(--color-danger); }
.toast-warning { border-left-color: var(--color-warning); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info { border-left-color: var(--color-primary); }
.toast-info .toast-icon { color: var(--color-primary); }

.light-theme .toast { background: #ffffff; }

/* ===== Security vulnerabilities ===== */
.badge.sev-critical { background-color: rgba(239, 68, 68, 0.18); color: #ef4444; font-weight: 700; }
.badge.sev-high { background-color: rgba(249, 115, 22, 0.16); color: #f97316; }
.badge.sev-medium { background-color: rgba(245, 158, 11, 0.15); color: var(--color-warning); }
.badge.sev-low { background-color: rgba(59, 130, 246, 0.15); color: var(--color-primary); }

.cve-tag {
  font-family: 'Outfit', monospace;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 5px;
  background-color: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Inline-editable vulnerability grid */
.vuln-grid td { padding: 8px 10px; vertical-align: middle; }
.grid-edit {
  width: 100%;
  background-color: rgba(0, 0, 0, 0.15);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text-main);
  font-size: 0.82rem;
  font-family: inherit;
  transition: all var(--transition-fast);
}
.light-theme .grid-edit { background-color: #f1f5f9; }
.grid-edit:hover { border-color: var(--border-color); }
.grid-edit:focus { border-color: var(--border-focus); background-color: rgba(0, 0, 0, 0.25); outline: none; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }
.light-theme .grid-edit:focus { background-color: #fff; }
select.grid-edit { cursor: pointer; }

/* Color the severity select text by row severity */
.sev-row-critical .sev-select { color: #ef4444; font-weight: 700; }
.sev-row-high .sev-select { color: #f97316; font-weight: 600; }
.sev-row-medium .sev-select { color: var(--color-warning); }
.sev-row-low .sev-select { color: var(--color-primary); }

/* ===== Asset management ===== */
.asset-type-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  background-color: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

/* 자원명 / 호스트 셀 — 호스트명이 길어도 열 폭을 넘기지 않도록 줄임표 처리 */
.asset-name-cell { max-width: 230px; }
.asset-name-cell .request-title-cell { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.asset-host-line {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  margin-top: 2px;
}

/* Asset row accordion (설치 SW/버전) */
.asset-name-line { display: flex; align-items: center; gap: 6px; }
.asset-caret-btn {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; border: none; border-radius: 4px;
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: transform var(--transition-fast), color var(--transition-fast);
}
.asset-caret-btn:hover { color: var(--text-main); background: rgba(255,255,255,0.06); }
.asset-caret-spacer { flex: 0 0 auto; display: inline-block; width: 18px; }
.asset-comp-count {
  flex: 0 0 auto; cursor: pointer; font-size: 0.68rem; font-weight: 600;
  padding: 1px 6px; border-radius: 999px;
  background: rgba(59, 130, 246, 0.15); color: var(--color-primary);
}
.asset-detail-row > td { background: rgba(0,0,0,0.12); padding: 8px 14px 10px 40px; }
.light-theme .asset-detail-row > td { background: rgba(15, 23, 42, 0.03); }
.asset-comp-detail { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.asset-comp-detail-label { display: inline-flex; align-items: center; gap: 4px; font-size: 0.74rem; font-weight: 600; color: var(--text-muted); margin-right: 4px; }
.asset-comp-chip {
  font-size: 0.76rem; padding: 2px 8px; border-radius: 6px;
  background: rgba(148, 163, 184, 0.14); border: 1px solid var(--border-color); color: var(--text-main);
}
.asset-comp-chip b { color: var(--color-primary); font-weight: 700; }

/* Asset modal: SW components accordion + editor */
.asset-components-accordion {
  border: 1px solid var(--border-color); border-radius: 10px;
  margin-bottom: 16px; background: rgba(0,0,0,0.10); overflow: hidden;
}
.light-theme .asset-components-accordion { background: #f8fafc; }
.asset-components-accordion > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 14px; font-weight: 600; font-size: 0.9rem; color: var(--text-main);
}
.asset-components-accordion > summary::-webkit-details-marker { display: none; }
.asset-components-accordion > summary svg { width: 15px; height: 15px; }
.asset-components-accordion > summary .acc-caret { color: var(--text-muted); transition: transform var(--transition-fast); }
.asset-components-accordion[open] > summary .acc-caret { transform: rotate(90deg); }
.asset-components-accordion .acc-count { color: var(--color-primary); font-size: 0.82rem; }
.asset-components-accordion .acc-hint { font-weight: 400; font-size: 0.76rem; color: var(--text-muted); flex-basis: 100%; padding-left: 23px; }
.asset-components-body { padding: 4px 14px 14px; border-top: 1px solid var(--border-color); }
.asset-components-presets { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.asset-components-presets .preset-label { font-size: 0.78rem; color: var(--text-muted); margin-right: 2px; }
.asset-components-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.asset-component-row { display: flex; gap: 8px; align-items: center; }
.asset-component-row .comp-name { flex: 2; }
.asset-component-row .comp-version { flex: 1; }
.asset-component-row .comp-remove { flex: 0 0 auto; padding: 8px 10px; }

/* 대상 시스템 추가 — 기존 자원 선택 피커 */
.asset-picker-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px;
}
.asset-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.asset-picker-item:hover { background-color: rgba(148, 163, 184, 0.1); }
.asset-picker-item input[type="checkbox"] { flex: 0 0 auto; width: 16px; height: 16px; cursor: pointer; }
.asset-picker-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-picker-item .asset-type-tag { flex: 0 0 auto; }
.asset-relevant-tag {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
}
.asset-match-tag {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background-color: rgba(59, 130, 246, 0.18);
  color: var(--color-primary);
  white-space: nowrap;
}
.asset-picker-item.matched { background-color: rgba(59, 130, 246, 0.08); box-shadow: inset 2px 0 0 var(--color-primary); }
.asset-picker-empty { padding: 24px 12px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.asset-type-tag.type-server { background-color: rgba(59, 130, 246, 0.15); color: var(--color-primary); }
.asset-type-tag.type-system { background-color: rgba(139, 92, 246, 0.15); color: var(--color-purple); }
.asset-type-tag.type-solution { background-color: rgba(16, 185, 129, 0.15); color: var(--color-success); }
.asset-type-tag.type-network { background-color: rgba(6, 182, 212, 0.15); color: var(--color-info); }
.asset-type-tag.type-db { background-color: rgba(245, 158, 11, 0.15); color: var(--color-warning); }

.asset-purpose-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  background-color: rgba(139, 92, 246, 0.14);
  color: var(--color-purple);
}

/* ===== Vulnerability → target asset impact panel ===== */
.vuln-impact-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background-color: rgba(59, 130, 246, 0.04);
  /* Bottom half of the split view: fill remaining space, scroll internally */
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.vuln-impact-panel .table-responsive {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
/* When the impact panel is open, cap the vuln list to the top half */
#security-view .requests-layout.split-active .requests-list-container {
  flex: 1 1 0;
}

.impact-add-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px dashed var(--border-color);
  border-radius: 10px;
  background-color: rgba(0, 0, 0, 0.08);
}
.impact-add-form input, .impact-add-form select { padding: 8px 10px; font-size: 0.85rem; }
.impact-add-form #impact-new-name { flex: 1; min-width: 180px; }
.impact-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.impact-panel-header h4 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.impact-panel-header h4 i { width: 18px; height: 18px; color: var(--color-primary); }

.impact-grid td { padding: 8px 10px; vertical-align: middle; }
.impact-grid tr.impact-affected { background-color: rgba(59, 130, 246, 0.06); }
.impact-toggle .insp-btn { padding: 5px 12px; font-size: 0.78rem; }
.impact-toggle .insp-btn.active[data-val="yes"] { background-color: var(--color-primary); color: #fff; }
.impact-toggle .insp-btn.active[data-val="no"] { background-color: rgba(148, 163, 184, 0.4); color: var(--text-main); }
.grid-edit:disabled { opacity: 0.4; cursor: not-allowed; }

.vuln-row-selected { box-shadow: inset 3px 0 0 var(--color-primary); }
.vuln-row-selected td:first-child { position: relative; }

.impact-count-badge {
  display: inline-block;
  min-width: 15px;
  height: 15px;
  line-height: 15px;
  padding: 0 4px;
  margin-right: 3px;
  border-radius: 8px;
  background-color: var(--color-danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
}

/* ===== Daily inspection ===== */
.inspection-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  flex: 1;
  min-height: 0;
}
@media (max-width: 1100px) { .inspection-layout { grid-template-columns: 1fr; } }

.inspection-form-card, .inspection-history-card {
  padding: 20px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;       /* allow the card to fit within the viewport height */
  overflow: hidden;
}
.inspection-history-card { overflow: auto; }

/* The item list scrolls so 특이사항·점검자·저장 버튼이 항상 보이게 유지 */
.inspection-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0;
  flex: 1 1 auto;
  min-height: 60px;
  overflow-y: auto;
  padding-right: 4px;
}
.inspection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.02);
}
.inspection-item-label { font-size: 0.9rem; font-weight: 600; color: var(--text-main); }

.inspection-toggle { display: flex; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.insp-btn {
  padding: 6px 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;   /* keep '비대상' on one line (CJK breaks mid-word otherwise) */
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.insp-btn:first-child { border-right: 1px solid var(--border-color); }
.insp-btn.active[data-val="normal"] { background-color: var(--color-success); color: #fff; }
.insp-btn.active[data-val="abnormal"] { background-color: var(--color-danger); color: #fff; }

.insp-dot {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}
.insp-dot.normal { background-color: rgba(16, 185, 129, 0.15); color: var(--color-success); }
.insp-dot.abnormal { background-color: rgba(239, 68, 68, 0.15); color: var(--color-danger); }

/* Category-grouped check form */
.inspection-category { margin-bottom: 14px; }
.inspection-category-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 6px 0 8px;
  padding-left: 8px;
  border-left: 3px solid var(--color-primary);
}

.insp-abn-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background-color: rgba(239, 68, 68, 0.12);
  color: var(--color-danger);
  margin: 1px 0;
}

/* Named-template blocks in the management modal */
.tpl-template-block {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background-color: rgba(59, 130, 246, 0.04);
}
.tpl-template-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}
.tpl-name-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 5px;
  background-color: rgba(59, 130, 246, 0.14);
  color: var(--color-primary);
  margin-top: 3px;
}

/* Template management list */
.tpl-group { margin-bottom: 12px; }
.tpl-group-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.tpl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.02);
  margin-bottom: 6px;
  font-size: 0.88rem;
  color: var(--text-main);
}

/* ===== AI report output ===== */
/* Saved reports bar (시점별 저장 목록) */
.saved-reports-bar {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  background-color: rgba(255, 255, 255, 0.015);
}
.saved-reports-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.saved-reports-title i { width: 15px; height: 15px; }
.saved-reports-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.saved-report-card {
  position: relative;
  flex: 0 0 auto;
  min-width: 150px;
  max-width: 200px;
  padding: 10px 28px 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background-color: rgba(59, 130, 246, 0.04);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.saved-report-card:hover { border-color: var(--border-focus); background-color: rgba(59, 130, 246, 0.1); }
.saved-report-card.active { border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary); }
.saved-report-card .src-label { font-size: 0.85rem; font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-report-card .src-meta { font-size: 0.72rem; color: var(--color-primary); margin-top: 2px; }
.saved-report-card .src-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; font-family: 'Outfit', monospace; }
.saved-report-del {
  position: absolute;
  top: 6px; right: 6px;
  width: 18px; height: 18px;
  border: none; border-radius: 5px;
  background: transparent; color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.saved-report-del i { width: 13px; height: 13px; }
.saved-report-del:hover { background-color: rgba(239, 68, 68, 0.15); color: var(--color-danger); }

/* Prettier report document (in-app) */
.report-doc-head {
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 12px;
  margin-bottom: 18px;
}
.report-doc-title { font-size: 1.35rem; font-weight: 800; color: var(--text-main); }
.report-doc-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 6px; }

.report-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 700px) { .report-chips { grid-template-columns: repeat(2, 1fr); } }
.report-chip {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  background-color: rgba(255, 255, 255, 0.02);
}
.report-chip .rc-val { display: block; font-size: 1.7rem; font-weight: 800; color: var(--text-main); }
.report-chip .rc-label { display: block; font-size: 0.76rem; color: var(--text-muted); margin-top: 2px; }
.report-chip.c-blue .rc-val { color: var(--color-primary); }
.report-chip.c-green .rc-val { color: var(--color-success); }
.report-chip.c-amber .rc-val { color: var(--color-warning); }
.report-chip.c-purple .rc-val { color: var(--color-purple); }

.report-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 720px) { .report-charts { grid-template-columns: 1fr; } }
.report-chart-box {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  background-color: rgba(255, 255, 255, 0.02);
}
.report-chart-title { font-size: 0.82rem; font-weight: 700; color: var(--text-main); margin-bottom: 8px; text-align: center; }
.report-chart-canvas { position: relative; height: 200px; }

.report-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 14px 16px;
  margin-bottom: 20px;
  background-color: rgba(59, 130, 246, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}
.report-bd-title { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.report-bd-item { display: inline-block; font-size: 0.82rem; color: var(--text-main); margin-right: 10px; }
.report-bd-item b { color: var(--color-primary); }

.report-body { color: var(--text-main); line-height: 1.7; }
.report-table-wrap { overflow-x: auto; margin: 12px 0; }
.report-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.report-table th, .report-table td {
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.report-table th { background-color: rgba(59, 130, 246, 0.1); font-weight: 700; color: var(--text-main); white-space: nowrap; }
.report-table tbody tr:nth-child(even) td { background-color: rgba(255, 255, 255, 0.02); }
.light-theme .report-table tbody tr:nth-child(even) td { background-color: rgba(0, 0, 0, 0.02); }
.report-body h3, .report-body h4, .report-body h5 {
  margin: 18px 0 8px;
  font-weight: 700;
  color: var(--text-main);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-color);
}
.report-body h3 { font-size: 1.1rem; }
.report-body h4 { font-size: 1rem; }
.report-body p { margin: 6px 0; font-size: 0.9rem; }
.report-body ul { padding-left: 22px; margin: 6px 0; }
.report-body li { margin: 3px 0; font-size: 0.9rem; }
.report-body strong { color: var(--color-primary); }

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background-color: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.light-theme .form-control {
  background-color: #f8fafc;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
  background-color: rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   PRETTY <select> — custom chevron, no native OS styling
   ========================================================================== */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  padding-right: 32px !important;
  cursor: pointer;
}
/* Make plain (non .form-control) selects match the input look */
select.form-control,
select:not(.grid-edit):not(.insp-btn) {
  background-color: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  transition: all var(--transition-fast);
}
.light-theme select.form-control,
.light-theme select:not(.grid-edit) {
  background-color: #f8fafc;
}
select:hover { border-color: rgba(148, 163, 184, 0.4); }
select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}
/* Compact selects inside grids/tables keep a tighter arrow */
select.grid-edit,
#maint-page-size,
.impact-add-form select,
#history-template-filter {
  background-position: right 7px center;
  background-size: 14px;
  padding-right: 26px !important;
}
/* dropdown options readable in both themes */
select option { background-color: var(--bg-sidebar); color: var(--text-main); }
.light-theme select option { background-color: #fff; color: #0f172a; }

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .col {
  flex: 1;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table th {
  padding: 14px 16px;
  background-color: rgba(0, 0, 0, 0.1);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.data-table tbody tr {
  transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Empty States */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 30px;
  font-style: italic;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   VIEW 1: DASHBOARD VIEW
   ========================================================================== */

/* Quick Stats Grid */
/* Dashboard toolbar (연도 필터) */
.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.dashboard-scope-label { font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }
.dashboard-year-filter { display: flex; align-items: center; gap: 8px; }
.dashboard-year-filter svg { width: 16px; height: 16px; color: var(--text-muted); }
.dashboard-year-filter label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.dashboard-year-filter select {
  width: auto;
  min-width: 120px;
  padding: 8px 12px;
  font-size: 0.86rem;
}

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

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all var(--transition-normal);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
}

.stat-card.blue::before { background: var(--color-primary-grad); }
.stat-card.purple::before { background: var(--color-purple-grad); }
.stat-card.green::before { background: var(--color-emerald-grad); }
.stat-card.amber::before { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card.teal::before { background: linear-gradient(135deg, #14b8a6, #0d9488); }

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card.blue .stat-icon { background-color: rgba(59, 130, 246, 0.1); color: var(--color-primary); }
.stat-card.purple .stat-icon { background-color: rgba(139, 92, 246, 0.1); color: var(--color-purple); }
.stat-card.green .stat-icon { background-color: rgba(16, 185, 129, 0.1); color: var(--color-success); }
.stat-card.amber .stat-icon { background-color: rgba(245, 158, 11, 0.1); color: var(--color-warning); }
.stat-card.teal .stat-icon { background-color: rgba(20, 184, 166, 0.1); color: #14b8a6; }

.stat-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background-color: rgba(255, 255, 255, 0.05);
}

.progress-bar {
  height: 100%;
  transition: width var(--transition-slow);
}

.stat-card.blue .progress-bar { background-color: var(--color-primary); }
.stat-card.purple .progress-bar { background-color: var(--color-purple); }
.stat-card.green .progress-bar { background-color: var(--color-success); }
.stat-card.amber .progress-bar { background-color: var(--color-warning); }

/* Dashboard Cards Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.dashboard-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-width: 0;   /* allow grid item to shrink so wide tables scroll instead of breaking layout */
}

/* Recent maintenance list: keep the content cell bounded so it ellipsis-truncates */
#recent-maint-table .maint-content-cell {
  max-width: 260px;
}

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

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-body {
  flex: 1;
}

/* Charts Card */
.charts-container {
  display: flex;
  gap: 20px;
}

.chart-wrapper {
  flex: 1;
  height: 200px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Upcoming Schedules List */
.upcoming-schedules-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
}

.upcoming-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.02);
  border-left: 4px solid var(--color-secondary);
}

.upcoming-item .date-badge {
  text-align: center;
  min-width: 48px;
  padding: 4px 6px;
  border-radius: 6px;
  background-color: rgba(255, 255, 255, 0.04);
  font-size: 0.75rem;
  font-weight: 600;
}

.upcoming-item .date-day {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: block;
}

.upcoming-item .date-month {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.upcoming-details {
  flex: 1;
}

.upcoming-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.upcoming-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.upcoming-time i {
  width: 12px;
  height: 12px;
}

/* Recent Documents list */
.recent-docs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recent-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.02);
}

.doc-info-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc-icon-wrapper {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-icon-wrapper i {
  width: 16px;
  height: 16px;
}

.doc-details {
  display: flex;
  flex-direction: column;
}

.doc-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.doc-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.doc-action-block .btn {
  padding: 6px;
  border-radius: 6px;
}

/* ==========================================================================
   SEARCH / FILTER CONTROLS
   ========================================================================== */

.search-filter-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.search-box {
  position: relative;
  width: 260px;
}

.search-box i,
.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  background-color: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 14px 10px 36px;
  color: var(--text-main);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.light-theme .search-box input {
  background-color: #f8fafc;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
  background-color: rgba(0, 0, 0, 0.2);
}

.light-theme .search-box input:focus {
  background-color: #fff;
}

.filter-group {
  display: flex;
  gap: 8px;
}

.filter-group select {
  min-width: 140px;
}

/* ==========================================================================
   LIST VIEW LAYOUT (header row, status tabs, table container)
   ========================================================================== */

.requests-layout {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.requests-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.filters-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.status-tabs {
  display: flex;
  gap: 4px;
}

.status-tab {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.status-tab:hover {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-main);
}

.status-tab.active {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.status-tab .badge.count {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.status-tab.active .badge.count {
  background-color: var(--color-primary);
  color: #fff;
}

.requests-list-container {
  margin-top: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.main-requests-table td {
  vertical-align: middle;
}

.request-title-cell {
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.request-title-cell:hover {
  color: var(--color-primary);
}

.action-cell {
  display: flex;
  justify-content: center;
  gap: 4px;
}

/* ==========================================================================
   MODALS SYSTEM
   ========================================================================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* 메일 작성 도킹창(1400)·사이트 메뉴(1200) 보다 위에 떠야 확인 버튼이 보인다 */
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(5, 7, 12, 0.6);
  backdrop-filter: blur(8px);
}

.modal-container {
  width: 90%;
  max-width: 550px;
  position: relative;
  z-index: 2001;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
  max-height: 90vh;
}

.modal.active .modal-container {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.btn-close-modal:hover {
  color: var(--text-main);
}

/* Modals wrap body+footer in a <form>; make it a flex column so the body scrolls
   and the footer (저장 버튼) stays pinned & visible even when content is tall. */
.modal-container > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;   /* allow body to shrink & scroll so the footer (저장 버튼) stays visible */
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: rgba(0, 0, 0, 0.1);
  flex-shrink: 0;   /* never let the footer be squeezed out */
}

/* ==========================================================================
   RESPONSIVENESS
   ========================================================================== */

@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .sidebar {
    width: 70px;
  }
  .sidebar-header {
    padding: 15px;
  }
  .logo-text-box, .profile-info {
    display: none;
  }
  .sidebar-nav {
    padding: 16px 10px;
  }
  .nav-link {
    padding: 12px;
    justify-content: center;
  }
  .nav-link span {
    display: none;
  }
  .main-content {
    margin-left: 70px;
    padding: 20px;
  }
}

@media (max-width: 768px) {
  .main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
  .requests-header-row {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    width: 100%;
  }
}

/* Auth Screen Overlay Styling */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  /* Opaque designed background so the app/dashboard is NOT visible behind the login */
  background-color: #0a0f1e;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44'%3E%3Cpath d='M44 0H0v44' fill='none' stroke='%23ffffff' stroke-opacity='0.05'/%3E%3C/svg%3E"),
    radial-gradient(circle at 16% 20%, rgba(59, 130, 246, 0.30), transparent 45%),
    radial-gradient(circle at 84% 78%, rgba(139, 92, 246, 0.26), transparent 45%),
    linear-gradient(135deg, #0a0f1e 0%, #121a30 50%, #0a0f1e 100%);
  background-repeat: repeat, no-repeat, no-repeat, no-repeat;
  background-size: 44px 44px, cover, cover, cover;
}

/* Decorative glow accents */
.login-screen::before,
.login-screen::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  pointer-events: none;
}
.login-screen::before { width: 320px; height: 320px; background: #3b82f6; top: -80px; left: -80px; }
.login-screen::after { width: 360px; height: 360px; background: #8b5cf6; bottom: -100px; right: -100px; }

.light-theme .login-screen {
  background-color: #eef2f9;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44'%3E%3Cpath d='M44 0H0v44' fill='none' stroke='%230f172a' stroke-opacity='0.05'/%3E%3C/svg%3E"),
    radial-gradient(circle at 16% 20%, rgba(59, 130, 246, 0.18), transparent 45%),
    radial-gradient(circle at 84% 78%, rgba(139, 92, 246, 0.16), transparent 45%),
    linear-gradient(135deg, #eef2f9 0%, #e2e8f5 50%, #eef2f9 100%);
}
.light-theme .login-screen::before,
.light-theme .login-screen::after { opacity: 0.25; }

.login-card { position: relative; z-index: 1; }

.login-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 40px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.light-theme .login-card {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.05);
}

.login-brand {
  margin-bottom: 32px;
}

.auth-toggle-text a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.auth-toggle-text a:hover {
  text-decoration: underline;
  color: var(--color-primary-hover);
}

.btn-logout:hover {
  color: var(--color-danger) !important;
}

/* Spinning icon (e.g. refresh button while loading).
   Applied to the stable button element so re-rendered lucide <svg> icons
   still animate and reliably stop when the class is removed. */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spin {
  animation: spin 0.8s linear infinite;
}
.btn.is-refreshing svg,
.btn.is-refreshing i {
  animation: spin 0.8s linear infinite;
}

/* 모달 내 접이식 섹션 (details/summary 기반 아코디언) */
.modal-accordion {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin-bottom: 14px;
  background: rgba(0, 0, 0, 0.04);
  overflow: hidden;
}
.light-theme .modal-accordion { background: rgba(0, 0, 0, 0.02); }
.modal-accordion > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
}
.modal-accordion > summary::-webkit-details-marker { display: none; }
.modal-accordion > summary .acc-caret {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}
.modal-accordion[open] > summary .acc-caret { transform: rotate(90deg); }
.modal-accordion > summary .acc-hint {
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--text-muted);
}
.modal-accordion-body {
  padding: 8px 14px 2px;
  border-top: 1px solid var(--border-color);
}


/* ==========================================================================
   GLICENSE — 라이선스 관리 전용 컴포넌트
   ========================================================================== */

/* ----- 공통 표 (라이선스/직원/제품 일람) ----- */
.data-table.lic-table td { vertical-align: middle; padding: 10px 12px; }
.data-table.lic-table th { padding: 11px 12px; white-space: nowrap; }

.lic-product-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
}

/* 제품 아이콘 뱃지 (제품명 첫 글자) */
.product-avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  background: var(--color-primary-grad);
}

/* 계정/비밀번호 셀 — 값은 기본 마스킹, 눈 아이콘으로 표시 */
.secret-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.secret-value {
  min-width: 84px;
  letter-spacing: 0.06em;
  color: var(--text-main);
}
.secret-value.masked { letter-spacing: 0.18em; color: var(--text-muted); }

.icon-mini-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.icon-mini-btn:hover { background: rgba(59, 130, 246, 0.12); color: var(--color-primary); }
.icon-mini-btn i, .icon-mini-btn svg { width: 14px; height: 14px; }

/* 사용자 칩 목록 */
.user-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.12);
  color: var(--color-primary);
  border: 1px solid rgba(59, 130, 246, 0.2);
}
.user-chip.empty {
  background: transparent;
  border-style: dashed;
  border-color: var(--border-color);
  color: var(--text-muted);
  font-weight: 500;
}
.user-chip .chip-del {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  opacity: 0.65;
}
.user-chip .chip-del:hover { opacity: 1; color: var(--color-danger); }
.user-chip .chip-del i, .user-chip .chip-del svg { width: 12px; height: 12px; }

/* 좌석 사용량 미터 */
.seat-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 110px;
}
.seat-bar {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}
.seat-bar span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--color-emerald-grad);
  transition: width var(--transition-normal);
}
.seat-bar.warn span { background: linear-gradient(135deg, #f59e0b, #b45309); }
.seat-bar.over span { background: var(--color-rose-grad); }
.seat-text { font-size: 0.76rem; font-weight: 700; color: var(--text-muted); white-space: nowrap; }

/* 금액 셀 */
.amount-cell { text-align: right; font-weight: 700; white-space: nowrap; }
.amount-cell .cycle { font-size: 0.72rem; font-weight: 500; color: var(--text-muted); margin-left: 3px; }

/* 갱신 D-day */
.badge.dday-safe { background-color: rgba(16, 185, 129, 0.15); color: var(--color-success); }
.badge.dday-soon { background-color: rgba(245, 158, 11, 0.15); color: var(--color-warning); }
.badge.dday-over { background-color: rgba(239, 68, 68, 0.15); color: var(--color-danger); }

/* 사용/미사용 상태 */
.badge.use-on { background-color: rgba(16, 185, 129, 0.15); color: var(--color-success); }
.badge.use-off { background-color: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

/* ----- 배정 매트릭스 (직원 × 제품) ----- */
.matrix-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: 12px;
}
.matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}
.matrix-table th, .matrix-table td {
  border-bottom: 1px solid var(--border-color);
  padding: 9px 10px;
  text-align: center;
  white-space: nowrap;
}
.matrix-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg-sidebar);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.matrix-table tbody tr:hover td { background-color: var(--bg-card-hover); }
.matrix-table .matrix-emp {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg-sidebar);
  text-align: left;
  font-weight: 600;
  min-width: 150px;
}
.matrix-table thead .matrix-emp { z-index: 4; }
.matrix-table .matrix-dept { font-size: 0.74rem; color: var(--text-muted); font-weight: 500; display: block; }
.matrix-cell { cursor: pointer; transition: background-color var(--transition-fast); }
.matrix-cell:hover { background-color: rgba(59, 130, 246, 0.1) !important; }
.matrix-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(148, 163, 184, 0.12);
  color: transparent;
}
.matrix-mark.on { background: rgba(16, 185, 129, 0.18); color: var(--color-success); }
.matrix-mark.multi { background: rgba(139, 92, 246, 0.18); color: var(--color-purple); }
.matrix-total { font-weight: 700; color: var(--color-primary); }

/* ----- 비용 분석 ----- */
.cost-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}
.cost-bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 110px;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border-color);
}
.cost-bar-row:last-child { border-bottom: none; }
.cost-bar-name { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cost-bar-track { height: 10px; border-radius: 99px; background: rgba(148, 163, 184, 0.15); overflow: hidden; }
.cost-bar-track span { display: block; height: 100%; border-radius: 99px; background: var(--color-primary-grad); }
.cost-bar-value { text-align: right; font-size: 0.85rem; font-weight: 700; white-space: nowrap; }
.cost-bar-value small { display: block; font-size: 0.7rem; font-weight: 500; color: var(--text-muted); }

/* ----- 라이선스 상세 모달 ----- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin-bottom: 16px;
}
.detail-item { min-width: 0; }
.detail-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}
.detail-value {
  font-size: 0.88rem;
  color: var(--text-main);
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-value a { color: var(--color-primary); }
.detail-value a:hover { text-decoration: underline; }

.assign-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}
.assign-picker select { flex: 1; }

/* ----- 임직원 카드 ----- */
.emp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.emp-card { padding: 18px; border-radius: 14px; }
.emp-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.emp-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--color-purple-grad);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.emp-name { font-weight: 700; font-size: 0.98rem; }
.emp-meta { font-size: 0.76rem; color: var(--text-muted); }
.emp-card-cost {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.emp-card-cost strong { color: var(--text-main); }

/* 툴바 우측 액션 묶음 */
.toolbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* 보안 안내 배너 */
.notice-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: var(--color-warning);
  font-size: 0.82rem;
  margin-bottom: 16px;
}
.notice-bar i, .notice-bar svg { width: 16px; height: 16px; flex-shrink: 0; }

/* 배정 모달 — 제품별 계정 목록 */
.matrix-account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.light-theme .matrix-account-row { background: rgba(0, 0, 0, 0.02); }
.matrix-account-row .btn { flex-shrink: 0; }
.matrix-account-id {
  font-size: 0.86rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 컬럼이 많은 표는 좁은 화면에서 찌그러지지 않도록 최소 폭을 주고 가로 스크롤한다. */
#persons-view .lic-table { min-width: 1280px; }
#groups-view .lic-table { min-width: 1000px; }
#authlog-view .lic-table { min-width: 900px; }
.user-chip { white-space: nowrap; }
/* 사용자(칩) 컬럼은 여러 명이 한 줄에 보이도록 넉넉히 확보 */
#persons-view .lic-table th:nth-child(6),
#persons-view .lic-table td:nth-child(6) { min-width: 260px; }

.badge { white-space: nowrap; }

/* 금액 카드는 자릿수가 길어 폰트를 한 단계 줄여 한 줄에 담는다 */
.stat-card.money .stat-value { font-size: 1.6rem; }

/* ----- 통화 표기 ----- */
.amount-cell .amount-krw {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ----- 변경 이력 ----- */
.data-table.history-table td { vertical-align: top; padding: 11px 12px; }

.change-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.change-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 0.75rem;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  max-width: 100%;
}
.change-chip b { color: var(--text-main); font-weight: 600; }
.change-chip i, .change-chip svg { width: 12px; height: 12px; flex-shrink: 0; }
.change-chip .chg-before { text-decoration: line-through; opacity: 0.75; }
.change-chip .chg-after { color: var(--color-primary); font-weight: 600; }

/* 라이선스 상세 모달의 이력 타임라인 */
.history-timeline {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}
.history-item {
  padding: 9px 11px;
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--color-primary);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}
.light-theme .history-item { background: rgba(0, 0, 0, 0.02); }
.history-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}
.history-time { font-size: 0.73rem; color: var(--text-muted); }
.history-actor { font-size: 0.73rem; color: var(--text-muted); margin-left: auto; }
.history-summary { font-size: 0.84rem; color: var(--text-main); line-height: 1.45; word-break: break-word; }

#history-view .lic-table { min-width: 1100px; }

/* ==========================================================================
   GIMAP 추가 — 상단 사이트 이동 메뉴 · 모바일 대응
   ========================================================================== */

/* 떠 있는 패널(드롭다운·작성창·모바일 서랍)은 불투명해야 뒤가 비치지 않는다.
   기본 --bg-card 는 반투명(rgba)이라 그대로 쓰면 뒤 내용이 겹쳐 보인다. */
:root { --panel-solid: #131a2c; }
.light-theme { --panel-solid: #ffffff; }

/* 상단 사이트 이동 */
.site-switcher { position: relative; }
.site-switcher-label { margin: 0 2px; }
.site-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--panel-solid);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  display: none;
  z-index: 1200;
}
.light-theme .site-menu { box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16); }
.site-menu.open { display: block; }
.site-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.86rem;
}
.site-menu-item:hover { background: rgba(59, 130, 246, 0.12); }
.site-menu-item.current { color: var(--color-primary); font-weight: 600; }
.site-menu-item i { width: 16px; height: 16px; }
.site-menu-empty { padding: 12px; font-size: 0.8rem; color: var(--text-muted); }

/* 설정 — 사이트 목록 편집 행 */
.site-row { align-items: flex-end; }

/* 모바일 햄버거 (데스크톱에서는 숨김) */
.header-title-row { display: flex; align-items: center; gap: 10px; }
.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  padding: 7px;
  cursor: pointer;
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(2px);
  z-index: 998;
  display: none;
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .app-container.sidebar-open .sidebar-backdrop { display: block; }

  /* 사이드바를 화면 밖으로 빼고 햄버거로 밀어 넣는다 */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .app-container.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar .logo-text-box, .sidebar .profile-info { display: block; }
  .sidebar-nav { padding: 16px; }
  .nav-link { padding: 12px 14px; justify-content: flex-start; }
  .nav-link span { display: inline; }
  .sidebar-toggle { display: none; }

  .main-content { margin-left: 0; padding: 14px; }
  .main-header { gap: 12px; }
  .main-header h1 { font-size: 1.15rem; }
  .header-right { gap: 8px; flex-wrap: wrap; }
  .datetime-widget { display: none; }
  .site-switcher-label { display: none; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-value { font-size: 1.4rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .toolbar-actions { flex-wrap: wrap; }
  .toolbar-actions .btn { flex: 1 1 auto; justify-content: center; }
  .status-tabs { overflow-x: auto; }

  /* 모달을 화면에 꽉 채운다 */
  .modal-container { max-width: 100% !important; width: 100%; margin: 0; border-radius: 14px; max-height: 92vh; }
  .modal-body { max-height: 68vh; overflow-y: auto; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1 1 auto; }

  /* 표 → 카드. 셀 앞에 data-label 값을 붙여 항목명을 보여준다 */
  .table-responsive { overflow-x: visible; }
  .data-table, .lic-table { min-width: 0 !important; }
  .data-table thead { display: none; }
  .data-table tr {
    display: block;
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
  }
  .light-theme .data-table tr { background: rgba(0, 0, 0, 0.02); }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border: none;
    padding: 5px 0;
    text-align: right;
    word-break: break-word;
  }
  .data-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-align: left;
  }
  .data-table td:empty { display: none; }
  .data-table td.empty-state, .data-table td[colspan] { display: block; text-align: center; }
  .data-table td[colspan]::before { content: none; }
}

/* ==========================================================================
   GIMAP 메일 쓰기 — 서식 편집기 · 첨부 · 예약
   ========================================================================== */
.link-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0 2px;
  text-decoration: underline;
}
.checkbox-line { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.86rem; }

/* 툴바 */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: rgba(255, 255, 255, 0.04);
}
.light-theme .editor-toolbar { background: rgba(0, 0, 0, 0.03); }
.editor-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}
.editor-btn:hover { background: rgba(59, 130, 246, 0.14); color: var(--text-main); }
.editor-btn i { width: 15px; height: 15px; }
.editor-btn.active, .editor-mode.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.4);
  color: var(--color-primary);
}
.editor-btn input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.editor-select {
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: transparent;
  color: var(--text-main);
  font-size: 0.78rem;
}
.editor-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--border-color); }

/* 본문 편집 영역 */
.editor-area {
  min-height: 220px;
  max-height: 45vh;
  overflow-y: auto;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 0 0 10px 10px;
  background: var(--bg-input, rgba(255, 255, 255, 0.03));
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.7;
  outline: none;
}
.light-theme .editor-area { background: #fff; }
.editor-area:focus { border-color: var(--color-primary); }
.editor-area:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
}
.editor-area h1 { font-size: 1.4rem; margin: 0.4em 0; }
.editor-area h2 { font-size: 1.2rem; margin: 0.4em 0; }
.editor-area h3 { font-size: 1.05rem; margin: 0.4em 0; }
.editor-area blockquote {
  margin: 0.5em 0;
  padding: 6px 12px;
  border-left: 3px solid var(--color-primary);
  color: var(--text-muted);
}
.editor-area ul, .editor-area ol { padding-left: 1.4em; margin: 0.4em 0; }
.editor-area a { color: var(--color-primary); }
.editor-area img { max-width: 100%; }

/* 첨부 */
.attach-drop {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px dashed var(--border-color);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.82rem;
}
.attach-drop.dragover { border-color: var(--color-primary); background: rgba(59, 130, 246, 0.08); }
.attach-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attach-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
}
.light-theme .attach-chip { background: rgba(0, 0, 0, 0.03); }
.attach-chip .attach-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip .attach-size { color: var(--text-muted); }
.attach-chip button { background: none; border: none; color: var(--text-muted); cursor: pointer; display: flex; }
.attach-chip button:hover { color: var(--danger, #ef4444); }

@media (max-width: 768px) {
  .editor-toolbar { gap: 1px; padding: 5px; }
  .editor-btn { min-width: 28px; height: 28px; padding: 0 5px; }
  .editor-area { min-height: 160px; max-height: 38vh; }
  .attach-chip .attach-name { max-width: 130px; }
}

/* ==========================================================================
   GIMAP 메일함 — 폴더 | 목록 | 읽기 3단 레이아웃
   ========================================================================== */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  flex: 0 0 auto;
}
.icon-btn:hover { background: rgba(59, 130, 246, 0.14); color: var(--text-main); }
.icon-btn i { width: 17px; height: 17px; }
.icon-btn.active { background: rgba(59, 130, 246, 0.2); color: var(--color-primary); }
.mobile-only { display: none; }

.mail-shell {
  display: grid;
  grid-template-columns: 220px minmax(300px, 380px) 1fr;
  height: calc(100vh - 190px);   /* JS 가 실제 여백에 맞춰 다시 잡아 준다 */
  min-height: 380px;
  border-radius: 16px;
  overflow: hidden;
}
/* grid·flex 자식은 기본 min-height:auto 라서 내용만큼 커진다.
   0 으로 낮춰야 목록이 컨테이너 안에서 스크롤된다(안 그러면 아래가 잘려 안 보인다). */
.mail-shell > * { min-height: 0; min-width: 0; }
.mail-list-pane, .mail-reader-pane, .mail-folders { overflow: hidden; }

/* 폴더 */
.mail-folders {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
}
.btn-compose-main { width: 100%; justify-content: center; border-radius: 999px; padding: 11px 14px; }
.mail-account-select { font-size: 0.8rem; }
.folder-list { list-style: none; margin: 4px 0 0; padding: 0; flex: 1; }
.folder-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.folder-item:hover { background: rgba(59, 130, 246, 0.1); color: var(--text-main); }
.folder-item.active { background: rgba(59, 130, 246, 0.18); color: var(--color-primary); font-weight: 600; }
.folder-item i { width: 16px; height: 16px; flex: 0 0 auto; }
.folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.folder-count { font-size: 0.72rem; font-weight: 700; }
.folder-refresh { width: 100%; justify-content: center; }

/* 목록 */
.mail-list-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  min-width: 0;
}
.mail-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}
.mail-toolbar .search-box { flex: 1; min-width: 0; }
.mail-count { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.mail-list { flex: 1; overflow-y: auto; }
.mail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  border-left: 3px solid transparent;
}
.mail-item:hover { background: rgba(59, 130, 246, 0.07); }
.mail-item.active { background: rgba(59, 130, 246, 0.13); border-left-color: var(--color-primary); }
.mail-item.unread .mail-item-from, .mail-item.unread .mail-item-subject { font-weight: 700; color: var(--text-main); }
.mail-item-top { display: flex; align-items: center; gap: 8px; }
.mail-item-from { flex: 1; font-size: 0.85rem; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item-date { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }
.mail-item-subject { font-size: 0.84rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item-meta { display: flex; align-items: center; gap: 6px; font-size: 0.71rem; color: var(--text-muted); }
.mail-item-meta i { width: 12px; height: 12px; }
.mail-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-primary); flex: 0 0 auto; }
.mail-list-empty, .mail-list-loading { padding: 40px 16px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* 읽기 */
.mail-reader-pane { display: flex; flex-direction: column; min-width: 0; }
.mail-reader-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.86rem;
}
.mail-reader-empty i { width: 42px; height: 42px; opacity: 0.4; }
.mail-reader { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.reader-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 16px 8px;
}
.reader-subject { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--text-main); line-height: 1.4; word-break: break-word; }
.reader-tools { display: flex; gap: 2px; flex: 0 0 auto; }
.reader-meta { display: flex; align-items: center; gap: 10px; padding: 0 16px 12px; border-bottom: 1px solid var(--border-color); }
.reader-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff; font-size: 0.82rem; font-weight: 700;
  flex: 0 0 auto;
}
.reader-who { flex: 1; min-width: 0; }
.reader-from { font-size: 0.86rem; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-to { font-size: 0.75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-date { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.reader-notice {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 16px 0;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.reader-notice i { width: 15px; height: 15px; }
.reader-attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 0; }
.reader-body { flex: 1; overflow: auto; padding: 14px 16px 20px; }
.reader-body pre.reader-text {
  margin: 0;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
}
.reader-frame { width: 100%; height: 60px; border: none; background: #fff; border-radius: 8px; }

/* ==========================================================================
   메일 쓰기 — 오른쪽 아래 도킹 창
   ========================================================================== */
.compose-dock {
  position: fixed;
  right: 24px;
  bottom: 0;
  z-index: 1400;
  display: flex;
  flex-direction: column;
  width: 620px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 60px);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  background: var(--panel-solid);
  box-shadow: 0 -6px 40px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.light-theme .compose-dock { box-shadow: 0 -6px 40px rgba(15, 23, 42, 0.18); }
.compose-dock.minimized { height: 44px; }
.compose-dock.maximized {
  right: 50%;
  bottom: 50%;
  transform: translate(50%, 50%);
  width: min(1000px, calc(100vw - 60px));
  height: min(88vh, 900px);
  border-radius: 12px;
  border-bottom: 1px solid var(--border-color);
}
.compose-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  background: rgba(59, 130, 246, 0.14);
  cursor: pointer;
  flex: 0 0 auto;
}
.compose-title { flex: 1; font-size: 0.86rem; font-weight: 600; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-head-tools { display: flex; gap: 2px; }
.compose-head-tools .icon-btn { width: 28px; height: 28px; }
.compose-dock.minimized .compose-body { display: none; }

.compose-body { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 10px 14px 12px; gap: 8px; overflow-y: auto; }
.compose-fields { display: flex; flex-direction: column; }
.compose-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
}
.compose-row label { flex: 0 0 76px; font-size: 0.78rem; color: var(--text-muted); }
.compose-row .link-btn { flex: 0 0 auto; padding-left: 8px; }
.compose-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  color: var(--text-main);
  font-size: 0.87rem;
  outline: none;
  padding: 3px 0;
}
.compose-input:focus { outline: none; }
select.compose-input { color: var(--text-main); }
select.compose-input option { background: var(--panel-solid); }

.compose-body .editor-toolbar { border-radius: 8px; border-bottom: 1px solid var(--border-color); }
.compose-body .editor-area { flex: 1; min-height: 140px; max-height: none; border-radius: 0 0 8px 8px; }
.compose-schedule {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.8rem;
}
.compose-schedule label { color: var(--text-muted); }
.compose-schedule .compose-input { flex: 0 0 auto; }
.compose-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  flex: 0 0 auto;
}
.compose-foot .btn-primary { border-radius: 999px; padding: 9px 20px; }
.compose-foot-info { flex: 1; font-size: 0.75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-schedule-toggle { cursor: pointer; }

@media (max-width: 1100px) {
  .mail-shell { grid-template-columns: 190px minmax(260px, 320px) 1fr; }
}

@media (max-width: 900px) {
  /* 목록과 읽기를 한 화면에 하나씩 */
  .mail-shell { grid-template-columns: 1fr; height: calc(100vh - 200px); }
  .mobile-only { display: inline-flex; }
  .mail-folders {
    position: absolute;
    z-index: 20;
    width: 230px;
    height: 100%;
    background: var(--panel-solid);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
  }
  .mail-shell.folders-open .mail-folders { transform: translateX(0); box-shadow: 8px 0 30px rgba(0, 0, 0, 0.3); }
  .mail-list-pane { border-right: none; }
  .mail-shell.reading .mail-list-pane { display: none; }
  .mail-shell:not(.reading) .mail-reader-pane { display: none; }

  .compose-dock, .compose-dock.maximized {
    right: 0; bottom: 0; left: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  .compose-dock.minimized { top: auto; height: 44px; }
  .compose-row label { flex: 0 0 62px; }
}

/* 좁은 화면에서는 정렬·문단형식 버튼을 숨겨 툴바를 두 줄 안에 넣는다 */
@media (max-width: 520px) {
  .editor-toolbar .editor-select,
  .editor-toolbar .editor-btn[data-cmd^="justify"],
  .editor-toolbar .editor-btn[data-cmd="insertHorizontalRule"] { display: none; }
}

/* ==========================================================================
   GIMAP 그룹웨어 — 메뉴 그룹 · 근태 · 캘린더 · 칸반 · 결재선
   ========================================================================== */

/* 사이드바 메뉴 그룹 헤더 */
.nav-group {
  padding: 14px 14px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  opacity: 0.7;
  text-transform: uppercase;
}
.nav-group:first-child { padding-top: 4px; }
.sidebar-collapsed .nav-group span { display: none; }
.sidebar-collapsed .nav-group {
  padding: 8px 0 4px;
  margin: 0 12px;
  border-top: 1px solid var(--border-color);
}
.nav-badge {
  margin-left: auto;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
}
.sidebar-collapsed .nav-badge { display: none; }

/* 근태 — 출퇴근 카드 */
.work-top { display: grid; grid-template-columns: minmax(300px, 1fr) 1fr; gap: 16px; }
.punch-times { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.punch-slot {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.light-theme .punch-slot { background: rgba(0, 0, 0, 0.02); }
.punch-label { font-size: 0.72rem; color: var(--text-muted); }
.punch-value { font-size: 1.15rem; font-weight: 700; color: var(--text-main); font-family: 'Outfit', sans-serif; }
.punch-actions { display: flex; gap: 8px; }
.punch-actions .btn { flex: 1; justify-content: center; padding: 12px; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 10px; }
.mini-stat {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  text-align: center;
}
.mini-stat-value { display: block; font-size: 1.2rem; font-weight: 700; color: var(--text-main); }
.mini-stat-label { font-size: 0.72rem; color: var(--text-muted); }

/* 캘린더 */
.calendar { padding: 0 16px 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border-color); border: 1px solid var(--border-color); border-radius: 10px; overflow: hidden; }
.cal-dow {
  padding: 8px 6px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}
.light-theme .cal-dow { background: rgba(0, 0, 0, 0.03); }
.cal-dow.sun { color: #f87171; }
.cal-dow.sat { color: #60a5fa; }
.cal-cell {
  min-height: 104px;
  padding: 6px;
  background: var(--bg-main, #0d1424);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.light-theme .cal-cell { background: #fff; }
.cal-cell.other { opacity: 0.45; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--color-primary); }
.cal-date { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
.cal-cell.today .cal-date { color: var(--color-primary); }
.cal-event {
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.71rem;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.cal-event.work { background: #3b82f6; }
.cal-event.meeting { background: #8b5cf6; }
.cal-event.outside { background: #f59e0b; }
.cal-event.etc { background: #64748b; }
.cal-event.leave { background: #10b981; cursor: default; }

/* 칸반 (업무) */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 0 16px; }
.kanban-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  min-height: 200px;
}
.light-theme .kanban-col { background: rgba(0, 0, 0, 0.02); }
.kanban-head { display: flex; align-items: center; justify-content: space-between; font-size: 0.8rem; font-weight: 700; color: var(--text-main); }
.kanban-card {
  padding: 10px;
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--color-primary);
  border-radius: 8px;
  background: var(--panel-solid);
  cursor: pointer;
}
.kanban-card:hover { border-color: var(--color-primary); }
.kanban-card.high { border-left-color: #ef4444; }
.kanban-card.low { border-left-color: #64748b; }
.kanban-title { font-size: 0.84rem; color: var(--text-main); margin-bottom: 6px; word-break: break-word; }
.kanban-meta { display: flex; align-items: center; gap: 8px; font-size: 0.72rem; color: var(--text-muted); flex-wrap: wrap; }
.kanban-meta .overdue { color: #f87171; font-weight: 600; }
.kanban-progress { height: 4px; margin-top: 8px; border-radius: 999px; background: rgba(148, 163, 184, 0.25); overflow: hidden; }
.kanban-progress span { display: block; height: 100%; background: var(--color-primary); }

/* 결재선 */
.approval-line { display: flex; flex-direction: column; gap: 8px; }
.appr-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
}
.appr-step.current { border-color: var(--color-primary); background: rgba(59, 130, 246, 0.08); }
.appr-no {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.2);
  font-size: 0.72rem; font-weight: 700;
  color: var(--text-muted);
  flex: 0 0 auto;
}
.appr-step.approved .appr-no { background: #10b981; color: #fff; }
.appr-step.rejected .appr-no { background: #ef4444; color: #fff; }
.appr-step.current .appr-no { background: var(--color-primary); color: #fff; }
.appr-who { flex: 1; font-size: 0.84rem; color: var(--text-main); }
.appr-comment { font-size: 0.75rem; color: var(--text-muted); }
.appr-when { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }
.approver-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.approver-row select { flex: 1; }

@media (max-width: 1100px) {
  .work-top { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .kanban { grid-template-columns: 1fr; padding: 0 12px; }
  .punch-times { grid-template-columns: repeat(2, 1fr); }
  .calendar { padding: 0 8px 12px; }
  .cal-cell { min-height: 66px; padding: 3px; }
  .cal-event { font-size: 0.62rem; padding: 1px 3px; }
  .cal-date { font-size: 0.68rem; }
}

/* 대시보드 홈 위젯 — 근무·일정·업무 3단 */
.home-widgets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.home-widgets .dashboard-card { min-height: 200px; }
@media (max-width: 1200px) { .home-widgets { grid-template-columns: 1fr 1fr; } }
@media (max-width: 768px) { .home-widgets { grid-template-columns: 1fr; } }

/* 비활성 버튼이 눌리는 것처럼 보이지 않게 */
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.3); }

/* 처리 중 버튼 — 스피너 + 비활성 */
.btn .spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 2px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
.btn.is-busy { pointer-events: none; opacity: 0.75; }

/* 발송 진행 표시 (작성창 하단) */
.compose-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--color-primary);
  font-size: 0.8rem;
}
.compose-progress .spinner { border-color: rgba(59, 130, 246, 0.3); border-top-color: var(--color-primary); }

/* 목록 끝 — 더 보기 / 마지막 안내 */
.mail-list-more { padding: 12px; text-align: center; }
.mail-list-more .btn { width: 100%; justify-content: center; }
.mail-list-end { padding: 14px; text-align: center; font-size: 0.74rem; color: var(--text-muted); }

/* 첨부 칩 (버튼·링크 공통) — 버튼은 색·글꼴을 물려받지 않아 다크테마에서 검게 보였다 */
.attach-chip, a.attach-chip, button.attach-chip {
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.78rem;
  text-decoration: none;
  cursor: pointer;
}
.attach-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.attach-chip .attach-name { color: inherit; }
.attach-chip.is-busy { opacity: 0.6; pointer-events: none; }

/* 본문 배경 전환 버튼 (밝게 / 어둡게) */
.reader-tools .icon-btn.tone-on { color: var(--color-primary); background: rgba(59, 130, 246, 0.16); }
.reader-frame.tone-dark { background: #0f172a; }

/* 메일 본문 로딩 표시 — 리더 위에 겹쳐 띄운다.
   (display:none 으로 감추면 iframe 이 로드되지 않아 본문이 영영 안 뜬다) */
.mail-reader-pane { position: relative; }
.reader-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--panel-solid);
  color: var(--text-muted);
  font-size: 0.86rem;
}
.reader-loading .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(148, 163, 184, 0.3);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
/* 목록에서 지금 열고 있는 메일 */
.mail-item.loading { opacity: 0.7; }
.mail-item.loading .mail-item-subject::after {
  content: ' · 여는 중…';
  color: var(--color-primary);
  font-size: 0.72rem;
}

/* 본문이 준비되면 부드럽게 나타난다 */
.reader-frame { transition: opacity 0.12s ease; }

/* ==========================================================================
   상단 알림 (벨)
   ========================================================================== */
.noti-wrap { position: relative; }
.noti-btn { width: 36px; height: 36px; border: 1px solid var(--border-color); border-radius: 10px; }
.noti-btn.has-new { color: var(--color-primary); border-color: rgba(59, 130, 246, 0.45); }
.noti-dot {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.noti-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-height: 60vh;
  display: none;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--panel-solid);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  z-index: 1300;
  overflow: hidden;
}
.light-theme .noti-panel { box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16); }
.noti-panel.open { display: flex; }
.noti-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}
.noti-list { overflow-y: auto; }
.noti-item {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}
.noti-item:hover { background: rgba(59, 130, 246, 0.08); }
.noti-item .noti-icon {
  width: 28px; height: 28px;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.14);
  color: var(--color-primary);
}
.noti-item .noti-icon i { width: 15px; height: 15px; }
.noti-item.kind-result .noti-icon { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.noti-item.kind-task .noti-icon { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.noti-item.kind-mail .noti-icon { background: rgba(148, 163, 184, 0.18); color: var(--text-muted); }
.noti-body { flex: 1; min-width: 0; }
.noti-title { font-size: 0.82rem; font-weight: 600; color: var(--text-main); }
.noti-detail { font-size: 0.76rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noti-at { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; }
.noti-empty { padding: 28px 14px; text-align: center; font-size: 0.8rem; color: var(--text-muted); }

@media (max-width: 768px) {
  .noti-panel { width: calc(100vw - 24px); right: -8px; }
}

/* 작성 편집기 — 붙여넣기·인용문이 색을 들고 와도 테마 색을 따르게 한다 */
.editor-area, .editor-area * { color: var(--text-main); }
.editor-area a { color: var(--color-primary); }
.editor-area blockquote { color: var(--text-muted); }
.editor-area hr { border-color: var(--border-color); }
/* 사용자가 툴바로 직접 고른 색은 그대로 살린다 */
.editor-area font[color], .editor-area [style*="color"] { color: revert; }
