/* Kiểu nền và thành phần dùng chung của mẫu CRM (file tĩnh, không dùng CSS hay token của site bán hàng). Font nằm ở fonts.css. */

/* ---------- Token ---------- */
:root {
  --font: 'Be Vietnam Pro', system-ui, sans-serif;
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --line: #e1e4ee;
  --text: #1c2033;
  --muted: #5d6480;
  --accent: #4452d6;
  --accent-ink: #ffffff;
  --accent-soft: #e8eaff;
  --ok: #1f8a63;
  --ok-soft: #dff5ec;
  --warn: #a96c0c;
  --warn-soft: #fbefd5;
  --danger: #c23a52;
  --danger-soft: #fde6ea;
  --side-bg: #181c33;
  --side-text: #c4c9e6;
  --side-active: #ffffff;
  --shadow-sm: 0 1px 2px rgb(28 32 51 / 8%);
  --shadow-md: 0 8px 24px rgb(28 32 51 / 12%);
  --shadow-lg: 0 24px 60px rgb(28 32 51 / 24%);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --side-w: 232px;
  --side-w-collapsed: 68px;
  --topbar-h: 64px;
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slide: 320ms;
  --duration-enter: 560ms;
  --stagger-step: 55ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #0f1220;
  --surface: #181c2f;
  --surface-2: #20253b;
  --line: #2c3250;
  --text: #e8eaf6;
  --muted: #9aa2c4;
  --accent: #7b88ff;
  --accent-ink: #0f1220;
  --accent-soft: #272d57;
  --ok: #4cc9a0;
  --ok-soft: #173a30;
  --warn: #e5b24f;
  --warn-soft: #3d3114;
  --danger: #ff7d93;
  --danger-soft: #412030;
  --side-bg: #0a0d18;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-md: 0 8px 24px rgb(0 0 0 / 40%);
  --shadow-lg: 0 24px 60px rgb(0 0 0 / 60%);
  color-scheme: dark;
}

