/* ═══════════════════════════════════════════
   Tracono V2 – Design System
   Notion-inspired: warm, friendly, soft
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,400;6..72,600&family=Source+Sans+3:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Warm palette */
  --bg: #FFFCF7;
  --bg-hover: #FFF8EF;
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --surface-sunken: #FAF6F1;
  --text: #37352F;
  --text-secondary: #9B9A97;
  --text-muted: #BFBDB8;
  --border: #E8E5DF;
  --border-strong: #D3D1CB;
  --focus: #2EAADC;

  /* Brand */
  --primary: #E8590C;
  --primary-light: #FFF4E6;
  --primary-hover: #C74B0A;
  --accent: #0F5132;
  --accent-light: #E6F4EA;

  /* Status */
  --success: #0F7B0F;
  --success-bg: #E6F9E6;
  --warning: #D97706;
  --warning-bg: #FEF3C7;
  --danger: #DC2626;
  --danger-bg: #FEE2E2;
  --info: #2563EB;
  --info-bg: #DBEAFE;

  /* Typography */
  --font-body: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Newsreader', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Sizing */
  --sidebar-w: 260px;
  --sidebar-collapsed: 64px;
  --topbar-h: 52px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 2px 8px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.08);
  --shadow-float: 0 16px 48px rgba(0,0,0,.12);
  --transition: 200ms cubic-bezier(.4,0,.2,1);
}

html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: var(--font-body); color: var(--text); background: var(--bg); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ─── Typography ──────────────────────── */
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 1.8rem; line-height: 1.2; }
h2 { font-size: 1.4rem; line-height: 1.3; }
h3 { font-size: 1.15rem; line-height: 1.3; }
.page-title { font-family: var(--font-display); font-size: 1.65rem; font-weight: 600; }
.page-subtitle { color: var(--text-secondary); font-size: .9rem; margin-top: 4px; }

/* ─── Layout ──────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  transition: width var(--transition);
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px; padding: 16px 20px; font-family: var(--font-display);
  font-weight: 600; font-size: 1.2rem; color: var(--primary); border-bottom: 1px solid var(--border);
  letter-spacing: -.02em;
}
.sidebar-logo svg { flex-shrink: 0; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.sidebar-section { margin-bottom: 8px; }
.sidebar-section-title {
  font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); padding: 8px 12px 4px; user-select: none;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: var(--radius);
  font-size: .88rem; color: var(--text-secondary); transition: all var(--transition); cursor: pointer;
  text-decoration: none; margin-bottom: 1px;
}
.sidebar-link:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.sidebar-link.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.sidebar-link .icon { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; opacity: .75; }
.sidebar-link.active .icon { opacity: 1; }
.sidebar-link .badge-count {
  margin-left: auto; background: var(--danger); color: #fff; font-size: .65rem;
  padding: 1px 6px; border-radius: 99px; font-weight: 600;
}

.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid var(--border); font-size: .78rem; color: var(--text-muted);
}

/* Main area */
.main-area { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }

/* Topbar */
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 16px;
  padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.topbar-breadcrumb { font-size: .82rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.topbar-breadcrumb a { color: var(--text-secondary); }
.topbar-breadcrumb .sep { color: var(--text-muted); }
.topbar-search {
  flex: 1; max-width: 400px; position: relative;
}
.topbar-search input {
  width: 100%; padding: 7px 12px 7px 34px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .85rem; background: var(--surface-sunken); color: var(--text); font-family: var(--font-body);
  transition: all var(--transition);
}
.topbar-search input:focus { outline: none; border-color: var(--focus); background: var(--surface); box-shadow: 0 0 0 3px rgba(46,170,220,.15); }
.topbar-search .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .9rem; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .75rem; cursor: pointer;
}

/* Content */
.content { padding: 28px; max-width: 1400px; }

/* ─── Cards ───────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 24px; transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; margin-bottom: 12px; }

/* KPI Cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--primary); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kpi-card.accent::before { background: var(--accent); }
.kpi-card.warning::before { background: var(--warning); }
.kpi-card.info::before { background: var(--info); }
.kpi-label { font-size: .78rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.kpi-value { font-family: var(--font-display); font-size: 1.8rem; font-weight: 600; color: var(--text); line-height: 1.1; }
.kpi-sub { font-size: .78rem; color: var(--text-secondary); margin-top: 4px; }
.kpi-change { font-size: .75rem; font-weight: 600; }
.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--danger); }

/* ─── Tables ──────────────────────────── */
.table-wrapper { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  text-align: left; padding: 10px 16px; font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary);
  background: var(--surface-sunken); border-bottom: 1px solid var(--border);
  white-space: nowrap; user-select: none;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); cursor: pointer; }
