/* ============================================================
   YBS85 — Component Library
   Cards, Tables, Forms, Buttons, Badges, etc.
   ============================================================ */

/* ============================================================
   1. BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--transition-fast);
}

.btn:hover::after  { background: rgba(255,255,255,0.08); }
.btn:active::after { background: rgba(0,0,0,0.08); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(79,70,229,0.45);
}

.btn-primary:active { transform: translateY(0); }

/* Secondary */
.btn-secondary {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: var(--border-base);
}

.btn-secondary:hover {
  background: var(--border-base);
  border-color: var(--border-strong);
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-outline:hover {
  background: rgba(79,70,229,0.08);
}

/* Danger */
.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
  box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 6px 18px rgba(239,68,68,0.4);
  transform: translateY(-1px);
}

/* Success */
.btn-success {
  background: var(--color-success);
  color: #fff;
  border-color: var(--color-success);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--surface-raised);
  color: var(--text-primary);
}

/* Sizes */
.btn-xs  { padding: 0.25rem 0.625rem; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-sm  { padding: 0.375rem 0.75rem; font-size: var(--text-xs); }
.btn-lg  { padding: 0.75rem 1.5rem;   font-size: var(--text-base); border-radius: var(--radius-lg); }
.btn-xl  { padding: 1rem 2rem;        font-size: var(--text-lg);   border-radius: var(--radius-lg); }
.btn-icon{ padding: 0.5rem;           border-radius: var(--radius-md); }

/* Button with spinner */
.btn .spinner {
  width: 16px; height: 16px;
  border-width: 2px;
  border-color: rgba(255,255,255,0.3);
  border-top-color: #fff;
}

/* ============================================================
   2. CARDS
   ============================================================ */
.card {
  background: var(--surface-base);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-base);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.card-title {
  font-size: var(--text-base);
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
}

.card-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-base);
  background: var(--surface-raised);
}

/* KPI / Stat Cards */
.stat-card {
  background: var(--surface-base);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card.primary::before   { background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent)); }