/* ---------- Nền ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  transition:
    background var(--duration-slide) var(--ease-in-out),
    color var(--duration-slide) var(--ease-in-out);
}
body.has-layer {
  overflow: hidden;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 22px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 16px;
  font-weight: 600;
}
h3 {
  font-size: 14px;
  font-weight: 600;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
a {
  color: var(--accent);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  transition: outline-offset var(--duration-fast) var(--ease-out);
}
.sprite {
  position: absolute;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.muted {
  color: var(--muted);
}
.i {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.num {
  font-variant-numeric: tabular-nums;
}

/* ---------- Khung ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns var(--duration-slide) var(--ease-out);
}
.shell.is-collapsed {
  grid-template-columns: var(--side-w-collapsed) minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 12px;
  background: var(--side-bg);
  color: var(--side-text);
  overflow: hidden;
  isolation: isolate;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 18px;
  color: var(--side-active);
  font-weight: 700;
  font-size: 17px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #7b88ff, #c8617a);
  color: #fff;
}
.nav-list {
  position: relative;
  display: grid;
  gap: 2px;
}
.nav-link,
.nav-collapse {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition:
    color var(--duration-base),
    transform var(--duration-fast);
}
.nav-link[aria-current='page'] {
  color: var(--side-active);
}
.nav-link:active,
.nav-collapse:active {
  transform: scale(0.97);
}
.nav-collapse {
  margin-top: auto;
}
.nav-ink {
  position: absolute;
  z-index: 0;
  left: 12px;
  width: calc(100% - 24px);
  height: 42px;
  top: 0;
  border-radius: var(--radius-sm);
  background: rgb(123 136 255 / 22%);
  transition: transform var(--duration-slide) var(--ease-out);
  pointer-events: none;
}
.shell.is-collapsed .nav-label,
.shell.is-collapsed .brand-name {
  opacity: 0;
  width: 0;
  overflow: hidden;
}
.nav-label,
.brand-name {
  transition: opacity var(--duration-base);
}
.orb {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.35;
  animation: drift 18s var(--ease-in-out) infinite alternate;
}
.orb-a {
  left: -40px;
  bottom: 60px;
  width: 160px;
  height: 160px;
  background: #4452d6;
}
.orb-b {
  right: -50px;
  top: 220px;
  width: 140px;
  height: 140px;
  background: #c8617a;
  animation-duration: 24s;
}
@media (hover: hover) {
  .nav-link:hover,
  .nav-collapse:hover {
    color: var(--side-active);
  }
}
.main-col {
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition:
    border-color var(--duration-base),
    box-shadow var(--duration-base);
}
.topbar.is-scrolled {
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 1 380px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  text-align: left;
  transition:
    border-color var(--duration-base),
    box-shadow var(--duration-base),
    transform var(--duration-fast);
}
.search-trigger span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-trigger:active {
  transform: scale(0.99);
}
@media (hover: hover) {
  .search-trigger:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
}
kbd {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  font: 500 11px var(--font);
  color: var(--muted);
}
.topbar-tools {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
.owner-select select {
  height: 40px;
  padding: 0 28px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.view {
  padding: 8px 24px 48px;
  outline: none;
}
.view-enter {
  animation: view-in var(--duration-slide) var(--ease-out) both;
}
.view-leave {
  animation: view-out var(--duration-fast) var(--ease-in-out) both;
}

/* ---------- Tiêu đề trang, thanh công cụ ---------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 20px;
}
.page-head p {
  color: var(--muted);
  margin-top: 2px;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.toolbar-grow {
  flex: 1;
}

/* ---------- Nút ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition:
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-base),
    background var(--duration-base),
    border-color var(--duration-base);
}
.btn:active {
  transform: scale(0.97);
}
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-danger {
  border-color: transparent;
  background: var(--danger);
  color: #fff;
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
}
.btn-sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}
@media (hover: hover) {
  .btn:hover:not([disabled]) {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
  }
  .btn-primary:hover:not([disabled]) {
    background: color-mix(in srgb, var(--accent) 88%, #fff);
  }
}
.btn.is-busy::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid currentcolor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
.btn.is-done {
  background: var(--ok);
}
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition:
    transform var(--duration-fast) var(--ease-out),
    border-color var(--duration-base),
    background var(--duration-base);
}
.icon-btn:active {
  transform: scale(0.92);
}
.icon-btn.is-small {
  width: 32px;
  height: 32px;
}
.icon-btn.is-flat {
  border-color: transparent;
  background: transparent;
}
@media (hover: hover) {
  .icon-btn:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
  }
}
#theme-btn .icon-moon,
:root[data-theme='dark'] #theme-btn .icon-sun {
  display: none;
}
:root[data-theme='dark'] #theme-btn .icon-moon {
  display: block;
}
#theme-btn .i {
  transition: transform var(--duration-slide) var(--ease-out);
}
#theme-btn:active .i {
  transform: rotate(40deg);
}

/* ---------- Chip, huy hiệu, phân đoạn ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  transition:
    background var(--duration-base),
    border-color var(--duration-base),
    color var(--duration-base),
    transform var(--duration-fast);
}
.chip:active {
  transform: scale(0.95);
}
.chip.is-active,
.chip[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
@media (hover: hover) {
  .chip:hover {
    border-color: var(--accent);
  }
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-hot,
.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge-warm,
.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge-cold,
.badge-info {
  background: var(--accent-soft);
  color: var(--accent);
}
.seg {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.seg-btn {
  position: relative;
  z-index: 1;
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-weight: 500;
  transition:
    color var(--duration-base),
    transform var(--duration-fast);
}
.seg-btn:active {
  transform: scale(0.96);
}
.seg-btn[aria-selected='true'] {
  color: var(--text);
}
.seg-ink {
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  left: 0;
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--duration-slide) var(--ease-out),
    width var(--duration-slide) var(--ease-out);
}

/* ---------- Thẻ, bảng ---------- */
.card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base),
    border-color var(--duration-base);
}
@media (hover: hover) {
  .card.is-lift:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
  }
}
.tilt {
  transform: perspective(700px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition:
    transform var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base);
}
.tbl-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.tbl {
  width: 100%;
  border-collapse: collapse;
}
.tbl th,
.tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
.tbl.is-compact th,
.tbl.is-compact td {
  padding: 5px 14px;
}
.tbl th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tbl tbody tr {
  transition:
    background var(--duration-base),
    transform var(--duration-base) var(--ease-out);
}
.tbl tbody tr.is-selected {
  background: var(--accent-soft);
}
@media (hover: hover) {
  .tbl tbody tr:hover {
    background: var(--surface-2);
  }
}
.tbl tr.is-leaving {
  animation: row-out var(--duration-slide) var(--ease-in-out) forwards;
}
.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}
.sort-btn .i {
  width: 14px;
  height: 14px;
  transition: transform var(--duration-base) var(--ease-out);
}
.sort-btn[data-dir='desc'] .i {
  transform: rotate(180deg);
}

