.dashboard-toolbar {
  padding: 0.25rem 0;
}
.dashboard-toolbar h4 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #495057;
  margin: 0;
}
[data-bs-theme='dark'] .dashboard-toolbar h4 {
  color: #e4e4e7;
}
[data-bs-theme='dark'] .dashboard-toolbar h4 i {
  color: #a1a1aa !important;
}
.dashboard-toolbar-actions .btn {
  margin-left: 0.25rem;
}

.dashboard-widget-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
  grid-auto-rows: max-content;
}
.dashboard-widget {
  min-width: 0;
  position: relative;
  transition:
    transform 0.2s,
    opacity 0.2s;
}
.dashboard-widget.col-span-1 {
  grid-column: span 12;
}
.dashboard-widget.col-span-2 {
  grid-column: span 6;
}
.dashboard-widget.col-span-3 {
  grid-column: span 4;
}
.dashboard-widget.col-span-4 {
  grid-column: span 3;
}
.dashboard-widget.widget-removing {
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
}
@media (max-width: 1100px) {
  .dashboard-widget.col-span-3 {
    grid-column: span 6;
  }
  .dashboard-widget.col-span-4 {
    grid-column: span 6;
  }
}
@media (max-width: 700px) {
  .dashboard-widget-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }
  .dashboard-widget.col-span-1 {
    grid-column: span 2;
  }
  .dashboard-widget.col-span-2 {
    grid-column: span 2;
  }
  .dashboard-widget.col-span-3,
  .dashboard-widget.col-span-4 {
    grid-column: span 1;
  }
  .dashboard-widget.mobile-full {
    grid-column: span 2 !important;
  }
}
@media (max-width: 480px) {
  .dashboard-widget-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-widget.col-span-1,
  .dashboard-widget.col-span-2,
  .dashboard-widget.col-span-3,
  .dashboard-widget.col-span-4 {
    grid-column: span 1;
  }
}

.dashboard-edit-mode .dashboard-widget {
  outline: 2px dashed rgba(13, 110, 253, 0.35);
  outline-offset: -4px;
  border-radius: 6px;
  cursor: move;
}
.dashboard-edit-mode .dashboard-widget:hover {
  outline-color: #0d6efd;
}
.dashboard-edit-mode .dashboard-widget.dragging {
  opacity: 0.45;
}
.dashboard-edit-mode .dashboard-widget.drag-over {
  outline: 3px solid #0d6efd;
}

.dashboard-widget-controls {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  gap: 4px;
  z-index: 30;
}
.dashboard-edit-mode .dashboard-widget-controls {
  display: flex;
}
.dashboard-widget-controls button {
  border: none;
  background: rgba(255, 255, 255, 0.95);
  color: #495057;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition:
    transform 0.1s,
    background 0.1s;
}
.dashboard-widget-controls button:hover {
  background: #fff;
  color: #000;
  transform: scale(1.06);
}
.dashboard-widget-controls button.dw-hide {
  color: #dc3545;
}
.dashboard-widget-controls button.dw-hide:hover {
  background: #dc3545;
  color: #fff;
}
.dashboard-widget-controls button.dw-resize {
  font-weight: 600;
  font-size: 12px;
  width: auto;
  padding: 0 8px;
  min-width: 42px;
}

.dashboard-widget-drag-handle {
  position: absolute;
  top: 6px;
  left: 6px;
  display: none;
  background: rgba(255, 255, 255, 0.95);
  color: #6c757d;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: grab;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  z-index: 30;
}
.dashboard-edit-mode .dashboard-widget-drag-handle {
  display: flex;
}
.dashboard-widget-drag-handle:active {
  cursor: grabbing;
}

/* ============ PICKER MODAL ============ */
#widgetPickerModal .modal-content {
  border: none;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
}
.widget-picker-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.widget-picker-search {
  padding-left: 2.25rem;
  height: 42px;
  font-size: 0.95rem;
  border-radius: 10px;
  border: 1px solid #dee2e6;
  min-width: 280px;
  flex: 1;
}
.widget-picker-search:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.15);
}
.widget-picker-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #adb5bd;
  pointer-events: none;
}
.widget-picker-stats {
  font-size: 0.85rem;
  color: #495057;
  white-space: nowrap;
}

.widget-picker-section {
  margin-bottom: 1.25rem;
}
.picker-cat-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #6c757d;
  font-weight: 700;
  margin: 0.5rem 0 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.picker-cat-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.picker-cat-count {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.7rem;
}

.widget-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.6rem;
}

.widget-picker-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid #e9ecef;
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.1s,
    box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}