tbody tr:hover { background: var(--bg-hover); }
.table-empty { padding: 48px; text-align: center; color: var(--text-muted); }

/* ─── Buttons ─────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: var(--radius);
  font-family: var(--font-body); font-size: .88rem; font-weight: 500; border: none; cursor: pointer;
  transition: all var(--transition); white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: none; color: var(--text-secondary); padding: 6px 12px; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: var(--radius); }

/* ─── Forms ───────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .82rem; font-weight: 500; color: var(--text); margin-bottom: 5px; }
.form-label .required { color: var(--accent); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .9rem; font-family: var(--font-body); color: var(--text); background: var(--surface);
  transition: all var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(46,170,220,.12);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: .75rem; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.form-checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: .88rem; }
.form-checkbox input { width: 18px; height: 18px; accent-color: var(--primary); }

/* ─── Tags/Badges ─────────────────────── */
.tag {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 99px;
  font-size: .72rem; font-weight: 500; letter-spacing: .01em;
}
.tag-green { background: var(--success-bg); color: var(--success); }
.tag-yellow { background: var(--warning-bg); color: var(--warning); }
.tag-red { background: var(--danger-bg); color: var(--danger); }
.tag-blue { background: var(--info-bg); color: var(--info); }
.tag-gray { background: var(--surface-sunken); color: var(--text-secondary); }

/* ─── Toolbar (above tables) ──────────── */
.toolbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.toolbar-search { position: relative; }
.toolbar-search input {
  padding: 8px 12px 8px 34px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .85rem; width: 260px; background: var(--surface); font-family: var(--font-body);
}
.toolbar-search input:focus { outline: none; border-color: var(--focus); }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* ─── Pagination ──────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; margin-top: 20px; justify-content: center; }
.pagination a, .pagination span {
  padding: 6px 12px; border-radius: var(--radius); font-size: .82rem; color: var(--text-secondary);
  border: 1px solid transparent; transition: all var(--transition); text-decoration: none;
}
.pagination a:hover { background: var(--bg-hover); border-color: var(--border); }
.pagination .current { background: var(--primary); color: #fff; font-weight: 600; }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ─── Tabs ────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab {
  padding: 10px 20px; font-size: .88rem; color: var(--text-secondary); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all var(--transition); text-decoration: none;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* ─── Modal ───────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(55,53,47,.4); backdrop-filter: blur(2px);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-float);
  width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 32px;
  transform: translateY(12px); transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-title { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ─── Toast ───────────────────────────── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius); font-size: .88rem; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px; animation: slideIn .3s ease-out;
  max-width: 400px;
}
.toast-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.toast-error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.toast-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── Anomaly Banner ──────────────────── */
.anomaly { padding: 14px 20px; border-radius: var(--radius); display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: .88rem; }
.anomaly-warning { background: var(--warning-bg); border: 1px solid var(--warning); }
.anomaly-critical { background: var(--danger-bg); border: 1px solid var(--danger); }
.anomaly-info { background: var(--info-bg); border: 1px solid var(--info); }
.anomaly .dismiss { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; opacity: .6; }

/* ─── Calendar ────────────────────────── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.cal-header { padding: 8px; text-align: center; font-size: .72rem; font-weight: 600; text-transform: uppercase; color: var(--text-secondary); background: var(--surface-sunken); }
.cal-day { min-height: 100px; padding: 6px 8px; background: var(--surface); cursor: pointer; transition: background var(--transition); }
.cal-day:hover { background: var(--bg-hover); }
.cal-day.today { background: var(--primary-light); }
.cal-day.other-month { opacity: .4; }
.cal-day-num { font-size: .78rem; font-weight: 500; margin-bottom: 4px; }
.cal-event { font-size: .7rem; padding: 2px 6px; border-radius: 4px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }

/* ─── Kanban ──────────────────────────── */
.kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; }
.kanban-column { min-width: 280px; flex: 1; }
.kanban-header { padding: 10px 12px; font-size: .82rem; font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.kanban-header .count { background: var(--surface-sunken); padding: 1px 8px; border-radius: 99px; font-size: .7rem; }
.kanban-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 8px; cursor: pointer; transition: all var(--transition);
}
.kanban-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kanban-card-title { font-weight: 500; font-size: .88rem; margin-bottom: 6px; }
.kanban-card-meta { font-size: .75rem; color: var(--text-secondary); }

