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

/* Custom scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
  border: 2px solid transparent;
  background-clip: padding-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

:root {
  --bg: #090a0f;
  --surface: rgba(17, 19, 28, 0.75);
  --surface2: rgba(25, 28, 41, 0.85);
  --surface3: rgba(33, 37, 54, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border2: rgba(255, 255, 255, 0.12);
  --accent: #7e81ea;
  --accent-hover: #6c70dc;
  --accent-dim: rgba(126, 129, 234, 0.12);
  --accent-glow: rgba(126, 129, 234, 0.25);
  --accent2: #48a6b8;
  --accent2-dim: rgba(72, 166, 184, 0.12);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --orange: #f97316;
  --radius: 16px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
}

html[data-theme="light"] {
  --bg: #f8f9fb;
  --surface: rgba(255, 255, 255, 0.9);
  --surface2: rgba(241, 245, 249, 0.9);
  --surface3: rgba(226, 232, 240, 0.9);
  --border: rgba(0, 0, 0, 0.06);
  --border2: rgba(0, 0, 0, 0.1);
  --accent: #6c70dc;
  --accent-hover: #7e81ea;
  --accent-dim: rgba(108, 112, 220, 0.1);
  --accent-glow: rgba(108, 112, 220, 0.2);
  --accent2: #3b84ac;
  --accent2-dim: rgba(59, 132, 172, 0.1);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --green: #059669;
  --red: #dc2626;
  --yellow: #d97706;
  --orange: #ea580c;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.08);
}

@media(prefers-color-scheme:light) {
  html[data-theme="system"] {
    --bg: #f8f9fb;
    --surface: rgba(255, 255, 255, 0.9);
    --surface2: rgba(241, 245, 249, 0.9);
    --surface3: rgba(226, 232, 240, 0.9);
    --border: rgba(0, 0, 0, 0.06);
    --border2: rgba(0, 0, 0, 0.1);
    --accent: #6c70dc;
    --accent-hover: #7e81ea;
    --accent-dim: rgba(108, 112, 220, 0.1);
    --accent-glow: rgba(108, 112, 220, 0.2);
    --accent2: #3b84ac;
    --accent2-dim: rgba(59, 132, 172, 0.1);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --green: #059669;
    --red: #dc2626;
    --yellow: #d97706;
    --orange: #ea580c;
  }
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', Inter, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  line-height: 1.55;
  background-image:
    radial-gradient(circle at 10% 20%, var(--accent-dim) 0%, transparent 45%),
    radial-gradient(circle at 90% 80%, var(--accent2-dim) 0%, transparent 45%);
  background-attachment: fixed;
}

/* Layout */
.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.main {
  overflow-x: hidden;
  width: 100%;
}

.sb-logo {
  padding: 36px 28px 24px;
  border-bottom: 1px solid var(--border);
}

.sb-logo .mark {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent);
  font-family: 'Plus Jakarta Sans', Inter, sans-serif;
  text-transform: uppercase;
  margin-bottom: 10px;
  opacity: 0.95;
}

.sb-logo h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.sb-logo p {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 6px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sb-nav {
  padding: 24px 16px;
  flex: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-tertiary);
  text-transform: uppercase;
  padding: 0 16px;
  margin: 24px 0 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 13.5px;
  color: var(--text-secondary);
  font-weight: 600;
  user-select: none;
  position: relative;
}

.nav-item .icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item .icon svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s;
}

.nav-item:hover {
  background: var(--surface3);
  color: var(--text-primary);
  transform: translateX(4px);
}

.nav-item:hover .icon svg {
  transform: scale(1.1);
}

.nav-item:active {
  transform: scale(0.97) translateX(4px);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  height: 70%;
  width: 4px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 8px var(--accent);
}

.sb-bottom {
  padding: 24px;
  border-top: 1px solid var(--border);
}

.logout-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s, transform 0.1s;
}

.logout-btn:hover {
  border-color: var(--red);
  color: var(--red);
  background: rgba(239, 68, 68, 0.06);
}

.logout-btn:active {
  transform: scale(0.97);
}

.page {
  display: none;
  padding: 48px 56px;
}

.page.active {
  display: block;
  animation: pageFadeIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}

.page-title h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-title p {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
  font-weight: 500;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff;
  border: none;
  padding: 10px 24px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px var(--accent-dim);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px var(--accent-dim);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 9px 20px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s, transform 0.1s;
}

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

.btn-ghost:active {
  transform: scale(0.97);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 8px 16px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s, transform 0.1s;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: var(--red);
}

.btn-danger:active {
  transform: scale(0.97);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.06), var(--shadow-sm);
}

html[data-theme="light"] .stat-card {
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.4), var(--shadow-sm);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.08), var(--shadow-lg);
  border-color: var(--border2);
}

html[data-theme="light"] .stat-card:hover {
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.6), var(--shadow-lg);
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: -40px;
  right: -40px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-dim) 0%, transparent 70%);
  opacity: 0.3;
  pointer-events: none;
}

.stat-card.accent::after {
  background: radial-gradient(circle, var(--accent-dim) 0%, transparent 70%);
}

.stat-card.neutral::after {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
}

.stat-card.green::after {
  background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, transparent 70%);
}

.stat-card.red::after {
  background: radial-gradient(circle, rgba(239, 68, 68, 0.08) 0%, transparent 70%);
}

.stat-content {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.stat-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.3s;
  flex-shrink: 0;
}

.stat-card.accent .stat-icon-box {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(99, 102, 241, 0.15);
}

.stat-card.green .stat-icon-box {
  color: var(--green);
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.15);
}

.stat-card.red .stat-icon-box {
  color: var(--red);
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.15);
}

.stat-svg {
  width: 22px;
  height: 22px;
}

.stat-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.stat-value.red,
.stat-value.green,
.stat-value.yellow,
.stat-value.accent {
  color: var(--text-primary);
}

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: visible;
  box-shadow: var(--shadow-sm);
  width: 100%;
  min-height: 320px;
  padding-bottom: 30px;
  transition: all 0.3s;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 800px;
}

thead tr {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 18px 24px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface3);
  box-shadow: inset 3px 0 0 var(--accent);
}

td {
  padding: 18px 24px;
  white-space: nowrap;
  vertical-align: middle;
}

