@import url('https://fonts.googleapis.com/css2?family=Segoe+UI:wght@400;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg-main: #f0f2f5;
  --bg-header: #ffffff;
  --bg-menu: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  
  --border-color: #cbd5e1;
  --border-dark: #94a3b8;
  
  --accent-blue: #0284c7;
  --accent-indigo: #4f46e5;
  --accent-emerald: #16a34a;
  --accent-rose: #dc2626;
  --accent-amber: #d97706;
  
  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  
  --radius: 6px;
  --box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  --box-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
}

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

body {
  font-family: 'Segoe UI', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

.bm-workspace {
  flex: 1;
  padding: 8px;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
}

.bm-view {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* --- TOP DESKTOP MENU BAR & NAVBAR (Book Manager Style) --- */
.bm-top-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  z-index: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.bm-header-title {
  background: linear-gradient(90deg, #1e293b, #334155);
  color: #ffffff;
  padding: 6px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
}

.bm-header-title .company-tag {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 10px;
  border-radius: 4px;
  color: #fbbf24;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.bm-menu-nav {
  display: flex;
  background: var(--bg-menu);
  border-bottom: 1px solid var(--border-color);
  padding: 0 10px;
  align-items: center;
}

.bm-menu-item {
  position: relative;
}

.bm-menu-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s ease;
}

.bm-menu-btn:hover, .bm-menu-item.open > .bm-menu-btn {
  background: #e2e8f0;
  color: var(--accent-indigo);
}

.bm-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #ffffff;
  border: 1px solid var(--border-dark);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  min-width: 220px;
  z-index: 600;
  padding: 4px 0;
}

.bm-menu-item.open .bm-dropdown-menu {
  display: block;
}

.bm-dropdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  font-size: 0.83rem;
  color: var(--text-main);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}

.bm-dropdown-item:hover {
  background: #f1f5f9;
  color: var(--accent-indigo);
  font-weight: 600;
}

.bm-dropdown-item .shortcut {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 15px;
}

.bm-dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

/* --- MULTI-TAB WORKSPACE BAR --- */
.bm-tab-strip {
  display: flex;
  background: #e2e8f0;
  padding: 4px 8px 0 8px;
  border-bottom: 1px solid var(--border-color);
  gap: 4px;
  overflow-x: auto;
}

.bm-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #cbd5e1;
  color: #475569;
  padding: 6px 14px;
  border-radius: 6px 6px 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  border-bottom: none;
  user-select: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.bm-tab:hover {
  background: #dbeafe;
  color: var(--accent-indigo);
}

.bm-tab.active {
  background: #ffffff;
  color: #0f172a;
  border-color: var(--border-dark);
  border-top: 3px solid var(--accent-indigo);
  border-bottom: 2px solid #ffffff;
  margin-bottom: -1px;
  font-weight: 700;
  box-shadow: 0 -2px 5px rgba(0,0,0,0.04);
}

/* --- SUB-TABS (Details vs Location(s)) --- */
.tab-btn, .bm-subtab-btn {
  background: #e2e8f0;
  color: #475569;
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  padding: 5px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.tab-btn:hover, .bm-subtab-btn:hover {
  background: #cbd5e1;
  color: #0f172a;
}

.tab-btn.active, .bm-subtab-btn.active {
  background: #ffffff !important;
  color: #0369a1 !important;
  font-weight: 700 !important;
  border-color: #94a3b8 !important;
  border-top: 3px solid #0284c7 !important;
  border-bottom: 2px solid #ffffff !important;
  margin-bottom: -1px;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
}

.bm-subtab-panel {
  border: 1px solid var(--border-dark);
  background: #ffffff;
  padding: 10px;
  border-radius: 0 4px 4px 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.bm-tab .close-tab {
  font-size: 0.9rem;
  color: var(--text-muted);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bm-tab .close-tab:hover {
  background: #fee2e2;
  color: #b91c1c;
}

/* --- MAIN WORKSPACE CONTAINER --- */
.bm-workspace {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* --- CARDS & PANELS --- */
.bm-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--box-shadow);
}

.bm-card-header {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group label.required {
  color: var(--accent-rose);
}

.form-control {
  background: #ffffff;
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  padding: 6px 10px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  width: 100%;
}

.form-control:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.form-control[readonly] {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

/* Enterprise Numeric Input Formatting (prevents number clipping behind browser spin buttons) */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield;
  text-align: right;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}

/* --- BUTTONS --- */
.btn {
  padding: 5px 14px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.12s ease;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

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

.btn-sm {
  padding: 2px 8px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: 3px;
  gap: 4px;
}

.btn-primary {
  background: var(--accent-indigo);
  color: #ffffff;
  border-color: #3730a3;
}

.btn-primary:hover {
  background: #4338ca;
  box-shadow: 0 2px 4px rgba(67, 56, 202, 0.25);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-body);
  border-color: #cbd5e1;
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.btn-success {
  background: #16a34a;
  color: #ffffff;
  border-color: #15803d;
}

.btn-success:hover {
  background: #15803d;
  box-shadow: 0 2px 4px rgba(22, 163, 74, 0.25);
}

.btn-danger {
  background: #dc2626;
  color: #ffffff;
  border-color: #b91c1c;
}

.btn-danger:hover {
  background: #b91c1c;
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.25);
}

/* --- TABLES --- */
.table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  -webkit-overflow-scrolling: touch;
}

.table-container::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.table-container::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.table-container::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  background: #ffffff;
}

.data-table th {
  background: #f1f5f9;
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  color: var(--text-main);
}

.data-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.data-table tbody tr:hover, .data-table tbody tr.selected {
  background: #e0e7ff;
}

.text-right { text-align: right !important; }

/* --- MODAL DIALOG OVERLAYS (Book Manager Company/Year Dialog) --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 15px;
}

.modal-overlay.active {
  display: flex;
}

.bm-dialog-card {
  background: #ffffff;
  border: 2px solid var(--accent-indigo);
  border-radius: 8px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--box-shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.bm-dialog-header {
  background: var(--bg-subtle);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bm-dialog-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bm-dialog-footer {
  background: var(--bg-subtle);
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* --- BOTTOM STATUS BAR (Book Manager Footer) --- */
.bm-status-bar {
  background: #e2e8f0;
  border-top: 1px solid var(--border-dark);
  padding: 4px 16px;
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-body);
  font-weight: 600;
  position: sticky;
  bottom: 0;
  z-index: 400;
}

