:root {
  --ink: #0b1f3a;
  --muted: #5b6b84;
  --bg: #f2f5fb;
  --card: #ffffff;
  --line: #d7e0ef;
  --brand: #033ab8;
  --brand-dark: #022a87;
  --brand-soft: rgba(3, 58, 184, 0.12);
  --accent: #0ea5a0;
  --ok: #1f7a4c;
  --err: #b42318;
  --shadow: 0 12px 40px rgba(3, 58, 184, 0.1);
  --radius: 14px;
  --font: "Be Vietnam Pro", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at 8% -12%, rgba(3, 58, 184, 0.14), transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(14, 165, 160, 0.08), transparent 50%),
    var(--bg);
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem 1.75rem;
}

.brand-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.45rem;
  margin-bottom: 1.5rem;
}
.brand-mark .auth-logo {
  width: 72px !important;
  height: 72px !important;
  max-width: 72px !important;
  max-height: 72px !important;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.35rem;
  border-radius: 12px;
  background: var(--brand-soft, rgba(3, 58, 184, 0.1));
}
.brand-mark strong {
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  color: var(--brand);
}

/* Chặn ảnh upload tràn layout */
.logo-img,
.user-avatar img,
.avatar-preview img,
.brand-preview img,
.auth-logo {
  max-width: 100%;
  height: auto;
}
.logo-img {
  width: 36px !important;
  height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  object-fit: contain !important;
  flex-shrink: 0;
}
.user-avatar img {
  width: 32px !important;
  height: 32px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  display: block;
}
.avatar-preview {
  width: 72px !important;
  height: 72px !important;
  overflow: hidden !important;
}
.avatar-preview img {
  width: 72px !important;
  height: 72px !important;
  object-fit: cover !important;
  display: block;
}
.brand-preview {
  max-width: 200px;
  max-height: 72px;
  overflow: hidden;
  margin: 0.35rem 0 0.6rem;
}
.brand-preview img {
  max-height: 56px !important;
  max-width: 180px !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  display: block;
}
.brand-preview-sm {
  max-width: 40px;
  max-height: 40px;
}
.brand-preview-sm img {
  max-height: 32px !important;
  max-width: 32px !important;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0.85rem 0 0.35rem;
}
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  background: #fff;
}
input:focus {
  outline: 2px solid rgba(3, 58, 184, 0.22);
  border-color: var(--brand);
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.92rem;
  color: var(--muted);
  user-select: none;
}
.remember-row input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--brand);
}
.remember-row label {
  display: inline;
  margin: 0;
  font-weight: 500;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.btn-primary {
  background: linear-gradient(180deg, #0646d4, var(--brand-dark));
  color: #fff;
  width: 100%;
  margin-top: 1.25rem;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
}
.btn-ghost:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.alert {
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font-size: 0.92rem;
  margin-bottom: 1rem;
}
.alert-error { background: #fef3f2; color: var(--err); border: 1px solid #fecdca; }
.alert-ok { background: #ecfdf3; color: var(--ok); border: 1px solid #abe8c3; }

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: linear-gradient(180deg, #033ab8 0%, #022a87 55%, #021f66 100%);
  color: #eef3ff;
  padding: 1.4rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 100vh;
}
.sidebar-top { flex: 1; }
.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.75rem;
}
.sidebar .logo-img {
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
}
.sidebar .logo small {
  display: block;
  font-weight: 500;
  opacity: 0.75;
  font-size: 0.78rem;
  margin-top: 0.2rem;
}
.nav a {
  display: block;
  color: rgba(238, 243, 255, 0.9);
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}
.nav a:hover, .nav a.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.nav .soon {
  opacity: 0.45;
  pointer-events: none;
  font-size: 0.88rem;
}
.sidebar-bottom {
  border-top: 1px solid rgba(255,255,255,0.16);
  padding-top: 0.85rem;
  margin-top: auto;
}
.nav-settings {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #ffffff !important;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
}
.nav-settings svg {
  color: #ffffff !important;
  stroke: #ffffff !important;
  flex-shrink: 0;
}
.nav-settings:hover,
.nav-settings.active {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff !important;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50% !important;
  overflow: hidden !important;
  background: var(--brand-soft, #033ab822);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--brand);
  flex-shrink: 0;
}
.user-avatar img {
  width: 32px !important;
  height: 32px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  display: block;
}
.settings-shell { max-width: 760px; }
.settings-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.settings-tab {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.98rem;
  box-shadow: var(--shadow);
}
.settings-tab small {
  display: block;
  margin-top: 0.25rem;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.82rem;
}
.settings-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.settings-tab.active small { color: rgba(255,255,255,0.85); }
.settings-panel-head {
  margin-bottom: 0.85rem;
}
.settings-panel-head h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  color: var(--brand-dark);
}
@media (max-width: 700px) {
  .settings-tabs { grid-template-columns: 1fr; }
}
.form-card-wide { max-width: 640px; }
.form-sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.25rem 0;
}
.avatar-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.avatar-preview {
  border-radius: 50%;
  background: var(--brand-soft, #033ab822);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--brand);
  flex-shrink: 0;
}
.color-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.color-row input[type="color"] {
  width: 48px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.color-row input[type="text"] {
  max-width: 140px;
}
input[type="file"] {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
}
input:disabled {
  background: #f3f5f9;
  color: var(--muted);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.btn-sm {
  width: auto;
  margin-top: 0;
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
}
.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.data th,
table.data td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
table.data th {
  background: #f7f9fc;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
}
table.data tr:last-child td { border-bottom: 0; }
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 650;
  background: #eef2ff;
  color: var(--brand-dark);
}
.badge-new { background: #eef2ff; color: #022a87; }
.badge-contacted { background: #ecfeff; color: #0e7490; }
.badge-qualified { background: #ecfdf3; color: #166534; }
.badge-lost { background: #fef3f2; color: #b42318; }
.badge-todo { background: #f3f4f6; color: #374151; }
.badge-doing { background: #eff6ff; color: #1d4ed8; }
.badge-done { background: #ecfdf3; color: #166534; }
.empty-state {
  padding: 1.5rem;
  color: var(--muted);
  text-align: center;
}
.stack-form {
  display: grid;
  gap: 0.35rem;
}
.stack-form .row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 700px) {
  .stack-form .row-2 { grid-template-columns: 1fr; }
}
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  min-height: 90px;
  resize: vertical;
}
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  background: #fff;
}

.mop-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.mop-modal.is-open { display: flex; }
.mop-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 31, 58, 0.45);
}
.mop-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem 1.25rem;
}
.mop-modal__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.mop-modal__head h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--brand-dark);
}
.main {
  padding: 1.5rem 1.75rem 2.5rem;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.topbar h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--brand-dark);
}
.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}
.form-card {
  max-width: 480px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.2rem;
  box-shadow: var(--shadow);
}
.muted { color: var(--muted); }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { padding-bottom: 0.5rem; }
  .nav { display: flex; flex-wrap: wrap; gap: 0.25rem; }
  .nav a { margin: 0; }
}