/* ---------- Avatar ---------- */
.avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}
.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}
.avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 20px;
}
.tone-0 {
  background: #4452d6;
}
.tone-1 {
  background: #c8617a;
}
.tone-2 {
  background: #1f8a63;
}
.tone-3 {
  background: #a96c0c;
}
.tone-4 {
  background: #2f7fb8;
}
.tone-5 {
  background: #8a54c4;
}
img.avatar {
  background: var(--surface-2);
  animation: fade-in var(--duration-slide) var(--ease-out);
}

/* ---------- Form ---------- */
.field {
  position: relative;
  display: grid;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 18px 12px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition:
    border-color var(--duration-base),
    box-shadow var(--duration-base);
}
.field textarea {
  resize: vertical;
}
.field label {
  position: absolute;
  top: 12px;
  left: 13px;
  color: var(--muted);
  pointer-events: none;
  transform-origin: left top;
  transition:
    transform var(--duration-base) var(--ease-out),
    color var(--duration-base);
}
.field input:focus ~ label,
.field input:not(:placeholder-shown) ~ label,
.field textarea:focus ~ label,
.field textarea:not(:placeholder-shown) ~ label,
.field.is-select label,
.field input[type='date'] ~ label,
.field input[type='time'] ~ label {
  transform: translateY(-9px) scale(0.78);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input:focus ~ label,
.field textarea:focus ~ label {
  color: var(--accent);
}
.field-msg {
  min-height: 18px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
}
.field.has-error .field-msg {
  color: var(--danger);
  animation: fade-in var(--duration-base) var(--ease-out);
}
.field.shake {
  animation: shake 360ms var(--ease-in-out);
}
.req {
  color: var(--danger);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 14px;
}
.form-grid .is-wide {
  grid-column: 1 / -1;
}
.switch,
.check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.switch input,
.check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch-track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--line);
  transition: background var(--duration-base);
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-base) var(--ease-out);
}
.switch input:checked + .switch-track {
  background: var(--accent);
}
.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}
.check-box {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-radius: 6px;
  transition:
    background var(--duration-base),
    border-color var(--duration-base),
    transform var(--duration-fast);
}
.check-box .i {
  width: 14px;
  height: 14px;
  stroke: #fff;
  stroke-width: 3;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  transition: stroke-dashoffset var(--duration-slide) var(--ease-out);
}
.check input:checked + .check-box {
  border-color: var(--accent);
  background: var(--accent);
}
.check input:checked + .check-box .i {
  stroke-dashoffset: 0;
}
.check:active .check-box {
  transform: scale(0.88);
}
.switch input:focus-visible + .switch-track,
.check input:focus-visible + .check-box {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Trạng thái rỗng, khung xương ---------- */
.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
}
.empty .i {
  width: 36px;
  height: 36px;
  color: var(--accent);
}
.empty-title {
  color: var(--text);
  font-weight: 600;
}
.skeleton-list {
  display: grid;
  gap: 10px;
}
.skeleton {
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--line) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

