:root {
  --bk-primary: #7c3aed;
  --bk-primary-dark: #6d28d9;
  --bk-primary-light: #a78bfa;
  --bk-accent: #0ea5e9;
  --bk-bg: #f0f2f5;
  --bk-bg-card: #ffffff;
  --bk-bg-sidebar: linear-gradient(180deg, #1e1b4b 0%, #2e1065 70%);
  --bk-text: #1e293b;
  --bk-text-muted: #475569;
  --bk-text-inverse: #ffffff;
  --bk-border: #e2e8f0;
  --bk-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --bk-shadow-lg: 0 10px 40px rgba(0,0,0,.12);
  --bk-radius: 12px;
  --bk-radius-sm: 8px;
  --bk-font: 'Inter', system-ui, -apple-system, sans-serif;
  --bk-transition: all .2s cubic-bezier(.4,0,.2,1);
  --bk-nav-width: 260px;
}

html {
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
}

html, body {
  font-family: var(--bk-font);
  background: var(--bk-bg);
  color: var(--bk-text);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  width: 100%;
}

img, svg, video, canvas, audio, iframe, embed, object {
  max-width: 100%;
  height: auto;
}

input, select, textarea, button {
  font-family: inherit;
}

*:focus-visible {
  outline: 2px solid var(--bk-primary);
  outline-offset: 2px;
}

.page {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--bk-nav-width);
  background: var(--bk-bg-sidebar);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  overflow-y: auto;
  transition: transform .3s ease;
}
main {
  margin-left: var(--bk-nav-width);
  flex: 1;
  padding: 0;
  min-width: 0;
}
.top-row {
  display: none;
  height: 56px;
  background: var(--bk-bg-card);
  border-bottom: 1px solid var(--bk-border);
  align-items: center;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 999;
}
.content {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.navbar-toggler {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--bk-text);
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 999;
  backdrop-filter: blur(4px);
}

.navbar-brand {
  display: block;
  padding: 20px 20px 8px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--bk-text-inverse);
  text-decoration: none;
}
.navbar-brand small {
  display: block;
  font-size: .7rem;
  font-weight: 400;
  opacity: .6;
  margin-top: 2px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: .9rem;
  border-radius: 8px;
  margin: 2px 8px;
  transition: var(--bk-transition);
  min-height: 44px;
}
.nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.1);
}
.nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--bk-primary), var(--bk-primary-dark));
  box-shadow: 0 4px 12px rgba(124,58,237,.3);
}
.nav-section-label {
  display: block;
  padding: 16px 20px 4px;
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
}