/* ─── POS ─────────────────────────────── */
.pos-layout { display: grid; grid-template-columns: 1fr 360px; gap: 0; height: calc(100vh - var(--topbar-h)); }
.pos-products { overflow-y: auto; padding: 20px; }
.pos-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.pos-product {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 12px; text-align: center; cursor: pointer; transition: all var(--transition);
}
.pos-product:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.pos-cart { background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; }

/* ─── Empty State ─────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; opacity: .5; }
.empty-state-title { font-family: var(--font-display); font-size: 1.15rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state-text { font-size: .88rem; max-width: 400px; margin: 0 auto 20px; line-height: 1.6; }

/* ─── Chatbot Widget ──────────────────── */
.chat-fab {
  position: fixed; bottom: 24px; right: 24px; width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 22px; cursor: pointer; box-shadow: var(--shadow-lg); z-index: 90;
  transition: all var(--transition); border: none;
}
.chat-fab:hover { transform: scale(1.05); box-shadow: var(--shadow-float); }

/* ─── Responsive ──────────────────────── */
@media (max-width: 1024px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar .sidebar-link span, .sidebar-section-title, .sidebar-logo span { display: none; }
  .sidebar-link { justify-content: center; padding: 10px; }
  .main-area { margin-left: var(--sidebar-collapsed); }
  .form-row { grid-template-columns: 1fr; }
  .pos-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
  .sidebar.open { transform: none; }
  .main-area { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kanban { flex-direction: column; }
  .kanban-column { min-width: 100%; }
}

/* ─── Utilities ───────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: .82rem; }
.text-xs { font-size: .72rem; }
.text-muted { color: var(--text-secondary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ═══════════════════════════════════════════
   ANIMATIONS & MICRO-INTERACTIONS
   ═══════════════════════════════════════════ */

/* ─── Page Load: Staggered Fade In ────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(.95); }
  to { opacity: 1; transform: none; }
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes pulse-ring {
  0% { transform: scale(.8); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}
@keyframes number-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes check-draw {
  0% { stroke-dashoffset: 24; }
  100% { stroke-dashoffset: 0; }
}
@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}
@keyframes confetti-fall {
  0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100px) rotate(360deg); opacity: 0; }
}
@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ─── Page Content Entry ─────────────── */
/* NOTE: animation on .content itself is intentionally removed because it creates
   a new containing block that breaks position:fixed on modal overlays inside.
   Only direct children animate. */

/* Staggered children */
.content > *:nth-child(1) { animation-delay: 0s; }
.content > *:nth-child(2) { animation-delay: .06s; }
.content > *:nth-child(3) { animation-delay: .12s; }
.content > *:nth-child(4) { animation-delay: .18s; }
.content > *:nth-child(5) { animation-delay: .24s; }
.content > *:not(.modal-overlay) {
  animation: fadeInUp .45s cubic-bezier(.22,1,.36,1) both;
}

/* ─── Sidebar Hover Effects ──────────── */
.sidebar-link {
  position: relative;
  overflow: hidden;
}
.sidebar-link::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
  transform: scaleY(0);
  transition: transform .25s cubic-bezier(.22,1,.36,1);
}
.sidebar-link.active::before,
.sidebar-link:hover::before {
  transform: scaleY(1);
}
.sidebar-link .icon {
  transition: transform .2s cubic-bezier(.22,1,.36,1);
}
.sidebar-link:hover .icon {
  transform: scale(1.15);
}

/* ─── KPI Cards ──────────────────────── */
.kpi-card {
  animation: fadeInScale .5s cubic-bezier(.22,1,.36,1) both;
  transition: transform .3s cubic-bezier(.22,1,.36,1), box-shadow .3s ease;
}
.kpi-card:nth-child(1) { animation-delay: .05s; }
.kpi-card:nth-child(2) { animation-delay: .1s; }
.kpi-card:nth-child(3) { animation-delay: .15s; }
.kpi-card:nth-child(4) { animation-delay: .2s; }
.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.kpi-card::before {
  transition: height .3s cubic-bezier(.22,1,.36,1);
}
.kpi-card:hover::before {
  height: 4px;
}
.kpi-value {
  transition: color .2s;
}
.kpi-card:hover .kpi-value {
  animation: number-pop .3s ease;
}