.tc-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.tc-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.tc-title:hover, .tc-sub:hover {
  overflow: visible;
  white-space: normal;
  position: relative;
  z-index: 10;
  background: var(--surface);
}

.tc-amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 13.5px;
}

.tc-amount-sub {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.badge.green {
  background: rgba(16, 185, 129, 0.08);
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.15);
}

.badge.red {
  background: rgba(239, 68, 68, 0.08);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.15);
}

.badge.yellow {
  background: rgba(245, 158, 11, 0.08);
  color: var(--yellow);
  border-color: rgba(245, 158, 11, 0.15);
}

.badge.orange {
  background: rgba(249, 115, 22, 0.08);
  color: var(--orange);
  border-color: rgba(249, 115, 22, 0.2);
}

.badge.blue {
  background: rgba(99, 102, 241, 0.08);
  color: var(--accent);
  border-color: rgba(99, 102, 241, 0.15);
}

.badge.gray {
  background: rgba(100, 116, 139, 0.08);
  color: var(--text-tertiary);
  border-color: rgba(100, 116, 139, 0.15);
}

/* Drawer */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.drawer-overlay.open {
  display: block;
  animation: fadeIn 0.25s forwards;
}

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 520px;
  max-width: 100vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(10px);
}

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

.drawer-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
}

.drawer-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.drawer-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-close:hover {
  color: var(--text-primary);
  background: var(--surface3);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.drawer-footer {
  padding: 24px 32px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--surface2);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-overlay.open {
  display: flex;
  animation: fadeIn 0.2s forwards;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  opacity: 0;
  animation: modalEnter 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

@keyframes fadeIn {
  to { opacity: 1; }
}
@keyframes fadeOut {
  to { opacity: 0; }
}
@keyframes modalEnter {
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Action Menu ⋮ */
.action-cell {
  position: relative;
}

.action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  opacity: 0.75;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

tr:hover .action-btn, .rc-footer:hover .action-btn {
  opacity: 1;
}

.action-btn:hover {
  color: var(--text-primary);
  background: var(--surface3);
}

.action-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 32px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  min-width: 150px;
  white-space: nowrap;
  z-index: 100;
  padding: 6px 0;
  backdrop-filter: blur(10px);
}

.action-menu.open {
  display: block;
  animation: fadeIn 0.15s ease;
}

.action-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.action-item:hover {
  background: var(--surface3);
  color: var(--text-primary);
}

.action-item.danger:hover {
  color: var(--red);
  background: rgba(239, 68, 68, 0.05);
}

/* Toast */
#toastContainer {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 600;
  min-width: 280px;
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}

.toast.toast-enter {
  transform: translateX(0);
  opacity: 1;
}

.toast.toast-leave {
  transform: translateX(120%);
  opacity: 0;
  pointer-events: none;
}

.toast.success {
  border-left-color: var(--green);
}
.toast.error {
  border-left-color: var(--red);
}

/* Confirm Dialog */
#confirmDialog {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}

#confirmDialog.open {
  display: flex;
  animation: fadeIn 0.2s forwards;
}

.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 380px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.confirm-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

.confirm-msg {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.55;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

.form-group.span2 {
  grid-column: span 2;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.form-label .req {
  color: var(--red);
}

input, select, textarea {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  border-radius: 8px;
  outline: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--surface2);
}

input[readonly] {
  color: var(--text-secondary);
  cursor: default;
  background: var(--surface2);
  opacity: 0.85;
}

.section-divider {
  grid-column: span 2;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.section-title {
  grid-column: span 2;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 8px;
}

.payments-list {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.payment-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.add-row-btn {
  background: none;
  border: 1px dashed var(--border2);
  color: var(--text-tertiary);
  padding: 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s;
  text-align: center;
}

.add-row-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.remove-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 20px;
  padding: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-btn:hover {
  color: var(--red);
}

/* Filters Panel */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 16px;
  font-size: 13.5px;
  border-radius: 10px;
  width: 100%;
  max-width: 260px;
}

.filter-btn-wrap {
  position: relative;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: var(--text-secondary);
  background: var(--surface3);
}

.filter-btn .f-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  line-height: 1;
  font-weight: 700;
}

.filter-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 20px;
  width: 380px;
  max-width: calc(100vw - 32px);
  z-index: 400;
  backdrop-filter: blur(16px);
}

.filter-panel.open {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

.filter-group {
  margin-bottom: 16px;
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 160px;
  overflow-y: auto;
}

.ms-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}

.ms-option:hover {
  color: var(--text-primary);
}

.ms-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* MultiSelect 下拉框优化 */
.ms-wrap {
  position: relative;
  margin-bottom: 12px;
}

.ms-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ms-header:hover {
  border-color: var(--accent);
}
.ms-header.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.ms-header .arrow {
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--text-tertiary);
}

.ms-header.active .arrow {
  transform: rotate(180deg);
}

.ms-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  max-height: 380px;
  overflow: hidden;
  z-index: 150;
  padding: 4px 0;
  flex-direction: column;
  backdrop-filter: blur(12px);
}

.ms-wrap.open .ms-menu {
  display: flex;
  animation: fadeIn 0.15s ease-out;
}

.ms-search-wrap {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.ms-search-input {
  width: 100%;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
}

.ms-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.ms-options-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ms-option {
  padding: 8px 10px;
  border-radius: 6px;
  transition: all 0.2s;
}

.ms-option:hover {
  background: var(--surface3);
}

/* Alerts */
.alert-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.alert-item {
  background: var(--accent-dim);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
}

.alert-item:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.alert-item.lawyer {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.05);
}
.alert-item.lawyer:hover {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.12);
}

.alert-item-left,
.alert-item-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.alert-item-right {
  align-items: flex-end;
  text-align: right;
}

.alert-item-tenant,
.alert-item-amount {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.alert-item-project,
.alert-item-due,
.alert-item-label,
.alert-item-date {
  font-size: 12.5px;
  font-weight: 500;
}

.alert-item-project {
  color: var(--text-tertiary);
}

.alert-item-label {
  font-weight: 600;
}

.alert-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  margin: 24px 0 12px 0;
  text-transform: uppercase;
}

/* OCR & Contract */
.ocr-drop-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  background: rgba(38, 43, 56, 0.3);
}

