/* ============================================================
   PM System - Complete Stylesheet
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: #1e293b;
  background: #f1f5f9;
  min-height: 100vh;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; outline: none; }
table { width: 100%; border-collapse: collapse; }
img { max-width: 100%; }

/* --- Colors --- */
:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --primary-bg: #eef2ff;
  --sidebar-bg: #1e1b4b;
  --sidebar-hover: #312e81;
  --sidebar-active: #4338ca;
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --info: #3b82f6;
  --info-bg: #dbeafe;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --transition: .2s ease;
}

/* =============== LOGIN PAGE =============== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  top: -200px;
  right: -200px;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  bottom: -100px;
  left: -100px;
}
.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-icon {
  width: 64px;
  height: 64px;
  background: var(--primary-bg);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.login-icon i { font-size: 28px; color: var(--primary); }
.login-header h1 { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.login-subtitle { color: var(--gray-500); font-size: 14px; margin-top: 4px; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.login-form label i { color: var(--gray-400); font-size: 12px; }
.login-form input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color var(--transition);
  background: var(--gray-50);
}
.login-form input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.login-footer { text-align: center; margin-top: 24px; color: var(--gray-400); font-size: 12px; }

/* =============== APP LAYOUT =============== */
#app {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  overflow: hidden;
}
.sidebar.collapsed { width: 60px; }
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: 60px;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  white-space: nowrap;
}
.sidebar-logo i { font-size: 22px; color: #818cf8; }
.sidebar-title { font-weight: 600; font-size: 15px; }
.sidebar.collapsed .sidebar-title { display: none; }
.sidebar-toggle {
  color: rgba(255,255,255,.5);
  font-size: 18px;
  padding: 4px;
  transition: color var(--transition);
}
.sidebar-toggle:hover { color: #fff; }
.sidebar.collapsed .sidebar-toggle { transform: rotate(90deg); }

.sidebar-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.65);
  transition: all var(--transition);
  margin-bottom: 2px;
  white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item i { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 500; white-space: nowrap; }
.user-role { font-size: 11px; color: rgba(255,255,255,.5); }
.sidebar.collapsed .user-info { display: none; }

/* --- Main Content --- */
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.sidebar.collapsed + .main-content,
.sidebar.collapsed ~ .main-content { margin-left: 60px; }

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-toggle {
  display: none;
  font-size: 20px;
  color: var(--gray-600);
  padding: 4px;
}
.page-title { font-size: 18px; font-weight: 600; color: var(--gray-800); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* Content Area */
.content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* =============== BUTTONS =============== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn i { font-size: 14px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}
.btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn .btn-loading { display: none; }
.btn.loading .btn-text { display: none; }
.btn.loading .btn-loading { display: inline-flex; align-items: center; gap: 6px; }

/* =============== FORMS =============== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fff;
  transition: border-color var(--transition);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.form-control-sm { padding: 6px 10px; font-size: 13px; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* =============== CARDS =============== */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon.purple { background: var(--primary-bg); color: var(--primary); }
.stat-info { flex: 1; }
.stat-label { font-size: 13px; color: var(--gray-500); }
.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}
.stat-value small { font-size: 14px; font-weight: 400; color: var(--gray-500); }

/* =============== TABLES =============== */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
table th, table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}
table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  background: var(--gray-50);
}
table td { font-size: 14px; }
table tr:hover td { background: var(--gray-50); }
table tr:last-child td { border-bottom: none; }

/* =============== TAGS / BADGES =============== */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.tag-blue { background: var(--info-bg); color: #2563eb; }
.tag-green { background: var(--success-bg); color: #059669; }
.tag-orange { background: var(--warning-bg); color: #d97706; }
.tag-red { background: var(--danger-bg); color: #dc2626; }
.tag-gray { background: var(--gray-100); color: var(--gray-600); }
.tag-purple { background: #ede9fe; color: #7c3aed; }

/* =============== MODAL =============== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-sm { max-width: 400px; }
.modal-lg { max-width: 700px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  font-size: 22px;
  color: var(--gray-400);
  padding: 0 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--gray-700); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* =============== TOAST =============== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: slideIn .3s ease;
  min-width: 280px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-warning { background: var(--warning); color: #fff; }
.toast-info { background: var(--info); color: #fff; }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* =============== LOADING =============== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--gray-400);
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============== EMPTY STATE =============== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; color: var(--gray-300); }
.empty-state h3 { color: var(--gray-600); font-size: 16px; margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

/* =============== GRID LAYOUTS =============== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* =============== TAB NAV =============== */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
}
.tab-item {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  cursor: pointer;
}
.tab-item:hover { color: var(--gray-700); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* =============== SEARCH BAR =============== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-input-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 14px;
}
.search-input-wrap input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fff;
  transition: border-color var(--transition);
}
.search-input-wrap input:focus { border-color: var(--primary); }
.filter-select {
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  background: #fff;
  font-size: 14px;
  min-width: 120px;
}

/* =============== PROJECT CARDS =============== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.project-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: box-shadow var(--transition);
  cursor: pointer;
}
.project-card:hover { box-shadow: var(--shadow-md); }
.project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.project-card-header h4 { font-size: 15px; font-weight: 600; }
.project-card-body { font-size: 13px; color: var(--gray-500); }
.project-progress {
  margin-top: 12px;
}
.progress-bar {
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width .3s ease;
}
.progress-fill.green { background: var(--success); }
.progress-fill.orange { background: var(--warning); }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--gray-500);
}

/* =============== KANBAN =============== */
.kanban {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.kanban-column {
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
}
.kanban-header {
  font-size: 14px;
  font-weight: 600;
  padding: 8px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kanban-count {
  background: var(--gray-300);
  color: var(--gray-600);
  padding: 1px 8px;
  border-radius: 100px;
  font-size: 12px;
}
.kanban-item {
  background: #fff;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow var(--transition);
}
.kanban-item:hover { box-shadow: var(--shadow-md); }
.kanban-item h5 { font-size: 14px; margin-bottom: 4px; }
.kanban-item .meta { font-size: 12px; color: var(--gray-500); }

/* =============== DETAIL PAGE =============== */
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.detail-header h2 { font-size: 20px; font-weight: 600; }
.back-btn {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--gray-600);
  background: var(--gray-100);
  transition: background var(--transition);
}
.back-btn:hover { background: var(--gray-200); }

/* =============== SETTINGS =============== */
.settings-section {
  margin-bottom: 24px;
}
.settings-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.setting-item:last-child { border-bottom: none; }
.setting-label { font-size: 14px; font-weight: 500; }
.setting-desc { font-size: 12px; color: var(--gray-500); }

/* =============== RESPONSIVE =============== */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); width: 240px; }
  .sidebar.open .sidebar-title { display: inline; }
  .sidebar.open .nav-label { display: inline; }
  .sidebar.open .nav-item { justify-content: flex-start; padding: 10px 14px; }
  .sidebar.open .user-info { display: flex; }
  .main-content { margin-left: 0; }
  .sidebar.open + .main-content,
  .sidebar.open ~ .main-content { margin-left: 0; }
  .topbar-toggle { display: block; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: 1fr; }
  .project-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .modal { max-width: 100%; margin: 10px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-right .btn span { display: none; }
}
