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

:root {
  --sidebar-width: 260px;
  --header-height: 70px;
  --font-family: 'Outfit', 'Noto Serif TC', system-ui, -apple-system, sans-serif;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Default Theme or Dark Theme */
html, html[data-theme="dark"] {
  --bg-main: #0b0f19;
  --bg-sidebar: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.45);
  --bg-card-hover: rgba(30, 41, 59, 0.65);
  
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-glow: rgba(139, 92, 246, 0.25);
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --success-glow: rgba(16, 185, 129, 0.25);
  
  --danger: #f43f5e;
  --danger-bg: rgba(244, 63, 94, 0.1);
  --danger-glow: rgba(244, 63, 94, 0.25);
  
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-active: rgba(139, 92, 246, 0.4);
  
  --input-bg: rgba(15, 23, 42, 0.6);
  --input-focus-bg: rgba(15, 23, 42, 0.8);
  --overlay-bg: rgba(4, 6, 12, 0.7);
  --modal-bg: rgba(15, 23, 42, 0.95);
  --main-grad: linear-gradient(135deg, #0b0f19 0%, #1e1b4b 100%);
  --sidebar-profile-bg: rgba(255, 255, 255, 0.01);
  --sidebar-menu-hover: rgba(255, 255, 255, 0.03);
  --shd-color: rgba(0, 0, 0, 0.3);
}

/* Light Theme Variables */
html[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-card-hover: rgba(255, 255, 255, 0.9);
  
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-glow: rgba(124, 58, 237, 0.15);
  
  --success: #059669;
  --success-bg: rgba(5, 150, 105, 0.1);
  --success-glow: rgba(5, 150, 105, 0.15);
  
  --danger: #e11d48;
  --danger-bg: rgba(225, 29, 72, 0.08);
  --danger-glow: rgba(225, 29, 72, 0.15);
  
  --warning: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  
  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-active: rgba(124, 58, 237, 0.4);
  
  --input-bg: rgba(255, 255, 255, 0.9);
  --input-focus-bg: #ffffff;
  --overlay-bg: rgba(15, 23, 42, 0.4);
  --modal-bg: rgba(255, 255, 255, 0.98);
  --main-grad: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 100%);
  --sidebar-profile-bg: rgba(0, 0, 0, 0.02);
  --sidebar-menu-hover: rgba(0, 0, 0, 0.03);
  --shd-color: rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow-x: hidden;
  min-height: 100vh;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Logo dark mode invert styling */
.logo-icon, .login-logo img {
  filter: invert(1);
  transition: filter var(--transition-normal);
}
html[data-theme="light"] .logo-icon {
  filter: none;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
html[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Common Layout Components */
.app-container {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex-grow: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--main-grad);
  position: relative;
  transition: margin-left var(--transition-normal);
}

.main-content::before {
  content: '';
  position: absolute;
  top: 15%;
  right: 10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.main-content::after {
  content: '';
  position: absolute;
  bottom: 10%;
  left: 5%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.content-body {
  padding: 30px;
  flex-grow: 1;
  z-index: 1;
  animation: fadeIn 0.4s ease-out;
}

/* Glassmorphism Styles */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  transition: all var(--transition-normal);
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  transition: all var(--transition-normal);
  box-shadow: 0 4px 30px var(--shd-color);
}

.glass-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 40px var(--shd-color);
  transform: translateY(-2px);
}

html[data-theme="light"] .glass-card:hover {
  border-color: rgba(0, 0, 0, 0.15);
}

/* Typography Helpers */
.title-large {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.title-medium {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.text-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Form Inputs */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.glass-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  outline: none;
}

.glass-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--input-focus-bg);
}

.glass-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--sidebar-profile-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--sidebar-menu-hover);
}

.btn-danger {
  background: var(--danger-bg);
  border: 1px solid rgba(244, 63, 94, 0.2);
  color: var(--danger);
}

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

.btn-success {
  background: var(--success-bg);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--success);
}

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

.btn-icon {
  padding: 8px;
  border-radius: 8px;
}

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

.btn-xs {
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(244, 63, 94, 0.15);
}

.badge-primary {
  background: rgba(139, 92, 246, 0.1);
  color: var(--primary);
  border: 1px solid rgba(139, 92, 246, 0.15);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.15);
}

/* Sidebar Styles */
.sidebar-container {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-radius: 0 24px 24px 0;
  overflow: hidden;
}

.sidebar-logo {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo .logo-icon {
  color: var(--primary);
}

.logo-text h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.logo-text span {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  display: block;
}

.sidebar-profile {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--sidebar-profile-bg);
  border-bottom: 1px solid var(--border-color);
}