/* --- SPLIT PANEL LAYOUT (Master & Transaction Screens) --- */
.bm-split-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 12px;
  align-items: start;
}

@media (max-width: 600px) {
  .bm-split-layout {
    display: flex;
    flex-direction: column;
  }
}

/* Stitch Mobile & Web UI: Dedicated Login Screen */
.login-page-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #f8fafc;
  padding: 16px;
  box-sizing: border-box;
}

.login-card {
  background-color: #ffffff;
  border-radius: 12px;
  width: 100%;
  max-width: 448px;
  padding: 32px 24px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
}

.login-header-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
  width: 100%;
  text-align: center;
}

.login-logo-icon {
  width: 64px;
  height: 64px;
  background-color: #3b82f6;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 4px 0;
  line-height: 1.25;
}

.login-subtitle {
  font-size: 0.875rem;
  color: #64748b;
  margin: 0;
}

.login-form-body {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-field-group {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.login-field-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
  margin-bottom: 6px;
}

.login-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.95rem;
  color: #1e293b;
  background-color: #ffffff;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-input:focus {
  outline: none;
  background-color: #fef08a !important;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.login-eye-btn {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  padding-right: 12px;
  display: flex;
  align-items: center;
  color: #94a3b8;
  background: none;
  border: none;
  cursor: pointer;
}

.login-eye-btn:hover {
  color: #475569;
}

.login-submit-btn {
  width: 100%;
  background-color: #2563eb;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 11px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: background-color 0.15s ease;
}

.login-submit-btn:hover {
  background-color: #1d4ed8;
}

.login-submit-btn:active {
  background-color: #1e40af;
}

.alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
}

/* Reports & Audit Sub-tabs */
.rpt-sub-btn {
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease-in-out;
}

.rpt-sub-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.rpt-sub-btn.active-subtab {
  background: #1e3a8a !important;
  color: #ffffff !important;
  border-color: #1e3a8a !important;
  font-weight: 700 !important;
  box-shadow: 0 1px 3px rgba(30, 58, 138, 0.3);
}

/* Desktop Toast Notification Container (Replaces Chrome Alert Popups) */
.bm-toast-container {
  position: fixed;
  top: 36px;
  right: 20px;
  z-index: 9999999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.bm-toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 440px;
  background: #1e293b;
  color: #ffffff;
  border-radius: 4px;
  padding: 9px 14px;
  font-size: 0.82rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: bmToastSlideIn 0.22s ease-out;
  border-left: 5px solid #3b82f6;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left-width: 5px;
}

.bm-toast.bm-toast-success {
  background: #064e3b;
  color: #ecfdf5;
  border-left-color: #10b981;
}

.bm-toast.bm-toast-error, .bm-toast.bm-toast-danger {
  background: #450a0a;
  color: #fef2f2;
  border-left-color: #ef4444;
}

.bm-toast.bm-toast-warning {
  background: #451a03;
  color: #fffbeb;
  border-left-color: #f59e0b;
}

.bm-toast.bm-toast-info {
  background: #0f172a;
  color: #f8fafc;
  border-left-color: #38bdf8;
}

