:root {
  --bg-1: #faf3e0;
  --bg-2: #e7efd6;
  --card: #fffcf6;
  --ink: #20222a;
  --accent: #005f73;
  --danger: #a11b40;
  --line: #cfbea0;
  --muted: #665948;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at top right, #ffd6a4, transparent 38%),
    radial-gradient(circle at bottom left, #c9eccf, transparent 35%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  min-height: 100vh;
}

.crm-shell {
  position: relative;
  padding: 1rem;
}

.crm-shell::before,
.crm-shell::after {
  content: "";
  position: fixed;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(48px);
  z-index: -1;
  opacity: 0.35;
}

.crm-shell::before {
  top: -110px;
  right: -80px;
  background: #fbbf24;
}

.crm-shell::after {
  bottom: -130px;
  left: -90px;
  background: #2dd4bf;
}

h1,
h2 {
  margin: 0 0 0.6rem;
  letter-spacing: 0.01em;
}

.subtitle,
.footnote {
  margin: 0 0 1rem;
  color: var(--muted);
}

.brand-login,
.brand-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  filter: drop-shadow(0 6px 10px rgba(10, 66, 120, 0.18));
}

.login-logo {
  width: 50px;
  height: 50px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 1rem;
}

.card {
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.4rem;
  box-shadow: 0 14px 32px rgba(31, 41, 51, 0.12);
  animation: rise 320ms ease-out;
}

label {
  display: block;
  margin: 0.7rem 0 0.4rem;
}

input,
select,
button {
  width: 100%;
  padding: 0.72rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  font: inherit;
}

button {
  margin-top: 0.9rem;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
}