.profile-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 4px 10px rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.profile-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.sidebar-menu {
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.menu-item:hover {
  color: var(--text-main);
  background: var(--sidebar-menu-hover);
  transform: translateX(4px);
}

.menu-item.active {
  color: var(--text-main);
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.02) 100%);
  border-left: 3px solid var(--primary);
  padding-left: 13px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

.logout-btn:hover {
  color: var(--danger);
  background: rgba(244, 63, 94, 0.05);
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

/* Unified Top Header Bar */
.top-header {
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-sidebar);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 99;
  position: sticky;
  top: 0;
  box-shadow: 0 2px 10px var(--shd-color);
  transition: all var(--transition-normal);
}

.page-title-indicator {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  color: var(--text-muted);
  background: var(--sidebar-profile-bg);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  color: var(--text-main);
  background: var(--sidebar-menu-hover);
  border-color: var(--primary);
}

/* Header Profile Capsule Styles */
.header-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--sidebar-profile-bg);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.header-profile:hover {
  background: var(--sidebar-menu-hover);
  border-color: var(--primary-glow);
}

.header-profile-avatar {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.8rem;
  box-shadow: 0 0 10px var(--primary-glow);
}

.header-profile-info {
  display: flex;
  flex-direction: column;
}

.header-profile-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.header-profile-role {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Ledger Table Styles */
.ledger-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.ledger-table th {
  padding: 16px 20px;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.01);
}