.ocr-drop-zone:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.ocr-drop-zone .dz-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.7;
}

.batch-table {
  width: 100%;
  font-size: 13px;
}

.batch-table th, .batch-table td {
  padding: 10px 12px;
}

/* Empty State */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.empty .icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.4;
}

/* AI Dashboard */
.ai-analysis-wrap {
  margin-bottom: 32px;
}

.ai-analysis-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  position: relative;
  transition: all 0.3s;
}

.ai-card-content {
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.7;
}
.ai-card-content p {
  margin-bottom: 14px;
}
.ai-card-content p:last-child {
  margin-bottom: 0;
}
.ai-card-content ul,
.ai-card-content ol {
  margin-bottom: 14px;
  padding-left: 18px;
}
.ai-card-content ul {
  list-style-type: disc;
}
.ai-card-content ol {
  list-style-type: decimal;
}
.ai-card-content li {
  margin-bottom: 8px;
  position: relative;
}
.ai-card-content strong {
  color: var(--text-primary);
  font-weight: 600;
}
.ai-card-content h1,
.ai-card-content h2,
.ai-card-content h3,
.ai-card-content h4 {
  color: var(--text-primary);
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 10px;
}
.ai-card-content h1 { font-size: 1.35em; }
.ai-card-content h2 { font-size: 1.2em; }
.ai-card-content h3 { font-size: 1.1em; }
.ai-card-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  background: rgba(0,0,0,0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.ai-analysis-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--radius) + 1px);
  background: linear-gradient(135deg, var(--accent), #a855f7, var(--accent2));
  z-index: -1;
  opacity: 0.12;
  transition: opacity 0.3s;
  animation: borderGlowPulse 4s infinite linear;
}

@keyframes borderGlowPulse {
  0%, 100% { opacity: 0.1; }
  50% { opacity: 0.25; }
}

.ai-analysis-card:hover::before {
  opacity: 0.35;
}

.ai-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.ai-icon {
  color: var(--accent);
  font-size: 18px;
  animation: aiPulse 2s infinite ease-in-out;
}

@keyframes aiPulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; filter: drop-shadow(0 0 4px var(--accent)); }
}

.ai-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #ffffff 40%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.ai-refresh-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  margin-left: auto;
  font-size: 16px;
  transition: transform 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.ai-refresh-btn:hover {
  color: var(--accent);
  background: var(--surface3);
  transform: rotate(180deg);
}

/* Calendar */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.cal-weekdays div {
  padding: 14px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(140px, auto);
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  gap: 1px;
  overflow: hidden;
}

.cal-day {
  background: var(--surface);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  transition: background 0.2s;
}

.cal-day.other-month {
  background: rgba(30, 34, 45, 0.4);
  opacity: 0.45;
}

.cal-day.today {
  background: var(--accent-dim);
}

.cal-day.today .cal-date-num {
  color: var(--accent);
  font-weight: 700;
  position: relative;
}

.cal-day.today .cal-date-num::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.cal-events {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
}

.cal-events::-webkit-scrollbar {
  width: 4px;
}
.cal-events::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 4px;
}
.cal-events::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

.cal-event {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 2.5px solid transparent;
  transition: all 0.2s;
}

.cal-event:hover {
  opacity: 0.85;
  transform: translateX(2px);
}

.cal-event.rent-paid {
  background: rgba(16, 185, 129, 0.08);
  color: var(--green);
  border-left-color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.cal-event.rent-unpaid, .cal-event.demand {
  background: rgba(245, 158, 11, 0.08);
  color: var(--yellow);
  border-left-color: var(--yellow);
  border: 1px solid rgba(245, 158, 11, 0.15);
}

.cal-event.rent-overdue, .cal-event.lawyer {
  background: rgba(239, 68, 68, 0.08);
  color: var(--red);
  border-left-color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.cal-event.rent-future {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.15);
}

.cal-date-num {
  align-self: flex-end;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Section Labels */
.section-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 28px 0 8px 0;
  padding-bottom: 8px;
}

/* Utility */
.hide {
  display: none !important;
}
.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
}

/* Overlay background (mobile sidebar) */
.overlay-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 190;
  backdrop-filter: blur(4px);
}
.sidebar.open ~ .overlay-bg, .overlay-bg.show {
  display: block;
}

/* Settings Page */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}

.settings-section-header {
  font-size: 14px;
  font-weight: 700;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-row-label strong {
  font-size: 14px;
  font-weight: 600;
}

.settings-row-label span {
  font-size: 12px;
  color: var(--text-tertiary);
}

.theme-options {
  display: flex;
  gap: 12px;
}

.theme-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.theme-opt.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.t-preview {
  width: 48px;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.t-preview-dark {
  width: 100%;
  height: 100%;
  background: #090a0f;
}
.t-preview-light {
  width: 100%;
  height: 100%;
  background: #f8f9fb;
}
.t-preview-system {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #090a0f 50%, #f8f9fb 50%);
}

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

/* Color Accent Switcher */
.theme-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 600px;
}

.color-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.color-opt:hover {
  background: var(--surface2);
}

.color-opt.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.c-preview {
  width: 48px;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}

.color-opt.selected .c-preview::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  font-size: 14px;
  font-weight: bold;
}

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

/* Emerald-Teal */
html[data-accent="emerald"] {
  --accent: #3fa788;
  --accent-hover: #338d72;
  --accent-dim: rgba(63, 167, 136, 0.12);
  --accent-glow: rgba(63, 167, 136, 0.25);
  --accent2: #3fa79b;
  --accent2-dim: rgba(63, 167, 155, 0.12);
}
html[data-theme="light"][data-accent="emerald"] {
  --accent: #338d72;
  --accent-hover: #3fa788;
  --accent-dim: rgba(51, 141, 114, 0.1);
  --accent-glow: rgba(51, 141, 114, 0.2);
  --accent2: #338c82;
  --accent2-dim: rgba(51, 140, 130, 0.1);
}
@media(prefers-color-scheme:light) {
  html[data-theme="system"][data-accent="emerald"] {
    --accent: #338d72;
    --accent-hover: #3fa788;
    --accent-dim: rgba(51, 141, 114, 0.1);
    --accent-glow: rgba(51, 141, 114, 0.2);
    --accent2: #338c82;
    --accent2-dim: rgba(51, 140, 130, 0.1);
  }
}