.stat-card.success::before   { background: linear-gradient(90deg, var(--color-success), #34d399); }
.stat-card.warning::before   { background: linear-gradient(90deg, var(--color-warning), #fbbf24); }
.stat-card.danger::before    { background: linear-gradient(90deg, var(--color-danger), #f87171); }
.stat-card.secondary::before { background: linear-gradient(90deg, var(--brand-secondary), #38bdf8); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-4);
}

.stat-card.primary .stat-icon   { background: rgba(79,70,229,0.1);  color: var(--brand-primary); }
.stat-card.success .stat-icon   { background: rgba(16,185,129,0.1); color: var(--color-success); }
.stat-card.warning .stat-icon   { background: rgba(245,158,11,0.1); color: var(--color-warning); }
.stat-card.danger .stat-icon    { background: rgba(239,68,68,0.1);  color: var(--color-danger); }
.stat-card.secondary .stat-icon { background: rgba(14,165,233,0.1); color: var(--brand-secondary); }

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: var(--space-1);
  color: var(--text-primary);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: var(--space-3);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.stat-change.up   { background: rgba(16,185,129,0.1); color: var(--color-success); }
.stat-change.down { background: rgba(239,68,68,0.1);  color: var(--color-danger); }

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

/* ============================================================
   3. GRID LAYOUTS
   ============================================================ */
.grid-cols-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-cols-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

.dashboard-grid .col-span-2 { grid-column: span 2; }

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid .col-span-2 { grid-column: span 1; }
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
}

/* ============================================================
   4. FORMS
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.form-label .required {
  color: var(--color-danger);
  margin-left: 3px;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Inputs */
.form-control {
  width: 100%;
  padding: 0.6rem 0.875rem;
  background: var(--surface-base);
  border: 1.5px solid var(--border-base);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  outline: none;
}

.form-control:hover {
  border-color: var(--border-strong);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
  background: var(--surface-base);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:invalid:not(:placeholder-shown),
.form-control.is-invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.12);
}

.form-control:valid:not(:placeholder-shown):not([type="text"]),
.form-control.is-valid {
  border-color: var(--color-success);
}

.form-control[readonly] {
  background: var(--surface-raised);
  cursor: default;
  color: var(--text-secondary);
}

.form-control[disabled] {
  background: var(--surface-raised);
  cursor: not-allowed;
  opacity: 0.6;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Input with icon */
.input-group {
  position: relative;
}

.input-group .input-icon {
  position: absolute;
  top: 50%; left: 12px;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px; height: 16px;
}

.input-group .input-icon-right {
  left: auto; right: 12px;
}

.input-group .form-control {
  padding-left: 36px;
}

.input-group.icon-right .form-control {
  padding-left: 0.875rem;
  padding-right: 36px;
}

/* Input prefix/suffix */
.input-addon-group {
  display: flex;
  align-items: stretch;
}

.input-addon {
  padding: 0.6rem 0.875rem;
  background: var(--surface-raised);
  border: 1.5px solid var(--border-base);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.input-addon:first-child {
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-addon:last-child {
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-addon-group .form-control {
  border-radius: 0;
  flex: 1;
}

.input-addon-group .form-control:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.input-addon-group .form-control:last-child  { border-radius: 0 var(--radius-md) var(--radius-md) 0; }

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-check-input {
  width: 18px; height: 18px;
  accent-color: var(--brand-primary);
  cursor: pointer;
}

.form-check-label {
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.toggle-switch input { display: none; }

.toggle-track {
  width: 44px; height: 24px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.toggle-track::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform var(--transition-fast);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--brand-primary);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(20px);
}

/* Form rows */
.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 600px) {
  .form-row, .form-row.cols-3 { grid-template-columns: 1fr; }
}

/* ============================================================
   5. TABLES
   ============================================================ */
.table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-base);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table thead {
  background: var(--surface-raised);
  position: sticky;
  top: 0;
  z-index: 1;
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-base);
}

.table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.table th.sortable:hover { color: var(--text-primary); }

.table th.text-right, .table td.text-right { text-align: right; }
.table th.text-center, .table td.text-center { text-align: center; }

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-base);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--surface-raised);
}

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

.table tfoot td {
  padding: var(--space-3) var(--space-4);
  font-weight: 700;
  border-top: 2px solid var(--border-strong);
  background: var(--surface-raised);
}

/* Table actions */
.table-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  justify-content: flex-end;
}

/* ============================================================
   6. BADGES & STATUS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-success { background: rgba(16,185,129,0.12); color: #059669; }
.badge-danger  { background: rgba(239,68,68,0.12);  color: #dc2626; }
.badge-warning { background: rgba(245,158,11,0.12); color: #d97706; }
.badge-info    { background: rgba(59,130,246,0.12); color: #2563eb; }
.badge-primary { background: rgba(79,70,229,0.12);  color: var(--brand-primary); }
.badge-secondary{ background: var(--surface-raised); color: var(--text-secondary); }
.badge-gray    { background: var(--surface-raised); color: var(--text-muted); }

[data-theme="dark"] .badge-success { color: #34d399; }
[data-theme="dark"] .badge-danger  { color: #f87171; }
[data-theme="dark"] .badge-warning { color: #fbbf24; }
[data-theme="dark"] .badge-info    { color: #60a5fa; }
[data-theme="dark"] .badge-primary { color: var(--brand-primary-l); }

/* No dot badges */
.badge-plain::before { display: none; }

/* ============================================================
   7. PROGRESS BARS
   ============================================================ */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
}

.progress-value {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-primary);
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: var(--surface-raised);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  transition: width var(--transition-slow);
  position: relative;
}