.ledger-table td {
  padding: 16px 20px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.ledger-tr {
  transition: background-color 0.2s;
}

.ledger-tr:hover {
  background-color: rgba(255, 255, 255, 0.015);
}

.date-td {
  font-family: monospace;
  color: var(--text-muted);
}

.category-td {
  font-weight: 500;
}

.amount-td {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.95rem;
}

.text-income {
  color: var(--success) !important;
}

.text-expense {
  color: var(--danger) !important;
}

.remark-td {
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-center {
  text-align: center;
}

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

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

.table-actions-container {
  display: inline-flex;
  gap: 8px;
  justify-content: center;
}

/* Pagination bar */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.font-bold {
  font-weight: 700;
  color: var(--text-main);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-indicator {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 90px;
  text-align: center;
}

/* Dashboard & Stat Grid Styles */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 24px;
  border-radius: 16px;
}

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.stat-lbl {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-icon {
  color: var(--primary);
  opacity: 0.8;
}

.stat-val {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: monospace;
}

/* Dashboard Layout Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* SVG Chart Styles */
.chart-container-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.chart-wrapper {
  margin-top: 16px;
  position: relative;
  width: 100%;
}

.chart-svg {
  width: 100%;
  max-height: 260px;
  height: auto;
  overflow: visible;
}

.chart-line-income {
  fill: none;
  stroke: var(--success);
  stroke-width: 3;
}

.chart-area-income {
  fill: url(#incomeGrad);
  opacity: 0.15;
}

.chart-line-expense {
  fill: none;
  stroke: var(--danger);
  stroke-width: 3;
}

.chart-area-expense {
  fill: url(#expenseGrad);
  opacity: 0.15;
}

.chart-grid-line {
  stroke: var(--border-color);
  stroke-dasharray: 4;
}

.chart-text {
  fill: var(--text-muted);
  font-size: 10px;
}

/* Donut Breakdown Chart */
.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  max-height: 250px;
  overflow-y: auto;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.breakdown-name-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.breakdown-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.breakdown-name {
  font-size: 0.85rem;
  color: var(--text-main);
}

.breakdown-val-wrapper {
  text-align: right;
}

.breakdown-percentage {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 8px;
}

.recent-ledger-card {
  margin-top: 24px;
}

/* Modals Overlay & Container */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.25s ease-out;
}

.modal-container {
  background: var(--modal-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  width: 550px;
  max-width: 90%;
  animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

@keyframes modalScale {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

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

.modal-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
}

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

/* Alert Notification Alert */
.alert-toast {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 16px 24px;
  border-radius: 12px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: slideInRight 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.alert-toast.success {
  background: rgba(16, 185, 129, 0.95);
  border: 1px solid #10b981;
  color: #fff;
}

.alert-toast.error {
  background: rgba(244, 63, 94, 0.95);
  border: 1px solid #f43f5e;
  color: #fff;
}

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

/* Advanced Filter Panel in Ledger */
.activity-tx-filters {
  background: rgba(15, 23, 42, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  backdrop-filter: blur(10px);
}

html[data-theme="light"] .activity-tx-filters {
  background: rgba(255, 255, 255, 0.4);
}

.filter-grid-layout {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1.2fr 1fr 1fr auto;
  gap: 12px;
  align-items: flex-end;
}

.filter-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-label-text {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-input-wrapper {
  position: relative;
}

.search-icon-inside {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-field {
  padding-left: 32px !important;
  width: 100%;
  height: 36px;
  font-size: 0.85rem;
}

.select-input, .date-picker-input {
  height: 36px;
  font-size: 0.85rem;
  width: 100%;
  cursor: pointer;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  padding: 0 12px;
  outline: none;
}

.select-input:focus, .date-picker-input:focus {
  border-color: var(--primary);
}

.reset-col {
  display: flex;
  align-items: flex-end;
}

.reset-filter-btn {
  height: 36px;
  padding: 0 16px;
  gap: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  white-space: nowrap;
}

/* Activities Visual Grid */
.activity-visual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.activity-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  cursor: pointer;
  border: 1px solid var(--border-color);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.activity-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 12px 35px var(--shd-color);
  border-color: rgba(139, 92, 246, 0.3);
  background: var(--bg-card-hover);
}

.card-top {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.title-block {
  display: flex;
  align-items: center;
  gap: 8px;
}

.act-code-badge {
  font-size: 0.72rem;
  font-family: monospace;
  font-weight: 700;
  color: var(--primary);
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 4px;
  padding: 2px 6px;
}

.act-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  flex-grow: 1;
}

.duration-block {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-mid {
  display: flex;
  gap: 16px;
  background: rgba(0, 0, 0, 0.12);
  padding: 10px 14px;
  border-radius: 8px;
}

.pl-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pl-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.pl-val {
  font-size: 0.88rem;
  font-weight: 700;
  font-family: monospace;
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.profit-display {
  display: flex;
  flex-direction: column;
}

.profit-display .lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.profit-display .val {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: monospace;
}

.act-actions {
  display: flex;
  gap: 6px;
}

/* Detail View Styles */
.activity-detail-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.4s ease-out;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.back-btn {
  gap: 8px;
  border-radius: 10px;
  font-weight: 600;
  padding: 8px 16px;
}

.activity-header-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 20px;
  margin-bottom: 8px;
  gap: 20px;
}

.activity-detail-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 8px;
  margin-bottom: 4px;
}

.activity-detail-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
  max-width: 700px;
  line-height: 1.6;
}

.activity-header-section .date-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
  background: var(--sidebar-profile-bg);
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.activity-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.stat-card-item {
  padding: 24px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--border-color);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.stat-icon-wrapper {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon-wrapper.income {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.stat-icon-wrapper.expense {
  background: rgba(244, 63, 94, 0.1);
  color: var(--danger);
}

.income-highlight {
  border-color: rgba(16, 185, 129, 0.15);
  background: rgba(16, 185, 129, 0.02);
}

.expense-highlight {
  border-color: rgba(244, 63, 94, 0.15);
  background: rgba(244, 63, 94, 0.02);
}

.profit-highlight.profit {
  border-color: rgba(16, 185, 129, 0.3);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(139, 92, 246, 0.03) 100%);
}

.profit-highlight.loss {
  border-color: rgba(244, 63, 94, 0.3);
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.08) 0%, rgba(139, 92, 246, 0.03) 100%);
}

.badge-profit-status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
}

.profit .badge-profit-status {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.loss .badge-profit-status {
  background: rgba(244, 63, 94, 0.15);
  color: var(--danger);
}

.transactions-card {
  padding: 24px;
}

.empty-txs {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.gl-code-badge {
  font-family: monospace;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
}

/* User Admin Cards list */
.user-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.user-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

.user-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.user-title-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-grow: 1;
}

.user-display-name {
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.95rem;
}

.user-username {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
}

.user-card-row {
  display: flex;
  justify-content: space-between;
}

.user-card-row .lbl {
  color: var(--text-muted);
}

.user-card-row .val {
  color: var(--text-main);
  font-weight: 500;
}

.user-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

/* Login Page Styles */
.login-body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #0b0f19 0%, #1e1b4b 100%);
}

.login-card {
  width: 420px;
  max-width: 90%;
  padding: 40px;
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo i {
  color: var(--primary);
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.login-logo h1 {
  font-size: 1.5rem;
  color: var(--text-main);
  font-weight: 700;
}

.login-logo span {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.login-error-alert {
  background: var(--danger-bg);
  border: 1px solid rgba(244, 63, 94, 0.2);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 20px;
}

/* Responsiveness Media Queries */
@media (max-width: 1200px) {
  .filter-grid-layout {
    grid-template-columns: 1.5fr 1fr 1fr auto;
  }
}

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 80px;
  }
  .sidebar-logo .logo-text,
  .sidebar-profile .profile-info,
  .sidebar-menu .menu-item span,
  .sidebar-footer .menu-item span {
    display: none;
  }
  .sidebar-logo {
    justify-content: center;
    padding: 20px 0;
  }
  .sidebar-profile {
    justify-content: center;
    padding: 16px 0;
  }
  .sidebar-menu {
    padding: 16px 8px;
    align-items: center;
  }
  .menu-item {
    justify-content: center;
    padding: 12px;
  }
  .menu-item.active {
    border-left: none;
    border-bottom: 3px solid var(--primary);
    padding-left: 12px;
    background: rgba(139, 92, 246, 0.08);
  }
  .dashboard-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .activity-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .filter-grid-layout {
    grid-template-columns: 1fr 1fr;
  }
  .reset-col {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .activity-stats-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --sidebar-width: 0px;
  }
  .sidebar-container {
    width: 100%;
    height: 60px;
    bottom: auto;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    justify-content: space-between;
  }
  .sidebar-logo {
    border-bottom: none;
    padding: 0 16px;
  }
  .sidebar-profile {
    display: none;
  }
  .sidebar-menu {
    flex-direction: row;
    padding: 0;
    margin: 0;
    height: 100%;
    flex-grow: 0;
    gap: 4px;
  }
  .menu-item {
    height: 100%;
    border-radius: 0;
    padding: 0 16px;
    justify-content: center;
  }
  .menu-item.active {
    border-bottom: 3px solid var(--primary);
    border-left: none;
    padding-left: 16px;
  }
  .sidebar-footer {
    border-top: none;
    padding: 0;
    margin-right: 8px;
  }
  .main-content {
    margin-left: 0;
  }
  .content-body {
    padding: 16px;
    margin-top: 60px;
  }
  .top-header {
    display: none;
  }
  .filter-grid-layout {
    grid-template-columns: 1fr;
  }
  .reset-col {
    grid-column: span 1;
  }
  .pagination-bar {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}

/* Dropdown panel */
.profile-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  z-index: 999;
  padding: 0;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  animation: profileSlideIn 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

@keyframes profileSlideIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.profile-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.profile-panel-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-panel-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px 18px;
}

.profile-field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-field-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.profile-field-input {
  font-size: 0.84rem !important;
  height: 36px !important;
  padding: 0 10px !important;
  border-radius: 8px !important;
}

.profile-pwd-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px dashed rgba(255,255,255,0.1);
  transition: all var(--transition-fast);
}
.profile-pwd-toggle:hover {
  background: rgba(139,92,246,0.08);
  color: var(--primary);
  border-color: var(--primary-glow);
}

#profile-pwd-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.profile-save-btn {
  width: 100%;
  height: 38px !important;
  font-size: 0.84rem !important;
  margin-top: 4px;
  justify-content: center;
}

/* Alert states */
.profile-alert {
  font-size: 0.8rem;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 500;
  line-height: 1.4;
}
.profile-alert-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-glow);
}
.profile-alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-glow);
}

/* Light theme adjustments */
html[data-theme="light"] .profile-panel {
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
html[data-theme="light"] .profile-panel-header {
  border-bottom-color: rgba(0,0,0,0.06);
}
html[data-theme="light"] .profile-pwd-toggle {
  border-color: rgba(0,0,0,0.1);
}

/* =========================================================
   PASSWORD STRENGTH METER
   ========================================================= */
.pwd-strength-bar-row {
  display: flex;
  gap: 4px;
  height: 4px;
  border-radius: 4px;
  overflow: hidden;
}

.pwd-strength-seg {
  flex: 1;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  transition: background 0.25s ease;
}

/* Filled segment colours by level */
.pwd-strength-seg.pwd-lvl-0 { background: #ef4444; }   /* 極弱 — red */
.pwd-strength-seg.pwd-lvl-1 { background: #f97316; }   /* 弱   — orange */
.pwd-strength-seg.pwd-lvl-2 { background: #eab308; }   /* 中等 — yellow */
.pwd-strength-seg.pwd-lvl-3 { background: #14b8a6; }   /* 強   — teal */
.pwd-strength-seg.pwd-lvl-4 { background: #22c55e; }   /* 極強 — green */

.pwd-strength-label {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.25s ease;
}
.pwd-strength-label.pwd-lvl-0 { color: #ef4444; }
.pwd-strength-label.pwd-lvl-1 { color: #f97316; }
.pwd-strength-label.pwd-lvl-2 { color: #eab308; }
.pwd-strength-label.pwd-lvl-3 { color: #14b8a6; }
.pwd-strength-label.pwd-lvl-4 { color: #22c55e; }

/* Light theme — unfilled segment */
html[data-theme="light"] .pwd-strength-seg {
  background: rgba(0,0,0,0.08);
}