button.ghost {
  width: auto;
  margin: 0;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

button:hover {
  filter: brightness(1.05);
}

.message {
  min-height: 1.2rem;
  margin-top: 0.8rem;
}

.message.error {
  color: var(--danger);
}

.admin-page {
  padding: 1rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.crm-topbar {
  padding: 1rem 1.1rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.quick-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.stat {
  font-size: 0.83rem;
  background: linear-gradient(180deg, #fffdf7 0%, #f2ebe1 100%);
  border: 1px solid #d8c2a0;
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  box-shadow: 0 3px 10px rgba(133, 92, 20, 0.08);
}

.dashboard {
  display: grid;
  gap: 1rem;
}

.crm-layout {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.crm-layout > .panel {
  grid-column: span 12;
}

.panel-hero {
  background: linear-gradient(135deg, #fffaf0 0%, #ecf7f2 100%);
  border-color: #badfd2;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.chip {
  background: linear-gradient(180deg, #fffaf1 0%, #f3ebe0 100%);
  border: 1px solid #d9c4a5;
  border-radius: 999px;
  padding: 0.32rem 0.62rem;
  font-size: 0.84rem;
  box-shadow: 0 4px 10px rgba(69, 54, 32, 0.08);
}

.project-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.project-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.34rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1f3a5a;
  background: linear-gradient(180deg, #edf5ff 0%, #dbeaff 100%);
  border: 1px solid #b8d1f5;
  box-shadow: 0 3px 8px rgba(59, 94, 156, 0.14);
}

.grid-form {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-form textarea {
  min-height: 92px;
  resize: vertical;
}

.grid-form > button {
  align-self: end;
}

.grid-form.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.crm-table {
  font-size: 0.9rem;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border: 1px solid #d9c8ad;
  border-radius: 14px;
  overflow: hidden;
}

.crm-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #113b4a 0%, #184e60 100%);
  color: #f8fcff;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-bottom: 1px solid #0a2b36;
}

.crm-table tbody tr:nth-child(4n + 1) {
  background: #fffefb;
}

.crm-table tbody tr:nth-child(4n + 3) {
  background: #fbfffe;
}

.crm-table tbody tr:hover {
  background: #f4fbff;
}

.crm-table select,
.crm-table button,
.crm-table input,
.crm-table textarea {
  width: 100%;
  min-width: 0;
}

.crm-table textarea {
  min-height: 70px;
  resize: vertical;
}

.priority-select {
  font-weight: 700;
  border-width: 2px;
}

.priority-nong {
  background: #b70000;
  color: #fff;
  border-color: #7f0000;
}

.priority-am {
  background: #e9b38a;
  color: #4f2a12;
  border-color: #cb8d61;
}

.priority-moi {
  background: #b7deac;
  color: #1c4d22;
  border-color: #8dc47f;
}

.priority-nguoi {
  background: #6c3f9d;
  color: #fff;
  border-color: #4f2b78;
}

.priority-het_quan_tam {
  background: #dfdfdf;
  color: #2b2b2b;
  border-color: #b8b8b8;
}

/* Demand color coding */
.demand-select {
  font-weight: 700;
  border-width: 2px;
}

.demand-o {
  background: #d7f4dd;
  color: #0d5d1c;
  border-color: #a8e6b3;
}

.demand-dau_tu {
  background: #fbe7d3;
  color: #7a3f1f;
  border-color: #f4c9a1;
}

.demand-ca_hai {
  background: #d9e9ff;
  color: #1a3a7f;
  border-color: #adc7f7;
}

/* Status color coding */
.status-select {
  font-weight: 700;
  border-width: 2px;
}

.status-moi {
  background: #c7f0d8;
  color: #0d5d22;
  border-color: #99e6b8;
}

.status-dang_cham {
  background: #fff4d6;
  color: #7a4f14;
  border-color: #ffe066;
}

.status-sap_chot {
  background: #ffd9d9;
  color: #852d2d;
  border-color: #ffaaaa;
}

.status-da_chot {
  background: #d4edda;
  color: #155724;
  border-color: #a3d5a3;
}

.status-booking {
  background: #e7d4f5;
  color: #5a1f7d;
  border-color: #d1a3e6;
}

.status-cup_ngang,
.status-khong_nghe_dt,
.status-khac {
  background: #ffe3e3;
  color: #7a2b2b;
  border-color: #f4b9b9;
}

.filter-status-hidden {
  background: #ffe3e3;
  color: #7a2b2b;
  border-color: #f4b9b9;
}

/* Property type color coding */
.property-select {
  font-weight: 700;
  border-width: 2px;
}

.property-studio {
  background: #f0d9ff;
  color: #5a1f7d;
  border-color: #e0b3ff;
}

.property-1pn {
  background: #c7e9f5;
  color: #003366;
  border-color: #99ddf0;
}

.property-1pn_plus {
  background: #d4f1e4;
  color: #0d5d22;
  border-color: #a3e6c1;
}

.property-2pn {
  background: #ffd699;
  color: #664400;
  border-color: #ffcc66;
}

.property-3pn {
  background: #ffb3b3;
  color: #660000;
  border-color: #ff8080;
}

.property-sky_penthouse {
  background: #e6c2ff;
  color: #4a0080;
  border-color: #cc99ff;
}

.property-shophouse {
  background: #fff0e0;
  color: #8b5a00;
  border-color: #ffe6cc;
}

/* Project styling */
.project-select {
  font-weight: 600;
}

.crm-table td {
  vertical-align: top;
  border-bottom: 1px solid #e8ddca;
}

.customer-call-trigger {
  width: 100%;
  text-align: left;
  border: 1px dashed #cbd5e1;
  background: #f8fcff;
  border-radius: 12px;
  padding: 0.5rem;
  margin: 0;
  color: inherit;
}

.customer-call-trigger:hover {
  background: #edf8ff;
  border-color: #7fb8da;
}

.customer-call-trigger strong {
  display: block;
  font-size: 1.05rem;
}

.customer-call-trigger .muted {
  display: block;
}

.detail-row td {
  background: #fbf7ef;
}

.detail-card {
  border: 1px solid #d7c5a7;
  border-radius: 14px;
  padding: 0.9rem;
  background: linear-gradient(180deg, #fffdf8 0%, #f8f2e7 100%);
  box-shadow: inset 0 1px 0 #fff;
}

.detail-card h4 {
  margin: 0 0 0.6rem;
}

.detail-grid {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-grid label {
  margin: 0;
  font-weight: 600;
  display: grid;
  gap: 0.35rem;
}

button.mini {
  padding: 0.45rem 0.52rem;
  margin-top: 0.45rem;
}

.muted {
  color: var(--muted);
  font-size: 0.82rem;
}

.timeline {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.6rem;
}

.timeline-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 0.65rem;
  background: #fffdf7;
}

.timeline-item header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.3rem;
  font-size: 0.88rem;
}

.hidden {
  display: none;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.role-admin {
  background: #ffe2c2;
  color: #8a3f00;
  border-color: #f0bb86;
}

.role-manager {
  background: #daefe8;
  color: #0a635a;
  border-color: #96cdc2;
}

.role-user {
  background: #e8e9f8;
  color: #39489e;
  border-color: #bdc4f0;
}

.panel {
  background: rgba(255, 252, 246, 0.9);
  border: 1px solid #dbc7a8;
  border-radius: 20px;
  padding: 1.05rem;
  box-shadow: 0 16px 32px rgba(39, 57, 74, 0.09);
  backdrop-filter: blur(8px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem;
  text-align: left;
}

td button,
td select {
  margin: 0;
  width: auto;
  min-width: 92px;
}

/* Pagination Navigation Styles */
#pagination-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  padding: 0.75rem 0;
  margin: 1rem 0;
}

#pagination-nav button {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 0.4rem;
  border: 1px solid #cbd5e1;
  background: white;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 2rem;
  text-align: center;
  line-height: 1.2;
}

#pagination-nav button:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

#pagination-nav button:disabled {
  background: #f5f5f5;
  color: #a0aec0;
  border-color: #e5e5e5;
  cursor: not-allowed;
  opacity: 0.5;
}

/* Current page button styling */
#pagination-nav button[disabled]:not(.nav-arrow) {
  background: #0f5ea8;
  color: white;
  border-color: #0f5ea8;
  cursor: default;
  font-weight: 700;
  box-shadow: none;
  opacity: 1;
}

/* Navigation arrow buttons */
.nav-arrow {
  font-weight: 700;
  font-size: 0.8rem;
  min-width: auto;
  padding: 0.35rem 0.7rem;
}

.nav-arrow:not(:disabled):hover {
  background: #0d766e;
  border-color: #0d766e;
  color: white;
}

/* Pagination info text */
#pagination-info {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 500;
  margin-top: 0.5rem;
}

.quick-call-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.quick-call-modal.hidden {
  display: none;
}

.quick-call-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 15, 24, 0.55);
  backdrop-filter: blur(3px);
}

.quick-call-card {
  position: relative;
  width: min(560px, calc(100vw - 2rem));
  border-radius: 18px;
  border: 1px solid #9cc7d9;
  background: linear-gradient(140deg, #f4fbff 0%, #eef7ec 100%);
  box-shadow: 0 22px 50px rgba(4, 32, 52, 0.35);
  padding: 1rem 1.15rem 1.25rem;
}

.quick-call-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.quick-call-head h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f3e56;
}

.quick-call-close {
  width: auto;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border: 1px solid #b8cbda;
  background: #ffffff;
  color: #274252;
  font-weight: 700;
}

.quick-call-label {
  margin: 0.35rem 0 0.2rem;
  font-size: 0.82rem;
  color: #5b6f7c;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quick-call-name {
  margin: 0;
  font-size: clamp(1.4rem, 3.4vw, 2.25rem);
  line-height: 1.2;
  font-weight: 800;
  color: #16384e;
}

.quick-call-phone {
  margin: 0.2rem 0 0;
  font-size: clamp(1.8rem, 5.4vw, 3rem);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: #0c6575;
}

@media (max-width: 860px) {
  .grid-form,
  .grid-form.compact {
    grid-template-columns: 1fr;
  }

  .topbar-right {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }

  .quick-stats {
    width: 100%;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    border-bottom: 1px solid var(--line);
    padding: 0.6rem 0;
  }

  td {
    border: none;
    padding: 0.35rem 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