/* Rose-Pink */
html[data-accent="rose"] {
  --accent: #eba0b8;
  --accent-hover: #e68aa7;
  --accent-dim: rgba(235, 160, 184, 0.12);
  --accent-glow: rgba(235, 160, 184, 0.25);
  --accent2: #f0a8b1;
  --accent2-dim: rgba(240, 168, 177, 0.12);
}
html[data-theme="light"][data-accent="rose"] {
  --accent: #cc6683;
  --accent-hover: #d57c96;
  --accent-dim: rgba(204, 102, 131, 0.1);
  --accent-glow: rgba(204, 102, 131, 0.2);
  --accent2: #cc6f91;
  --accent2-dim: rgba(204, 111, 145, 0.1);
}
@media(prefers-color-scheme:light) {
  html[data-theme="system"][data-accent="rose"] {
    --accent: #cc6683;
    --accent-hover: #d57c96;
    --accent-dim: rgba(204, 102, 131, 0.1);
    --accent-glow: rgba(204, 102, 131, 0.2);
    --accent2: #cc6f91;
    --accent2-dim: rgba(204, 111, 145, 0.1);
  }
}

/* Violet-Amber */
html[data-accent="violet"] {
  --accent: #9e82f2;
  --accent-hover: #8462eb;
  --accent-dim: rgba(158, 130, 242, 0.12);
  --accent-glow: rgba(158, 130, 242, 0.25);
  --accent2: #dba340;
  --accent2-dim: rgba(219, 163, 64, 0.12);
}
html[data-theme="light"][data-accent="violet"] {
  --accent: #8462eb;
  --accent-hover: #9e82f2;
  --accent-dim: rgba(132, 98, 235, 0.1);
  --accent-glow: rgba(132, 98, 235, 0.2);
  --accent2: #b6802c;
  --accent2-dim: rgba(182, 128, 44, 0.1);
}
@media(prefers-color-scheme:light) {
  html[data-theme="system"][data-accent="violet"] {
    --accent: #8462eb;
    --accent-hover: #9e82f2;
    --accent-dim: rgba(132, 98, 235, 0.1);
    --accent-glow: rgba(132, 98, 235, 0.2);
    --accent2: #b6802c;
    --accent2-dim: rgba(182, 128, 44, 0.1);
  }
}

/* Amber-Orange */
html[data-accent="amber"] {
  --accent: #dba340;
  --accent-hover: #b9842a;
  --accent-dim: rgba(219, 163, 64, 0.12);
  --accent-glow: rgba(219, 163, 64, 0.25);
  --accent2: #e27a42;
  --accent2-dim: rgba(226, 122, 66, 0.12);
}
html[data-theme="light"][data-accent="amber"] {
  --accent: #b9842a;
  --accent-hover: #dba340;
  --accent-dim: rgba(185, 132, 42, 0.1);
  --accent-glow: rgba(185, 132, 42, 0.2);
  --accent2: #be5e26;
  --accent2-dim: rgba(190, 94, 38, 0.1);
}
@media(prefers-color-scheme:light) {
  html[data-theme="system"][data-accent="amber"] {
    --accent: #b9842a;
    --accent-hover: #dba340;
    --accent-dim: rgba(185, 132, 42, 0.1);
    --accent-glow: rgba(185, 132, 42, 0.2);
    --accent2: #be5e26;
    --accent2-dim: rgba(190, 94, 38, 0.1);
  }
}

/* Blue-Sky */
html[data-accent="blue"] {
  --accent: #739cee;
  --accent-hover: #5484eb;
  --accent-dim: rgba(115, 156, 238, 0.12);
  --accent-glow: rgba(115, 156, 238, 0.25);
  --accent2: #4caacb;
  --accent2-dim: rgba(76, 170, 203, 0.12);
}
html[data-theme="light"][data-accent="blue"] {
  --accent: #5484eb;
  --accent-hover: #739cee;
  --accent-dim: rgba(84, 132, 235, 0.1);
  --accent-glow: rgba(84, 132, 235, 0.2);
  --accent2: #3389a9;
  --accent2-dim: rgba(51, 137, 169, 0.1);
}
@media(prefers-color-scheme:light) {
  html[data-theme="system"][data-accent="blue"] {
    --accent: #5484eb;
    --accent-hover: #739cee;
    --accent-dim: rgba(84, 132, 235, 0.1);
    --accent-glow: rgba(84, 132, 235, 0.2);
    --accent2: #3389a9;
    --accent2-dim: rgba(51, 137, 169, 0.1);
  }
}

/* Batch */
.batch-notice {
  font-size: 13.5px;
  color: var(--text-secondary);
  background: var(--surface2);
  padding: 14px 16px;
  border-radius: 10px;
  margin-bottom: 20px;
  line-height: 1.6;
}

