/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  background: #f4f5f8;
  color: #1a1d26;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== Nav ===== */
.app-nav {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  display: flex; align-items: center; gap: 1.5rem;
  height: 56px; padding: 0 2rem; overflow: visible;
  background: rgba(255,255,255,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.app-nav .logo { font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em; color: #1e3a5f; display: flex; align-items: center; gap: .5rem; }
.app-nav .logo span { background: #1e3a5f; color: #fff; font-size: .65rem; padding: .15rem .5rem; border-radius: 4px; letter-spacing: .03em; }
.nav-pages { display: flex; gap: .25rem; margin-left: 2rem; overflow: visible; scrollbar-width: none; flex-shrink: 0; }
.nav-pages::-webkit-scrollbar { display: none; }
.nav-pages button {
  all: unset; cursor: pointer; padding: .4rem .85rem; border-radius: 6px;
  font-size: .82rem; color: #5a6270; white-space: nowrap; transition: all .2s;
}
.nav-pages button:hover { background: rgba(30,58,95,.06); color: #1a1d26; }
.nav-pages button.active { background: #1e3a5f; color: #fff; font-weight: 500; }

/* ===== Nav dropdown ===== */
.nav-drop-wrap { position: relative; display: flex; align-items: center; overflow: visible; }
.nav-drop-wrap > button { padding-right: .55rem; }
.nav-drop-wrap > button::after { content: '▾'; font-size: .55rem; margin-left: .15rem; opacity: .55; vertical-align: middle; }
.nav-dropdown { display: none; position: absolute; top: 100%; left: 0; z-index: 9999; min-width: 130px; background: #fff; border-radius: 8px; border: 1px solid #e2e6ed; box-shadow: 0 8px 24px rgba(0,0,0,.08); padding: .3rem; margin-top: 2px; }
.nav-dropdown.open { display: block; }
.nav-dropdown button { all: unset; display: flex; align-items: center; width: 100%; padding: .4rem .7rem; border-radius: 5px; font-size: .8rem; color: #374151; cursor: pointer; white-space: nowrap; box-sizing: border-box; }
.nav-dropdown button:hover { background: #f3f4f6; color: #1a1d26; }
.nav-dropdown button.active { background: #eef3f8; color: #1e3a5f; font-weight: 500; }
.nav-drop-wrap:hover .nav-dropdown { display: block; }

/* ===== Nav special buttons ===== */
.nav-pages button.nav-new { background: #b6510b; color: #fff; }
.nav-pages button.nav-new:hover { background: #d4620f; }
.nav-pages button.nav-admin { background: #6b7280; color: #fff; }
.nav-pages button.nav-admin:hover { background: #7c838f; }

.nav-extra { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.nav-extra .avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg,#1e3a5f,#2d5f8b); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 600; cursor: pointer; }

/* ===== Layout ===== */
.main { margin-top: 56px; padding: 2rem; max-width: 1280px; margin-left: auto; margin-right: auto; }
.page { display: none; }
.page.active { display: block; animation: fadeUp .35s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Common Components ===== */
.page-hdr { margin-bottom: 2rem; }
.page-hdr h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.03em; color: #0f141c; }
.page-hdr .sub { font-size: .88rem; color: #5a6270; margin-top: .25rem; }
.flex { display: flex; gap: 1rem; flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.gap-sm { gap: .5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.text-sm { font-size: .82rem; }
.text-xs { font-size: .72rem; }
.text-muted { color: #5a6270; }
.text-right { text-align: right; }
.w-full { width: 100%; }

/* ===== Cards ===== */
.card {
  background: #fff; border-radius: 12px; border: 1px solid rgba(0,0,0,.06);
  box-shadow: 0 1px 3px rgba(0,0,0,.04); transition: box-shadow .2s;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.card-hdr { padding: 1rem 1.25rem; border-bottom: 1px solid rgba(0,0,0,.04); font-weight: 600; font-size: .92rem; display: flex; align-items: center; justify-content: space-between; }
.card-body { padding: 1.25rem; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; padding: .12rem .5rem; border-radius: 100px;
  font-size: .7rem; font-weight: 500; letter-spacing: .01em;
}
.badge-blue { background: #e8eeff; color: #2d5f8b; }
.badge-green { background: #e4f4e8; color: #1f6e3a; }
.badge-orange { background: #fff0e0; color: #b6510b; }
.badge-red { background: #ffe8e8; color: #b91c1c; }
.badge-gray { background: #eff0f2; color: #5a6270; }
.badge-purple { background: #ede8ff; color: #5a3e9e; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: 8px;
  font-size: .85rem; font-weight: 500; border: none; cursor: pointer; transition: all .2s;
  text-decoration: none;
}
.btn-primary { background: #1e3a5f; color: #fff; }
.btn-primary:hover { background: #2a4e78; }
.btn-outline { background: transparent; color: #1a1d26; border: 1px solid #d4d6dd; }
.btn-outline:hover { background: rgba(0,0,0,.03); border-color: #b0b4be; }
.btn-ghost { background: transparent; color: #5a6270; }
.btn-ghost:hover { background: rgba(0,0,0,.04); }
.btn-sm { padding: .3rem .65rem; font-size: .78rem; border-radius: 6px; }
.btn-lg { padding: .7rem 1.5rem; font-size: .95rem; }

/* ===== Input ===== */
.input-group { margin-bottom: 1rem; }
.input-group label { display: block; font-size: .82rem; font-weight: 500; margin-bottom: .3rem; color: #2a2d36; }
.input-group input, .input-group textarea, .input-group select {
  width: 100%; padding: .55rem .75rem; border: 1px solid #d4d6dd; border-radius: 8px;
  font-size: .85rem; font-family: inherit; transition: border-color .2s; background: #fff;
}
.input-group input:focus, .input-group textarea:focus, .input-group select:focus {
  outline: none; border-color: #1e3a5f; box-shadow: 0 0 0 3px rgba(30,58,95,.1);
}
.input-group textarea { resize: vertical; min-height: 80px; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th { text-align: left; padding: .65rem .75rem; font-weight: 600; color: #5a6270; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid #eeeef0; }
td { padding: .65rem .75rem; border-bottom: 1px solid #f0f0f2; }
tr:last-child td { border-bottom: none; }

/* ===== Tabs (for plan page) ===== */
.tabs { display: flex; gap: 0; margin-bottom: 0; border-bottom: 2px solid #e2e6ed; }
.tab { padding: .7rem 1.5rem; font-size: .9rem; font-weight: 500; color: #6b7280; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; user-select: none; }
.tab:hover { color: #374151; }
.tab.active { color: #1e3a5f; border-bottom-color: #1e3a5f; }
.tab .count { display: inline-flex; align-items: center; justify-content: center; background: #e8eaee; color: #5a6270; font-size: .7rem; font-weight: 600; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 .35rem; margin-left: .4rem; }
.tab.active .count { background: #e0e7f0; color: #1e3a5f; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Bottom bar (for plan page table) ===== */
.bottom-bar { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1.25rem; border-top: 1px solid #f0f2f4; }

/* ===== Plan page inline editing ===== */
.inline-input-sm { width: 100%; padding: .3rem .4rem; border: 1.5px solid #d4d6dd; border-radius: 5px; font-size: .78rem; font-family: inherit; outline: none; box-sizing: border-box; background: #fff; }
.inline-input-sm:focus { border-color: #1e3a5f; box-shadow: 0 0 0 2px rgba(30,58,95,.06); }
.inline-date { width: 100%; padding: .3rem .4rem; border: 1.5px solid #d4d6dd; border-radius: 5px; font-size: .78rem; font-family: inherit; outline: none; box-sizing: border-box; min-width: 110px; background: #fff; }
.inline-date:focus { border-color: #1e3a5f; box-shadow: 0 0 0 2px rgba(30,58,95,.06); }
.inline-select { width: 100%; padding: .3rem .4rem; border: 1.5px solid #d4d6dd; border-radius: 5px; font-size: .78rem; font-family: inherit; outline: none; box-sizing: border-box; background: #fff; }
.inline-select:focus { border-color: #1e3a5f; }

/* ===== Plan page operation buttons ===== */
.op-btns { display: flex; gap: .2rem; justify-content: center; }
.op-btns .btn-op { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 6px; border: none; cursor: pointer; font-size: .78rem; background: transparent; color: #6b7280; transition: all .12s; }
.op-btns .btn-op:hover { background: #f3f4f6; }
.op-btns .btn-op.edit:hover { color: #1e3a5f; background: #eef3f8; }
.op-btns .btn-op.delete:hover { color: #b91c1c; background: #fef2f2; }
.op-btns .btn-op.add:hover { color: #1f6e3a; background: #f0fdf4; }
.op-btns .btn-op.save { color: #1f6e3a; }
.op-btns .btn-op.cancel { color: #6b7280; }

/* ===== New row placeholder ===== */
.new-row td { color: #9ca3af; cursor: pointer; font-style: italic; }
.new-row:hover td { color: #1e3a5f; background: #fafbfc; }

/* ===== Phase tags ===== */
.phase-tag { display: inline-block; font-size: .72rem; padding: .15rem .5rem; border-radius: 4px; font-weight: 500; }
.phase-1 { background: #eef3f8; color: #1e3a5f; }
.phase-2 { background: #f0fdf4; color: #1f6e3a; }
.phase-3 { background: #fff8f0; color: #b6510b; }
.phase-4 { background: #faf0ff; color: #7c3aed; }

/* ===== Sprint page inline inputs ===== */
.sp-inp { width: 100%; padding: .2rem .35rem; border: 1.5px solid #d4d6dd; border-radius: 4px; font-size: .75rem; font-family: inherit; outline: none; box-sizing: border-box; background: #fff; min-width: 56px; }
.sp-inp:focus { border-color: #1e3a5f; box-shadow: 0 0 0 2px rgba(30,58,95,.06); }
.sp-date { width: 100%; padding: .2rem .35rem; border: 1.5px solid #d4d6dd; border-radius: 4px; font-size: .75rem; font-family: inherit; outline: none; box-sizing: border-box; background: #fff; min-width: 88px; }
.sp-date:focus { border-color: #1e3a5f; }
.sp-progress { width: 44px; padding: .15rem .25rem; border: 1.5px solid #d4d6dd; border-radius: 4px; font-size: .75rem; text-align: center; outline: none; font-family: inherit; background: #fff; }
.sp-progress:focus { border-color: #1e3a5f; }

/* ===== Week picker ===== */
.week-picker select { padding: .35rem .6rem; border: 1.5px solid #d4d6dd; border-radius: 6px; font-size: .82rem; outline: none; background: #fff; min-width: 120px; }

/* ===== Progress ===== */
.progress-bar { height: 6px; background: #e8eaee; border-radius: 100px; overflow: hidden; }
.progress-bar .fill { height: 100%; border-radius: 100px; transition: width .5s ease; }
.fill-blue { background: #2d5f8b; }
.fill-green { background: #1f6e3a; }
.fill-orange { background: #b6510b; }
.fill-gray { background: #b0b4be; }

/* ===== Project Grid ===== */
.project-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem;
}
.project-card {
  background: #fff; border-radius: 12px; border: 1px solid rgba(0,0,0,.06);
  padding: 1.25rem; cursor: pointer; transition: all .25s;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.project-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,.08); transform: translateY(-2px);
  border-color: rgba(30,58,95,.15);
}
.project-card .pname { font-weight: 600; font-size: 1rem; margin-bottom: .25rem; }
.project-card .pdesc { font-size: .82rem; color: #5a6270; margin-bottom: .75rem; }
.project-card .pmeta { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: #7a8290; }
.create-card {
  border: 2px dashed #d4d6dd; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 140px; color: #7a8290; transition: all .25s;
}
.create-card:hover { border-color: #1e3a5f; color: #1e3a5f; background: rgba(30,58,95,.02); }
.create-card .icon { font-size: 2rem; line-height: 1; margin-bottom: .5rem; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .main { padding: 1rem; }
  .app-nav { padding: 0 1rem; gap: .75rem; }
  .nav-pages { margin-left: .5rem; }
  .nav-pages button { font-size: .72rem; padding: .3rem .5rem; }
  .project-grid { grid-template-columns: 1fr; }
}