.progress-bar-fill.success { background: linear-gradient(90deg, var(--color-success), #34d399); }
.progress-bar-fill.warning { background: linear-gradient(90deg, var(--color-warning), #fbbf24); }
.progress-bar-fill.danger  { background: linear-gradient(90deg, var(--color-danger), #f87171); }

/* ============================================================
   8. TABS
   ============================================================ */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-base);
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab-item {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.tab-item:hover { color: var(--text-primary); }

.tab-item.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

.tab-content {
  padding-top: var(--space-5);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Pill tabs */
.tabs-pill {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--surface-raised);
  border-radius: var(--radius-md);
  border: none;
  flex-wrap: wrap;
}

.tabs-pill .tab-item {
  border: none;
  border-radius: var(--radius-sm);
  margin: 0;
  padding: var(--space-2) var(--space-4);
}

.tabs-pill .tab-item.active {
  background: var(--surface-base);
  color: var(--brand-primary);
  box-shadow: var(--shadow-xs);
  border-color: transparent;
}

/* ============================================================
   9. FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.filter-bar .form-control {
  width: auto;
}

.search-input {
  min-width: 220px;
  flex: 1;
  max-width: 360px;
}

/* ============================================================
   10. CHART CONTAINERS
   ============================================================ */
.chart-container {
  position: relative;
  width: 100%;
}

.chart-container canvas {
  max-width: 100%;
}

/* ============================================================
   11. DIVIDER
   ============================================================ */
.divider {
  border: none;
  border-top: 1px solid var(--border-base);
  margin: var(--space-4) 0;
}

.divider-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.divider-label::before,
.divider-label::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border-base);
}

/* ============================================================
   12. ALERTS / CALLOUTS
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid;
}

.alert-icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }

.alert-success { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.25); color: #065f46; }
.alert-danger  { background: rgba(239,68,68,0.08);  border-color: rgba(239,68,68,0.25);  color: #991b1b; }
.alert-warning { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.25); color: #78350f; }
.alert-info    { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.25); color: #1e40af; }

[data-theme="dark"] .alert-success { color: #6ee7b7; }
[data-theme="dark"] .alert-danger  { color: #fca5a5; }
[data-theme="dark"] .alert-warning { color: #fde68a; }
[data-theme="dark"] .alert-info    { color: #93c5fd; }

/* ============================================================
   13. PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  justify-content: center;
  margin-top: var(--space-4);
}

.page-btn {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  background: var(--surface-base);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.page-btn:hover {
  background: var(--surface-raised);
  color: var(--text-primary);
}

.page-btn.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================================
   14. DROPDOWN
   ============================================================ */
.dropdown-wrapper {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface-base);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: var(--z-dropdown);
  overflow: hidden;
  animation: dropdown-in var(--transition-fast) forwards;
}

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

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover { background: var(--surface-raised); }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item.danger:hover { background: rgba(239,68,68,0.08); }

.dropdown-divider {
  border: none;
  border-top: 1px solid var(--border-base);
  margin: 4px 0;
}

/* ============================================================
   15. DATA LIST (Key-Value Pairs)
   ============================================================ */
.data-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-4);
  align-items: start;
}

.data-list-key {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.data-list-val {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: 500;
}

/* ============================================================
   16. ACCORDION
   ============================================================ */
.accordion-item {
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  cursor: pointer;
  background: var(--surface-base);
  transition: background var(--transition-fast);
  user-select: none;
}

.accordion-header:hover { background: var(--surface-raised); }

.accordion-title {
  font-size: var(--text-sm);
  font-weight: 600;
}

.accordion-chevron {
  width: 18px; height: 18px;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.accordion-item.open .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-body {
  padding: 0 var(--space-4);
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-base), padding var(--transition-base);
}

.accordion-item.open .accordion-body {
  max-height: 2000px;
  padding: var(--space-4);
  border-top: 1px solid var(--border-base);
}

/* ============================================================
   17. FILE UPLOAD
   ============================================================ */
.file-upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--surface-raised);
}

.file-upload-zone:hover,
.file-upload-zone.drag-over {
  border-color: var(--brand-primary);
  background: rgba(79,70,229,0.05);
}

.file-upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.file-upload-icon {
  width: 48px; height: 48px;
  color: var(--text-muted);
  margin: 0 auto var(--space-3);
}

.file-upload-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.file-upload-text strong { color: var(--brand-primary); }
.file-upload-hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-1); }

/* ============================================================
   18. TRANSACTION SPECIFIC
   ============================================================ */
.debit-row  { background: rgba(16,185,129,0.04); }
.credit-row { background: rgba(239,68,68,0.04); }

.amount-debit  { color: var(--color-success); font-weight: 700; }
.amount-credit { color: var(--color-danger);  font-weight: 700; }
.amount-neutral{ color: var(--text-primary);  font-weight: 700; }