.bm-toast-close {
  background: none;
  border: none;
  color: currentColor;
  opacity: 0.75;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 4px;
  line-height: 1;
}

.bm-toast-close:hover {
  opacity: 1;
}

@keyframes bmToastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ==========================================================================
   MOBILE RESPONSIVE & PROGRESSIVE WEB APP (PWA) STYLING (<= 768px)
   ========================================================================== */

.mobile-header-bar {
  display: none;
}

.mobile-bottom-nav {
  display: none;
}

.mobile-drawer-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: flex-end;
  justify-content: center;
  animation: fadeInOverlay 0.2s ease-out;
}

.mobile-drawer-overlay.active {
  display: flex;
}

.mobile-drawer-card {
  background: #ffffff;
  width: 100%;
  max-width: 500px;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px)) 16px;
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.2);
  animation: slideUpDrawer 0.25s ease-out;
  max-height: 85vh;
  overflow-y: auto;
}

@keyframes slideUpDrawer {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.mobile-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 1rem;
  color: #0f172a;
}

.mobile-profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
  margin: 12px 0;
}

.mobile-avatar {
  width: 44px;
  height: 44px;
  background: #e0f2fe;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.mobile-drawer-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.mob-drawer-action {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
  width: 100%;
}

.mob-drawer-action:active {
  background: #f1f5f9;
}

.mob-action-icon {
  font-size: 1.4rem;
  width: 32px;
  text-align: center;
}

.mob-drawer-action strong {
right: 20px;
  z-index: 9999999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.bm-toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 440px;
  background: #1e293b;
  color: #ffffff;
  border-radius: 4px;
  padding: 9px 14px;
  font-size: 0.82rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: bmToastSlideIn 0.22s ease-out;
  border-left: 5px solid #3b82f6;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left-width: 5px;
}

.bm-toast.bm-toast-success {
  background: #064e3b;
  color: #ecfdf5;
  border-left-color: #10b981;
}

.bm-toast.bm-toast-error, .bm-toast.bm-toast-danger {
  background: #450a0a;
  color: #fef2f2;
  border-left-color: #ef4444;
}

.bm-toast.bm-toast-warning {
  background: #451a03;
  color: #fffbeb;
  border-left-color: #f59e0b;
}

.bm-toast.bm-toast-info {
  background: #0f172a;
  color: #f8fafc;
  border-left-color: #38bdf8;
}

.bm-toast-close {
  background: none;
  border: none;
  color: currentColor;
  opacity: 0.75;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 4px;
  line-height: 1;
}

.bm-toast-close:hover {
  opacity: 1;
}

@keyframes bmToastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ==========================================================================
   MOBILE RESPONSIVE & PROGRESSIVE WEB APP (PWA) STYLING (<= 768px)
   ========================================================================== */

.mobile-header-bar {
  display: none;
}

.mobile-bottom-nav {
  display: none;
}

.mobile-drawer-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 9999999 !important;
  align-items: flex-end;
  justify-content: center;
  animation: fadeInOverlay 0.2s ease-out;
}

.mobile-drawer-overlay.active {
  display: flex !important;
}

.mobile-drawer-card {
  background: #ffffff;
  width: 100%;
  max-width: 100%;
  border-radius: 16px 16px 0 0;
  padding: 0 0 calc(28px + env(safe-area-inset-bottom, 16px)) 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
  animation: slideUpDrawer 0.22s ease-out;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

@keyframes slideUpDrawer {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.mobile-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 1rem;
  color: #0f172a;
}

.mobile-profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
  margin: 12px 0;
}

.mobile-avatar {
  width: 44px;
  height: 44px;
  background: #e0f2fe;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.mobile-drawer-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.mob-drawer-action {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
  width: 100%;
}

.mob-drawer-action:active {
  background: #f1f5f9;
}

.mob-action-icon {
  font-size: 1.4rem;
  width: 32px;
  text-align: center;
}

.mob-drawer-action strong {
  display: block;
  font-size: 0.9rem;
  color: #1e293b;
}

/* --- PLATFORM ADMINISTRATION DESKTOP 2-COLUMN SPLIT --- */
.sysadmin-companies-layout {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 16px;
  align-items: start;
}

.sysadmin-desktop-header {
  display: flex;
}

.sysadmin-accordion-btn {
  display: none;
}

#provisionFormCollapseBody {
  display: block;
}