/* ─── Table Rows ─────────────────────── */
tbody tr {
  animation: fadeInUp .3s cubic-bezier(.22,1,.36,1) both;
}
tbody tr:nth-child(1) { animation-delay: .02s; }
tbody tr:nth-child(2) { animation-delay: .04s; }
tbody tr:nth-child(3) { animation-delay: .06s; }
tbody tr:nth-child(4) { animation-delay: .08s; }
tbody tr:nth-child(5) { animation-delay: .1s; }
tbody tr:nth-child(6) { animation-delay: .12s; }
tbody tr:nth-child(7) { animation-delay: .14s; }
tbody tr:nth-child(8) { animation-delay: .16s; }
tbody tr:nth-child(9) { animation-delay: .18s; }
tbody tr:nth-child(10) { animation-delay: .2s; }
tbody tr:hover {
  transform: scale(1.005);
  transition: transform .15s ease, background .15s ease;
}

/* ─── Cards ──────────────────────────── */
.card {
  transition: transform .3s cubic-bezier(.22,1,.36,1), box-shadow .3s ease, border-color .3s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

/* Quick action cards on dashboard */
a.card {
  position: relative;
  overflow: hidden;
}
a.card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(232,89,12,.06), transparent 60%);
  opacity: 0;
  transition: opacity .3s;
}
a.card:hover::after { opacity: 1; }

/* ─── Buttons ────────────────────────── */
.btn {
  position: relative;
  overflow: hidden;
  transition: all .25s cubic-bezier(.22,1,.36,1);
}
.btn::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: radial-gradient(circle, rgba(255,255,255,.25) 10%, transparent 10.01%);
  transform: scale(10);
  opacity: 0;
  transition: transform .4s, opacity .8s;
}
.btn:active::after {
  transform: scale(0);
  opacity: .3;
  transition: 0s;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(232,89,12,.25);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}
.btn-secondary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn-danger:hover {
  transform: translateY(-1px);
}

/* ─── Form Focus Effects ─────────────── */
.form-input, .form-select, .form-textarea {
  transition: border-color .25s, box-shadow .25s, transform .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgba(46,170,220,.12), 0 2px 8px rgba(46,170,220,.08);
}

/* ─── Tags ───────────────────────────── */
.tag {
  transition: transform .15s ease, box-shadow .15s ease;
}
.tag:hover {
  transform: scale(1.05);
}

/* ─── Kanban Cards ───────────────────── */
.kanban-card {
  animation: fadeInUp .35s cubic-bezier(.22,1,.36,1) both;
  transition: transform .25s cubic-bezier(.22,1,.36,1), box-shadow .25s ease;
}
.kanban-card:hover {
  transform: translateY(-3px) rotate(-.5deg);
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
}
.kanban-card:active {
  transform: scale(.97);
  box-shadow: var(--shadow-sm);
}

/* ─── Calendar ───────────────────────── */
.cal-day {
  transition: background .2s, transform .15s;
}
.cal-day:hover {
  transform: scale(1.02);
  z-index: 1;
}
.cal-day.today {
  animation: breathe 3s ease-in-out infinite;
}
.cal-event {
  animation: fadeInLeft .3s cubic-bezier(.22,1,.36,1) both;
  transition: transform .15s ease;
}
.cal-event:hover {
  transform: scale(1.04);
}

/* ─── Modal ──────────────────────────── */
.modal-overlay {
  transition: opacity .25s cubic-bezier(.22,1,.36,1);
}
.modal {
  transition: transform .3s cubic-bezier(.22,1,.36,1), opacity .25s;
}
.modal-overlay.open .modal {
  animation: fadeInScale .3s cubic-bezier(.22,1,.36,1) both;
}

/* ─── Toast Notifications ────────────── */
.toast {
  animation: slideInRight .35s cubic-bezier(.22,1,.36,1) both;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }

/* ─── Anomaly Banners ────────────────── */
.anomaly {
  animation: fadeInDown .4s cubic-bezier(.22,1,.36,1) both;
}
.anomaly-critical {
  animation: fadeInDown .4s cubic-bezier(.22,1,.36,1) both, breathe 2s ease-in-out infinite 1s;
}

/* ─── Chatbot Widget ─────────────────── */
.chat-fab {
  animation: fadeInScale .5s cubic-bezier(.22,1,.36,1) .5s both;
  transition: transform .3s cubic-bezier(.22,1,.36,1), box-shadow .3s;
}
.chat-fab:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 8px 32px rgba(232,89,12,.3);
}
.chat-fab::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  animation: pulse-ring 2s ease-out infinite;
}
.chat-fab:hover::before {
  animation: none;
}

#chatPanel {
  animation: slideInRight .3s cubic-bezier(.22,1,.36,1) both;
}