.batch-setup {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.batch-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.batch-count-badge {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.period-tag {
  font-size: 12px;
  font-weight: 600;
}

/* Letter Modal */
.letter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.letter-box,
#letterContent,
#paymentNoticeContent,
#letterBreachContent,
#c_breachClause,
#b_clauseText {
  font-family: 'Noto Serif SC', 'Songti SC', SimSun, serif;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  font-size: 14px;
  line-height: 1.85;
  margin-bottom: 16px;
  white-space: pre-wrap;
  letter-spacing: 0.02em;
}

.copy-btn {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.copy-btn.copied {
  border-color: var(--green);
  color: var(--green);
  background: rgba(16, 185, 129, 0.08);
}

.letter-tag-lawyer {
  background: rgba(239, 68, 68, 0.08);
  color: var(--red);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

/* Demand Table */
.demand-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

/* Contract Parsing */
.contract-result-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.result-section h4 {
  font-size: 14.5px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.pdf-thumbnails-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.pdf-thumb-wrapper {
  position: relative;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.pdf-thumb-wrapper.selected {
  border-color: var(--accent);
}

.pdf-thumb-wrapper canvas {
  width: 100%;
  display: block;
}

.pdf-page-num {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

.pdf-selection-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  display: none;
}

.pdf-thumb-wrapper.selected .pdf-selection-badge {
  display: block;
}

/* Loading Spinner */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinRing 0.8s linear infinite;
  margin: 0 auto;
}

/* AI Skeleton */
.ai-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-line {
  height: 12px;
  background: var(--surface3);
  border-radius: 6px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-line.short {
  width: 60%;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Chat Panel */
.chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff;
  border: none;
  font-size: 28px;
  cursor: pointer;
  z-index: 500;
  box-shadow: 0 4px 16px var(--accent-glow);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.chat-bubble:active {
  transform: scale(0.95);
}

.chat-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--red);
  display: none;
}

.chat-dot.show {
  display: block;
}

.chat-panel {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 480px;
  height: 600px;
  max-height: calc(90vh - 120px);
  max-width: 90vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 500;
  overflow: hidden;
  transition: opacity 0.25s, transform 0.25s, width 0.3s, height 0.3s, max-height 0.3s;
  transform-origin: bottom right;
  backdrop-filter: blur(16px);
}

.chat-panel.hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  display: flex !important;
}

.chat-panel.expanded {
  width: 760px;
  height: 720px;
  max-height: calc(95vh - 120px);
  max-width: 95vw;
}

.chat-panel.expanded .chat-messages {
  max-height: none;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.chat-panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-panel-header h4 {
  font-size: 14px;
  font-weight: 700;
}

.chat-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.chat-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.2s;
}

.chat-close:hover {
  background: var(--surface3);
  color: var(--text-primary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: none;
}

.chat-msg {
  display: flex;
  gap: 10px;
}

.chat-msg.user {
  flex-direction: row-reverse;
}

.chat-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  font-weight: 600;
}

.chat-msg-body {
  max-width: 80%;
}

.chat-msg-text {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg.ai .chat-msg-text {
  background: var(--surface2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  white-space: normal; /* Let browser handle flow of parsed HTML */
}

/* Nested Markdown Overrides inside AI Responses */
.chat-msg.ai .chat-msg-text p {
  margin: 6px 0;
}
.chat-msg.ai .chat-msg-text p:first-child {
  margin-top: 0;
}
.chat-msg.ai .chat-msg-text p:last-child {
  margin-bottom: 0;
}
.chat-msg.ai .chat-msg-text ul,
.chat-msg.ai .chat-msg-text ol {
  margin: 8px 0;
  padding-left: 20px;
}
.chat-msg.ai .chat-msg-text ul {
  list-style-type: disc;
}
.chat-msg.ai .chat-msg-text ol {
  list-style-type: decimal;
}
.chat-msg.ai .chat-msg-text li {
  margin-bottom: 4px;
}
.chat-msg.ai .chat-msg-text h1,
.chat-msg.ai .chat-msg-text h2,
.chat-msg.ai .chat-msg-text h3,
.chat-msg.ai .chat-msg-text h4 {
  margin: 12px 0 6px 0;
  font-weight: 600;
  line-height: 1.3;
}
.chat-msg.ai .chat-msg-text h1 { font-size: 1.4em; }
.chat-msg.ai .chat-msg-text h2 { font-size: 1.25em; }
.chat-msg.ai .chat-msg-text h3 { font-size: 1.15em; }
.chat-msg.ai .chat-msg-text h4 { font-size: 1.05em; }
.chat-msg.ai .chat-msg-text pre {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 10px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
}
.chat-msg.ai .chat-msg-text code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 4px;
  border-radius: 4px;
}
.chat-msg.ai .chat-msg-text pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
}
.chat-msg.ai .chat-msg-text table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 12px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.chat-msg.ai .chat-msg-text th,
.chat-msg.ai .chat-msg-text td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.chat-msg.ai .chat-msg-text th {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-weight: 600;
}
.chat-msg.ai .chat-msg-text tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.02);
}
.chat-msg.ai .chat-msg-text tr:hover {
  background-color: rgba(255, 255, 255, 0.04);
}
.chat-msg.ai .chat-msg-text blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Thought block styling */
.chat-thought {
  border-left: 3px solid var(--border2);
  background: var(--surface2);
  margin-bottom: 12px;
  border-radius: 12px;
  overflow: hidden;
  font-size: 13px;
}
.chat-thought summary {
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
  outline: none;
}
.chat-thought summary::-webkit-details-marker {
  display: none;
}
.chat-thought summary::after {
  content: '▼';
  font-size: 8px;
  margin-left: auto;
  transition: transform 0.2s ease;
  color: var(--text-tertiary);
}
.chat-thought[open] summary::after {
  transform: rotate(180deg);
}
.chat-thought .thought-content {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.05);
}
.chat-thought .thought-content p {
  margin: 6px 0;
}
.chat-thought .thought-content p:first-child {
  margin-top: 0;
}
.chat-thought .thought-content p:last-child {
  margin-bottom: 0;
}

.chat-msg.user .chat-msg-text {
  background: var(--accent);
  color: #fff;
  white-space: pre-wrap; /* Keep raw line breaks for user messages */
}

.chat-msg-time {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
  font-weight: 500;
}

.chat-msg.user .chat-msg-time {
  text-align: right;
}

.chat-error {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  background: rgba(239, 68, 68, 0.08);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  resize: none;
  outline: none;
  font-family: inherit;
}

.chat-send {
  background: var(--accent);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-send:hover {
  background: var(--accent-hover);
}

.chat-mic {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-mic:hover {
  border-color: var(--accent);
}

.chat-mic.recording {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--red);
  color: var(--red);
  animation: recording-pulse 1.2s ease-in-out infinite;
}

.chat-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typing-bounce 1.4s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

/* Full-Screen Chat */
.fs-chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 180px);
}

.fs-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fs-chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.fs-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.fs-chat-input {
  flex: 1;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-primary);
  resize: none;
  outline: none;
  font-family: inherit;
}