@media screen and (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* Code Master Mobile Layout */
  #view-code-master {
    padding-bottom: 75px !important;
  }

  #view-code-master .bm-split-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }

  #codeCatHeaderBanner {
    display: none !important;
  }

  #codeCategoryDesktopContainer {
    display: none !important;
  }

  .code-master-mobile-cat-wrapper {
    display: flex !important;
  }

  .code-master-actions-bar {
    justify-content: stretch !important;
    gap: 8px !important;
    margin-top: 10px !important;
  }

  .code-master-actions-bar button {
    flex: 1 1 auto !important;
    justify-content: center !important;
    padding: 8px 10px !important;
    font-size: 0.82rem !important;
  }

  #codeMasterDesktopContainer {
    display: none !important;
  }

  #codeMasterMobileContainer {
    display: flex !important;
  }

  #view-code-master .table-container {
    max-height: 450px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: 4px;
  }

  /* Platform Administration Mobile Layout */
  .sysadmin-companies-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .sysadmin-desktop-header {
    display: none !important;
  }

  .sysadmin-accordion-btn {
    display: flex !important;
  }

  #provisionFormCollapseBody {
    display: none;
  }

  /* Full-width responsive audit action bar on mobile */
  .audit-actions-container {
    width: 100% !important;
    display: flex !important;
    gap: 6px !important;
    margin-top: 6px !important;
  }

  .audit-actions-container button {
    flex: 1 1 auto !important;
    justify-content: center !important;
    padding: 8px 10px !important;
    font-size: 0.8rem !important;
  }

  /* Responsive search & filter bar on mobile */
  .user-search-filter-bar {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .user-search-filter-bar > div {
    width: 100% !important;
    min-width: 100% !important;
  }

  html, body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
    -webkit-text-size-adjust: 100%;
  }

  /* Prevent iPhone Safari auto-zoom on input focus */
  input:not([type=checkbox]):not([type=radio]),
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Hide the redundant desktop top bar on mobile to maximize vertical screen space */
  .bm-top-bar {
    display: none !important;
  }

  /* Hide redundant desktop top menu navigation on mobile in favor of bottom nav bar */
  .bm-menu-nav {
    display: none !important;
  }

  .bm-tab-strip {
    display: flex !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    width: 100% !important;
    padding: 4px 6px 0 6px !important;
    background: #e2e8f0 !important;
  }

  /* Show Mobile Bottom Navigation with 4 exact web menu categories */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #ffffff;
    border-top: 1px solid #cbd5e1;
    z-index: 1000;
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.08);
  }

  .mob-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 600;
    gap: 3px;
    cursor: pointer;
    transition: color 0.15s ease;
    padding: 6px 0;
  }

  .mob-nav-item.active {
    color: #1e40af;
    font-weight: 800;
  }

  .mob-nav-item.active svg {
    stroke: #1e40af;
    stroke-width: 2.5;
  }

  /* Unified Single-Stream Mobile Scrolling (Eliminates Nested Scroll Trapping) */
  html, body {
    height: auto !important;
    min-height: 100% !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .bm-workspace {
    padding: 8px 8px calc(85px + env(safe-area-inset-bottom, 16px)) 8px !important;
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: visible !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  .bm-view,
  #view-system-admin,
  #view-operational-tabs,
  #view-transaction-entry,
  #view-reports {
    height: auto !important;
    min-height: 0 !important;
    overflow-y: visible !important;
    overflow-x: hidden !important;
    padding: 0 !important;
  }

  /* Universal Real Tabular Accounting Tables on Mobile (Zero Broken Box-Cards) */
  .table-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-height: 420px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
  }

  table.data-table {
    display: table !important;
    width: 100% !important;
    min-width: 100% !important;
    border-collapse: collapse !important;
    font-size: 0.78rem !important;
  }

  table.data-table thead {
    display: table-header-group !important;
    background: #f1f5f9 !important;
  }

  table.data-table thead th {
    display: table-cell !important;
    background: #f1f5f9 !important;
    color: #1e293b !important;
    font-weight: 700 !important;
    font-size: 0.76rem !important;
    padding: 6px 8px !important;
    border: 1px solid #cbd5e1 !important;
    white-space: nowrap !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
  }

  table.data-table tbody {
    display: table-row-group !important;
  }

  table.data-table tbody tr {
    display: table-row !important;
    background: #ffffff !important;
    cursor: pointer !important;
  }

  table.data-table tbody tr:nth-child(even) {
    background: #f8fafc !important;
  }

  table.data-table tbody tr.selected,
  table.data-table tbody tr:hover {
    background: #fef08a !important;
  }

  table.data-table tbody tr td {
    display: table-cell !important;
    padding: 6px 8px !important;
    border: 1px solid #e2e8f0 !important;
    font-size: 0.78rem !important;
    color: #334155 !important;
    white-space: nowrap !important;
    text-align: left !important;
  }

  table.data-table tbody tr td::before {
    display: none !important;
    content: none !important;
  }

  /* Mobile Masters Layouts (Account, Item, User, Company, Platform Admin) */
  .account-master-layout,
  .item-master-layout,
  .user-master-layout,
  .company-master-layout,
  .sysadmin-stitch-layout,
  .bm-split-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    width: 100% !important;
  }

  /* Prevent any grid clipping in Company, Account, and Item forms on mobile */
  .company-master-layout div[style*="grid-template-columns"],
  .account-master-layout div[style*="grid-template-columns"],
  .item-master-layout div[style*="grid-template-columns"],
  .user-master-layout div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .bm-card {
    padding: 6px !important;
  }

  /* Mobile Document Preview & Print Modal */
  #docModal .bm-dialog-card {
    width: 98vw !important;
    max-width: 98vw !important;
    height: 92vh !important;
    max-height: 92vh !important;
    margin: 4px auto !important;
  }

  #docFormatSwitchButtons {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    display: flex !important;
    flex-wrap: nowrap !important;
    padding-bottom: 2px;
    width: 100%;
  }

  #docFormatSwitchButtons .btn {
    white-space: nowrap !important;
    padding: 3px 8px !important;
    font-size: 0.72rem !important;
  }

  #docPreviewIframe {
    height: calc(100% - 5px) !important;
    min-height: 380px !important;
  }
}