.widget-picker-card:hover {
  border-color: #0d6efd;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.1);
}
.widget-picker-card.is-active {
  background: linear-gradient(135deg, #d4f0d4 0%, #c3e6cb 100%);
  border-color: #28a745;
}
.widget-picker-card.is-active:hover {
  background: linear-gradient(135deg, #b8e0c1 0%, #a3d6ae 100%);
  border-color: #198754;
}
.widget-picker-card.is-busy {
  pointer-events: none;
  opacity: 0.55;
}
.picker-card-icon {
  font-size: 1.5rem;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 8px;
}
.widget-picker-card.is-active .picker-card-icon {
  background: rgba(255, 255, 255, 0.5);
}
.picker-card-body {
  flex: 1;
  min-width: 0;
}
.picker-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: #212529;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.picker-card-meta {
  font-size: 0.72rem;
  color: #6c757d;
  margin-top: 0.15rem;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.picker-card-status {
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.1s;
}
.picker-card-status:hover {
  transform: scale(1.05);
}
.picker-card-status:active {
  transform: scale(0.95);
}
.picker-status-on,
.picker-status-off {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.picker-status-on {
  display: none;
  background: #28a745;
  color: #fff;
}
.picker-status-off {
  display: inline-block;
  background: #e9ecef;
  color: #495057;
}
.widget-picker-card.is-active .picker-status-on {
  display: inline-block;
}
.widget-picker-card.is-active .picker-status-off {
  display: none;
}
.widget-picker-card.hidden-by-search {
  display: none;
}

/* ============ DARK MODE PICKER ============ */
[data-bs-theme='dark'] #widgetPickerModal .modal-content {
  background: #1f1f23;
  border-color: rgba(255, 255, 255, 0.08);
}
[data-bs-theme='dark'] .widget-picker-search {
  background: #27272a;
  border-color: rgba(255, 255, 255, 0.12);
  color: #f4f4f5;
}
[data-bs-theme='dark'] .widget-picker-search::placeholder {
  color: #71717a;
}
[data-bs-theme='dark'] .widget-picker-stats {
  color: #d4d4d8;
}
[data-bs-theme='dark'] .picker-cat-title {
  color: #a1a1aa;
}
[data-bs-theme='dark'] .widget-picker-card {
  background: #27272a;
  border-color: rgba(255, 255, 255, 0.08);
}
[data-bs-theme='dark'] .widget-picker-card:hover {
  background: #3f3f46;
  border-color: #3b82f6;
}
[data-bs-theme='dark'] .widget-picker-card.is-active {
  background: linear-gradient(135deg, #14532d 0%, #166534 100%);
  border-color: #22c55e;
}
[data-bs-theme='dark'] .widget-picker-card.is-active:hover {
  background: linear-gradient(135deg, #166534 0%, #15803d 100%);
}
[data-bs-theme='dark'] .picker-card-icon {
  background: rgba(255, 255, 255, 0.05);
}
[data-bs-theme='dark'] .picker-card-title {
  color: #f4f4f5;
}
[data-bs-theme='dark'] .picker-card-meta {
  color: #a1a1aa;
}
[data-bs-theme='dark'] .picker-status-off {
  background: #3f3f46;
  color: #d4d4d8;
}

[data-bs-theme='dark'] .dashboard-edit-mode .dashboard-widget {
  outline-color: rgba(59, 130, 246, 0.4);
}
[data-bs-theme='dark'] .dashboard-edit-mode .dashboard-widget:hover {
  outline-color: #3b82f6;
}
[data-bs-theme='dark'] .dashboard-widget-controls button,
[data-bs-theme='dark'] .dashboard-widget-drag-handle {
  background: #27272a;
  color: #e4e4e7;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
}
[data-bs-theme='dark'] .dashboard-widget-controls button:hover {
  background: #3f3f46;
  color: #fff;
}

/* ============ PICKER SPLIT LAYOUT ============ */
.widget-picker-split {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.1fr);
  min-height: 520px;
  max-height: 75vh;
}
.widget-picker-list {
  border-right: 1px solid #e9ecef;
  overflow-y: auto;
  max-height: 75vh;
}
.widget-picker-preview {
  padding: 1.2rem;
  overflow-y: auto;
  max-height: 75vh;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
}
.widget-picker-preview-empty {
  text-align: center;
  margin: auto;
  padding: 2rem;
}
.widget-picker-preview-card-wrap {
  margin-bottom: 1rem;
}
.widget-picker-preview-meta {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e9ecef;
}
.widget-picker-preview-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.widget-picker-preview-desc {
  font-size: 0.8rem;
  color: #6c757d;
}
.widget-picker-preview-actions {
  margin-top: auto;
  padding-top: 0.75rem;
}
.widget-picker-preview-actions .btn {
  width: 100%;
}
.widget-picker-card.is-selected {
  border-color: #0d6efd;
  background: linear-gradient(135deg, #e7f1ff 0%, #d6e7ff 100%);
}
.widget-picker-card.is-selected.is-active {
  background: linear-gradient(135deg, #c3e6cb 0%, #a3d6ae 100%);
  border-color: #198754;
}
[data-bs-theme='dark'] .widget-picker-list {
  border-right-color: rgba(255, 255, 255, 0.08);
}
[data-bs-theme='dark'] .widget-picker-preview {
  background: #18181b;
}
[data-bs-theme='dark'] .widget-picker-preview-meta {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}
[data-bs-theme='dark'] .widget-picker-preview-title {
  color: #f4f4f5;
}
[data-bs-theme='dark'] .widget-picker-card.is-selected {
  background: linear-gradient(135deg, #1e3a5f 0%, #1d4878 100%);
  border-color: #3b82f6;
}
@media (max-width: 800px) {
  .widget-picker-split {
    grid-template-columns: 1fr;
  }
  .widget-picker-list {
    border-right: none;
    border-bottom: 1px solid #e9ecef;
    max-height: 50vh;
  }
  .widget-picker-preview {
    max-height: 40vh;
  }
}

/* ============ CALCULATOR ============ */
/* Light mode: clean modern slate + indigo palette. */
.calc-widget .dashboard-card-body {
  padding: 0.65rem !important;
}
.calc {
  background: #d0d4db;
  border-radius: 10px;
  padding: 8px;
}
.calc-display {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 8px;
  text-align: right;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}
.calc-history {
  font-size: 0.75rem;
  color: #64748b;
  min-height: 14px;
}
.calc-result {
  font-size: 1.4rem;
  font-weight: 600;
  color: #0f172a;
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}
.calc-pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.calc-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 7px;
  padding: 0.55rem 0;
  cursor: pointer;
  transition:
    background 0.1s,
    transform 0.05s,
    box-shadow 0.1s;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.calc-btn:hover {
  background: #f1f5f9;
}
.calc-btn:active,
.calc-btn.calc-btn-pressed {
  transform: scale(0.96);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}
.calc:focus {
  outline: none;
}
.calc:focus-within .calc-display {
  box-shadow:
    inset 0 1px 2px rgba(15, 23, 42, 0.08),
    0 0 0 2px rgba(99, 102, 241, 0.3);
}
.calc-btn.calc-fn {
  background: #e2e8f0;
  color: #475569;
  border-color: #cbd5e1;
}
.calc-btn.calc-fn:hover {
  background: #cbd5e1;
  color: #0f172a;
}
.calc-btn.calc-op {
  background: #475569;
  color: #fff;
  border-color: #475569;
}
.calc-btn.calc-op:hover {
  background: #334155;
}
.calc-btn.calc-eq {
  background: #4f46e5;
  color: #fff;
  border-color: #4f46e5;
}
.calc-btn.calc-eq:hover {
  background: #4338ca;
}
.calc-btn.calc-zero {
  grid-column: span 2;
}

/* Dark mode: keep the original full-dark calculator look. */
[data-bs-theme='dark'] .calc-widget .dashboard-card-body {
  background: #18181b;
}
[data-bs-theme='dark'] .calc-widget .dashboard-card-header {
  background: #1f1f23;
  border-bottom-color: rgba(255, 255, 255, 0.06);
}
[data-bs-theme='dark'] .calc-widget .dashboard-card-header h5 {
  color: #f4f4f5;
}
[data-bs-theme='dark'] .calc {
  background: #18181b;
}
[data-bs-theme='dark'] .calc-display {
  background: #27272a;
  border-color: transparent;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
[data-bs-theme='dark'] .calc-history {
  color: #a1a1aa;
}
[data-bs-theme='dark'] .calc-result {
  color: #f4f4f5;
}
[data-bs-theme='dark'] .calc-btn {
  background: #27272a;
  color: #f4f4f5;
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
[data-bs-theme='dark'] .calc-btn:hover {
  background: #3f3f46;
}
[data-bs-theme='dark'] .calc:focus-within .calc-display {
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(59, 130, 246, 0.35);
}
[data-bs-theme='dark'] .calc-btn.calc-fn {
  background: #3f3f46;
  color: #d4d4d8;
}
[data-bs-theme='dark'] .calc-btn.calc-fn:hover {
  background: #52525b;
  color: #fff;
}

/* ============ TOAST ============ */
.dashboard-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #212529;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  font-size: 0.88rem;
  z-index: 99999;
  transform: translateY(20px);
  opacity: 0;
  transition:
    transform 0.25s,
    opacity 0.25s;
}
.dashboard-toast.show {
  transform: translateY(0);
  opacity: 1;
}
.dashboard-toast.toast-success {
  background: #198754;
}
.dashboard-toast.toast-error {
  background: #dc3545;
}
.dashboard-toast i {
  margin-right: 6px;
}