.fs-chat-send {
  background: var(--accent);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fs-chat-mic {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fs-chat-tip {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 8px;
  text-align: center;
  font-weight: 500;
}

/* Loading Keyframes */
@keyframes spinRing { to { transform: rotate(360deg); } }
@keyframes pulseDot {
  0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(0.8); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
}
@keyframes dotFade { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
@keyframes recording-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* Mobile Rules */
.menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 210;
  display: none;
}

.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 300;
  padding: 8px 0 env(safe-area-inset-bottom);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.fab {
  display: none;
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff;
  border: none;
  font-size: 24px;
  cursor: pointer;
  z-index: 300;
  box-shadow: 0 4px 16px var(--accent-glow);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab:hover {
  transform: scale(1.1);
  background: var(--accent-hover);
  box-shadow: 0 8px 24px var(--accent-glow);
}
.fab:active {
  transform: scale(0.95);
}

.record-cards {
  display: none;
}

/* Dashboard Body Layout */
.dashboard-body-layout {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 28px;
  align-items: start;
}

.dashboard-main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dashboard-side-col {
  display: flex;
  flex-direction: column;
}

/* Visual Widgets styling */
.visual-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.visual-card:hover {
  border-color: var(--border2);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.v-card-header {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.02em;
}

.v-card-icon {
  color: var(--accent);
  display: flex;
  align-items: center;
}

.progress-ring-container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  margin-bottom: 24px;
}

.progress-ring-circle-bg {
  stroke: var(--border2);
}

.progress-ring-circle {
  transition: stroke-dashoffset 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  transform: rotate(-90deg);
  transform-origin: 65px 65px;
}

.progress-ring-text {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.progress-percent {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.progress-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 600;
  margin-top: 2px;
}

.progress-details {
  display: flex;
  justify-content: space-around;
  gap: 16px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.p-detail-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.p-detail-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.p-detail-item .dot.green {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.p-detail-item .dot.red {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}

.p-detail-info {
  display: flex;
  flex-direction: column;
}

.p-detail-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.p-detail-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}

/* Horizontal bar chart style */
.chart-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.chart-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
}

.chart-project-name {
  color: var(--text-secondary);
  font-weight: 600;
}

.chart-project-amounts {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-tertiary);
  font-size: 11.5px;
}

.chart-progress-bar-bg {
  height: 6px;
  background: var(--surface3);
  border-radius: 3px;
  overflow: hidden;
}

.chart-progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Report Export Modal Grid Styles */
.export-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
  margin-bottom: 20px;
}

.export-col-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--border);
  padding-right: 20px;
}

.export-col-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media(max-width:1100px) {
  .dashboard-body-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media(max-width:768px) {
  .shell {
    display: block;
  }
  .sidebar {
    position: fixed;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .page {
    padding: 24px 20px;
    padding-top: 64px;
    padding-bottom: 80px;
  }
  .menu-btn {
    display: flex;
  }
  .mobile-nav {
    display: flex;
    justify-content: space-around;
  }
  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .drawer {
    width: 100%;
  }
  .table-wrap.desktop-only {
    display: none !important;
  }
  .record-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .record-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
  }
  .rc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
  }
  .rc-tenant {
    font-size: 15px;
    font-weight: 700;
  }
  .rc-project {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-top: 2px;
    font-weight: 500;
  }
  .rc-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .rc-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .rc-label {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 600;
  }
  .rc-value {
    font-size: 13px;
    font-weight: 600;
  }
  .rc-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  .floating-batch-bar {
    bottom: calc(72px + env(safe-area-inset-bottom, 12px));
    width: calc(100vw - 32px);
    max-width: 480px;
    padding: 8px 14px;
    gap: 8px;
    justify-content: space-between;
    z-index: 999;
  }
  .console-workspace-layout {
    flex-direction: column;
    height: auto;
    min-height: 0;
  }
  .console-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 220px;
  }
  .chat-bubble {
    bottom: 150px;
  }
  .chat-panel {
    bottom: 222px;
    right: 12px;
    width: calc(100vw - 24px);
  }
  .page-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
  }
  .export-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .export-col-left {
    border-right: none;
    padding-right: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
  }
  .calendar-grid {
    grid-auto-rows: minmax(70px, auto);
  }
  .cal-weekdays div {
    padding: 8px 4px;
    font-size: 10px;
  }
  .cal-day {
    padding: 4px;
  }
  .cal-date-num {
    font-size: 11px;
  }
  .cal-event {
    font-size: 9px;
    padding: 2px 4px;
  }
  .m-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px 8px;
    transition: all 0.2s;
    font-weight: 600;
  }
  .m-nav-item.active {
    color: var(--accent);
  }
  .m-icon {
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .m-icon svg {
    width: 20px;
    height: 20px;
  }
  .filter-panel {
    left: auto;
    right: 0;
  }
  input, select, textarea {
    font-size: 16px;
  }
}

/* Batch Modal Tabs */
.batch-tabs .tab-btn:hover {
  background: rgba(148, 163, 184, 0.1) !important;
  color: var(--text-primary) !important;
}
.batch-tabs .tab-btn.active:hover {
  background: var(--accent) !important;
  color: #ffffff !important;
}
#b_clauseText:focus {
  border-color: var(--accent) !important;
}

/* Breach Clause Text in Contract Table */
.breach-clause-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-all;
  line-height: 1.5;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 4px 6px;
  border-radius: 6px;
}

.breach-clause-text:hover {
  background: var(--surface2);
  color: var(--text-primary);
}

.breach-clause-text.expanded {
  display: block;
  overflow: visible;
  text-overflow: clip;
  max-height: none;
  background: var(--surface2);
  color: var(--text-primary);
  padding: 8px;
  border: 1px dashed var(--border);
  box-shadow: var(--shadow-sm);
}

/* Knowledge Base Styles & Layout Fixes */
#page-settings .settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: block;
  clear: both;
  width: 100%;
}

#page-settings .settings-section-header {
  font-size: 15px;
  font-weight: 700;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

#page-settings .settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}

#page-settings .settings-row:last-child {
  border-bottom: none;
}

#page-settings .settings-row-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 200px;
}

#page-settings .settings-row-label strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

#page-settings .settings-row-label span {
  font-size: 12px;
  color: var(--text-tertiary);
}

.theme-options, .theme-colors {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.theme-opt, .color-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  transition: all 0.2s ease;
}

.theme-opt:hover, .color-opt:hover {
  background: var(--surface2);
}