/* --- UNIVERSAL SEARCHABLE TYPEAHEAD COMBOBOX --- */
.searchable-combo-container {
  position: relative;
  display: inline-block;
  width: 100%;
}

.searchable-combo-input {
  width: 100%;
  box-sizing: border-box;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px !important;
}

.searchable-combo-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 420px;
  z-index: 1050;
  background: #ffffff;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  max-height: 220px;
  overflow-y: auto;
  margin-top: 2px;
  display: none;
}

.searchable-combo-item {
  padding: 6px 10px;
  font-size: 0.84rem;
  color: #1e293b;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  display: block;
  text-align: left;
  white-space: nowrap;
  user-select: none;
}

.searchable-combo-item:last-child {
  border-bottom: none;
}

.searchable-combo-item:hover,
.searchable-combo-item.active {
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 600;
}

.searchable-combo-item mark {
  background: #fef08a;
  color: #000000;
  padding: 0;
  margin: 0;
  font-weight: 700;
  border-radius: 2px;
  display: inline;
}

/* Code Master Mobile Category Chips */
.cm-mobile-chip {
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.cm-mobile-chip:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.cm-mobile-chip.active {
  background: #1e3a8a !important;
  color: #ffffff !important;
  border-color: #1e3a8a !important;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(30,58,138,0.25);
}

/* Document Numbering Series Modal Styling */
#docNumberingModal .data-table th,
#docNumberingModal .data-table td {
  padding: 6px 8px;
  vertical-align: middle;
}

@media (max-width: 768px) {
  #docNumberingModal .bm-dialog-box {
    width: 96vw !important;
    max-height: 94vh !important;
  }
  #docNumberingModal .data-table {
    font-size: 0.75rem;
  }
}

/* ==========================================================================
   DAYBOOK — ZERO-KNOWLEDGE E2EE DIGITAL LEDGER SYSTEM STYLES
   ========================================================================== */

.daybook-root {
  min-height: 100vh;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
}

/* Dark Stealth Theme (Default) */
.daybook-root.daybook-dark,
.daybook-root[data-theme="dark"] {
  --db-bg: #090d16;
  --db-surface: #111827;
  --db-card-bg: #1e293b;
  --db-card-hover: #283548;
  --db-card-border: #334155;
  --db-text-main: #f8fafc;
  --db-text-muted: #94a3b8;
  --db-in-color: #10b981;
  --db-out-color: #ef4444;
  --db-header-bg: rgba(15, 23, 42, 0.88);
  --db-input-bg: #0f172a;
  --db-input-border: #475569;
  background-color: var(--db-bg);
  color: var(--db-text-main);
}

/* Light Stealth Theme */
.daybook-root.daybook-light,
.daybook-root[data-theme="light"] {
  --db-bg: #f8fafc;
  --db-surface: #ffffff;
  --db-card-bg: #ffffff;
  --db-card-hover: #f1f5f9;
  --db-card-border: #e2e8f0;
  --db-text-main: #0f172a;
  --db-text-muted: #64748b;
  --db-in-color: #059669;
  --db-out-color: #dc2626;
  --db-header-bg: rgba(255, 255, 255, 0.92);
  --db-input-bg: #ffffff;
  --db-input-border: #cbd5e1;
  background-color: var(--db-bg);
  color: var(--db-text-main);
}

/* Header */
.db-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--db-header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--db-card-border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.db-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.db-book-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--db-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-cycle-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--db-in-color);
  border: 1px solid rgba(16, 185, 129, 0.3);
  white-space: nowrap;
}