/* Journal entry display */
.journal-entry {
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.journal-header {
  padding: var(--space-4);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border-base);
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.journal-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.journal-meta-label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.journal-meta-value { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast, 400);
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-base);
  border: 1px solid var(--border-base);
  border-left: 4px solid;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 420px;
  pointer-events: all;
  animation: toast-slide-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.toast.removing {
  animation: toast-slide-out 0.3s ease forwards;
}

@keyframes toast-slide-in {
  from { opacity:0; transform: translateX(100%) scale(0.95); }
  to   { opacity:1; transform: translateX(0) scale(1); }
}

@keyframes toast-slide-out {
  from { opacity:1; transform: translateX(0); max-height: 200px; }
  to   { opacity:0; transform: translateX(100%); max-height: 0; margin:0; padding:0; }
}

.toast.success { border-left-color: var(--color-success); }
.toast.error   { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }
.toast.info    { border-left-color: var(--brand-secondary); }

.toast-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.toast-icon.success { color: var(--color-success); }
.toast-icon.error   { color: var(--color-danger); }
.toast-icon.warning { color: var(--color-warning); }
.toast-icon.info    { color: var(--brand-secondary); }

.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: var(--text-sm); font-weight: 700; color: var(--text-primary); }
.toast-message { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; line-height: 1.5; }

.toast-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 2px; border-radius: 4px;
  flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.toast-close:hover { color: var(--text-primary); background: var(--surface-raised); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal, 300);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade-in 0.2s ease both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface-base);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-base);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: modal-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  overflow: hidden;
}

.modal.modal-sm { max-width: 440px; }
.modal.modal-lg { max-width: 720px; }
.modal.modal-xl { max-width: 960px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-title {
  font-size: var(--text-lg); font-weight: 800;
  font-family: var(--font-display);
  color: var(--text-primary);
}

.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 6px; border-radius: var(--radius-sm);
  display: flex; align-items: center;
  transition: all var(--transition-fast);
  font-size: 18px;
}
.modal-close:hover { color: var(--text-primary); background: var(--surface-raised); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-base);
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  flex-shrink: 0;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.search-input { flex: 1; min-width: 200px; }

.input-group {
  position: relative;
  display: flex; align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
  width: 16px; height: 16px;
}

.input-group .form-control { padding-left: 38px; }

