:root {
  --bg: #fdf7fa;
  --surface: #ffffff;
  --text: #172033;
  --muted: #6f7787;
  --line: #eadce6;
  --primary: #1f5eff;
  --primary-2: #0d43c7;
  --success: #16865c;
  --warning: #b46b00;
  --danger: #c93d45;
  --shadow: 0 16px 44px rgba(88, 56, 92, .10);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 800; letter-spacing: .11em; color: #7d8596; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(rgba(251, 243, 248, .76), rgba(252, 247, 250, .82)),
    url("./login-bg-hcmue.webp") center center / cover no-repeat;
}
.login-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 14% 16%, rgba(255,255,255,.52), transparent 20%),
    radial-gradient(circle at 84% 20%, rgba(255, 204, 228, .20), transparent 18%),
    radial-gradient(circle at 78% 84%, rgba(244, 204, 230, .18), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,.12), rgba(249,236,244,.24));
  z-index: -1;
}
.login-card {
  width: min(460px, 100%);
  background: linear-gradient(160deg, rgba(255, 252, 254, .97), rgba(255, 238, 247, .96));
  border: 1px solid rgba(220, 150, 188, .72);
  border-radius: 30px;
  box-shadow: 0 28px 74px rgba(104, 58, 89, .22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 36px;
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 7px;
  background: linear-gradient(90deg, #ffbdd8 0%, #f7a8cf 36%, #c7d8ff 100%);
}
.login-card h1 { margin: 0 0 12px; font-size: 38px; line-height: 1.18; color: #3b2532; }
.login-card > * { position: relative; z-index: 1; }
.login-main-title {
  max-width: 360px;
  font-weight: 900;
  letter-spacing: -.02em;
  text-wrap: balance;
}
.login-eyebrow {
  max-width: 320px;
  margin: 0 0 8px;
  font-size: 11px;
  line-height: 1.45;
  letter-spacing: .08em;
}
.login-watermark {
  position: absolute;
  left: 50%;
  top: 56%;
  width: 82%;
  height: 82%;
  transform: translate(-50%, -50%);
  opacity: .08;
  pointer-events: none;
  z-index: 0;
  filter: saturate(1.05);
}
.login-watermark-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.login-note { margin: 18px 0 0; font-size: 13px; color: #5e6880; text-align: center; }
.login-slogan {
  margin: 10px 0 0;
  padding-bottom: 12px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.55;
  text-align: center;
  color: #a14f77;
  letter-spacing: .01em;
}
.brand-mark {
  width: 54px; height: 54px; border-radius: 16px;
  display: grid; place-items: center; margin-bottom: 22px;
  font-weight: 900; color: white; background: var(--primary);
  box-shadow: 0 10px 24px rgba(31,94,255,.25);
}
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; margin: 0; }
.brand-mark.image-mode { background: transparent; box-shadow: none; padding: 0; }
.brand-logo { width: 100%; height: 100%; object-fit: contain; display: block; }
#loginBrandMark.image-mode, #sidebarBrandMark.image-mode { background: transparent; box-shadow: none; }
.auth-switch { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 18px 0 8px; }
.auth-switch .text-btn { padding: 0; font-weight: 700; }
.auth-switch .text-btn.active { color: var(--primary-2); text-decoration: underline; text-underline-offset: 3px; }

.form-stack { display: grid; gap: 16px; margin-top: 24px; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; color: #454d5c; }
input, select, textarea {
  width: 100%; border: 1px solid #e7cfdb; border-radius: 11px;
  background: rgba(255,255,255,.92); padding: 11px 12px; outline: none; color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus { border-color: #d38ab3; box-shadow: 0 0 0 3px rgba(220, 118, 172, .12); background: #fffdfd; }
textarea { resize: vertical; }
.error-text { color: var(--danger); font-size: 13px; min-height: 20px; }

.btn {
  border: 0; border-radius: 11px; padding: 10px 14px; font-weight: 800;
  transition: transform .12s, opacity .12s, background .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-2); }
.btn.ghost { background: #eef2f7; color: #394150; }
.btn.danger { background: #fff0f1; color: var(--danger); }
.btn.full { width: 100%; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 245px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px;
  background: #101827; color: white; display: flex; flex-direction: column;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.side-brand strong { display: block; font-size: 15px; }
.side-brand small { color: #9aa5b6; }
.nav-list { display: grid; gap: 7px; }
.nav-item {
  border: 0; border-radius: 11px; padding: 11px 12px; text-align: left;
  background: transparent; color: #aeb7c6; font-weight: 700;
}
.nav-item:hover, .nav-item.active { color: white; background: #1c2940; }
.sidebar-footer { margin-top: auto; display: grid; gap: 14px; }
.mini-profile { display: flex; gap: 10px; align-items: center; padding: 10px 6px; min-width: 0; }
.avatar { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: #263754; font-weight: 900; }
.mini-profile-text { min-width: 0; }
.mini-profile-text strong, .mini-profile-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-profile-text small { color: #98a4b6; margin-top: 2px; }

.main { min-width: 0; padding: 28px 32px 42px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.topbar h2 { margin: 0; font-size: 28px; }

.welcome-card {
  display: flex; justify-content: space-between; gap: 20px; align-items: center;
  background: linear-gradient(135deg, #ffffff, #f4f7ff); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px 26px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.welcome-card h3 { margin: 0 0 7px; font-size: 25px; }
.overall-progress { width: 108px; height: 108px; border-radius: 50%; background: #eef3ff; border: 10px solid #d8e4ff; display: grid; place-items: center; align-content: center; }
.overall-progress span { font-size: 25px; font-weight: 900; color: var(--primary); line-height: 1; }
.overall-progress small { margin-top: 5px; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 18px; }
.stat-card strong { display: block; font-size: 32px; margin: 8px 0 4px; }
.stat-card small { color: var(--muted); }
.stat-label { color: #5e6676; font-weight: 800; font-size: 13px; }
.warning-card { border-top: 3px solid #e9a742; }
.danger-card { border-top: 3px solid #e4676e; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 7px 24px rgba(34,47,78,.04); }
.panel.slim { padding: 14px; margin-bottom: 15px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 16px; }
.panel-head h3 { margin: 0; font-size: 18px; }
.text-btn { border: 0; background: transparent; color: var(--primary); font-weight: 800; }
.count-pill { background: #eef2f8; color: #596273; border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }

.task-list { display: grid; gap: 10px; }
.task-card { border: 1px solid var(--line); border-radius: 13px; padding: 13px; display: grid; gap: 9px; cursor: pointer; transition: border-color .15s, transform .15s; }
.task-card:hover { border-color: #b9c8ed; transform: translateY(-1px); }
.task-title-line { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.task-title-line strong { font-size: 14px; }
.task-meta { display: flex; flex-wrap: wrap; gap: 8px 12px; color: var(--muted); font-size: 12px; }
.progress-track { height: 7px; background: #edf0f5; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 999px; }
.progress-line { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }

.badge { display: inline-flex; align-items: center; white-space: nowrap; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 900; }
.status-todo { background: #eef1f5; color: #5c6574; }
.status-doing { background: #eaf1ff; color: #2557c6; }
.status-review { background: #fff4df; color: #9b650e; }
.status-done { background: #e8f7f0; color: #147350; }
.priority-normal { background: #f0f2f5; color: #69717e; }
.priority-important { background: #fff2dc; color: #9e6205; }
.priority-urgent { background: #ffecee; color: #bc3340; }
.deadline-overdue { color: var(--danger); font-weight: 800; }
.deadline-soon { color: var(--warning); font-weight: 800; }

.filters { display: flex; gap: 10px; align-items: center; }
.filter-grow { flex: 1; }
.filters select { width: auto; min-width: 170px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 10px; border-bottom: 1px solid #edf0f4; text-align: left; vertical-align: middle; font-size: 13px; }
th { color: #737b89; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fafbfe; }
.table-title { font-weight: 800; color: var(--text); }
.table-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.inline-progress { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.inline-progress .progress-track { flex: 1; }

.team-mini-list { display: grid; gap: 12px; }
.team-mini { display: grid; gap: 7px; }
.team-mini-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.team-mini-head span { color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 36px 14px; border: 1px dashed #dfe4ec; border-radius: 13px; }

.dialog { border: 0; padding: 0; background: transparent; width: min(720px, calc(100% - 28px)); max-height: 92vh; }
.dialog::backdrop { background: rgba(15, 23, 42, .48); backdrop-filter: blur(2px); }
.dialog-card { background: white; border-radius: 20px; padding: 22px; box-shadow: 0 25px 70px rgba(18,27,47,.26); overflow: auto; max-height: 92vh; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.dialog-head h3 { margin: 0; font-size: 22px; }
.icon-btn { border: 0; background: #eef1f5; width: 34px; height: 34px; border-radius: 10px; font-size: 23px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.span-2 { grid-column: span 2; }
.top-gap { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.dialog-actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; }
.spacer { flex: 1; }

.toast { position: fixed; z-index: 1000; right: 22px; bottom: 22px; max-width: min(380px, calc(100% - 44px)); background: #101827; color: white; border-radius: 11px; padding: 12px 15px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #a82832; }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .side-brand { padding-bottom: 12px; }
  .nav-list { grid-template-columns: repeat(3, 1fr); }
  .nav-item { text-align: center; }
  .nav-item span { display: none; }
  .sidebar-footer { margin-top: 12px; grid-template-columns: 1fr auto; align-items: center; }
  .sidebar-footer .btn.full { width: auto; }
  .main { padding: 20px 14px 30px; }
  .topbar { align-items: flex-start; }
  .topbar h2 { font-size: 24px; }
  .welcome-card { padding: 18px; }
  .overall-progress { width: 88px; height: 88px; border-width: 8px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card strong { font-size: 27px; }
  .filters { align-items: stretch; flex-direction: column; }
  .filters select { width: 100%; }
  .form-grid.two { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .login-card { padding: 26px 22px; }
  .login-card h1 { font-size: 32px; }
  .login-watermark { width: 88%; height: 88%; top: 58%; opacity: .075; }
}

/* PWA / mobile-ready */
html[data-runtime="pwa"] body,
html[data-runtime="android"] body,
html[data-runtime="ios"] body { overscroll-behavior-y: none; }

@supports (padding: max(0px)) {
  .sidebar { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
  .main { padding-bottom: max(42px, calc(24px + env(safe-area-inset-bottom))); }
  .topbar { padding-top: env(safe-area-inset-top); }
}

@media (max-width: 760px) {
  .top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  #installAppBtn { font-size: 12px; }
}


/* Password helpers */
.auth-help-row { display: flex; justify-content: center; margin: 2px 0 6px; }
.auth-help-row .text-btn { font-weight: 700; }
.small-dialog { width: min(480px, calc(100vw - 30px)); }
.dialog-note { margin: -4px 0 14px; line-height: 1.55; }
.force-dialog::backdrop { background: rgba(7, 15, 31, .72); }
.reset-btn { white-space: nowrap; }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.danger-lite { background: #fff2f3; color: #b22835; border: 1px solid #f0c8cd; }
.btn.danger-lite:hover { background: #ffe6e9; }


/* Login-only rose theme */
.login-card .btn.primary {
  background: linear-gradient(135deg, #c85f91 0%, #a84376 100%);
  box-shadow: 0 10px 24px rgba(168, 67, 118, .20);
}
.login-card .btn.primary:hover {
  background: linear-gradient(135deg, #b94f83 0%, #913563 100%);
}
.login-card .text-btn,
.login-card .auth-switch .text-btn {
  color: #a84376;
}
.login-card .auth-switch .text-btn.active {
  color: #8f315f;
}
.login-card input:focus {
  border-color: #cf80a9;
  box-shadow: 0 0 0 3px rgba(200, 95, 145, .12);
}
.login-slogan {
  margin-top: 12px;
  color: #9f4772;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .015em;
}


.login-card select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #a84376 50%),
    linear-gradient(135deg, #a84376 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 38px;
}