.db-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.db-action-btn {
  background: var(--db-card-bg);
  color: var(--db-text-main);
  border: 1px solid var(--db-card-border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.db-action-btn:hover {
  background: var(--db-card-hover);
  border-color: #64748b;
}

/* Main Content Container */
.db-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 12px 16px 110px 16px;
  box-sizing: border-box;
}

/* Balance Overview Card */
.db-balance-card {
  background: linear-gradient(135deg, var(--db-surface) 0%, var(--db-card-bg) 100%);
  border: 1px solid var(--db-card-border);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.db-balance-header {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--db-text-muted);
  margin-bottom: 4px;
}

.db-net-balance {
  font-size: 2.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-bottom: 14px;
  line-height: 1.1;
  color: var(--db-in-color);
}

.db-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border-top: 1px solid var(--db-card-border);
  padding-top: 12px;
}

.db-stat-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.db-stat-label {
  font-size: 0.74rem;
  color: var(--db-text-muted);
  font-weight: 500;
}

.db-stat-val {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.db-stat-in .db-stat-val {
  color: var(--db-in-color);
}

.db-stat-out .db-stat-val {
  color: var(--db-out-color);
}

/* Search & Filter Toolbar */
.db-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.db-search-input {
  flex: 1;
  min-width: 180px;
  background: var(--db-input-bg);
  border: 1px solid var(--db-input-border);
  color: var(--db-text-main);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.84rem;
  outline: none;
  box-sizing: border-box;
}

.db-search-input:focus {
  border-color: #3b82f6;
}

.db-filter-pills {
  display: flex;
  gap: 4px;
}

.db-filter-btn {
  background: var(--db-card-bg);
  border: 1px solid var(--db-card-border);
  color: var(--db-text-muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.db-filter-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.db-filter-btn.db-filter-in.active {
  background: var(--db-in-color);
  border-color: var(--db-in-color);
}

.db-filter-btn.db-filter-out.active {
  background: var(--db-out-color);
  border-color: var(--db-out-color);
}

/* 2-Line Ledger Cards */
.db-transaction-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.db-ledger-card {
  background: var(--db-card-bg);
  border: 1px solid var(--db-card-border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.db-ledger-card:hover {
  background: var(--db-card-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.db-ledger-card:active {
  transform: scale(0.99);
}

.db-card-line1 {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 3px;
}

.db-card-party {
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--db-text-main);
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
  flex: 1;
}

.db-card-amount {
  font-weight: 800;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
  text-align: right;
}

.db-card-type-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
}

.db-card-remark {
  font-size: 0.82rem;
  color: var(--db-text-muted);
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.4;
  margin-bottom: 4px;
}

.db-card-remark span {
  font-weight: 600;
  color: #38bdf8;
  margin-right: 4px;
}

.db-card-line2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  border-top: 1px dashed rgba(148, 163, 184, 0.18);
  padding-top: 4px;
  margin-top: 2px;
}

.db-card-meta {
  color: var(--db-text-muted);
  flex: 1;
}

.db-card-running {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--db-text-main);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Bottom Tactile Action Bar */
.db-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99;
  background: var(--db-header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--db-card-border);
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  gap: 12px;
}

.db-btn-quick-in,
.db-btn-quick-out {
  flex: 1;
  max-width: 380px;
  height: 48px;
  border-radius: 12px;
  border: none;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, filter 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.db-btn-quick-in {
  background: #10b981;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.db-btn-quick-out {
  background: #ef4444;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.db-btn-quick-in:hover,
.db-btn-quick-out:hover {
  filter: brightness(1.08);
}

.db-btn-quick-in:active,
.db-btn-quick-out:active {
  transform: scale(0.98);
}

.db-kbd-hint {
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* Bottom Sheet Drawer */
.db-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999998;
}

.daybook-bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 540px;
  margin: 0 auto;
  background: var(--db-card-bg);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--db-card-border);
  border-bottom: none;
  z-index: 999999;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 12px 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

.daybook-bottom-sheet.open {
  transform: translateY(0);
}

.db-sheet-handle-bar {
  display: flex;
  justify-content: center;
  padding-bottom: 8px;
}

.db-sheet-handle {
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: var(--db-card-border);
}

.db-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.db-sheet-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--db-text-main);
}

.db-sheet-close {
  background: transparent;
  border: none;
  color: var(--db-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}

.db-sheet-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.db-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.db-form-row label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--db-text-muted);
}

.db-input {
  background: var(--db-input-bg);
  border: 1px solid var(--db-input-border);
  color: var(--db-text-main);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.92rem;
  outline: none;
  box-sizing: border-box;
}

.db-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.db-amount-input {
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.db-party-chips-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0;
}

.db-party-chips-row::-webkit-scrollbar {
  display: none;
}

.db-party-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--db-card-border);
  color: var(--db-text-main);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.76rem;
  white-space: nowrap;
  cursor: pointer;
}

.db-party-chip:hover {
  background: rgba(255, 255, 255, 0.16);
}