.theme-opt.selected, .color-opt.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.kb-search-box {
  padding: 16px 20px 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.kb-search-input {
  width: 100%;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  background: var(--surface3);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.kb-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.kb-accordion {
  display: flex;
  flex-direction: column;
}

.kb-item {
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s ease;
}

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

.kb-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 18px 20px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.2s ease;
}

.kb-trigger:hover {
  background: var(--surface2);
}

.kb-trigger-icon {
  margin-right: 12px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kb-trigger-title {
  flex: 1;
}

.kb-trigger-arrow {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-left: 8px;
}

.kb-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .kb-content {
  background: rgba(0, 0, 0, 0.015);
}

.kb-content-inner {
  padding: 18px 20px 24px 20px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  border-top: 1px dashed var(--border);
}

.kb-content-inner p {
  margin: 0 0 12px 0;
}

.kb-content-inner strong {
  color: var(--text-primary);
}

.kb-bullet-list, .kb-numbered-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kb-bullet-list li, .kb-numbered-list li {
  margin-bottom: 4px;
}

.kb-code-block {
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  overflow-x: auto;
}

.kb-code-block pre {
  margin: 0;
}

.kb-code-block code {
  font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
  font-size: 12px;
  color: var(--text-primary);
}

/* Import/Export Console Premium Styles */
.console-sidebar {
  width: 240px;
  border-right: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 16px 8px;
  gap: 4px;
}

.console-sidebar-header {
  padding: 12px 14px 6px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.console-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  margin-bottom: 2px;
}

.console-nav-icon {
  font-size: 14px;
  opacity: 0.8;
  transition: transform 0.2s ease;
}

.console-nav-btn:hover {
  background: var(--surface3);
  color: var(--text-primary);
  transform: translateX(4px);
}

.console-nav-btn:hover .console-nav-icon {
  transform: scale(1.15);
}

.console-nav-btn.active {
  background: var(--accent-dim) !important;
  color: var(--accent) !important;
  font-weight: 600;
}

.console-nav-btn.active .console-nav-icon {
  opacity: 1;
}

/* Month Selector Premium Accordion & Grid Styles */
.month-menu {
  width: 290px !important;
  max-height: 450px !important;
  overflow-y: auto !important;
  padding: 8px !important;
}

.month-quick-bar {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.quick-chip {
  background: var(--surface3);
  border: 1px solid var(--border2);
  color: var(--text-secondary);
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quick-chip:hover {
  background: var(--border2);
  color: var(--text-primary);
  border-color: var(--accent);
}

.year-accordion-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
  margin-top: 2px;
}

.year-accordion-row:hover {
  background: var(--surface3);
}

.year-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.year-checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.year-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.year-count-badge {
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 500;
}

.year-arrow {
  font-size: 10px;
  color: var(--text-tertiary);
  transition: transform 0.2s ease;
}

.year-block.open .year-arrow {
  transform: rotate(90deg);
}

.month-capsule-grid {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 6px 4px 10px 4px;
  border-bottom: 1px dashed var(--border);
}

.year-block.open .month-capsule-grid {
  display: grid;
}

.month-capsule {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.month-capsule:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--surface2);
}

.month-capsule.active {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* No data months: visual distinction, but remains clickable */
.month-capsule.no-data {
  color: var(--text-tertiary);
  opacity: 0.65;
  background: repeating-linear-gradient(
    45deg,
    var(--surface3),
    var(--surface3) 4px,
    var(--surface2) 4px,
    var(--surface2) 8px
  ) !important;
  border-style: dashed;
}

.month-capsule.no-data:hover {
  opacity: 0.95;
  border-color: var(--accent);
  color: var(--text-secondary);
}

/* Console Excel Preview Table Custom Horizontal Scrolling */
#consolePreviewTable {
  table-layout: auto !important;
}

#consolePreviewTable th,
#consolePreviewTable td {
  white-space: nowrap !important;
}

/* ==========================================================================
   UI/UX Enhanced System Styles
   ========================================================================== */

/* 1. Sortable Headers */
th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}
th.sortable:hover {
  background: var(--surface3) !important;
}
.sort-icon {
  font-size: 11px;
  opacity: 0.35;
  margin-left: 4px;
  display: inline-block;
  transition: transform 0.2s, opacity 0.2s, color 0.2s;
}
th.sortable:hover .sort-icon {
  opacity: 0.8;
}
th.sortable.active .sort-icon {
  opacity: 1;
  color: var(--accent);
}

/* 2. Floating Batch Action Bar */
.floating-batch-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface2);
  border: 1px solid var(--accent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4), 0 0 16px var(--accent-dim);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 99px;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 500;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  opacity: 0;
  pointer-events: none;
}
.floating-batch-bar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.fbb-info {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.fbb-count strong {
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
}
.fbb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row-chk, .chk-all {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}

/* 3. Sticky Headers & First Column Pinning */
.table-wrap {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
}
.table-wrap table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--border2);
}
.table-wrap table td:first-child,
.table-wrap table th:first-child {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--surface);
  box-shadow: 3px 0 10px rgba(0, 0, 0, 0.12);
}
.table-wrap table th:first-child {
  z-index: 15;
  background: var(--surface2);
}
html[data-theme="light"] .table-wrap table td:first-child {
  background: #ffffff;
}

/* 4. Illustrated Empty States */
.empty-state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  width: 100%;
}
.empty-state-illustration {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.empty-state-desc {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 20px;
  max-width: 360px;
  line-height: 1.5;
}

/* 5. Active Filter Chips */
.active-chips-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  margin-bottom: 4px;
}
.chip-tag {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(126, 129, 234, 0.25);
  border-radius: 6px;
  padding: 3px 8px 3px 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.chip-tag button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
  opacity: 0.7;
}
.chip-tag button:hover {
  opacity: 1;
}
.chip-clear-all {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  margin-left: 4px;
  transition: color 0.2s;
}
.chip-clear-all:hover {
  color: var(--red);
}

