/* Dashboards — switcher, widget grid, edit-mode drag/resize, mini charts.
   EH tokens only; lime reserved as signal (goal line, drop indicator). */

.db-screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ------------------------------------------------------------- top bar */
.db-topbar { display: flex; align-items: center; gap: 14px; padding: 16px var(--pad-page) 14px; }
.db-switcher { position: relative; }
.db-switch-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: transparent; border: 0; cursor: pointer; padding: 2px 4px;
  color: var(--text-primary);
}
.db-switch-btn .nm { font-size: 21px; font-weight: 500; letter-spacing: -0.018em; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-switch-btn .chev { color: var(--text-tertiary); transition: transform var(--dur-hover) var(--ease); }
.db-switch-btn.open .chev { transform: rotate(180deg); }
.db-menu-btn {
  width: 34px; height: 34px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); border: 1px solid var(--border-soft);
  background: var(--surface-1); color: var(--text-secondary); cursor: pointer;
  transition: background var(--dur-hover) var(--ease);
}
.db-menu-btn:hover { background: var(--surface-2); }
.db-top-grow { flex: 1; }
.db-top-actions { display: flex; align-items: center; gap: 12px; }

.db-dropdown {
  position: absolute;
  top: calc(100% + 8px); left: 0;
  z-index: 40;
  width: 320px;
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.db-dd-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: transparent; border: 0; cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13.5px; color: var(--text-primary);
  transition: background var(--dur-hover) var(--ease);
}
.db-dd-item:hover { background: var(--surface-2); }
.db-dd-item.on { background: var(--accent-soft); color: var(--accent-ink); }
.db-dd-item .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; opacity: 0.7; }
.db-dd-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.db-dd-badge { font-family: var(--mono); font-size: 9px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-tertiary); background: var(--surface-3); border-radius: var(--radius-sm); padding: 2px 7px; }

/* ------------------------------------------------------------ controls */
.db-controls { display: flex; align-items: center; gap: 14px; padding: 0 var(--pad-page) 14px; }
.db-search { flex: 1; max-width: 520px; }
.db-edit-state {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent-ink);
  display: inline-flex; align-items: center; gap: 7px;
}

/* --------------------------------------------------------------- grid */
.db-stage { flex: 1; min-height: 0; display: flex; }
.db-grid-wrap { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; padding: 0 var(--pad-page) var(--pad-page); }
.db-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 116px;
  grid-auto-flow: row dense;
  gap: 16px;
}

/* --------------------------------------------------------------- widget */
.db-widget {
  position: relative;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  padding: 18px 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: border-color var(--dur-hover) var(--ease), box-shadow 0.2s var(--ease);
}
.db-widget.editing { cursor: grab; }
.db-widget.editing:hover { border-color: var(--border-soft); }
.db-widget.dragging { opacity: 0.4; }
.db-widget.drop-target { border-color: var(--accent-border); box-shadow: 0 0 0 2px var(--accent-soft); }

.db-w-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.db-w-titles { flex: 1; min-width: 0; }
.db-w-title { font-size: 16px; font-weight: 500; letter-spacing: -0.012em; line-height: 1.25; color: var(--text-primary); }
.db-w-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 3px; line-height: 1.4; }
.db-w-err { color: var(--error-ink); flex: 0 0 auto; display: inline-flex; }
.db-w-grip { color: var(--text-muted); flex: 0 0 auto; cursor: grab; display: none; }
.db-widget.editing .db-w-grip { display: inline-flex; }

.db-w-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; margin-top: 8px; }
.db-w-desc { font-size: 12.5px; line-height: 1.55; color: var(--text-secondary); margin-bottom: 12px; }
.db-w-desc.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* process group rows */
.db-groups { display: flex; flex-direction: column; }
.db-group-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--border-faint);
}
.db-group-row:first-child { border-top: 0; }
.db-group-label { font-size: 12.5px; color: var(--text-primary); flex: 1; }
.db-group-count { font-family: var(--mono); font-size: 10px; color: var(--text-tertiary); background: var(--surface-2); border: 1px solid var(--border-faint); border-radius: var(--radius-sm); padding: 2px 8px; }
.db-featured { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-faint); flex: 1; min-height: 0; display: flex; flex-direction: column; }
.db-featured .ft-name { font-size: 13.5px; font-weight: 500; letter-spacing: -0.006em; color: var(--text-primary); margin-bottom: 6px; }

/* states */
.db-na {
  flex: 1; min-height: 60px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-tertiary);
}
.db-na .lbl { font-size: 12px; }

/* footer */
.db-w-foot { display: flex; align-items: flex-end; gap: 24px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-faint); }
.db-foot-k { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-tertiary); }
.db-freq-pill {
  display: inline-block; margin-top: 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em;
  color: var(--text-secondary); background: var(--surface-2);
  border: 1px solid var(--border-soft); border-radius: 999px; padding: 3px 10px;
}
.db-target-v { font-size: 13.5px; color: var(--text-primary); margin-top: 5px; }
.db-target-v.empty { color: var(--text-muted); }

/* resize handle */
.db-resize {
  position: absolute;
  right: 5px; bottom: 5px;
  width: 18px; height: 18px;
  cursor: nwse-resize;
  display: none;
  align-items: flex-end; justify-content: flex-end;
  color: var(--text-tertiary);
  z-index: 3;
}
.db-widget.editing .db-resize { display: flex; }
.db-resize svg { pointer-events: none; }