/* Addon input (Rp prefix) */
.input-addon-group {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border-base);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input-addon-group:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.input-addon {
  padding: 0 12px;
  background: var(--surface-raised);
  font-size: var(--text-sm); font-weight: 600;
  color: var(--text-muted);
  border-right: 1px solid var(--border-base);
  white-space: nowrap;
  height: 100%;
  display: flex; align-items: center;
}
.input-addon-group .form-control {
  border: none; background: transparent; box-shadow: none;
}
.input-addon-group .form-control:focus { box-shadow: none; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-wrap { display: flex; flex-direction: column; gap: 4px; }
.progress-header {
  display: flex; justify-content: space-between; align-items: center;
}
.progress-label { font-size: var(--text-xs); color: var(--text-secondary); }
.progress-value { font-size: var(--text-xs); font-weight: 700; color: var(--text-primary); }
.progress-bar-track {
  width: 100%; height: 8px;
  background: var(--surface-raised);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-bar-fill.success { background: linear-gradient(90deg, #10b981, #34d399); }
.progress-bar-fill.warning { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-bar-fill.danger  { background: linear-gradient(90deg, #ef4444, #f97316); }

/* ============================================================
   DASHBOARD GRID
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.dashboard-grid .col-span-2 { grid-column: span 2; }

@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid .col-span-2 { grid-column: span 1; }
}

/* ============================================================
   FILE UPLOAD ZONE
   ============================================================ */
.file-upload-zone {
  border: 2px dashed var(--border-base);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--surface-raised);
}
.file-upload-zone:hover {
  border-color: var(--brand-primary);
  background: rgba(79,70,229,0.04);
}
.file-upload-icon {
  width: 36px; height: 36px;
  margin: 0 auto 8px;
  color: var(--text-muted);
}
.file-upload-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.file-upload-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   DROPDOWN
   ============================================================ */
.dropdown-wrapper { position: relative; }

.dropdown-menu {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  background: var(--surface-base);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: var(--z-dropdown, 100);
  overflow: hidden;
}

.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 16px;
  font-size: var(--text-sm); font-weight: 500;
  color: var(--text-secondary);
  background: none; border: none; cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}
.dropdown-item:hover { background: var(--surface-raised); color: var(--text-primary); }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item.danger:hover { background: rgba(239,68,68,0.08); }

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

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid;
  font-size: var(--text-sm);
}
.alert-icon { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.2); color: #065f46; }
.alert-warning { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.2); color: #92400e; }
.alert-danger  { background: rgba(239,68,68,0.08);  border-color: rgba(239,68,68,0.2);  color: #991b1b; }
.alert-info    { background: rgba(59,130,246,0.08);  border-color: rgba(59,130,246,0.2);  color: #1e40af; }

[data-theme="dark"] .alert-success { color: #6ee7b7; }
[data-theme="dark"] .alert-warning { color: #fbbf24; }
[data-theme="dark"] .alert-danger  { color: #fca5a5; }
[data-theme="dark"] .alert-info    { color: #93c5fd; }

/* ============================================================
   DATA LIST (label-value pairs)
   ============================================================ */
.data-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 16px;
  font-size: var(--text-sm);
}
.data-list-key {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex; align-items: center;
}
.data-list-val { color: var(--text-primary); font-weight: 500; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex; align-items: center; gap: 4px;
}
.page-btn {
  min-width: 34px; height: 34px;
  padding: 0 8px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  background: none;
  border: 1.5px solid var(--border-base);
  font-size: var(--text-sm); font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.page-btn:hover:not(:disabled) {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.page-btn.active {
  background: var(--brand-primary);
  color: #fff; border-color: var(--brand-primary);
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
.toggle-switch {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
}
.toggle-switch input { display: none; }
.toggle-track {
  width: 40px; height: 22px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}
.toggle-switch input:checked + .toggle-track { background: var(--brand-primary); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(18px); }

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.currency { font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.no-print { }

/* Tabs pill style */
.tabs-pill {
  display: flex; gap: 4px;
  background: var(--surface-raised);
  border-radius: var(--radius-md);
  padding: 4px;
  width: fit-content;
}

/* Button sizes */
.btn-xs { padding: 4px 10px; font-size: 11px; border-radius: 6px; }
.btn-icon { width: 34px; height: 34px; padding: 0; }

/* Form check */
.form-check {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
}
.form-check-input {
  width: 16px; height: 16px;
  cursor: pointer;
  accent-color: var(--brand-primary);
}
.form-check-label { font-size: var(--text-sm); color: var(--text-secondary); }

/* Print styles */
@media print {
  .no-print, .app-sidebar, .app-header, .filter-bar, .btn { display: none !important; }
  .app-main { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
}

/* Columns */
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }

/* Badge dot (notification) */
.badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--color-danger);
  border-radius: 50%;
  border: 2px solid var(--surface-base);
}

.header-icon-btn { position: relative; }

/* ============================================================
   MOBILE RESPONSIVE (components)
   ============================================================ */
@media (max-width: 768px) {
  /* Tables: force scroll inside card, not outside */
  .table-container {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }

  .table th {
    font-size: 10px;
    padding: var(--space-2) var(--space-3);
  }

  .table td {
    font-size: 12px;
    padding: var(--space-2) var(--space-3);
  }

  /* Filter bar: stack vertically */
  .filter-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: var(--space-2) !important;
  }

  .filter-bar .form-control,
  .filter-bar select,
  .filter-bar input {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .search-input {
    min-width: 0;
    max-width: 100%;
  }

  /* Card body padding smaller on mobile */
  .card-body {
    padding: var(--space-3) !important;
  }

  .card-header {
    padding: var(--space-3) var(--space-4) !important;
  }

  .card-footer {
    padding: var(--space-3) var(--space-4) !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: var(--space-2) !important;
  }

  /* Pagination: center on mobile */
  .pagination {
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
  }

  /* Stats cards: smaller text */
  .stat-card {
    padding: var(--space-4) !important;
  }

  .stat-value {
    font-size: var(--text-xl) !important;
  }

  /* Form rows: single column */
  .form-row,
  .form-row.cols-2,
  .form-row.cols-3 {
    grid-template-columns: 1fr !important;
  }

  /* Buttons: full width in filter bars */
  .filter-bar .btn {
    width: 100% !important;
    justify-content: center !important;
  }
}