.db-sheet-footer {
  margin-top: 8px;
}

.db-btn-submit {
  width: 100%;
  padding: 10px 18px;
  border-radius: 8px;
  background: #0f766e;
  border: 1px solid #14b8a6;
  color: #ffffff !important;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
  box-sizing: border-box;
}

.db-btn-submit:hover {
  background: #115e59;
  border-color: #2dd4bf;
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.35);
  transform: translateY(-1px);
}

.db-btn-submit:active {
  background: #042f2e;
  transform: translateY(0);
}

/* Toast */
.daybook-toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2000000;
  white-space: nowrap;
}

.daybook-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Entry Details / Options Modal */
.db-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.db-modal-box {
  background: var(--db-card-bg);
  border: 1px solid var(--db-card-border);
  border-radius: 16px;
  max-width: 440px;
  width: 100%;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
}

/* Super Admin DayBook Section Styling */
.db-admin-key-badge {
  font-family: monospace;
  font-size: 0.72rem;
  background: #f1f5f9;
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
}

.db-admin-escrow-active {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
}

/* ==========================================================================
   DAYBOOK MOBILE-FIRST RESPONSIVENESS & THEME PARITY
   ========================================================================== */

/* 1. Utility: Hide text labels on mobile viewports */
@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
}

/* 2. Mobile Header Optimization (Screens <= 768px) */
@media (max-width: 768px) {
  .db-header {
    padding: 8px 12px;
    gap: 8px;
  }

  .db-header-left {
    flex: 1;
    min-width: 0;
    gap: 6px;
  }

  .db-book-switcher-btn {
    max-width: 160px;
    padding: 6px 8px !important;
    font-size: 0.82rem !important;
  }

  .db-book-title {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
  }

  /* Move cycle badge out of crowded header on small screens */
  .db-header .db-cycle-badge {
    display: none !important;
  }

  .db-header-actions {
    gap: 4px;
    flex-shrink: 0;
  }

  .db-header .db-action-btn,
  .db-header-actions .db-action-btn {
    width: 36px;
    height: 36px;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.95rem;
  }

  .db-modal-box .db-action-btn {
    width: auto;
    height: auto;
  }

  /* 3. Mobile Ledger Switcher Dropdown */
  .db-dropdown-menu {
    position: fixed !important;
    top: 56px !important;
    left: 12px !important;
    right: 12px !important;
    min-width: auto !important;
    max-width: none !important;
    width: auto !important;
    z-index: 100001 !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5) !important;
  }

  /* 4. Mobile Search & Filter Toolbar: 2 Clean Rows */
  .db-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .db-search-input {
    width: 100%;
    min-width: 0;
    font-size: 0.88rem;
    padding: 10px 14px;
  }

  .db-filter-pills {
    display: flex;
    width: 100%;
    gap: 6px;
    background: var(--db-surface);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--db-card-border);
  }

  .db-filter-btn {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: 0.8rem;
    border-radius: 6px;
  }

  /* 5. Mobile 2-Line Ledger Cards */
  .db-ledger-card {
    padding: 12px 12px;
  }

  .db-card-party {
    font-size: 0.92rem;
  }

  .db-card-amount {
    font-size: 1rem;
  }

  /* 6. Mobile Safe-Area Inset & Keyboard Handling for Bottom Sheet Drawer */
  .daybook-bottom-sheet {
    max-height: 85dvh;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .db-bottom-bar {
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }

  .db-btn-quick-in,
  .db-btn-quick-out {
    height: 48px;
    font-size: 0.9rem;
    min-width: 0;
  }

  /* Hide physical keyboard hints (+ / -) on touchscreens */
  .db-kbd-hint {
    display: none !important;
  }

  .db-container {
    padding: 10px 12px calc(90px + env(safe-area-inset-bottom, 0px)) 12px;
  }

  /* 7. Mobile Bottom Sheet for Date Range & Period Modal */
  #dbDateRangeModal {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .db-date-range-modal {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 90dvh !important;
    overflow-y: auto !important;
    padding: 16px 18px calc(16px + env(safe-area-inset-bottom, 12px)) 18px !important;
    animation: dbSheetSlideUp 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .db-sheet-handle-bar {
    display: flex;
  }

  .db-history-chips {
    gap: 6px;
    padding: 2px 0 6px 0;
  }

  .db-hchip {
    padding: 8px 12px;
    font-size: 0.78rem;
    min-height: 44px;
    flex: 0 0 auto;
  }

  .db-presets-grid {
    gap: 6px;
  }

  .db-preset-btn {
    min-height: 44px;
    padding: 8px 10px;
    font-size: 0.78rem;
  }
}