/* ---------------------------------------------------------- mini chart */
.db-chart { flex: 1; min-height: 90px; }
.db-chart svg { display: block; overflow: visible; }
.db-chart .grid-line { stroke: var(--border-faint); stroke-width: 1; }
.db-chart .axis-y { font-family: var(--mono); font-size: 9px; fill: var(--text-tertiary); }
.db-chart .axis-x { font-family: var(--mono); font-size: 9px; fill: var(--text-tertiary); }
.db-chart .line { fill: none; stroke: var(--text-primary); stroke-width: 1.8; stroke-linejoin: miter; }
.db-chart .pt { fill: var(--text-primary); }
.db-chart .goal-line { stroke: var(--accent-ink); stroke-width: 1.2; stroke-dasharray: 4 4; }
.db-chart .goal-lbl { font-family: var(--mono); font-size: 8.5px; fill: var(--accent-ink); }

/* empty board */
.db-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 80px 20px; text-align: center; }
.db-empty .t { font-size: 15px; font-weight: 500; color: var(--text-primary); }
.db-empty .s { font-size: 13px; color: var(--text-secondary); max-width: 40ch; }

/* ---------------------------------------------------------- widget tools */
.db-w-tools { position: relative; display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.db-w-btn {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface-1);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease);
}
.db-w-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.db-w-menu {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  z-index: 6;
  width: 168px;
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.db-w-menu-h { font-family: var(--mono); font-size: 9px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-tertiary); padding: 4px 8px 6px; }
.db-w-opt {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  background: transparent; border: 0; cursor: pointer;
  border-radius: var(--radius-sm); padding: 8px 9px;
  font-size: 13px; color: var(--text-primary);
  transition: background var(--dur-hover) var(--ease);
}
.db-w-opt svg:first-child { color: var(--text-tertiary); }
.db-w-opt:hover { background: var(--surface-2); }
.db-w-opt.on { color: var(--accent-ink); }
.db-w-opt.on svg { color: var(--accent-ink); }
.db-w-opt .check, .db-w-opt > svg:last-child { margin-left: auto; }

/* ------------------------------------------------------------- stat block */
.db-stat { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; padding: 6px 0; }
.db-stat-val { font-size: 32px; font-weight: 500; letter-spacing: -0.02em; line-height: 1; color: var(--text-primary); }
.db-stat-val .unit { font-size: 15px; font-weight: 400; letter-spacing: -0.005em; color: var(--text-tertiary); margin-left: 7px; }
.db-stat-delta { font-size: 13px; color: var(--text-secondary); margin-top: 10px; }
.db-stat-delta .d { font-weight: 500; }
.db-stat-delta.up .d { color: var(--accent-ink); }
.db-stat-delta.down .d { color: var(--error-ink); }
.db-stat-delta.flat .d { color: var(--text-tertiary); }

/* --------------------------------------------------- process metric list */
.db-pgroup { display: flex; flex-direction: column; }
.db-pgroup + .db-pgroup { margin-top: 4px; }
.db-pmetric { padding: 14px 0; border-top: 1px solid var(--border-faint); display: flex; flex-direction: column; }
.db-pmetric-name { font-size: 14px; font-weight: 500; letter-spacing: -0.008em; color: var(--text-primary); margin-bottom: 8px; }
.db-pmetric .db-w-desc { margin-bottom: 10px; }
.db-pmetric .db-w-foot { margin-top: 12px; }
.db-pmetric .db-stat { padding: 2px 0; }
.db-pmetric .db-chart { min-height: 120px; }

/* ============================================================= LIBRARY */
.db-library {
  flex: 0 0 312px;
  width: 312px;
  border-left: 1px solid var(--border-faint);
  background: var(--surface-1);
  display: flex; flex-direction: column;
  min-height: 0;
  margin-left: 4px;
}
.db-lib-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 16px 12px; border-bottom: 1px solid var(--border-faint); }
.db-lib-title { font-size: 14.5px; font-weight: 500; letter-spacing: -0.008em; color: var(--text-primary); }
.db-lib-sub { font-size: 12px; line-height: 1.45; color: var(--text-tertiary); margin-top: 3px; }
.db-lib-search { margin: 12px 16px 8px; }
.db-lib-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.db-lib-card {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-md);
  background: var(--canvas);
  padding: 11px 12px;
  cursor: grab;
  transition: border-color var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease);
}
.db-lib-card:hover { border-color: var(--border-soft); background: var(--surface-2); }
.db-lib-card:active { cursor: grabbing; }
.db-lib-grip { color: var(--text-muted); flex: 0 0 auto; display: inline-flex; }
.db-lib-ic {
  width: 30px; height: 30px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-faint);
  background: var(--surface-2);
  color: var(--text-secondary);
}
.db-lib-main { flex: 1; min-width: 0; }
.db-lib-nm { font-size: 13px; font-weight: 500; letter-spacing: -0.006em; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-lib-kind { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-tertiary); margin-top: 2px; }
.db-lib-empty { font-size: 12.5px; line-height: 1.5; color: var(--text-tertiary); text-align: center; padding: 28px 12px; }
.db-grid-wrap.drop-active { outline: 2px dashed var(--accent-border); outline-offset: -8px; border-radius: var(--radius-lg); background: var(--accent-soft); }