/* ---------- Lớp phủ: hộp thoại và ngăn kéo ---------- */
.layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
}
.layer-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(15 18 32 / 55%);
  opacity: 0;
  transition: opacity var(--duration-slide) var(--ease-out);
}
.layer.is-open .layer-backdrop {
  opacity: 1;
}
.layer-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition:
    transform var(--duration-slide) var(--ease-out),
    opacity var(--duration-slide) var(--ease-out);
}
.layer-modal {
  place-items: center;
  padding: 16px;
}
.layer-panel.modal {
  width: min(520px, 100%);
  max-height: min(90vh, 100%);
  border-radius: var(--radius-lg);
  transform: scale(0.94) translateY(12px);
}
.layer-panel.modal.is-wide {
  width: min(760px, 100%);
}
.layer-panel.drawer {
  justify-self: end;
  width: min(520px, 100%);
  height: 100%;
  transform: translateX(40px);
}
.layer.is-open .layer-panel {
  opacity: 1;
  transform: none;
}
.layer-head,
.layer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
}
.layer-head {
  border-bottom: 1px solid var(--line);
}
.layer-title {
  font-size: 17px;
}
.layer-body {
  flex: 1;
  padding: 18px 20px;
  overflow: auto;
}
.layer-foot {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

/* ---------- Toast ---------- */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 200;
  display: grid;
  gap: 8px;
  justify-items: end;
}
.toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #20243d;
  color: #fff;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px);
  transition:
    transform var(--duration-slide) var(--ease-out),
    opacity var(--duration-slide);
}
.toast.is-in {
  opacity: 1;
  transform: none;
}
.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
}
.toast-action {
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: rgb(255 255 255 / 14%);
  color: #fff;
  font-weight: 600;
}
.toast-timer {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: #7b88ff;
  transform-origin: left;
  animation: shrink var(--toast-ms) linear forwards;
}

/* ---------- Chuông thông báo, menu nhanh ---------- */
.bell-wrap {
  position: relative;
}
.bell-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  animation: pop var(--duration-slide) var(--ease-out);
}
.bell-panel,
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  width: min(360px, calc(100vw - 32px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform-origin: top right;
  animation: pop-in var(--duration-slide) var(--ease-out);
}
.bell-panel[hidden],
.menu[hidden] {
  display: none;
}
.menu {
  width: 220px;
}
.menu-item,
.note-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  text-align: left;
  transition:
    background var(--duration-base),
    transform var(--duration-fast);
}
.menu-item:active,
.note-item:active {
  transform: scale(0.98);
}
@media (hover: hover) {
  .menu-item:hover,
  .note-item:hover {
    background: var(--surface-2);
  }
}
.note-item.is-read {
  opacity: 0.55;
}
.bell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 8px;
}