@keyframes dbSheetSlideUp {
  from {
    transform: translateY(100%);
    opacity: 0.8;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 7. Light Theme Parity for Dropdown & Modals */
.daybook-root.daybook-light #dbBookDropdownMenu,
.daybook-root[data-theme="light"] #dbBookDropdownMenu {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12) !important;
}

.daybook-root.daybook-light .db-book-dropdown-row,
.daybook-root[data-theme="light"] .db-book-dropdown-row {
  color: #0f172a !important;
}

.daybook-root.daybook-light .db-modal-box,
.daybook-root[data-theme="light"] .db-modal-box {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

/* 8. DayBook Perpetual History, Carousel Filter Chips & Archive Bar */
.db-history-bar {
  margin-bottom: 12px;
}

.db-history-chips {
  display: flex;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px 6px 2px;
}

.db-history-chips::-webkit-scrollbar {
  display: none;
}

.db-hchip {
  flex: 0 0 auto;
  min-width: max-content;
  justify-content: center;
  background: var(--db-card-bg, #1e293b);
  border: 1px solid var(--db-card-border, #334155);
  color: var(--db-text-muted, #94a3b8);
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  user-select: none;
  min-height: 44px;
  white-space: nowrap;
}

.db-hchip:hover {
  border-color: #64748b;
  color: var(--db-text-main, #f8fafc);
  background: rgba(255, 255, 255, 0.05);
}

.db-hchip.active {
  background: #0f766e !important;
  border-color: #14b8a6 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 10px rgba(20, 184, 166, 0.35);
  font-weight: 700;
}

.daybook-root.daybook-light .db-hchip,
.daybook-root[data-theme="light"] .db-hchip {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #334155;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.daybook-root.daybook-light .db-hchip:hover,
.daybook-root[data-theme="light"] .db-hchip:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.daybook-root.daybook-light .db-hchip.active,
.daybook-root[data-theme="light"] .db-hchip.active {
  background: #0f766e !important;
  border-color: #0f766e !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.25);
  font-weight: 700;
}

/* Consolidated Date Range & Period Filter Modal */
.db-date-range-modal {
  max-width: 440px;
  width: 92%;
}

.db-sheet-handle-bar {
  display: none;
  justify-content: center;
  padding-bottom: 12px;
}

.db-sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--db-card-border, #475569);
}

.db-presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.db-preset-btn {
  background: var(--db-input-bg, #0f172a);
  border: 1px solid var(--db-card-border, #334155);
  color: var(--db-text-main, #f8fafc);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  min-height: 44px;
  touch-action: manipulation;
}

.db-preset-btn:hover {
  background: var(--db-card-hover, #283548);
  border-color: #64748b;
  transform: translateY(-1px);
}

.db-preset-btn.db-preset-all {
  grid-column: 1 / -1;
  background: rgba(15, 118, 110, 0.15);
  border-color: rgba(20, 184, 166, 0.4);
  color: #2dd4bf;
}

.db-preset-btn.db-preset-all:hover {
  background: rgba(15, 118, 110, 0.28);
  border-color: #14b8a6;
}

.db-filter-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 14px 0;
  color: var(--db-text-muted, #94a3b8);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.db-filter-divider::before,
.db-filter-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--db-card-border, #334155);
}

.db-filter-divider span {
  padding: 0 10px;
}

/* Light Theme Styling for Date Modal & Presets */
.daybook-root.daybook-light .db-date-range-modal,
.daybook-root[data-theme="light"] .db-date-range-modal {
  background: #ffffff;
  border-color: #e2e8f0;
}

.daybook-root.daybook-light .db-preset-btn,
.daybook-root[data-theme="light"] .db-preset-btn {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.daybook-root.daybook-light .db-preset-btn:hover,
.daybook-root[data-theme="light"] .db-preset-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.daybook-root.daybook-light .db-preset-btn.db-preset-all,
.daybook-root[data-theme="light"] .db-preset-btn.db-preset-all {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.daybook-root.daybook-light .db-preset-btn.db-preset-all:hover,
.daybook-root[data-theme="light"] .db-preset-btn.db-preset-all:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
}

.daybook-root.daybook-light .db-filter-divider,
.daybook-root[data-theme="light"] .db-filter-divider {
  color: #64748b;
}

.daybook-root.daybook-light .db-filter-divider::before,
.daybook-root.daybook-light .db-filter-divider::after,
.daybook-root[data-theme="light"] .db-filter-divider::before,
.daybook-root[data-theme="light"] .db-filter-divider::after {
  border-color: #e2e8f0;
}

.db-cycle-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--db-card-border, #334155);
  background: var(--db-surface, #1e293b);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 8px;
}

.db-cycle-card-item:hover {
  border-color: #14b8a6;
  background: rgba(20, 184, 166, 0.08);
}

.db-cycle-card-item.selected {
  border-color: #14b8a6;
  background: rgba(20, 184, 166, 0.15);
}