/* 6. Console Navigation Wizard & Accordion */
.console-group {
  margin-bottom: 12px;
}
.console-group-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  text-transform: uppercase;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  transition: background 0.2s;
}
.console-group-title:hover {
  background: var(--surface2);
  color: var(--text-secondary);
}
.cg-arrow {
  font-size: 9px;
  transition: transform 0.2s ease;
}
.console-group.collapsed .cg-arrow {
  transform: rotate(-90deg);
}
.console-group.collapsed .console-group-items {
  display: none;
}
.console-breadcrumb {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.console-breadcrumb .cb-active {
  color: var(--accent);
  font-weight: 600;
}

/* 7. Quick Suggestion Chips */
.quick-prompts-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 16px;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.quick-prompts-bar::-webkit-scrollbar {
  display: none;
}
.prompt-chip-btn {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}
.prompt-chip-btn:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* 8. Mobile Swipe Actions */
.record-card-swipe-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.card-swipe-actions {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  background: var(--surface2);
  z-index: 1;
}
.card-swipe-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}
.card-swipe-btn.settle { background: var(--green); }
.card-swipe-btn.notice { background: var(--accent); }
.card-inner-slide {
  position: relative;
  z-index: 2;
  background: var(--surface);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 9. Timeline Agenda View for Mobile Calendar */
.calendar-agenda-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 0;
}
.agenda-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  position: relative;
}
.agenda-date {
  width: 60px;
  text-align: right;
  flex-shrink: 0;
}
.a-day {
  font-size: 15px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  display: block;
  color: var(--text-primary);
}
.a-week {
  font-size: 10px;
  color: var(--text-tertiary);
}
.agenda-node-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding-top: 4px;
}
.agenda-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-tertiary);
  z-index: 2;
}
.agenda-dot.red { background: var(--red); box-shadow: 0 0 8px var(--red); }
.agenda-dot.yellow { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.agenda-dot.green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.agenda-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}
.agenda-card:hover {
  border-color: var(--accent);
  transform: translateX(4px);
}
.ac-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.ac-header strong {
  font-size: 13.5px;
  color: var(--text-primary);
}
.ac-amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--accent);
}
.ac-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* 10. Tabular Numerics for Financial & Quantitative Data */
.stats-val,
.p-detail-val,
td,
.rc-value,
.cal-date-num,
.progress-percent,
#cdTotalAmount,
#cdTotalPaid,
#cdTotalOwed,
.kpi-num,
.stat-value,
.amount-val,
.ac-amount,
.stats-card-val,
.tbl-amount {
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-feature-settings: "tnum" 1, "lnum" 1;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* 11. Console (Data Center) Workspace Layout */
.console-workspace-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 120px);
  min-height: 580px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.console-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 24px;
  background: var(--surface);
}

/* 12. Settings & Guidelines Segmented Navigation */
.settings-segmented-nav {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: fit-content;
  margin-bottom: 24px;
}

.seg-nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.seg-nav-btn:hover {
  color: var(--text-primary);
  background: var(--surface3);
}

.seg-nav-btn.active {
  color: var(--text-primary);
  background: var(--surface);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.settings-tab-pane {
  display: none;
}

.settings-tab-pane.active {
  display: block;
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 13. Clean SVG Icon Utilities */
.sec-label-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  vertical-align: -2px;
}

.btn-svg-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  vertical-align: -2px;
}

/* 14. Draft Auto-Recovery & Unsaved Changes Guard */
.draft-recovery-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: 0 4px 18px var(--accent-dim);
  animation: slideDownFade 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

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

.drb-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  flex-shrink: 0;
}

.drb-icon {
  width: 18px;
  height: 18px;
}

.drb-content {
  flex: 1;
  min-width: 0;
}

.drb-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.drb-time {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  opacity: 0.95;
}

.drb-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.drb-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: calc(var(--radius) - 6px);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.drb-btn.primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}

.drb-btn.primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 12px var(--accent-glow);
}

.drb-btn.ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border2);
}

.drb-btn.ghost:hover {
  color: var(--text-primary);
  background: var(--surface3);
  border-color: var(--border);
}

#unsavedDialog.open {
  display: flex;
  animation: fadeIn 0.2s forwards;
}

@media (max-width: 600px) {
  .draft-recovery-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .drb-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ======== Dashboard Interactive Drill-Down Styles ======== */
.section-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-label-row .section-label {
  margin-bottom: 0;
}

.sec-drill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 3px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sec-drill-btn:hover {
  background: var(--accent);
  color: #fff;
  transform: translateX(2px);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.stat-card.clickable {
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-card.clickable:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md), 0 0 12px var(--accent-glow);
}

.stat-drill-hint {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 10px;
  color: var(--accent);
  opacity: 0;
  transform: translateX(-4px);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 2px;
}

.stat-card.clickable:hover .stat-drill-hint {
  opacity: 0.9;
  transform: translateX(0);
}

.chart-item.clickable {
  cursor: pointer;
  padding: 8px 6px;
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.chart-item.clickable:hover {
  background: var(--surface2);
  transform: translateX(2px);
}

.chart-drill-tag {
  font-size: 10.5px;
  color: var(--accent);
  margin-left: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.chart-item.clickable:hover .chart-drill-tag {
  opacity: 1;
}

.p-detail-item.clickable {
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.p-detail-item.clickable:hover {
  background: var(--surface2);
  transform: translateX(2px);
}

/* ======== Mobile More Action Bottom Sheet ======== */
.mobile-more-sheet {
  position: fixed;
  bottom: -100%;
  left: 0;
  right: 0;
  background: var(--surface-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 12px 16px 36px 16px;
  z-index: 1000;
  transition: bottom 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
}

.drawer-overlay#mobileMoreSheet.open {
  display: block;
  animation: fadeIn 0.2s forwards;
}

.drawer-overlay#mobileMoreSheet.open .mobile-more-sheet {
  bottom: 0;
}

.m-sheet-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 16px;
  cursor: pointer;
}

.m-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border2);
  margin-bottom: 10px;
}

.m-sheet-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.m-sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.m-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  user-select: none;
}

.m-sheet-item:active {
  transform: scale(0.95);
  background: var(--surface3);
}

.m-sheet-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.m-sheet-icon svg {
  width: 20px;
  height: 20px;
}

.m-sheet-item.danger .m-sheet-icon {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
}

.m-sheet-item.danger:hover {
  border-color: var(--red);
}

/* Fix for orphan batch import button and stray elements appearing at page bottom */
body > #conExcelSubmitBtn,
body > #saveCdLinkBtn,
body > table.batch-table,
body > .batch-tabs {
  display: none !important;
}

#conExcelSubmitBtn {
  display: none;
}

#contractEditModal.open #conFormBatch #conExcelPreviewArea #conExcelSubmitBtn,
#conExcelPreviewArea #conExcelSubmitBtn {
  display: block;
}