.btn {
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--bk-radius-sm);
  font-weight: 500;
  transition: var(--bk-transition);
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--bk-primary), var(--bk-primary-dark));
  border: none;
  color: #fff;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124,58,237,.35);
}
.btn-success {
  background: linear-gradient(135deg, var(--bk-success), #059669);
  border: none;
  color: #fff;
}
.btn-danger {
  background: linear-gradient(135deg, var(--bk-danger), #dc2626);
  border: none;
  color: #fff;
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--bk-border);
  color: var(--bk-text);
}
.btn-outline:hover {
  border-color: var(--bk-primary);
  color: var(--bk-primary);
  background: rgba(124,58,237,.05);
}
.btn-sm {
  min-height: 44px;
  padding: 8px 14px;
  font-size: .85rem;
}

.glass-card {
  background: var(--bk-bg-card);
  border-radius: var(--bk-radius);
  box-shadow: var(--bk-shadow);
  border: 1px solid var(--bk-border);
  transition: var(--bk-transition);
  overflow: hidden;
}
.glass-card .card-header {
  background: transparent;
  border-bottom: 1px solid var(--bk-border);
  padding: 16px 20px;
  font-weight: 600;
}
.glass-card .card-body {
  padding: 20px;
}

.glass-card.glass-primary { border-left: 4px solid var(--bk-primary); }
.glass-card.glass-success { border-left: 4px solid var(--bk-success); }
.glass-card.glass-warning { border-left: 4px solid var(--bk-warning); }
.glass-card.glass-danger { border-left: 4px solid var(--bk-danger); }
.glass-card.glass-info { border-left: 4px solid var(--bk-info); }
.glass-card.glass-accent { border-left: 4px solid var(--bk-accent); }

.card {
  border-radius: var(--bk-radius);
  box-shadow: var(--bk-shadow);
  border: 1px solid var(--bk-border);
  transition: var(--bk-transition);
}
.card .card-header {
  background: transparent;
  border-bottom: 1px solid var(--bk-border);
  padding: 16px 20px;
  font-weight: 600;
}
.card .card-body {
  padding: 20px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, var(--bk-primary), var(--bk-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.bottom-nav {
    display: none;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 12px;
    color: var(--bk-text-muted, #64748b);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    min-height: 56px;
    min-width: 64px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:hover,
.bottom-nav-item:active {
    color: var(--bk-primary, #7c3aed);
    background: rgba(124,58,237,.08);
}

.bottom-nav-item.active {
    color: var(--bk-primary, #7c3aed);
}

.bottom-nav-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--bk-radius-sm);
  border: 1px solid var(--bk-border);
}
.table-wrap table {
  margin-bottom: 0;
  min-width: 600px;
}
.table-wrap th {
  background: #f8fafc;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--bk-text-muted);
  padding: 12px 16px;
  border-bottom: 2px solid var(--bk-border);
  white-space: nowrap;
}
.table-wrap td {
  padding: 12px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--bk-border);
}
.table-wrap tr:hover td {
  background: rgba(124,58,237,.03);
}

.mobile-card-list {
  display: none;
}
.mobile-card-list .list-item {
  background: var(--bk-bg-card);
  border-radius: var(--bk-radius-sm);
  padding: 16px;
  margin-bottom: 8px;
  box-shadow: var(--bk-shadow);
  border: 1px solid var(--bk-border);
  transition: var(--bk-transition);
  cursor: pointer;
}
.mobile-card-list .list-item:active {
  transform: scale(.98);
}
.mobile-card-list .list-item .item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}
.mobile-card-list .list-item .item-label {
  font-size: .8rem;
  color: var(--bk-text-muted);
}
.mobile-card-list .list-item .item-value {
  font-weight: 500;
}

.entry-form .form-label {
  font-weight: 500;
  font-size: .85rem;
  color: var(--bk-text-muted);
  margin-bottom: 4px;
}
.entry-form .form-control,
.entry-form .form-select {
  border-radius: var(--bk-radius-sm);
  border: 2px solid var(--bk-border);
  padding: 12px 16px;
  min-height: 48px;
  font-size: .95rem;
  transition: var(--bk-transition);
  background: var(--bk-bg-card);
}
.entry-form .form-control:focus,
.entry-form .form-select:focus {
  border-color: var(--bk-primary);
  box-shadow: 0 0 0 4px rgba(124,58,237,.1);
}

/* ===== Themed nav-tabs ===== */
.nav-tabs .nav-link {
  color: var(--bk-text-muted);
  border: none;
  padding: 10px 16px;
  font-weight: 500;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  background: none;
  min-height: 44px;
  transition: var(--bk-transition);
}
.nav-tabs .nav-link:hover {
  color: var(--bk-primary);
  border-bottom-color: var(--bk-primary);
}
.nav-tabs .nav-link.active {
  color: var(--bk-primary);
  border-bottom-color: var(--bk-primary);
  background: none;
}

/* ===== Responsive: tablets (769px-991px) ===== */
@media (min-width: 769px) and (max-width: 991px) {
  [class*="col-lg-"] {
    flex: 0 0 50% !important;
    max-width: 50% !important;
  }
  [class*="col-xl-"] {
    flex: 0 0 50% !important;
    max-width: 50% !important;
  }
  .content {
    padding: 20px;
  }
  .desktop-table {
    display: table;
  }
  .mobile-card-list {
    display: none;
  }
}

/* ===== Responsive: mobile (≤768px) ===== */
@media (max-width: 768px) {
  .bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 72px;
    background: var(--bk-bg-card, #fff);
    border-top: 1px solid var(--bk-border, #e2e8f0);
    z-index: 1001 !important;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
  }

  .sidebar {
    display: none !important;
  }
  .mobile-overlay {
    display: none !important;
  }
  .more-menu-panel {
    max-height: none;
    height: 100dvh;
    border-radius: 0;
    top: 0;
  }
  .more-menu-header {
    padding-top: calc(env(safe-area-inset-top, 0) + 16px);
  }

  [class*="col-"] {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  .btn, button, .form-control, .form-select {
    width: 100%;
  }

  .table-wrap table {
    min-width: 0;
  }

  main {
    margin-left: 0;
    padding-bottom: 80px;
  }
  .top-row {
    display: flex;
    height: 56px;
  }
  .content {
    padding: 16px;
  }
  .desktop-table {
    display: none;
  }
  .mobile-card-list {
    display: block;
  }
  .nav-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-tabs::-webkit-scrollbar {
    display: none;
  }
  .nav-tabs .nav-link {
    white-space: nowrap;
    padding: 10px 12px;
    font-size: .85rem;
  }
}

@media (min-width: 769px) {
  .desktop-table {
    display: table;
  }
  .mobile-card-list {
    display: none;
  }
}

/* ===== Swipe & touch native gestures ===== */
.swipe-track {
  will-change: transform;
  touch-action: pan-y;
}
.swipe-track > * {
  touch-action: pan-y;
}
.ptr-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60px;
  margin-top: -60px;
  color: var(--bk-text-muted);
  font-size: .85rem;
  gap: 4px;
  will-change: transform, opacity;
}
.ptr-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--bk-border);
  border-top-color: var(--bk-accent);
  border-radius: 50%;
  animation: ptr-spin .6s linear infinite;
}
@keyframes ptr-spin { to { transform: rotate(360deg); } }

.list-item {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}
.swipe-action {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bk-danger);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  will-change: transform;
}

@media (max-width: 576px) {
  .stat-card {
    padding: 16px;
  }
  .stat-card .stat-value {
    font-size: 1.1rem;
  }
  .content {
    padding: 12px;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .page-header .page-actions {
    width: 100%;
  }
  .page-header .page-actions .btn {
    flex: 1;
  }
}

@media (min-width: 1400px) {
  .content {
    max-width: 1400px;
  }
}