/* ─── Avatar Hover ───────────────────── */
.topbar-avatar {
  transition: transform .2s, box-shadow .2s;
}
.topbar-avatar:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ─── POS Product Tiles ──────────────── */
.pos-product {
  transition: all .2s cubic-bezier(.22,1,.36,1);
}
.pos-product:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
}
.pos-product:active {
  transform: scale(.95);
  transition-duration: .08s;
}

/* ─── Empty State ────────────────────── */
.empty-state {
  animation: fadeInUp .6s cubic-bezier(.22,1,.36,1) .2s both;
}
.empty-state-icon {
  animation: float 3s ease-in-out infinite;
}

/* ─── Loading Skeleton ───────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--bg-hover) 50%, var(--surface-sunken) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 24px; width: 60%; margin-bottom: 12px; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }

/* ─── Success Checkmark ──────────────── */
.success-check {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--success);
  display: flex; align-items: center; justify-content: center;
  animation: fadeInScale .4s cubic-bezier(.22,1,.36,1) both;
}
.success-check svg {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  animation: check-draw .4s ease-out .2s forwards;
}

/* ─── Progress Bar ───────────────────── */
.progress-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-sunken);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  background-size: 200% 100%;
  animation: gradient-shift 2s ease infinite;
  transition: width .6s cubic-bezier(.22,1,.36,1);
}

/* ─── Page Transition ────────────────── */
.page-enter {
  animation: fadeInUp .35s cubic-bezier(.22,1,.36,1) both;
}
.page-exit {
  animation: fadeInUp .2s cubic-bezier(.22,1,.36,1) reverse both;
}

/* ─── Notification Badge Pulse ────────── */
.sidebar-link .badge-count {
  animation: fadeInScale .3s cubic-bezier(.22,1,.36,1) both;
}
.sidebar-link:hover .badge-count {
  animation: number-pop .3s ease;
}

/* ─── Tooltip ────────────────────────── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--text);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: .72rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all .2s cubic-bezier(.22,1,.36,1);
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Reduce motion for accessibility ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── PWA Styles ─────────────────────── */
@media (display-mode: standalone) {
  /* Hide browser-specific UI when running as PWA */
  .topbar { padding-top: env(safe-area-inset-top); }
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* iOS safe areas */
@supports (padding: max(0px)) {
  .sidebar { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .pos-cart { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}

/* PWA Install Banner animation */
#pwa-install {
  animation: fadeInUp .4s cubic-bezier(.22,1,.36,1) both;
}

/* ─── Calendar Views ───────────────────── */
.view-btn { background: none; border: none; color: var(--text-muted); padding: 4px 10px; border-radius: var(--radius); font-size: 0.8rem; cursor: pointer; }
.view-btn.active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow-sm); }
#cal-sidebar { transition: all 0.2s; overflow: hidden; }
#cal-sidebar:not(.open) { min-width: 0; max-width: 0; padding: 0; border: none; opacity: 0; }
.cal-hour-cell:hover { background: var(--primary-bg); }

/* ─── WYSIWYG Editor ──────────────────── */
.editor-btn {
  width: 30px; height: 28px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  cursor: pointer; font-size: .8rem; color: var(--text);
}
.editor-btn:hover { background: var(--bg); }
.editor-btn:active { background: var(--primary-light); }
#reply-editor:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(46,170,220,.15); }
#reply-editor ul, #reply-editor ol { margin: 4px 0; padding-left: 24px; }
#reply-editor table { border-collapse: collapse; width: 100%; margin: 8px 0; }
#reply-editor td, #reply-editor th { border: 1px solid var(--border); padding: 6px 8px; }

/* Rich content (rendered HTML in descriptions/comments) */
.rich-content ul, .rich-content ol { margin: 4px 0; padding-left: 24px; }
.rich-content table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.rich-content td, .rich-content th { border: 1px solid var(--border); padding: 6px 8px; }
.rich-content p { margin: 4px 0; }
.rich-content b, .rich-content strong { font-weight: 600; }

/* ─── Calendar Event Blocks ────────────── */
.cal-event-block { transition: opacity 0.15s; }
.cal-event-block:hover { opacity: 0.9; filter: brightness(1.1); }
.cal-event-block[draggable]:active { cursor: grabbing; }
.cal-hour-cell { transition: background 0.1s; }

/* ─── Table Context Menu ───────────────── */
#table-ctx-menu { animation: fadeInUp .15s ease-out; }
#reply-editor td:hover, #reply-editor th:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
