/* Respect reduced-motion: keep surfaces functional, drop the movement */
@media (prefers-reduced-motion: reduce) {
  .drawer,
  .modal,
  .drawer-overlay,
  .modal-overlay,
  .drawer-overlay.is-open .pd-body > * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
  }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.01em;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}

.btn svg { width: 15px; height: 15px; }

.btn:active { transform: translateY(1px); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }

.btn-outline {
  background: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-outline:hover { background: var(--bg-hover); }

.btn-outline-accent {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent-strong);
}
:root[data-theme="dark"] .btn-outline-accent { color: var(--accent-soft-text); }
.btn-outline-accent:hover { background: var(--accent-soft-bg); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

.btn-tone-blue { background: var(--tone-blue); color: #fff; }
.btn-tone-blue:hover { filter: brightness(1.08); }
.btn-tone-amber { background: var(--tone-amber); color: #fff; }
.btn-tone-amber:hover { filter: brightness(1.08); }
.btn-tone-green { background: var(--tone-green); color: #fff; }
.btn-tone-green:hover { filter: brightness(1.08); }
.btn-tone-red { background: var(--tone-red); color: #fff; }
.btn-tone-red:hover { filter: brightness(1.08); }

.btn-icon-only { width: 34px; height: 34px; padding: 0; }

/* ---------- Card ---------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-header .card-icon { color: var(--accent); width: 18px; height: 18px; }
.card-header-meta { color: var(--text-muted); font-size: 12.5px; margin-left: 2px; }
.card-header-actions { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; }
.card-body { padding: var(--space-5); }
.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 12.5px;
}
:root[data-theme="dark"] .footer-link { color: var(--accent-soft-text); }
.footer-link:hover { text-decoration: underline; }
.footer-link svg { width: 14px; height: 14px; }

.count-pill {
  background: var(--tone-gray-bg);
  color: var(--tone-gray-text);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
}

/* ---------- Status pill ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill-blue { background: var(--tone-blue-bg); color: var(--tone-blue); }
.pill-green { background: var(--tone-green-bg); color: var(--tone-green); }
.pill-amber { background: var(--tone-amber-bg); color: var(--tone-amber); }
.pill-red { background: var(--tone-red-bg); color: var(--tone-red); }
.pill-purple { background: var(--tone-purple-bg); color: var(--tone-purple); }
.pill-gray { background: var(--tone-gray-bg); color: var(--tone-gray-text); }

/* ---------- Avatar ---------- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }

.avatar-blue { background: var(--tone-blue); }
.avatar-green { background: var(--tone-green); }
.avatar-amber { background: var(--tone-amber); }
.avatar-red { background: var(--tone-red); }
.avatar-purple { background: var(--tone-purple); }
.avatar-accent { background: var(--accent); }

/* ---------- Data table ---------- */

.table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  text-align: left;
  font-family: var(--font-heading);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-4) var(--space-4) var(--space-3);
  white-space: nowrap;
}

.data-table.in-card thead th:first-child,
.data-table.in-card tbody td:first-child { padding-left: var(--space-5); }
.data-table.in-card thead th:last-child,
.data-table.in-card tbody td:last-child { padding-right: var(--space-5); }

.data-table tbody tr { border-top: 1px solid var(--border); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody td { padding: var(--space-3) var(--space-4); vertical-align: middle; }

.data-table .cell-primary { font-weight: 700; color: var(--text-primary); }
.data-table .cell-secondary { color: var(--text-secondary); }
.data-table .cell-muted { color: var(--text-muted); font-size: 12.5px; }
.data-table .row-clickable { cursor: pointer; }

.name-cell { display: flex; align-items: center; gap: var(--space-3); }
.name-cell-text .cell-primary { display: block; line-height: 1.3; }
.name-cell-text .cell-muted { display: block; }

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--space-3) var(--space-2);
  margin-bottom: -1px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 13px;
  color: var(--text-muted);
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.is-active { color: var(--accent-strong); border-bottom-color: var(--accent); }
:root[data-theme="dark"] .tab-btn.is-active { color: var(--accent-soft-text); }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---------- Filters / chips ---------- */

.filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.filter-search { position: relative; flex: 1; min-width: 220px; max-width: 340px; }
.filter-search input { width: 100%; padding: 9px 12px 9px 34px; border-radius: var(--radius-md); font-size: 13px; }
.filter-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-muted); }

.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.chip:hover { background: var(--bg-hover); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Forms ---------- */

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field.span-2 { grid-column: span 2; }

.field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.field input, .field select, .field textarea {
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  width: 100%;
}

.field textarea { resize: vertical; min-height: 80px; }
.field .hint { font-size: 11.5px; color: var(--text-muted); }

.form-section { margin-bottom: var(--space-6); }
.form-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0; background: var(--border-strong);
  border-radius: var(--radius-pill); transition: background-color 0.15s ease;
}
.switch-track::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.15s ease;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }

/* ---------- Dropdown menus ---------- */

.dropdown { position: relative; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  padding: var(--space-2);
  z-index: 60;
  display: none;
}

.dropdown.is-open .dropdown-menu { display: block; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--text-muted); }
.dropdown-divider { height: 1px; background: var(--border); margin: var(--space-2) 0; }
.dropdown-label { padding: var(--space-2) var(--space-3) 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }

.owner-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 13px;
}
.owner-trigger svg { width: 14px; height: 14px; color: var(--text-muted); }

/* ---------- Notification panel ---------- */

.notif-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  align-items: flex-start;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item p { margin: 0; font-size: 12.5px; line-height: 1.4; }
.notif-item .notif-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 9, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  backdrop-filter: blur(0);
  transition: opacity 0.22s ease, visibility 0.22s ease, backdrop-filter 0.22s ease;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-dropdown);
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: transform 0.26s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.26s ease;
}

.modal-overlay.is-open .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 16px; }
.modal-close { margin-left: auto; }
.modal-body { padding: var(--space-5); }
.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ---------- Drawer ---------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 9, 0.45);
  opacity: 0;
  visibility: hidden;
  backdrop-filter: blur(0);
  transition: opacity 0.28s ease, visibility 0.28s ease, backdrop-filter 0.28s ease;
  z-index: 100;
}

.drawer-overlay.is-open {
  opacity: 1;
  visibility: visible;
  backdrop-filter: blur(2px);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 92vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-drawer);
  transform: translateX(100%);
  transition: transform 0.42s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
  overflow-y: auto;
  z-index: 101;
}

.drawer-overlay.is-open .drawer { transform: translateX(0); }

/* Gentle staggered settle of the sections as the panel arrives */
.drawer-overlay.is-open .pd-body > * {
  animation: drawerContentIn 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.drawer-overlay.is-open .pd-body > *:nth-child(1) { animation-delay: 0.10s; }
.drawer-overlay.is-open .pd-body > *:nth-child(2) { animation-delay: 0.15s; }
.drawer-overlay.is-open .pd-body > *:nth-child(3) { animation-delay: 0.20s; }
.drawer-overlay.is-open .pd-body > *:nth-child(4) { animation-delay: 0.25s; }
.drawer-overlay.is-open .pd-body > *:nth-child(n+5) { animation-delay: 0.30s; }

@keyframes drawerContentIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
}

.drawer-header h2 { font-size: 17px; }
.drawer-header p { margin: 3px 0 0; color: var(--text-secondary); font-size: 12.5px; }
.drawer-close { margin-left: auto; }
.drawer-body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-5); }

.detail-row { display: flex; justify-content: space-between; gap: var(--space-3); font-size: 13px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-muted); }
.detail-row .v { color: var(--text-primary); font-weight: 600; text-align: right; }

.drawer-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.timeline li { position: relative; padding-left: var(--space-4); font-size: 12.5px; }
.timeline li::before {
  content: ''; position: absolute; left: 0; top: 5px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent);
}
.timeline li::after {
  content: ''; position: absolute; left: 3px; top: 12px; bottom: -12px; width: 1px; background: var(--border);
}
.timeline li:last-child::after { display: none; }
.timeline .t-date { color: var(--text-muted); display: block; font-size: 11px; margin-bottom: 2px; }

.drawer-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }

/* ---------- Toasts ---------- */

.toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-dropdown);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  min-width: 280px;
  max-width: 360px;
  animation: toast-in 0.18s ease;
  font-size: 13px;
}

.toast svg { width: 17px; height: 17px; color: var(--tone-green); flex-shrink: 0; }
.toast.toast-info svg { color: var(--tone-blue); }
.toast .toast-msg { flex: 1; }
.toast .toast-tag { font-size: 10.5px; color: var(--text-muted); display: block; margin-top: 1px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
}
.empty-state svg { width: 34px; height: 34px; margin-bottom: var(--space-3); opacity: 0.6; }
.empty-state p { margin: 0; font-size: 13px; }

/* ---------- Search results dropdown ---------- */

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  max-height: 360px;
  overflow-y: auto;
  z-index: 60;
  display: none;
}

.search-results.is-open { display: block; }

.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-item .sr-type { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-strong); font-weight: 700; }
:root[data-theme="dark"] .search-result-item .sr-type { color: var(--accent-soft-text); }
.search-result-item .sr-label { font-weight: 700; font-size: 13px; }
.search-result-item .sr-sub { font-size: 11.5px; color: var(--text-muted); }
.search-empty { padding: var(--space-4); text-align: center; color: var(--text-muted); font-size: 12.5px; }