/* ---------- Bảng lệnh ---------- */
.palette-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.palette-list {
  display: grid;
  gap: 2px;
  margin-top: 10px;
  max-height: 50vh;
  overflow: auto;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  text-align: left;
  transition:
    background var(--duration-fast),
    transform var(--duration-fast);
}
.palette-item[aria-selected='true'] {
  background: var(--accent-soft);
  transform: translateX(3px);
}
.palette-group {
  padding: 8px 10px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.palette-kind {
  margin-left: auto;
}

/* ---------- Hiệu ứng vào ---------- */
.stagger {
  animation: rise var(--duration-enter) var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * var(--stagger-step));
}
.confetti {
  position: fixed;
  z-index: 300;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  pointer-events: none;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
@keyframes view-out {
  to {
    opacity: 0;
  }
}
@keyframes pop {
  from {
    transform: scale(0.4);
  }
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(-6px);
  }
}
@keyframes row-out {
  to {
    opacity: 0;
    transform: translateX(-24px);
  }
}
@keyframes shake {
  20% {
    transform: translateX(-5px);
  }
  40% {
    transform: translateX(5px);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(3px);
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}
@keyframes shrink {
  to {
    transform: scaleX(0);
  }
}
@keyframes drift {
  to {
    transform: translate(30px, -40px);
  }
}
@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

/* ---------- Bảng "Khác" (chỉ hiện ở điện thoại) ---------- */
.nav-more-item {
  display: none;
}
.more-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.more-tile {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  min-height: 84px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  transition:
    background var(--duration-base),
    border-color var(--duration-base),
    transform var(--duration-fast) var(--ease-out);
}
.more-tile .i {
  width: 24px;
  height: 24px;
  color: var(--accent);
}
.more-tile:active {
  transform: scale(0.96);
}
.more-tile[aria-current='page'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.more-prefs {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.more-switch {
  min-height: 44px;
}

/* ---------- Di động: thanh bên thành thanh tab dưới đáy ---------- */
@media (max-width: 720px) {
  .shell,
  .shell.is-collapsed {
    display: block;
  }
  .sidebar {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    flex-direction: row;
    align-items: center;
    height: auto;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid rgb(255 255 255 / 8%);
  }
  .brand,
  .nav-collapse,
  .orb,
  .nav-ink,
  .nav-off-tabbar {
    display: none;
  }
  .nav-list {
    flex: 1;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
  }
  .nav-more-item {
    display: block;
  }
  .nav-link,
  .shell.is-collapsed .nav-link {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 100%;
    min-height: 54px;
    padding: 4px 2px;
    font-size: 11px;
    transition:
      color var(--duration-base),
      background var(--duration-base),
      transform var(--duration-fast);
  }
  .nav-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .nav-link[aria-current='page'],
  .nav-more.is-active {
    background: rgb(123 136 255 / 22%);
    color: var(--side-active);
  }
  .nav-link[aria-current='page'] .i,
  .nav-more.is-active .i {
    animation: pop var(--duration-slide) var(--ease-out);
  }
  .shell.is-collapsed .nav-label {
    opacity: 1;
    width: auto;
  }
  .topbar {
    padding: 0 12px;
  }
  .search-trigger kbd,
  .owner-select,
  #quick-add span {
    display: none;
  }
  .view {
    padding: 4px 12px calc(96px + env(safe-area-inset-bottom));
  }
  /* Chữ ô nhập dưới 16px làm Safari trên iPhone tự phóng to trang khi chạm vào ô. */
  input,
  select,
  textarea {
    font-size: 16px;
  }
  .page-head {
    align-items: stretch;
  }
  .layer-foot {
    flex-wrap: wrap;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .layer-modal {
    align-items: end;
    padding: 0;
  }
  .layer-panel.modal,
  .layer-panel.drawer {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    height: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(40px);
  }
  /* Thanh nắm trang trí cho biết đây là tấm trượt từ đáy. */
  .layer-panel.modal::before,
  .layer-panel.drawer::before {
    content: '';
    align-self: center;
    width: 40px;
    height: 4px;
    margin-top: 8px;
    border-radius: 999px;
    background: var(--line);
  }
  .layer-drawer {
    align-items: end;
  }
  .toasts {
    right: 8px;
    left: 8px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    justify-items: stretch;
  }
  .toast {
    max-width: none;
  }
}

/* ---------- Màn hình cảm ứng: vùng chạm tối thiểu 44px ---------- */
@media (pointer: coarse) {
  .btn,
  .btn-sm,
  .chip,
  .seg-btn {
    min-height: 44px;
  }
  .icon-btn,
  .icon-btn.is-small {
    width: 44px;
    height: 44px;
  }
  .menu-item,
  .note-item,
  .palette-item {
    min-height: 44px;
  }
}

/* ---------- Giảm chuyển động ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .orb {
    display: none;
  }
}

/* ---------- In báo giá ---------- */
@media print {
  .sidebar,
  .topbar,
  .toasts,
  .no-print {
    display: none !important;
  }
  .shell {
    display: block;
  }
  body {
    background: #fff;
    color: #000;
  }
}
